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

No clip paths? #337

Closed
jkrumbiegel opened this issue Dec 25, 2018 · 2 comments · Fixed by #359
Closed

No clip paths? #337

jkrumbiegel opened this issue Dec 25, 2018 · 2 comments · Fixed by #359

Comments

@jkrumbiegel
Copy link

I can't find documentation on clipping paths, like making a half moon by subtracting a circle from another circle. Is this not possible in compose.jl?

@Mattriks
Copy link
Member

There is basic clipping, not documented yet. For basic clipping, everything outside the clip() shape is clipped out:

set_default_graphic_size(7inch,3.5inch)

points(x::Compose.Form) = x.primitives[1].points

X = rand(10,2)
colv = HSVA.(range(0,stop=180,length=10), 1, 1, 0.5)

img = compose(context(units=UnitBox(0,0,2,1)), stroke("black"),
    (context(), rectangle(), fill(nothing)),
    (context(), ngon([0.5,1.5],[0.5], [0.4], [10]), fill(nothing), stroke("lightgray")),
    (context(), xgon(X[:,1],X[:,2],[0.2],[4]), fill(colv)),
    (context(), xgon(X[:,1].+1,X[:,2],[0.2],[4]), fill(colv),
        clip(points(ngon(1.5,0.5, 0.4, 10))) )
)

draw(PNG(), img)
# draw(SVG(), img)

iss337

Your hypothetical example of a crescent moon is interesting because that would involve inner clipping i.e. everything inside the inner circle (or shape) is clipped out. Pasting a white circle would have the same effect (but don't know if that's suitable):

img = compose(context(),
    (context(), circle([0.5,0.35], [0.5], [0.25,0.3]), fill(["gold","white"]))
)

@tlnagy
Copy link
Member

tlnagy commented Dec 30, 2018

It would be awesome to have this make it into the docs, looks great @Mattriks

@Mattriks Mattriks mentioned this issue Oct 5, 2019
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 a pull request may close this issue.

3 participants