Recent

Author Topic: Canvas Origin  (Read 2689 times)

JimKueneman

  • Full Member
  • ***
  • Posts: 178
Canvas Origin
« on: May 06, 2017, 07:06:21 pm »
Is there the concept of the viewport origin in TCanvas that I an change the definition of what 0, 0 means to the drawing functions?  I have a large viewport of rectangles and would like to move them around in the client window by changing the origin of the canvas, that way I can always draw the rectangle to the point that I have defined its upper left corner to be.

Thanks,
Jim

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: Canvas Origin
« Reply #1 on: May 06, 2017, 08:50:11 pm »
Is there the concept of the viewport origin in TCanvas that I an change the definition of what 0, 0 means to the drawing functions?  I have a large viewport of rectangles and would like to move them around in the client window by changing the origin of the canvas, that way I can always draw the rectangle to the point that I have defined its upper left corner to be.
Not to my knowledge. I have a custom canvas that supports something similar in my simplegraph's port to lcl at https://sourceforge.net/projects/evssimplegraph/ it has two properties offsetx, offsety which are used internally to offset the coordinates of the canvas drawing methods only. I do not know how useful this would be to you (not much I assume) at least you'll have a starting point.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Canvas Origin
« Reply #2 on: May 07, 2017, 01:07:35 pm »
You can make a temporary TBitmap size it to the viewport. Draw graphics in it and finally draw the bitmap on the main canvas. Any graphics that you draw that go over boundaries of the bitmap are clipped out.

Thaddy

  • Hero Member
  • *****
  • Posts: 10293
Re: Canvas Origin
« Reply #3 on: May 07, 2017, 01:27:24 pm »
Maybe you can move a TPaintbox around in your case, given left-top.
[edit] Just tested that. Works pretty good...
« Last Edit: May 07, 2017, 01:32:15 pm by Thaddy »
I am more like donkey than shrek

 

TinyPortal © 2005-2018