that works

thanks !

On Thursday, August 27, 2015 at 12:28:22 PM UTC-4, Darwin Darakananda wrote:
>
> This sounds like the same issue as 
> https://github.com/dcjones/Compose.jl/issues/133. Try using polygon 
> instead of rectangle for now. 
>
> On Wednesday, August 26, 2015 at 10:34:21 AM UTC-7, Mark wrote: 
> > Learning Compose. 
> > 
> > Trying the code below to rotate images. 
> > 
> > The rotate function seems to work on the line-drawn "V" but not on the 
> colored checker box. 
> > 
> > How do I fix this so the rotate function works for drawings like the 
> checker box? 
> > 
> > Some outputs attached. 
> > 
> > Thank you for your advice. 
> > 
> > 
> > ******** 
> > 
> > using Compose 
> > using Color 
> > 
> > # draw a black box 
> > function blackbox() 
> >    compose(context(), rectangle(), fill("black")) 
> > end 
> > 
> > # draw a blue box 
> > function bluebox() 
> >    compose(context(), rectangle(), fill("lightblue")) 
> > end 
> > 
> > # join pic2 to pic1 horizontally 
> > function hsplice(pic1, pic2) 
> >    compose(context(), compose(context(0.0, 0.0, 0.5, 1.0), pic1), 
> >            compose(context(0.5, 0.0, 0.5, 1.0), pic2)) 
> > end 
> > 
> > # join pic2 to pic1 vertically 
> > function vsplice(pic1, pic2) 
> >    compose(context(), compose(context(0.0, 0.0, 1, 0.5), pic1), 
> >            compose(context(0.0, 0.5, 1, 0.5), pic2)) 
> > end 
> > 
> > # rotate pic counter-clockwise 90 degrees 
> > function rotate(pic) 
> >     compose(context(rotation=Rotation(-pi/2)), pic) 
> > end 
> > 
> > # draw a checker pattern 
> > function checker(p1, p2) 
> >    compose(vsplice(hsplice(p1, p2), 
> >                    hsplice(p2, p1))) 
> > end 
> > 
> > 
> > # cpic is a blue and black checker picture 
> > cpic = checker(bluebox(), blackbox()) 
> > 
> > # cimg receives cpic 
> > cimg = SVG("cpic.svg", 8cm, 8cm) 
> > 
> > # draw cpic to cimg 
> > draw(cimg, cpic) 
> > 
> > #rotate checker: 
> > rpic = rotate(cpic) 
> > rimg = SVG("rpic.svg", 8cm, 8cm) 
> > draw(rimg, rpic) 
> > 
> > # check rotate function: 
> > 
> > # points to draw a "V" 
> > Vpoints = [ (0.2, 0), 
> >             (0.5, 1), 
> >             (0.8, 0) ] 
> > 
> > 
> > # draw a V: 
> > vpic = compose(context(), stroke("black"), line(Vpoints)) 
> > 
> > # file for "V" drawing: 
> > vimg = SVG("vimg.svg", 8cm, 8cm) 
> > 
> > # draw vimg: 
> > draw(vimg, vpic) 
> > 
> > # rotate vpic: 
> > rvpic = rotate(vpic) 
> > rvimg = SVG("rvimg.svg", 8cm, 8cm) 
> > draw(rvimg, rvpic) 
>

Reply via email to