From 3b8ccf95ec0cc3968f3be916c1065b9758ef8361 Mon Sep 17 00:00:00 2001 From: Martin Mares <mj@ucw.cz> Date: Wed, 3 May 2023 10:36:46 +0200 Subject: [PATCH] =?UTF-8?q?P=C5=99=C3=ADklady=20k=20Asymptote?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- asymptote/asy-label.asy | 19 +++++++++++++++ asymptote/asy-pattern.asy | 22 ++++++++++++++++++ asymptote/asy-pen.asy | 8 +++++++ asymptote/asy-size.asy | 12 ++++++++++ asymptote/bezier.asy | 49 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 110 insertions(+) create mode 100644 asymptote/asy-label.asy create mode 100644 asymptote/asy-pattern.asy create mode 100644 asymptote/asy-pen.asy create mode 100644 asymptote/asy-size.asy create mode 100644 asymptote/bezier.asy diff --git a/asymptote/asy-label.asy b/asymptote/asy-label.asy new file mode 100644 index 0000000..1a7611a --- /dev/null +++ b/asymptote/asy-label.asy @@ -0,0 +1,19 @@ +string rule = "\hbox to 30pt{\vrule height 10pt depth 2pt\hrulefill\vrule height 10pt depth 2pt}"; +unitsize(20mm); +dotfactor = 4; +labelmargin = 0.5; + +label(rule, (0,0)); +dot((0,0), red); + +label(rule, (1,0), N); +dot((1,0), red); + +label(rule, (2,0), 2N); +dot((2,0), red); + +label(rule, (3,0), W); +dot((3,0), red); + +label(rule, (4,0), dir(30)); +dot((4,0), red); diff --git a/asymptote/asy-pattern.asy b/asymptote/asy-pattern.asy new file mode 100644 index 0000000..602bc52 --- /dev/null +++ b/asymptote/asy-pattern.asy @@ -0,0 +1,22 @@ +import patterns; + +size(10cm, 0); + +add("tile", tile()); +add("checker", checker()); +add("brick", brick()); + +filldraw(circle((0,0), 2), pattern("tile"), black + 1); +filldraw(circle((5,0), 2), pattern("checker"), black + 1); +filldraw(circle((0,-5), 2), pattern("brick"), black + 1); + +picture test; +real d = 5; +pen p = defaultpen + 1; +draw(test, (0,0)--(d,d), p); +draw(test, (d,0)--(0,d), p); + +// add("test", test); +// add("test", test, (1,1), (1,1)); +add("test", test, (-0.3, -0.3), (-0.3, -0.3)); +filldraw(circle((5,-5), 2), pattern("test"), black + 1); diff --git a/asymptote/asy-pen.asy b/asymptote/asy-pen.asy new file mode 100644 index 0000000..8b04fd6 --- /dev/null +++ b/asymptote/asy-pen.asy @@ -0,0 +1,8 @@ +size(10cm, 0); + +path hex = dir(0) -- dir(60) -- dir(120) -- dir(180) -- dir(240) -- dir(300) -- cycle; +pen p = makepen(scale(5)*hex); + +draw((0,0) -- (10,10), p); + +draw((0,0), p + red); diff --git a/asymptote/asy-size.asy b/asymptote/asy-size.asy new file mode 100644 index 0000000..6ead093 --- /dev/null +++ b/asymptote/asy-size.asy @@ -0,0 +1,12 @@ +picture p; +pen q = currentpen + 3; +draw(p, (0,0) -- (1,1), q); +label(p, "$x$", (0.5, 0.5), 3NW); + +frame f1 = align(p.fit(1cm), (0,0)); +frame f2 = align(p.fit(2cm), (0,0)); +frame f3 = align(p.fit(4cm), (0,0)); + +attach(f1); +attach(f2, (2cm, 0)); +attach(f3, (5cm, 0)); diff --git a/asymptote/bezier.asy b/asymptote/bezier.asy new file mode 100644 index 0000000..1f55afe --- /dev/null +++ b/asymptote/bezier.asy @@ -0,0 +1,49 @@ +unitsize(10cm); + +pair a = (0,0); +pair b = (1, 0.25); +pair c = (2,0); + +pair bb = (1, 0.5); +pair cc = (1.5,0); + +transform xf = identity; + +void dots() { + dot(xf * a); + dot(xf * b); + dot(xf * c); +} + +void d(real t) { + path p = a{N} .. tension t .. b{E} .. tension t .. c{S}; + draw(xf * p); +} + +dots(); +d(1); + +xf = shift((0, -0.5)); +dots(); +d(0.8); +d(1); +d(2); +d(3); +d(10); + +xf = shift((0, -1)); +dots(); +draw(xf * (a{N} .. tension atleast 1 .. b{E} .. tension atleast 1 .. c{S})); + +xf = shift((0, -1.5)); +dots(); +draw(xf * (a{N} .. tension atleast 0.8 .. b{E} .. tension atleast 0.8 .. c{S}), red); +draw(xf * (a{N} .. tension atleast 1 .. b{E} .. tension atleast 1 .. c{S})); + +xf = shift((0.3, -2.3)); +dot(xf * a); +dot(xf * bb); +dot(xf * cc); +draw(xf * (a .. bb .. cc)); +draw(xf * (a{curl 2} .. bb .. {curl 2}cc), red); +draw(xf * (a{curl 10} .. bb .. {curl 10}cc), blue); -- GitLab