summaryrefslogtreecommitdiff
path: root/graphics/circuit_macros/examples/Shaky.m4
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/circuit_macros/examples/Shaky.m4')
-rw-r--r--graphics/circuit_macros/examples/Shaky.m445
1 files changed, 23 insertions, 22 deletions
diff --git a/graphics/circuit_macros/examples/Shaky.m4 b/graphics/circuit_macros/examples/Shaky.m4
index 7bd5113a57..7eff994d91 100644
--- a/graphics/circuit_macros/examples/Shaky.m4
+++ b/graphics/circuit_macros/examples/Shaky.m4
@@ -5,27 +5,27 @@ NeedDpicTools
divert(-1)
`An attempt to draw shaky hand-drawn lines'
- `shakyline(linespec,type,s=shake,[shakevals])
+ `shakyline(linespec,type,shake=expr,[shakevals])
Draw a line with a tremor
- arg3: s=shake parameter (default 1)
+ arg3: shake parameter (default 1)
arg4=normal(0,1) perturbations used if given'
define(`shakyline',
`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1'))
- M4_start: last line.start
- M4_end: last line.end
- [ Start: M4_start
- End: M4_end
+ L_start_: last line.start
+ L_end_: last line.end
+ [ Start: L_start_
+ End: L_end_
llen = distance(Start,End)
npts = round_(llen/linewid*4)
- setkey_($3,s,1)
- if "$4"=="" then { randn(d,npts-1,0,m4s*(llen/npts/8)) }\
- else { for i=1 to npts-1 do { d[i] = $4[i]*m4s*(llen/npts/8) }}
+ setkey_($3,shake,1)
+ if "$4"=="" then { randn(d,npts-1,0,m4shake*(llen/npts/8)) }\
+ else { for i=1 to npts-1 do { d[i] = $4[i]*m4shake*(llen/npts/8) }}
P[0]: Start
for i=1 to npts-1 do { P[i]: i/npts between Start and End + (vec_(0,d[i])) }
P[npts]: End
spline $2 from P[0] to P[1]
for i=2 to npts do { continue to P[i] }
- ] with .Start at last line.start; move to last line.end')
+ ] with .Start at L_start_; move to L_end_')
`shakyarc(arcspec,type,s=shake,[shakevals])
Draw an arc with a tremor
@@ -33,12 +33,12 @@ define(`shakyline',
arg4=normal(0,1) perturbations used if given'
define(`shakyarc',
`arc invis $1
- M4_start: last arc.start
- M4_end: last arc.end
- M4_C: last arc.c
- [ Start: M4_start
- End: M4_end
- C: M4_C
+ A_start_: last arc.start
+ A_end_: last arc.end
+ A_C_: last arc.c
+ [ Start: A_start_
+ End: A_end_
+ C: A_C_
as = atan2(Start.y-C.y,Start.x-C.x)
ae = atan2(End.y-C.y,End.x-C.x)
ar = distance(Start,C)
@@ -60,10 +60,10 @@ define(`shakyarc',
arg4=normal(0,1) perturbations used if given'
define(`shakyspline',
`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1'))
- M4_start: last line.start
- M4_end: last line.end
- [ Start: M4_start
- End: M4_end
+ SP_start_: last line.start
+ SP_end: last line.end
+ [ Start: SP_start_
+ End: SP_end
llen = distance(Start,End)
npts = round_(llen/linewid*4)
setkey_($3,s,1)
@@ -115,8 +115,9 @@ divert(0)
linethick = 2.5
round(,,colored "gray")
nl = 10
- for i=1 to nl do {
- shakyline(right 6/nl up 2*(2*pmod(i,2)-1),colored "gray",s=1)
+ for i=0 to nl do {
+ shakyline(right 6/nl up 2*(2*pmod(i,2)-1),colored "gray",shake=2-i/nl*2)
+ {sprintf("%g",2-i/nl*2) at 1/2 between L_start_ and L_end_ }
round(,,colored "gray") }
]