Pikchr

Proof-of-Concept of Macro as Part of Object Definition
Login

Proof-of-Concept of Macro as Part of Object Definition

(1) By pskechr on 2025-06-19 21:23:56 [link] [source]

With many thanks to Michael Thornburgh (zenomt) for his example, and many apologies to everyone else, this was a proof-of-concept of some macro abuse potentially non-standard use as part of an object definition, specifically a line, specifically to make a semicircle.

define thenTo { then to @AR heading $1 from (0,0) }

define thenToX5 { thenTo($1) thenTo($2) thenTo($3) thenTo($4) thenTo($5) }

define thenArc45 { \
thenToX5(@AA+ 3*@AD,@AA+ 6*@AD,@AA+ 9*@AD,@AA+12*@AD,@AA+15*@AD) \
thenToX5(@AA+18*@AD,@AA+21*@AD,@AA+24*@AD,@AA+27*@AD,@AA+30*@AD) \
thenToX5(@AA+33*@AD,@AA+36*@AD,@AA+39*@AD,@AA+42*@AD,@AA+45*@AD) \
}

define thenArc90 { \
thenArc45() \
thenToX5(@AA+48*@AD,@AA+51*@AD,@AA+54*@AD,@AA+57*@AD,@AA+60*@AD) \
thenToX5(@AA+63*@AD,@AA+66*@AD,@AA+69*@AD,@AA+72*@AD,@AA+75*@AD) \
thenToX5(@AA+78*@AD,@AA+81*@AD,@AA+84*@AD,@AA+87*@AD,@AA+90*@AD) \
}

define thenArc135 { \
thenArc90() \
thenToX5(@AA+ 93*@AD,@AA+ 96*@AD,@AA+ 99*@AD,@AA+102*@AD,@AA+105*@AD) \
thenToX5(@AA+108*@AD,@AA+111*@AD,@AA+114*@AD,@AA+117*@AD,@AA+120*@AD) \
thenToX5(@AA+123*@AD,@AA+126*@AD,@AA+129*@AD,@AA+132*@AD,@AA+135*@AD) \
}

define thenArc180 { \
thenArc135() \
thenToX5(@AA+138*@AD,@AA+141*@AD,@AA+144*@AD,@AA+147*@AD,@AA+150*@AD) \
thenToX5(@AA+153*@AD,@AA+156*@AD,@AA+159*@AD,@AA+162*@AD,@AA+165*@AD) \
thenToX5(@AA+168*@AD,@AA+171*@AD,@AA+174*@AD,@AA+177*@AD,@AA+180*@AD) \
}

[
@AR = 0.75in
@AA = 0

@AD = 1
line from @AR heading @AA from (0,0) thenArc180() close color none fill black
@AD = -1
line from @AR heading @AA from (0,0) thenArc180() close color none fill white

circle at @AR/2 heading @AA from (0,0) radius @AR/2 color none fill white
circle at @AR/2 heading @AA+180 from (0,0) radius @AR/2 color none fill black

circle at @AR/2 heading @AA from (0,0) radius @AR/7 color none fill black
circle at @AR/2 heading @AA+180 from (0,0) radius @AR/7 color none fill white

circle at (0,0) radius @AR thin thin color black fill none
] with c at (0,0)

Note to self: read the documented limitations of macros; especially, but not limited to:

Arguments to nested macros can be arbitrary text, or a single "$N" parameter, but not both.

(2) By pskechr on 2025-06-22 00:40:29 in reply to 1 [link] [source]

Version 2. Cleaned up and enhanced. These are all resizable and rotatable via the @AR and (initial value of) @AA variables.

define thenTo { \
then to $1 heading $2+$3*$4 from AO \
}

define thenToX5 { \
thenTo($1,$2,$3,$4) \
thenTo($1,$2,$3,$5) \
thenTo($1,$2,$3,$6) \
thenTo($1,$2,$3,$7) \
thenTo($1,$2,$3,$8) \
}

define thenArc45 { \
thenToX5($1,$2,$3, 3, 6, 9,12,15) \
thenToX5($1,$2,$3,18,21,24,27,30) \
thenToX5($1,$2,$3,33,36,39,42,45) \
}

define thenArc60 { \
thenArc45($1,$2,$3) \
thenToX5($1,$2,$3,48,51,54,57,60) \
}

define thenArc90 { \
thenArc60($1,$2,$3) \
thenToX5($1,$2,$3,63,66,69,72,75) \
thenToX5($1,$2,$3,78,81,84,87,90) \
}

define thenArc120 { \
thenArc90($1,$2,$3) \
thenToX5($1,$2,$3, 93, 96, 99,102,105) \
thenToX5($1,$2,$3,108,111,114,117,120) \
}

define thenArc180 { \
thenArc120($1,$2,$3) \
thenToX5($1,$2,$3,123,126,129,132,135) \
thenToX5($1,$2,$3,138,141,144,147,150) \
thenToX5($1,$2,$3,153,156,159,162,165) \
thenToX5($1,$2,$3,168,171,174,177,180) \
}

[
AO: (0,0)
@AR = 0.75in
@AA = 0

circle at AO radius @AR color black fill black

line \
from @AR heading @AA from AO \
thenArc180(@AR,@AA,-1) \
close \
color none fill white

circle at @AR/2 heading @AA from AO radius @AR/2 color none fill white
circle at @AR/2 heading @AA+180 from AO radius @AR/2 color none fill black
circle at @AR/2 heading @AA from AO radius @AR/8 color none fill black
circle at @AR/2 heading @AA+180 from AO radius @AR/8 color none fill white
] with c at (0,0)


