dr-geo
[Top][All Lists]
Advanced

[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: Wed, 10 Apr 2024 16:42:54 +0200
User-agent: Mozilla Thunderbird

Yes that's it.

But I will make it simpler with a value model described by a block of code (something like DrGValueBlockItem) . So the value will be directly associated with the ruler object (it returns a block of code evaluating to a number)

We already have this for point, (DrGPointBlockItem). In the Cobweb diagram, in the repeat block, the points are recursively defined by a block of code and a previous instance of the point as an argument to the block (message #point:parent:).

| canvas r f u |

canvas := DrGeoSketch new axesOn scale: 500.
r := canvas float: 2 at: 0 @ -0.1 from: 0 to: 4 name: 'r' showValue: true.
f := [ :x | r value * x * (1 - x) ].
canvas ray: 0@0 to: 1@1.
canvas plot: f from: 0 to: 1.
u := canvas pointOnLine: (canvas segment: 0@0 to: 1@0) hide at: 0.2.

100 timesRepeat: [ | v |
	v := canvas	" v sequence term "
		point: [ :previous | previous point x @ (f value: previous point x) ] 
		parent: u.
	(canvas segment: u to: v) dotted.
	u := canvas	" u is a point on the Ray (0,0) (1,1) " 
		point: [:previous | previous point y @ previous point y ]
		parent: v.
	v hide. u hide.
	(canvas segment: u to: v) dotted.
	v := u].

Always fun to hack with Smalltalk

Hilaire

Le 09/04/2024 à 20:19, stes@telenet.be a écrit :
Thanks that works.

I see now that this is also the way it is done in the "Cobweb diagram" example.

Regards,
David Stes
-- 
GNU Dr. Geo
http://gnu.org/s/dr-geo/
http://gnu-drgeo.blogspot.com/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]