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

The logic of the "Undo Image" and "Redo image" buttons #97

Open
TaunT opened this issue Aug 2, 2024 · 4 comments
Open

The logic of the "Undo Image" and "Redo image" buttons #97

TaunT opened this issue Aug 2, 2024 · 4 comments

Comments

@TaunT
Copy link

TaunT commented Aug 2, 2024

If we are in the "Paste Translations" panel after inserting text and click the "Undo Image" button, the cleaned image is loaded, but the text blocks do not appear =( Although they were in the previous step "Clean image", I want to move them and change their sizes

@TaunT
Copy link
Author

TaunT commented Aug 2, 2024

comic.py
image
Oh! I did it myself, just 3 lines) it became much more convenient, you can insert text, cancel, move blocks and insert again, easy

p.s. As a result, there is a condition >= 2 , I didn’t know that each time there is a new entry in the history

image

@TaunT
Copy link
Author

TaunT commented Aug 2, 2024

p.s. Damn, but if I move or resize the blocks - it doesn't seem to affect anything, the text seems to be inserted into the very first version. I'll have to try to figure it out again

and self.update_blk_list() in render_text doesn't help. also tried self.pipeline.load_box_coords(self.blk_list)
@ogkalu2 can you give me some advice?)

I logged the block coordinates - they are fresh, but the text is still inserted in the old place. It's a mystery

@ogkalu2
Copy link
Owner

ogkalu2 commented Aug 2, 2024

remove @cachedproperty from the xywh function in modules.utils.textblock

Then in modules.rendering.render, replace blk.xywh with blk.xywh()

@TaunT
Copy link
Author

TaunT commented Aug 2, 2024

Thank you!! It worked
in the end, I did it like this:

comic.py

def render_text(self):
.
.
            use_cache = self.automatic_radio.isChecked()
            self.run_threaded(draw_text, self.on_render_complete, self.default_error_handler, 
                              None, inpaint_image, self.blk_list, font_path, 15, fixed_font_size, use_cache, colour=font_color)

modules/rendering/render.py

def draw_text(image: np.ndarray, blk_list: List[TextBlock], font_pth: str, init_font_size, fixed_font_size: str = None, use_cache: bool = False, colour: str = "#000"):
.
.
    for blk in blk_list:
        if use_cache:
            x1, y1, width, height = blk.xywh()
        else:
            x1, y1, width, height = blk.xywh_wo_cache()

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

No branches or pull requests

2 participants