Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jan 2006
    Posts
    243
    Thanks
    14
    Thanked 2 Times in 2 Posts

    What's so handy about saving canvas drawing state?

    Right, so I've been reading about saving canvas drawing states and I understand how it works, but I just don't get the use of it when compared to setting it manually...

    Instead of writing restore(), re-writing the color value would do the same thing. And whith restore it isn't immediatly obvious what color is set, but when writing out the color it is. So obviously I'm missing what's so handy about this state saving bussiness... Can somebody please enlighten me?

    Thanks!

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    It's not only color. The graphics state of a canvas includes fillStyle, strokeStyle, lineWidth, and lineJoin

  • Users who have thanked devnull69 for this post:

    Kirl (11-16-2012)

  • #3
    Regular Coder
    Join Date
    Jan 2006
    Posts
    243
    Thanks
    14
    Thanked 2 Times in 2 Posts
    I see, thanks! For now I guess I prefer to reset everything manually as I can quickly edit single elements like lineWidth directly where it matters.

    Does it make any difference speed-wise if I use the stack or reset elements manually?

  • #4
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,294
    Thanks
    10
    Thanked 583 Times in 564 Posts
    you may want to try a 3000X4000 image and see if you notice a performance diff between the two.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •