-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dynamic canvas scaling? #108
Conversation
Signed-off-by: Victor Seiji Hariki <[email protected]>
And, if you want to ask, this system probably supports infinite canvasing (autoscale and whatnot). Just need to tweak the black magic a bit, detecting external draw requests and sending an expand() call when a draw is attempted outside the allocated area. It could be an exercise for the viewer :P |
Signed-off-by: Victor Seiji Hariki <[email protected]>
aaaaaaaaaaaaaaaaaaaaaaahahahahahahahahahahaha it IS exactly what i was thinking it was lmao literally my first response to expanding the canvas: this is so so so so so good, like i swear to god i tried to do exactly this and ... yeah |
very very obviously i haven't put any real time into playing with it yet but my god it's perfect i <3 black magic [edit] huh ok well i swear there was an instance in which outpainting wasn't working at all but now i can't reproduce it [more edit] 🤦 well seems that was because i had runway's non inpainting 1.5 model loaded |
Signed-off-by: Victor Seiji Hariki <[email protected]>
Will be pushing some fixes for tools as I find issues. A quick demo: Peek.2022-12-17.01-03.mp4 |
Signed-off-by: Victor Seiji Hariki <[email protected]>
Signed-off-by: Victor Seiji Hariki <[email protected]>
Signed-off-by: Victor Seiji Hariki <[email protected]>
Is this after the last commits done to the branch? I can give it a look. |
[edit] yep, happening on fc7302f ohh, interesting, i hadn't given it much of a thorough poke around or anything; just tried it again though and made THREE whole images on it and oh hey guess what but export gives me [more edit] lol please don't think this is some kind of OMG EMERGENCY BUGFIX thing, i'm about to go to bed but seriously this really is black magic and i love it |
Signed-off-by: Victor Seiji Hariki <[email protected]>
Fixed |
I'm going to bed as well, actually. Good night! |
Haha, I mean, I've fixed so many of these tiny fixed-coordinate related bugs while implementing this that it became second nature to me to fix these. Also, that is a great example of the 0,0 coordinate not meaning anything anymore. It previously represented the top-leftmost point in the canvas. Now it's just a random point inside it. (-context.origin.x, -context.origin.y) is now the top-leftmost point. Could use layer.origin or collection.origin instead (imageCollection for the main image collection). |
Signed-off-by: Victor Seiji Hariki <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh very absolutely yes, 100% all about the black magic
/** | ||
* Represents a size | ||
*/ | ||
class Size { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love it
let minx = Infinity; | ||
let maxx = -Infinity; | ||
let miny = Infinity; | ||
let maxy = -Infinity; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah negative infinity is one of those things i have trouble even conceptualizing lmao
We finally have some working (?) dynamic canvas scaling. For now, uses buttons to scale the canvas manually. It has some of the black magic everyone loves, and messing with prototypes (which is okay, I think. This is an end-user application and not a lib, and changes only affect canvases with the .origin property set on its context.).
But the good thing of using this approach is that "most" code didn't change much, and if you just develop your tools using world coordinates as normal, everything should work fine. Hard-coded coordinates have no more meaning practically, not even (0, 0) for the layer canvases, so for these particular uses you will have to use the Root functions, like
drawImageRoot
, or use utility layer functions such as layer.clear().So, basically:
Initially, I was trying to use translate() transform and other transformation matrices. But some things (drawImage did not take translate into account when sourcing; same as getImageData and putImageData) were making this a painful transition.
So, this is the black magic commit. If you find any problems during testing (I would be surprised if there aren't any), please open an issue, so I can give this a look.
@zero01101 I don't know what you were expecting, but I guess it may be this.
Signed-off-by: Victor Seiji Hariki [email protected]