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

Composing with an array of forms #80

Open
Keno opened this issue Sep 6, 2014 · 3 comments
Open

Composing with an array of forms #80

Keno opened this issue Sep 6, 2014 · 3 comments

Comments

@Keno
Copy link
Collaborator

Keno commented Sep 6, 2014

It seems that the following was intended to work:

u = 16
lines = [line([(0.5,0.6),((1+(i-1)/sqrt(u))*0.5w,0.7w)]) for i=1:sqrt(u)]
compose(context(),lines,linewidth(0.1mm),stroke("black"))

It fails with:

`compose` has no method matching compose(::Form{LinePrimitive}, ::Form{LinePrimitive}, ::Form{LinePrimitive}, ::Form{LinePrimitive})
while loading In[43], in expression starting on line 1

 in compose at /Users/kfischer/.julia/Compose/src/container.jl:253

The following works though:

compose(context(),lines...,linewidth(0.1mm),stroke("black"))
@dcjones
Copy link
Collaborator

dcjones commented Sep 7, 2014

This is pretty much by design. Since compose will interpret its arguments as a sort of S-expression, here it will try to make the first object in the array an internal and the rest it's children, but forms like Lines are always leaves in the tree.

I should have a more descriptive error than "no matching method" though.

@kzapfe
Copy link

kzapfe commented Jun 25, 2015

I am baffled here... What does ... mean here and how should it be used correctly?
I am having similar problems. I can create circles with vector arguments as the examples, but not lines, and that is quite unconfortable.

@dcjones
Copy link
Collaborator

dcjones commented Jun 25, 2015

The ... is regular Julia syntax. For example f(xs...) is equivalent to f(xs[1], xs[2], xs[3]) if xs has three elements. See http://julia.readthedocs.org/en/latest/manual/functions/#varargs-functions.

There are two ways to draw multiple lines. As multiple line forms...

compose(context(), line([(0,0), (1,1)]), line([(0,1), (1,0)]), stroke("black"))

...or as a single vectorized line form

compose(context(), line([[(0,0), (1,1)], [(0,1), (1,0)]]), stroke("black"))

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

3 participants