diff options
author | bnewbold <bnewbold@robocracy.org> | 2016-02-21 18:08:55 -0800 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2016-02-21 18:08:55 -0800 |
commit | b24f282bca4af63982937c10835063d3e6e9eb74 (patch) | |
tree | fd8c58601beb3964ccecf4709f7b28944fc1c36b /examples/drawing | |
parent | 84572be10cdfc852530787a5dc78ddef3e0f23cd (diff) | |
download | PyX.jl-b24f282bca4af63982937c10835063d3e6e9eb74.tar.gz PyX.jl-b24f282bca4af63982937c10835063d3e6e9eb74.zip |
add many, many more example conversions. still not complete
Diffstat (limited to 'examples/drawing')
-rw-r--r-- | examples/drawing/arrow.jl | 23 | ||||
-rw-r--r-- | examples/drawing/metapost.jl.broken | 51 | ||||
-rw-r--r-- | examples/drawing/path.jl | 20 | ||||
-rw-r--r-- | examples/drawing/pathitem.jl | 46 | ||||
-rw-r--r-- | examples/drawing/strokefill.jl | 20 | ||||
-rw-r--r-- | examples/drawing/style.jl | 29 |
6 files changed, 189 insertions, 0 deletions
diff --git a/examples/drawing/arrow.jl b/examples/drawing/arrow.jl new file mode 100644 index 0000000..ec2cb06 --- /dev/null +++ b/examples/drawing/arrow.jl @@ -0,0 +1,23 @@ + +# Original Python: +# from pyx import * + +# c = canvas.canvas() +# c.stroke(path.curve(0, 0, 0, 4, 2, 4, 3, 3), +# [style.linewidth.THICK, style.linestyle.dashed, color.rgb.blue, +# deco.earrow([deco.stroked([color.rgb.red, style.linejoin.round]), +# deco.filled([color.rgb.green])], size=1)]) +# c.writeEPSfile("arrow") +# c.writePDFfile("arrow") +# c.writeSVGfile("arrow") + + +using PyX + +c = canvas.canvas() +stroke(c, path.curve(0, 0, 0, 4, 2, 4, 3, 3), + [style_linewidth.THICK, style_linestyle.dashed, color_rgb.blue, + deco.earrow([deco.stroked([color_rgb.red, style_linejoin.round]), + deco.filled([color_rgb.green])], size=1)]) +writeEPSfile(c, "arrow") +writePDFfile(c, "arrow") diff --git a/examples/drawing/metapost.jl.broken b/examples/drawing/metapost.jl.broken new file mode 100644 index 0000000..bcd2f84 --- /dev/null +++ b/examples/drawing/metapost.jl.broken @@ -0,0 +1,51 @@ + +# Original Python: +# from pyx import * +# from pyx.metapost.path import beginknot, endknot, smoothknot, tensioncurve + +# p1, p2, p3, p4, p5 = (0, 0), (2, 1.33), (1.3, 3), (0.33, 2.33), (1, 1.67) +# openpath = metapost.path.path([ +# beginknot(*p1), tensioncurve(), smoothknot(*p2), tensioncurve(), +# smoothknot(*p3), tensioncurve(), smoothknot(*p4), tensioncurve(), +# endknot(*p5)]) +# closedpath = metapost.path.path([ +# smoothknot(*p1), tensioncurve(), smoothknot(*p2), tensioncurve(), +# smoothknot(*p3), tensioncurve(), smoothknot(*p4), tensioncurve(), +# smoothknot(*p5), tensioncurve()]) +# c = canvas.canvas() +# for p in [p1, p2, p3, p4, p5]: +# c.fill(path.circle(p[0], p[1], 0.05), [color.rgb.red]) +# c.fill(path.circle(p[0], p[1], 0.05), [color.rgb.red, trafo.translate(2, 0)]) +# c.stroke(openpath) +# c.stroke(closedpath, [trafo.translate(2, 0)]) + +# c.writeEPSfile("metapost") +# c.writePDFfile("metapost") +# c.writeSVGfile("metapost") + +using PyX + +beginknot = metapost_path.beginknot +endknot = metapost_path.endknot +smoothknot = metapost_path.smoothknot +tensioncurve = metapost_path.smoothknot + +p1, p2, p3, p4, p5 = (0, 0), (2, 1.33), (1.3, 3), (0.33, 2.33), (1, 1.67) +openpath = metapost_path.path([ + beginknot(p1...), tensioncurve(), smoothknot(p2...), tensioncurve(), + smoothknot(p3...), tensioncurve(), smoothknot(p4...), tensioncurve(), + endknot(p5...)]) +closedpath = metapost_path.path([ + smoothknot(p1...), tensioncurve(), smoothknot(p2...), tensioncurve(), + smoothknot(p3...), tensioncurve(), smoothknot(p4...), tensioncurve(), + smoothknot(p5...), tensioncurve()]) +c = canvas.canvas() +for p in [p1, p2, p3, p4, p5]: + fill(c, path.circle(p[0], p[1], 0.05), [color_rgb.red]) + fill(c, path.circle(p[0], p[1], 0.05), [color_rgb.red, trafo.translate(2, 0)]) +stroke(c, openpath) +stroke(c, closedpath, [trafo.translate(2, 0)]) + +writeEPSfile(c, "metapost") +writePDFfile(c, "metapost") + diff --git a/examples/drawing/path.jl b/examples/drawing/path.jl new file mode 100644 index 0000000..380d3ed --- /dev/null +++ b/examples/drawing/path.jl @@ -0,0 +1,20 @@ +# Original Python: +# from pyx import * + +# c = canvas.canvas() +# c.stroke(path.line(0, 0, 3, 0)) +# c.stroke(path.rect(0, 1, 1, 1)) +# c.fill(path.circle(2.5, 1.5, 0.5)) +# c.writeEPSfile("path") +# c.writePDFfile("path") +# c.writeSVGfile("path") + +using PyX + +c = canvas.canvas() +stroke(c, path.line(0, 0, 3, 0)) +stroke(c, path.rect(0, 1, 1, 1)) +pyx_fill(c, path.circle(2.5, 1.5, 0.5)) + +writeEPSfile(c, "path") +writePDFfile(c, "path") diff --git a/examples/drawing/pathitem.jl b/examples/drawing/pathitem.jl new file mode 100644 index 0000000..2835313 --- /dev/null +++ b/examples/drawing/pathitem.jl @@ -0,0 +1,46 @@ + +# Original Python: +# from pyx import * + +# c = canvas.canvas() + +# rect1 = path.path(path.moveto(0, 0), path.lineto(1, 0), +# path.moveto(1, 0), path.lineto(1, 1), +# path.moveto(1, 1), path.lineto(0, 1), +# path.moveto(0, 1), path.lineto(0, 0)) +# rect2 = path.path(path.moveto(2, 0), path.lineto(3, 0), +# path.lineto(3, 1), path.lineto(2, 1), +# path.lineto(2, 0)) +# rect3 = path.path(path.moveto(4, 0), path.lineto(5, 0), +# path.lineto(5, 1), path.lineto(4, 1), +# path.closepath()) + +# c.stroke(rect1, [style.linewidth.THICK]) +# c.stroke(rect2, [style.linewidth.THICK]) +# c.stroke(rect3, [style.linewidth.THICK]) + +# c.writeEPSfile("pathitem") +# c.writePDFfile("pathitem") +# c.writeSVGfile("pathitem") + +using PyX + +c = canvas.canvas() + +rect1 = path.path(path.moveto(0, 0), path.lineto(1, 0), + path.moveto(1, 0), path.lineto(1, 1), + path.moveto(1, 1), path.lineto(0, 1), + path.moveto(0, 1), path.lineto(0, 0)) +rect2 = path.path(path.moveto(2, 0), path.lineto(3, 0), + path.lineto(3, 1), path.lineto(2, 1), + path.lineto(2, 0)) +rect3 = path.path(path.moveto(4, 0), path.lineto(5, 0), + path.lineto(5, 1), path.lineto(4, 1), + path.closepath()) + +stroke(c, rect1, [style_linewidth.THICK]) +stroke(c, rect2, [style_linewidth.THICK]) +stroke(c, rect3, [style_linewidth.THICK]) + +writeEPSfile(c, "pathitem") +writePDFfile(c, "pathitem") diff --git a/examples/drawing/strokefill.jl b/examples/drawing/strokefill.jl new file mode 100644 index 0000000..50b2d35 --- /dev/null +++ b/examples/drawing/strokefill.jl @@ -0,0 +1,20 @@ +# Original Python: +# from pyx import * + +# c = canvas.canvas() +# c.stroke(path.rect(0, 0, 1, 1), [style.linewidth.Thick, +# color.rgb.red, +# deco.filled([color.rgb.green])]) +# c.writeEPSfile("strokefill") +# c.writePDFfile("strokefill") +# c.writeSVGfile("strokefill") + +using PyX + +c = canvas.canvas() +stroke(c, path.rect(0, 0, 1, 1), + [style_linewidth.Thick, + color_rgb.red, + deco.filled([color_rgb.green])]) +writeEPSfile(c, "strokefill") +writePDFfile(c, "strokefill") diff --git a/examples/drawing/style.jl b/examples/drawing/style.jl new file mode 100644 index 0000000..3a8c105 --- /dev/null +++ b/examples/drawing/style.jl @@ -0,0 +1,29 @@ +# Original Python: +# from pyx import * + +# c = canvas.canvas() +# c.stroke(path.line(0, 0, 4, 0), +# [style.linewidth.THICK, style.linestyle.dashed, color.rgb.red]) +# c.stroke(path.line(0, -1, 4, -1), +# [style.linewidth(0.2), style.linecap.round, color.rgb.green]) +# c.fill(path.rect(0, -3, 4, 1), [color.rgb.blue]) +# c.writeEPSfile("style") +# c.writePDFfile("style") +# c.writeSVGfile("style") + +using PyX + +c = canvas.canvas() +stroke(c, path.line(0, 0, 4, 0), + [style_linewidth.THICK, + style_linestyle.dashed, + color_rgb.red]) +stroke(c, path.line(0, -1, 4, -1), + [style.linewidth(0.2), + style_linecap.round, + color_rgb.green]) +pyx_fill(c, path.rect(0, -3, 4, 1), + [color_rgb.blue]) + +writeEPSfile(c, "style") +writePDFfile(c, "style") |