Skip to content
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

Automatic Layers and Not-Quite Infinity #60

Merged
merged 22 commits into from
Dec 1, 2022
Merged

Automatic Layers and Not-Quite Infinity #60

merged 22 commits into from
Dec 1, 2022

Conversation

seijihariki
Copy link
Collaborator

This is a pull request for something that I have been working when I could these past few days. Most of the changes are regarding the new layer management lib. (yes, it should support implementation of photoshop/gimp style layering; no, I did not implement it)

It should make some things more efficient, and others easier. It also supports multi-resolution, (aligned layers with different resolutions), as well as canvas with different sizes (a step to infinity).

This is a draft for now, to test for potential bugs and because after the revamp there are some very annoying half-a-pixel offsets when putting images and things that I want to try fixing.

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
Been working on this when I could the last few days.
Not quite infinity. Middle mouse button drag, ctrl mouse wheel zoom.

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
@seijihariki
Copy link
Collaborator Author

Oh, controls: ctrl + wheel is canvas zoom; middle mouse + drag is canvas move; rest should be as always.

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
At least temporarily, still want to check what causes smaller canvases
to break pixel perfection

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
@seijihariki seijihariki marked this pull request as ready for review November 29, 2022 23:26
Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
@zero01101
Copy link
Owner

zero01101 commented Nov 30, 2022

This is a pull request for something that I have been working when I could these past few days.

oh sure, just a tiny little adjustment here and there whenever you've got a few seconds ;)

spent like 10 minutes trying to figure out why /sdapi/v1/txt2img was 404ing until i noticed i was surprisingly getting CORS errors, and even more surprisingly they stopped when i cleared out my localstorage which i don't even know what to think about that

i also experienced the reticle "decentering" from the cursor at a few zoom levels but i suspect 6b0a25c fixes that nicely

love the "more" button after generation completes :D

haven't had a chance to go through all of this particularly deeply yet but i suspect i'll learn some new concepts as your commits generally have that effect :) what i've seen so far looks wonderful as always though, thanks!

-edit

minor visual bug, if you refresh the page with devtools open and then close them, checkerboard pans down the screen to "compensate"

@seijihariki
Copy link
Collaborator Author

spent like 10 minutes trying to figure out why /sdapi/v1/txt2img was 404ing until i noticed i was surprisingly getting CORS errors, and even more surprisingly they stopped when i cleared out my localstorage which i don't even know what to think about that

That is... Weird. Probably something about the loading of the host from the storage? If there was something strange it should have asked you to re-enter the host though.

i also experienced the reticle "decentering" from the cursor at a few zoom levels but i suspect 6b0a25c fixes that nicely

That should not have fixed anything, really. It's just a fix for the debug part of the ui. About decentering, maybe it is with a odd number of scale? I noticed it is snapping to both tile center and corners.

love the "more" button after generation completes :D

We should do more of these small quality of life updates, actually

haven't had a chance to go through all of this particularly deeply yet but i suspect i'll learn some new concepts as your commits generally have that effect :) what i've seen so far looks wonderful as always though, thanks!

No worries, any questions please tell.

-edit

minor visual bug, if you refresh the page with devtools open and then close them, checkerboard pans down the screen to "compensate"

Could you file this as an issue? I can give it a look later.

@zero01101
Copy link
Owner

zero01101 commented Nov 30, 2022

That is... Weird

right?? it handled the OPTIONS and GET calls to extra-single-image fine and dandy, but i honestly don't even remember seeing OPTIONS calls to txt2img while it was doing that... look, i've got a pretty singular talent for ruining everything around me so i sorta suspect this one's on me ;)

That should not have fixed anything, really.

:badpokerface: welp i just saw the addition of the offset and decided "yes, that must've been it, jolly good" :D

We should do more of these small quality of life updates, actually

