Forum > LCL

Help creating a simple canvas/paint program

(1/1)

ad1mt:
I need help creating a simple paint/canvas program. I've studied the documentation but I'm still struggling.

What I'd like to do, I think, should be fairly easy... I just want to create a white square, and from within the program, paint dots/spots in the white square, using a mathematical formula.  No user input or interaction needed whatsoever.

This might, for example, be used to plot the mandelbrot set, something similar, using hard-coded parameters.

Would anyone be prepared to help me code this?  Or alternatively, suggest tutorials that would show me how to do it?

EDIT - maybe this post should have gone into the Free Pascal -> Beginners section? If so, then I can delete & repost there.

Many thanks.

dsiders:

--- Quote from: ad1mt on February 19, 2024, 06:31:44 pm ---I need help creating a simple paint/canvas program. I've studied the documentation but I'm still struggling.

What I'd like to do, I think, should be fairly easy... I just want to create a white square, and from within the program, paint dots/spots in the white square, using a mathematical formula.  No user input or interaction needed whatsoever.

This might, for example, be used to plot the mandelbrot set, something similar, using hard-coded parameters.

Would anyone be prepared to help me code this?  Or alternatively, suggest tutorials that would show me how to do it?

EDIT - maybe this post should have gone into the Free Pascal -> Beginners section? If so, then I can delete & repost there.

Many thanks.

--- End quote ---

Might help...

https://wiki.lazarus.freepascal.org/Developing_with_Graphics?
https://lazarus-ccr.sourceforge.io/docs/lcl/graphics/tcanvas.html

KodeZwerg:
I am absolute unsure what you want to get at the end.
So to begin with, put a TImage on form client aligned.
Put a FBitmap: TBitmap in your class definition.
At program startup do a FBitmap := TBitmap.Create.
Now you have a cached Bitmap that you can access at any time with whatever you need to do, draw a dot for example.
So write a method that draw on x/y a dot in your desired color and do Image1.Picture.Bitmap.Assign(FBitmap) after you draw all your dots.

If anything is unclear, ask.

jamie:
TAChart package? its already on the tabs up there.

Navigation

[0] Message Index

Go to full version