Scrolling graphics on canvas

  1. 5 weeks ago

    I've read a lot of old posts about scrolling canvases, read the documentation but still having difficulties. Here's the scenario:

    I am directly drawing a complicated graphic image to a canvas, not a picture. Here's the simple code which is in the Paint event of the canvas:

    g.ScaleX = PS.ScaleX
    g.ScaleY = PS.ScaleY
    
    PS.PrintPuzzle(g)

    The scaling is so I can zoom in on the drawing. The PS.PrintPuzzle is the whole complicated drawing set of methods. It works fine except when I try adding this to the Paint event:

    Me.Scroll (-scroll2, -scroll1)

    I get the drawing followed by the scrolling and a general mess. Do I have to use DrawPicture to get this to work?

    Or in a more simple way use a clip
    ...
    PS.PrintPuzzle(g.clip(-scrollX, -scrollY, neededHeight, neededWidth))

    In this way your draw is with the original coordinates

    In any case (and Greg's suggestion is right) you should try to avoid drawing commands that you know will happen out of the used graphic area.

  2. Greg O

    Sep 14 Xojo Inc

    You could pass scroll amounts to your printpuzzle method and just add that to every x and y coordinate.

  3. Antonio R

    Sep 14 Pre-Release Testers, Xojo Pro, Third Party Store Answer Europe (Italy)

    Or in a more simple way use a clip
    ...
    PS.PrintPuzzle(g.clip(-scrollX, -scrollY, neededHeight, neededWidth))

    In this way your draw is with the original coordinates

    In any case (and Greg's suggestion is right) you should try to avoid drawing commands that you know will happen out of the used graphic area.

  4. 4 weeks ago

    Thanks for the replies. (I forgot I had posted the question. Busy weekend.)

    I'll try Antonio's idea first. I had done, in a previous rendition, a lot of x,y adjusting and it seemed to clunk up the code. But it may be what I need to do.

or Sign Up to reply!