genuinely agreed! actually on that, i wanted to apologize for not pushing more stuff recently; you keep just cranking out these PRs that are fantastic if a bit over my head sometimes and i'm simple and need time to catch up, and admittedly, like 97% of the functionality i wanted at first is functionally here already and i just can't stop playing with it lol

i may have also wasted some time trying to learn how to talk to SD2 over the weekend

Could you file this as an issue? I can give it a look later.

done and done; it's really quite minor in the fact that a user could quite easily just... pan the canvas back to origin :D #61

@seijihariki
Copy link
Collaborator Author

That is... Weird

right?? it handled the OPTIONS and GET calls to extra-single-image fine and dandy, but i honestly don't even remember seeing OPTIONS calls to txt2img while it was doing that... look, i've got a pretty singular talent for ruining everything around me so i sorta suspect this one's on me ;)

Now that I think about it, it may have been my fault, as I basically reimplemented the full pipeline of dream() in general. If I remember correctly, when I saw the fetch() call used for dream, I removed most of the headers that I considered redundant.

Probably there was a cache-related header that triggered some issues, and cleaning site data may have resolved the cache issue.

That should not have fixed anything, really.

:badpokerface: welp i just saw the addition of the offset and decided "yes, that must've been it, jolly good" :D

If you could create an issue for this one too, it would be perfect!

We should do more of these small quality of life updates, actually

genuinely agreed! actually on that, i wanted to apologize for not pushing more stuff recently; you keep just cranking out these PRs that are fantastic if a bit over my head sometimes and i'm simple and need time to catch up, and admittedly, like 97% of the functionality i wanted at first is functionally here already and i just can't stop playing with it lol

No problems whatsoever! I am quite satisfied with the current state of the app, actually.

I may have also wasted some time trying to learn how to talk to SD2 over the weekend

That is something I have to give a deeper look; Interestingly, even though I created the discussion on SD2, I have still not used it myself.

Could you file this as an issue? I can give it a look later.

done and done; it's really quite minor in the fact that a user could quite easily just... pan the canvas back to origin :D #61

Yeah, that's what I was thinking. I'm not really sure how to address this issue, as we don't really receive any information as to how the window was resized. Only that it was, indeed, resized, and the new window size.

Add some shortcuts to dream image selection and fix strange cursor
behavior on resource add from dream. (l/r arrow keys for navigation,
enter for image select; esc for reject)

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
@seijihariki
Copy link
Collaborator Author

Fixed canvas on chrome. It seems chrome doesn't like to transform layer coords based on CSS transforms, so we will have to do this manually.

Windows now are kept inside the viewable area. No more losing them when resizing the window or dragging them outside.

Fix for image gen shortcuts, now "+" generates more images.

@seijihariki
Copy link
Collaborator Author

Viewport also starts in the center now, maybe could be a fix to #61.

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
@zero01101
Copy link
Owner

zero01101 commented Nov 30, 2022

you are legitimately a machine

That should not have fixed anything, really.

:badpokerface: welp i just saw the addition of the offset and decided "yes, that must've been it, jolly good" :D

If you could create an issue for this one too, it would be perfect!

if i could reproduce it, i'd be glad to but it hasn't happened since lol; it was very similar to how it behaved long before i even pushed this to github if i was using it with devtools open and i was scrolled down the page, it was definitely offsetting incorrectly due to actual mouseX/Y vs canvasX/Y (ergo the coord monitors) back then... hasn't occurred since though, but if it does i'll try to recreate it reliably :)

locking the floating windows to the active viewport is a little pinch of genius

Fixed canvas on chrome. It seems chrome doesn't like to transform layer coords based on CSS transforms, so we will have to do this manually.

sigh i need to start testing things on more than firefox because i didn't even know that was a thing lol

Viewport also starts in the center now, maybe could be a fix to #61.

hah, i was 100% prepared to completely write off the checkerboard positioning as not-a-bug, wontfix, this is literally just how browsers work but here you are with more fixes already!

i just noticed that if you answer N to an img2img batch, it leaves the previous marching ants behind - issue #63 opened :)

