I was playing around with Compose.jl
recently, when I realise that Forms
that use a radius, such as circle
have their radius tied to the width of the context window. See the two images and the code below for an example. As you can see, the first image fits nicely in the left and right halves of the image as I want, but in the second image, the radius fills to the width of the top and bottom halves, and the circle
“exceeds” the respective halves.
using Compose
set_default_graphic_size(10cm, 10cm)
function beside(left, right)
compose(
context(),
(context(0, 0, 0.5, 1), left),
(context(0.5, 0, 0.5, 1), right)
)
end
function stack(top, btm)
compose(
context(),
(context(0, 0, 1, 0.5), top),
(context(0, 0.5, 1, 0.5), btm)
)
end
c = circle()
besided = beside(c, c)
compose(
context(),
besided,
(context(), rectangle(), fill("white"))
)
besided |> SVG("besided.svg")
stacked = stack(c, c)
compose(
context(),
stacked,
(context(), rectangle(), fill("white"))
)
stacked |> SVG("stacked.svg")
The behavior seems to persist with other “radius based” Forms like star
, ngon
. I’m wondering if there is any way to tell the Form
to always use the shorter side for the radius instead of only sticking to the width?