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

"Document Size" for multiple images #125

Open
srush opened this issue Sep 14, 2023 · 3 comments
Open

"Document Size" for multiple images #125

srush opened this issue Sep 14, 2023 · 3 comments

Comments

@srush
Copy link
Collaborator

srush commented Sep 14, 2023

Since people are posting issues again, let me add one :)

I am having a lot of trouble keeping my images for my course at a standard size. The problem is that when I use SVG the images get rescaled in strange ways in different parts of the lecture.

For example the thickness of lines is set relative to the image size, but if I have 6 images all of different sizes the lines get resized differently. I can set a fixed height, put then sometimes the diagrams are really long and clip off the page.

I have some workarounds for this, but I feel like I am doing something incorrect, and I end up having to do hacks like "with_envelope" on each diagram to get it to look good.

@srush srush changed the title Standard sizes "Document Size" for multiple images Sep 14, 2023
@danoneata
Copy link
Collaborator

Thanks for the feature suggestion, Sasha! 🙂 These semantics would correspond to those of output units in diagrams, right?

@srush
Copy link
Collaborator Author

srush commented Sep 15, 2023

Ah, yup we should just copy their structure here. It is a bit annoying that you need to know about this when drawing (lwO). However if they did it that way, there is probably not a better solution.

@danoneata
Copy link
Collaborator

danoneata commented Sep 18, 2023

On a closer look it seems that our line_width_local already behaves like diagram's "output units" (so we should probably update this name?). For example, the diagrams generated by the following example result in the same line width (as far as I could tell):

from chalk import *

sq = square(1).line_width_local(1.5)
dia = hcat([sq.scale(s) for s in [0.5, 0.8, 1, 1.5, 2]], sep=0.2)
dia.render_svg("/tmp/out-1.svg", height=128)
dia.render_svg("/tmp/out-2.svg", height=512)

Apart from line width, I guess we also want to control the arrowhead size and font size in a similar manner, right?

It is a bit annoying that you need to know about this when drawing (lwO)

I think that this attribute can be specified at the end (just before rendering)? For example:

dia = hcat([square(1).scale(s) for s in [0.5, 0.8, 1, 1.5, 2]], sep=0.2)
dia.line_width_local(1.5).render_svg("/tmp/out.svg", height=128)

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