as always, thanks for all you do and sorry i haven't been contributing more; lousy job that pays my bills demands my attention ;)

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
@zero01101
Copy link
Owner

i also think i failed to mention that i love love love the new progress indicator; i was seriously thinking "gee this could be a nice little feature that i might be able to write" about something extremely similar and then it just kinda showed up :D

this is all marvelous and your suggestion of actual layers is maybe more intriguing than my original designs for infinite canvas lol

i haven't experienced much in those offsets you mentioned in the initial PR message but that's probably because i'm simply inobservant :D

Copy link
Owner

@zero01101 zero01101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(comments: look up)

@zero01101
Copy link
Owner

zero01101 commented Dec 1, 2022

oh did i mention that i learned if you leave your prompt field empty and use img2img on a chunk of existing image, it works as a very effective "alternative" of what currently exists, like a more literal mutate button and it's wonderful :D

...this has literally nothing to do with the PR, did i mention i'm inobservant

Copy link
Owner

@zero01101 zero01101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there better way to do this currently?

@seijihariki
Copy link
Collaborator Author

Hi, could you specify what exactly? I'm uncertain if there is a way for me to see what you are referring to...

@seijihariki
Copy link
Collaborator Author

Are you talking about the body scroll fix?

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
@seijihariki
Copy link
Collaborator Author

i haven't experienced much in those offsets you mentioned in the initial PR message but that's probably because i'm simply inobservant :D

And this is probably less of a lack of attention and more that I kinda gave up on fixing small canvas offsets for now and just used a full-sized layer for the dream image insertion overlay: b2d51d4

oh did i mention that i learned if you leave your prompt field empty and use img2img on a chunk of existing image, it works as a very effective "alternative" of what currently exists, like a more literal mutate button and it's wonderful :D

...this has literally nothing to do with the PR, did i mention i'm inobservant

That's cool! I need to play more with some of the features.

@zero01101
Copy link
Owner

lmao i'm bad at github, i warned you :P i meant my little brushed mask clearing fix 4dafe50; layers sensibly only permit deleting the whole thing, but i figured i might have missed a better way to manage the boundary box than a for loop

const imgCanvas = imgLayer.canvas; // where dreams go
const imgCtx = imgLayer.ctx;

const maskPaintCanvas = maskPaintLayer.canvas; // where mouse cursor renders
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I expose the mask layers with the same names as before, so using them as in the past should not be an issue.

@seijihariki
Copy link
Collaborator Author

lmao i'm bad at github, i warned you :P i meant my little brushed mask clearing fix 4dafe50;

Is this for clearing mask where the image was put? If so, that could use the ctx.clearRect() function. Should work wonders for clearing a square area! (ex: 4dafe50#r91620767)

layers sensibly only permit deleting the whole thing, but i figured i might have missed a better way to manage the boundary box than a for loop

All layers have both their canvas and context accessible, and for the main ones (mask for example) I continued exposing the canvas and Ctx with the same names as before for backwards compatibility, as seen in my previous line comment.

So, don't be afraid to use the canvases as normal.

@seijihariki
Copy link
Collaborator Author

So, when referencing a specific line, I would recommend you to comment on the line itself of the changes:
image
When hovering the line you should see a blue plus thing on the side. Clicking that allows you to comment on a specific line.

@zero01101
Copy link
Owner

your guidance is hugely appreciated as always, clearRect() is precisely what i should have been using the whole time

Copy link
Owner

@zero01101 zero01101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all systems go from my perspective :D

@seijihariki
Copy link
Collaborator Author

Added one more comment to your commit, regarding imagedata objects.
4dafe50#r91621617
Some more info that may be useful for you in the future.

@seijihariki
Copy link
Collaborator Author

I will then be merging the pull for now.

@seijihariki seijihariki merged commit 3281277 into main Dec 1, 2022
@zero01101
Copy link
Owner

i'll spiff up the readme tomorrow after work, many thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants