Recent

Author Topic: Canvas questions  (Read 2209 times)

Blestan

  • Sr. Member
  • ****
  • Posts: 461
Canvas questions
« on: April 02, 2013, 10:27:10 pm »
hi! i have 2 questions about canvas
1/ how to get update rect on overiding paint method in multiplatform way...
2/ how to set viewport org to offset all draw operations on the canvas...
thanks
Speak postscript or die!
Translate to pdf and live!

Blaazen

  • Hero Member
  • *****
  • Posts: 2838
  • POKE 54296,15
    • Eye-Candy Controls
Re: Canvas questions
« Reply #1 on: April 02, 2013, 11:22:53 pm »
I don't understand the questions very well.

To 1) I think you are looking for InvalidateRect, it means that only part of component's canvas is repainted. It works well on Qt and GTk2.
Lazarus 2.1.0 r63594 FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Blestan

  • Sr. Member
  • ****
  • Posts: 461
Re: Canvas questions
« Reply #2 on: April 03, 2013, 07:37:47 am »
hummmm....
1. updaterect structure must me available during
paint. invalidaterect just add another rect to
list of invalid regions...
2. setviewport allows to set
an origin to all drawing operations,  so you can for
example draw at negative coordinates and still view
the drawing on the control.
Speak postscript or die!
Translate to pdf and live!

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Canvas questions
« Reply #3 on: April 03, 2013, 11:36:07 am »
There is no origin property on TCanvas. You can make your own TPoint variable for origin, and decrease it from every coordinate you use for drawing.

Example, origin:=point(100, 100).
Draw picture to (120-origin.x, 120-origin.y)
So now picture is drawn to (20, 20), relatively to origin.

 

TinyPortal © 2005-2018