simple paint program questions

I would like to integrate a very simple paint module with a program I working on. Think MS Paint or MacPaint and possibly not even that complicated. I have some questions though. The images being edit won’t be any bigger than maybe 128x128. Most will be around 32x32. So this is more of a pixel level editor.

How do I delete a pixel (i.e. make it transparent)?
How could I draw a circle with the mouse? Line?
Any recent examples of a simple paint program? I’'m aware of a couple of really old examples that really don’t work very well.

I just need some pointers in the right direction. I’m kind of clueless when it comes to graphics processing



Step one: use a canvas.
Step 2: consider the canvas as a grid.
The size of each square is one ‘real’ pixel

eg a canvas of 200 x 200 representing 20 x 20 pixels has an onscreen ‘pixel’ size of 10

When someone puts the mouse down in that canvas , divide the x by 10 and the y by 10 to get the x,y co-ordinates of the ‘actual’ picture.

Have a selection of colors to choose from.
Draw a pixel of the right color at x,y on the real thing, and a rectangle of x10, y10, 10 ,10 on the canvas

You could draw all your wok on the real thing and simply paint it large on the canvas.

Lines and circles require you to record the mouse down position, and the mouse up position, then draw the relevant shape one ‘real’ image, and paint it large on the canvas afterwards

The following examples in Example Projects\\Graphics and Multimedia can be good study :


Ah, yes… I always forget to look at the Xojo examples. :slight_smile:

Also, a very simple black/white editor that uses a grid based editor
It may give you some ideas:

What I would like to see is a Desktop version of the Xojo iOS Paint program (unless it is already in the Examples folder ?).

Hi Jeff,

minimalist, but works fine as is (on OS X El Capitan).

I copy / pasted the two parts of the XML on TextEdit, save it as xml, open it in Xojo 2015r1, run and it works. I was even able to save the “new” cursor as xml.

Nice !

Thank you for the sharing.

Man ! 10 years old xml project !

Thanks for the tip on the cursor editor. It did give me some more ideas.