[
define drawIonizingRadiationLobe {
line \
from @AR/11*10 heading @AA from AO \
thenArc60(@AR/11*10,@AA,1) \
then to @AR/11*3 heading @AA+60 from AO \
thenArc60(@AR/11*3,@AA+60,-1) \
close \
color none fill black
}

AO: (0,0)
@AR = 0.75in
@AA = 30

circle at AO radius @AR color black fill none
circle at AO radius @AR color none fill 0xE8BF28

drawIonizingRadiationLobe()

@AA = @AA+120

drawIonizingRadiationLobe()

@AA = @AA+120

drawIonizingRadiationLobe()

circle at AO radius @AR/11*2 color none fill black
] with c at (1.75in,0)


[
define drawCurvedArrow {
line \
from @AR/10*8 heading @AA from AO \
thenArc90(@AR/10*8,@AA,1) \
then to @AR/10*9 heading @AA+90 from AO \
then to @AR/10*2.5 heading @AA+90+90 from @AR/10*7 heading @AA+90 from AO \
then to @AR/10*5 heading @AA+90 from AO \
then to @AR/10*6 heading @AA+90 from AO \
thenArc90(@AR/10*6,@AA+90,-1) \
close \
color black fill black
}

AO: (0,0)
@AR = 0.75in
@AA = 30

circle at AO radius @AR color black fill none
circle at AO radius @AR color none fill white

drawCurvedArrow()

@AA = @AA+120

drawCurvedArrow()

@AA = @AA+120

drawCurvedArrow()
] with c at (3.5in,0)

Note to self: work smarter not harder. Ideally, a version 3 would allow the arc origin to change via macro parameters, which should be relatively straightforward, and which would allow for drawing a cloud shape or Dixon's egg shapes.

(3) By pskechr on 2025-06-22 14:47:50 in reply to 2 [source]

Version 3. The egg below can be resized and rotated, but the cloud is just a hard-coded example.

define thenTo { \
then to $1 heading $2+$3*$6 from AO+($4,$5) \
}

define thenToX2 { \
thenTo($1,$2,$3,$4,$5,$6) \
thenTo($1,$2,$3,$4,$5,$7) \
}

define thenToX3 { \
thenToX2($1,$2,$3,$4,$5,$6,$7) \
thenTo($1,$2,$3,$4,$5,$8) \
}

define thenToX4 { \
thenToX2($1,$2,$3,$4,$5,$6,$7) \
thenToX2($1,$2,$3,$4,$5,$8,$9) \
}

define thenArc45 { \
thenToX4($1,$2,$3,$4,$5, 3, 6, 9,12) \
thenToX4($1,$2,$3,$4,$5,15,18,21,24) \
thenToX4($1,$2,$3,$4,$5,27,30,33,36) \
thenToX3($1,$2,$3,$4,$5,39,42,45) \
}

define thenArc60 { \
thenArc45($1,$2,$3,$4,$5) \
thenToX4($1,$2,$3,$4,$5,48,51,54,57) \
thenTo($1,$2,$3,$4,$5,60) \
}

define thenArc90 { \
thenArc60($1,$2,$3,$4,$5) \
thenToX4($1,$2,$3,$4,$5,63,66,69,72) \
thenToX4($1,$2,$3,$4,$5,75,78,81,84) \
thenToX2($1,$2,$3,$4,$5,87,90) \
}

define thenArc120 { \
thenArc90($1,$2,$3,$4,$5) \
thenToX4($1,$2,$3,$4,$5, 93, 96, 99,102) \
thenToX4($1,$2,$3,$4,$5,105,108,111,114) \
thenToX2($1,$2,$3,$4,$5,117,120) \
}

define thenArc180 { \
thenArc120($1,$2,$3,$4,$5) \
thenToX4($1,$2,$3,$4,$5,123,126,129,132) \
thenToX4($1,$2,$3,$4,$5,135,138,141,144) \
thenToX4($1,$2,$3,$4,$5,147,150,153,156) \
thenToX4($1,$2,$3,$4,$5,159,162,165,168) \
thenToX4($1,$2,$3,$4,$5,171,174,177,180) \
}

[
AO: (0,0)
@AA = 90
@V1 = 0.625in
@V2 = 2*@V1-sqrt(2*@V1*@V1)
AO1: @V1 heading @AA+90 from AO
AO2: @V1 heading @AA from AO
AO3: @V1 heading @AA+270 from AO
AO4: AO

line \
from @V1 heading @AA+270 from AO \
thenArc45(@V1*2,@AA+270,1,AO1.x,AO1.y) \
thenArc90(@V2,@AA+315,1,AO2.x,AO2.y) \
thenArc45(@V1*2,@AA+45,1,AO3.x,AO3.y) \
thenArc180(@V1,@AA+90,1,AO4.x,AO4.y) \
close \
color black fill plum
]

[
AO: (0,0)
line \
from (0,0) \
then left 0.75in \
thenArc180(0.25in,180,1,-0.75in,0.25in) \
thenArc90(0.125in,270,1,-0.625in,0.5in) \
thenArc180(0.3125in,270,1,-0.3125in,0.625in) \
thenArc180(0.3125in,0,1,0,0.3125in) \
close \
color black fill whitesmoke
] with c at (1.75in,0)

Moving the arc origin around can be a bit of an effort. I think that about concludes this exercise.