chalk-diagrams / chalk

A declarative drawing API in Python
MIT License
276 stars 13 forks source link

Envelope scaling #109

Closed srush closed 2 years ago

srush commented 2 years ago

There is still a bug in calculation of envelope scaling. Tried to implement this code but I think I missed a scaling factor.

https://hackage.haskell.org/package/diagrams-core-1.5.0/docs/src/Diagrams.Core.Envelope.html#Envelope

As part of fixing this will also implement some tests for traces / envelopes / trails. Possibly using Hypothesis. It is nice that these are easy to tests.

danoneata commented 2 years ago

Thanks! Do you happen to have an example showcasing the problem?

What properties do you have in mind to test, in particular for envelopes? Something like what they mention in the comments:

‖proj(u, v)‖ / ‖v‖ ≤ dia.envelope(v)

for all dia, u ∈ dia and v ∈ R²?

srush commented 2 years ago

This should be 2 but is failing circle(1).get_envelope()(2 * unit_x) . All the logic is in envelope apply_transform so my guess that is not handling magnitude properly.

Yes, I think that property is good. Think we could come up with some others as well. The interesting part would be a sampling strategy for transforms / diagrams.