Recent

Author Topic: Help creating a simple canvas/paint program  (Read 1073 times)

ad1mt

  • Sr. Member
  • ****
  • Posts: 327
    • Mark Taylor's Home Page
Help creating a simple canvas/paint program
« 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.
« Last Edit: February 19, 2024, 06:33:50 pm by ad1mt »

dsiders

  • Hero Member
  • *****
  • Posts: 1431
Re: Help creating a simple canvas/paint program
« Reply #1 on: February 19, 2024, 07:09:22 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.

Might help...

https://wiki.lazarus.freepascal.org/Developing_with_Graphics?
https://lazarus-ccr.sourceforge.io/docs/lcl/graphics/tcanvas.html
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Help creating a simple canvas/paint program
« Reply #2 on: February 19, 2024, 07:12:47 pm »
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.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

jamie

  • Hero Member
  • *****
  • Posts: 6953
Re: Help creating a simple canvas/paint program
« Reply #3 on: February 20, 2024, 01:20:26 am »
TAChart package? its already on the tabs up there.
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018