Simple script

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Simple script

Hliaire Fernandes
Administrator
Benoît,

Responding to you on the forum for the record.

The slider only updates its label when its value is request through a *a
value*,'*b value* or *c value* message.
This should logically happen later in your script code, otherwise your
slider is not used and not needed.

You may have already read the* wave.st* script example.

You may add a :
*   a inspect*
at the end of your script.

The slider is quick hack I wrote directly at DrGeoCanvas class to answer to
a request. It does pretty well it job so far.

Hilaire

/
Hi Hilaire

I'm trying to be a simple script to experiment a few thing and I'm not
successful!

I just want a "slider", a point I can move on a segment and display it's
value.  So far, it looks like this but the value is never displayed:

------------
|canvas a b c|

canvas := DrGeoCanvas new.

a := canvas float: 0 at: -10@5 from: -10.0 to: 10.0 name: 'a' showValue:
true.
b := canvas float: 0 at: -10@4 from: -10.0 to: 10.0 name: 'b' showValue:
true.
c := canvas integer: 0 at: -10@3 from: -10.0 to: 10.0 name: 'c' showValue:
true.

-------------

Am I missing something?

-----------------
Benoît St-Jean/



--
Sent from: http://forum.drgeo.eu/Dr-Geo-users-f4023913.html

Reply | Threaded
Open this post in threaded view
|

Simple script

Hliaire Fernandes
Administrator
To make my point clearer, try the script bellow:

|canvas a b c|

canvas := DrGeoCanvas new axesOn fullScreen.

a := canvas float: 0 at: -10@5 from: -10.0 to: 10.0 name: 'a' showValue:
true.
b := canvas float: 0 at: -10@4 from: -10.0 to: 10.0 name: 'b' showValue:
true.
c := canvas integer: 0 at: -10@3 from: -10.0 to: 10.0 name: 'c' showValue:
true.

canvas point: [ a value @ b value].
canvas point: [ b value @ c value].



--
Sent from: http://forum.drgeo.eu/Dr-Geo-users-f4023913.html

Reply | Threaded
Open this post in threaded view
|

Re: Simple script

Hliaire Fernandes
Administrator
From Dr. Geo, looking at the source code of an integer slider, you can read label is updated only when the label value is requested (and updated too).
As it is Smalltalk land here, the slider code be adjusted if needed.

integer: aValue at: aPoint from: startValue to: endValue name: name showValue: isValueDisplay
"A valueslider ranging between startValue and endValue"
	| segment mobile|
	segment := self segment: aPoint to: aPoint + (170 / drgeo area scale @0).
	mobile := self pointOnCurve:  segment at: (aValue - startValue) / (endValue - startValue).
	segment color: Color black; large.
	mobile name: name;
		color: Color black;
		round;
		large.	
	^ isValueDisplay 
		ifTrue:  [[|value |
			value := (mobile mathItem abscissa * ( endValue - startValue) + startValue) floor.
			mobile rename: name,  ' = ', value printString.
			value]]
		ifFalse: [[(mobile mathItem abscissa * ( endValue - startValue) + startValue) floor]]  	
       
Reply | Threaded
Open this post in threaded view
|

Re: Simple script

Benoît St-Jean
Oups!  Just saw the 2 brackets!  So we're dealing with a block at this time, not a PointOnCurve!  I was unable to halt the code inside the inner block!

If this is something (a slider segment with a point on it) that is often used, perhaps a slider object (that automatically updates itself on #move:) would be useful ? The slider could display min, max, current position, integer and determined "steps" size (e.g. steps of 0.25 along the segment for a float slider, or increments of 2 for integer segments).

Something similar to this:

https://www.desmos.com/calculator/ialhd71we3
Benoît St-Jean
bstjean@yahoo.com
IRC: lamneth
Blog: endormitoire.wordpress.com
"A standpoint is an intellectual horizon of radius zero".  (A. Einstein)
Reply | Threaded
Open this post in threaded view
|

Re: Simple script

Hliaire Fernandes
Administrator
Yep, the slider is a hack at the user level in the Canvas, à-la Smalltalk.
An implementation at the application level could be possible, indeed.

Note: in this user level, it is possible to re-hack it to show min and max level. One may imagine a hack to get min max out of others sliders, still hacked at the user level.