Issue #709 resolved

Backing up and restoring Scissor state

John Kaniarz avatarJohn Kaniarz created an issue

Here's the minimum code for what I'm trying to do

function myDrawSubFunction()
    local x,y,w,h = --backup scissor
    --draw stuff,y,w,h) --restore scissor

I get a nil parameter error from setScissor() because, naturally, nil is not a valid scissor value. It would be nice if the returns from getScissor() were always valid to pass to setScissor(). (say, by making nils disable scissor)

This same problem also applies to get/setFont (and probably others), but at least with the font function once you set a default font, you're good for the run. Not so with scissor which is breaks whenever scissor is disabled.

Comments (4)

  1. Alex Szpakowski

    Fixed and to not error if a single nil argument is given (resolves issue #709)

    → <<cset d42d1079f2ba>>

    With fonts, I don't think it really makes sense to disable the font entirely, even though it's lazy-loaded.

  2. John Kaniarz

    I haven't tested the fix yet, but I expected the solution to check for exactly 4 nills. And shouldn't 1,2, or 3 parameters (nil or not) be an error?

    As for the font, perhaps getFont() when unitialized should create a default font and return it.

  3. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.