Canvas1.Graphics help please

  1. 2 months ago

    Lennox J

    Feb 8 Jamaica. West Indies
    Edited 2 months ago

    Hello,

    I am using help from https://forum.xojo.com/51035-graphics

    I am trying to upgrade my project which works well in Xojo 2018 Release 2, I am now building it in Xojo 2018 Release 4 and am having some issues...

    In Xojo 2018 Release 2 Canvas1.MouseDown I have the following code
    app.gMousedownXD = X
    app.gMousedownyD = Y

    In Canvas1.MouseUp, I have
    app.gMousedownXU = X
    app.gMousedownYU = Y

    Canvas1.Graphics.ForeColor = &cFF0000
    Canvas1.Graphics.DrawOval ( app.gMousedownXD-3, app.gMousedownYD-3, app.gMousedownXU-app.gMousedownXD+6, app.gMousedownYU-app.gMousedownYD+6 )
    Canvas1.Graphics.DrawOval ( app.gMousedownXD, app.gMousedownYD, app.gMousedownXU-app.gMousedownXD, app.gMousedownYU-app.gMousedownYD )

    and that works well... the marquee is displayed.

    ***********************

    in Xojo 2018 Release 4 Canvas1.MouseDown I have the following code
    app.gMousedownXD = X
    app.gMousedownyD = Y

    In Canvas1.MouseUp, I have
    app.gMousedownXU = X
    app.gMousedownYU = Y

    MouseUp = true // MouseUp is a property
    Invalidate()

    In Canvas1.Paint I have
    if MouseUp = true Then
    g.ForeColor = &cFF0000
    g.DrawOval ( app.gMousedownXD-3, app.gMousedownYD-3, app.gMousedownXU-app.gMousedownXD+6, app.gMousedownYU-app.gMousedownYD+6 )
    g.DrawOval ( app.gMousedownXD, app.gMousedownYD, app.gMousedownXU-app.gMousedownXD, app.gMousedownYU-app.gMousedownYD )

    MouseUp = false

    else
    // Paint it in normal state
    end if

    When I do a Canvas1.MouseDown followed by a Canvas1.MouseUp at a different co-ordinate
    I do not see any marquee but in Xojo 2018 Release 2 the marquee is displayed.

    Any suggestions?

    Thanks.

    Lennox

    Here you go Lennox, not my best work as it was a bit quick, you'll need to put in some error checking etc.

    https://www.dropbox.com/s/2qlyc0ntkur8c5b/TestDropOval.xojo_binary_project?dl=1

  2. Julian S

    Feb 8 Pre-Release Testers, Xojo Pro UK

    Make sure you don't have any controls on top of your canvas that are set to transparent as this will cause an additional paint of Canvas which will render at the MouseUp = False state.

  3. Lennox J

    Feb 8 Jamaica. West Indies

    Hi Julian,

    I removed all controls from the window and it's a canvas only in a window now... No marquee displayed.

    Thanks.

    Lennox

  4. jim m

    Feb 8 Pre-Release Testers piDog.com

    Did you return true from MouseDown?

  5. Lennox J

    Feb 8 Jamaica. West Indies

    Thanks Julian,

    Working now.

    Thanks again.

    But If I wand a second marquee how do I do that?

    Thanks.

    Lennox

  6. Lennox J

    Feb 8 Jamaica. West Indies

    @jim m Did you return true from MouseDown?

    Yes I did Jim, and Julian's advice worked, but now I want a second and more marquees.

    Any advice?

    Thanks.

    Lennox

  7. Julian S

    Feb 20 Pre-Release Testers, Xojo Pro UK

    Sorry I didn't respond to this, I must have got distracted by something shiny ;)

    I'd suggest drawing to a separate picture much like you would have done with your previous version. Then in the paint just draw the picture to the canvas. That will keep any state mechanics away from your paint routines, make your paint routines quicker and allow you to use refrechrect where you are drawing your ovals so you can target your paint to just update the portions of the image that change, again making everything quicker.

  8. Julian S

    Feb 20 Pre-Release Testers, Xojo Pro UK

    Here's a simple version I put together for someone back in November.

    https://www.dropbox.com/s/rduxbjwkgp3yzzn/PaintBuffer.xojo_binary_project?dl=1

  9. Lennox J

    Feb 20 Jamaica. West Indies

    Thanks Julian,

    I will try it out.

    Regards.

    Lennox

  10. Emile S

    Feb 20 Europe (France, Strasbourg)

    https://blog.xojo.com/2018/12/06/updating-code-that-used-the-graphics-property/

  11. Lennox J

    Feb 20 Jamaica. West Indies

    Thanks Emile,

    I tried that but I cannot get multiple ovals.

    I can do multiple ovals when compiled in Xojo 2018 Release 2 but not Xojo 2018 Release 3 or Xojo 2018 Release 4.

    Would you like to see the project?

    Thanks.

    Lennox

  12. Julian S

    Feb 20 Pre-Release Testers, Xojo Pro UK

    Yes please

  13. The Paint Buffer project extended a bit
    works fine under R4

    https://www.dropbox.com/preview/PaintBuffer%20(10).xojo_binary_project?role=personal

  14. sorry
    https://www.dropbox.com/s/yqk6x1m7d3fbyfx/PaintBuffer%20%2810%29.xojo_binary_project?dl=0

  15. Julian S

    Feb 20 Pre-Release Testers, Xojo Pro UK

    Do you have a link for the HalloMann image?

  16. https://www.dropbox.com/s/flujft58k7djnde/Malmann.png?dl=0

    You can take any picture

  17. Lennox J

    Feb 21 Jamaica. West Indies

    Hi Julian,

    The project has been uploaded here... https://www.mediafire.com/file/4ngk8i7ha8aq2al/Multiple_Graphic_Marquee_2019_Feb_10%27.xojo_binary_project/file

    After compiling on Mac, launch the app, drop a .jpg or .png file, then do multiple marquees.

    Thanks again.

    Lennox

  18. Emile S

    Feb 21 Europe (France, Strasbourg)
    Edited 2 months ago

    It was said here (and everywhere) that:

    Canvas1.Graphics

    no more working and was deprecated since Alley Oop was a teenager ;)

    So, create a Picture,
    draw into it,
    and in .Graphics, Draw that Picture (or in .backdrop).

    In MouseUp: draw your small red circle in that Picture.

    Edit:
    BTW: your project works fine with 2015r1 ;)

  19. Emile S

    Feb 21 Europe (France, Strasbourg)

    Did you read the two links at the bottom of:

    https://forum.xojo.com/51639-old-funktion-graphics-in-xojo-2018r4

  20. Lennox J

    Feb 21 Jamaica. West Indies

    Hi Emile,

    These two...
    Xojo Blog: Updating Code That Used The Graphics Property
    Xojo Documentation: Updating Code That Used the Graphics Property

    I read them and I tried them, did not work, maybe I am still doing something wrong, any other advice?

    Thanks.

    Lennox

  21. Newer ›

or Sign Up to reply!