[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Dr. Geo] how to use a input parameter in DrGeo SmalltalkSketch
From: |
Hilaire Fernandes |
Subject: |
Re: [Dr. Geo] how to use a input parameter in DrGeo SmalltalkSketch |
Date: |
Mon, 8 Apr 2024 00:35:53 +0200 |
User-agent: |
Mozilla Thunderbird |
Hi David,
Try a hack like:
| f s p |
f := DrGeoSketch new.
s := f integer: 1 at: 4@0 from: 3 to: 15.
p := f point: [s value @ 0].
p hide.
f regularPolygonCenter: 0@0 vertex: 3@0 sides: (f distance: 0@0 to: p)
Somehow I should extend DrGeo to make it shorter, by avoiding the p
point. The use can also extent DrGeoSketch by integrating this hack.
Hilaire
Le 07/04/2024 à 18:57, stes@telenet.be a écrit :
Suppose I want to use the radius in the SmalltalkSketch below ('Lunulae Alexander 2') as
"input parameter" for a DrG "Macro" how to do this please ?
Is the DrGMacroBuilder applicable to SmalltalkSketches ?
Are DrGMacro's the right tool to do this in the first place ? Or is the
SmalltalkSketch mechanism a replacement for macro's (because the
SmalltalkSketch is based on programmable Smalltalk code anyway).
In the SmalltalkSketch below it is setting radius to 2
radius _ 2.
but I'd like to make the radius an input parameter that can be manipulated
interactively in the sketch.
Thanks,
David Stes
|sketch origin sin60 hexagon rHexagon semiCircle semiCircle1 semiCircle2
semiCircle3 point1 point2 point3 a b c d r radis point4 semiCircle4 e f radius2
s line |
sketch _ DrGeoSketch new.
sketch gridOn.
sketch axesOn.
origin _ 0@0.
sin60 _ 60 sinus.
radius _ 2.
a _ (-1 * radius) @ 0.
b _ (-0.5 * radius) @ (sin60 * radius).
c _ (0.5 * radius) @ (sin60 * radius).
d _ radius @ 0.
hexagon _ sketch polygon: { a.b.c.d}.
rHexagon _ sketch regularPolygonCenter: origin vertex: d sides: 6.
semiCircle _ sketch arcCenter: origin from:d to: a.
point1 _ sketch middleOf:b and: a.
semiCircle1 _ sketch arcCenter: point1 from: b to: a.
point2 _ sketch middleOf:c and: b.
semiCircle2 _ sketch arcCenter: point2 from: c to: b.
point3 _ sketch middleOf:d and: c.
semiCircle3 _ sketch arcCenter: point3 from: d to: c.
radius2 _ radius // 2.
s _ -1.5 * radius.
point4 _ s @ (-1 * radius).
e _ (-1 * radius2 +s) @ (-1 * radius).
f _ (radius2 + s) @ (-1 * radius) .
semiCircle4 _ sketch arcCenter: point4 from: f to: e.
line _ sketch segment: f to: e.
semiCircle color:Color red.
semiCircle1 color:Color red.
semiCircle2 color:Color red.
semiCircle3 color:Color red.
semiCircle4 color:Color red.
line color: Color red.
hexagon filled.
rHexagon color: Color green.
sketch text:'Lunulae Alexander 2' at:(- 1 * radius) @(radius + (radius // 2) +
1).