SketchPad (advanched)

Help Contents Examples SketchPad (advanched)
SinCos Star (fractal)

SketchPad (advanched)

Example:    SketchPad.eli
Modified:   February 27, 2000
Version:    2.0
Author:     Pavel Boychev
E-mail:     pavel@elica.net

Copyright © 2000 Elica Group

Advanced example which has some SketchPad-like functionality.

run "geomland
run "win

make "Asp 375

make "Picture set
make "PicNo 1

to onmousedown_s2 :x :y

	if (:phase=0) or (:phase=4) 
	[
		make :point1name point :Asp*:x :Asp*:y
		make "phase 1

		onmousemove :x+1 :y
	]
end

to onmousemove_s2 :x :y

	if :phase=1
	[ 
		make :point2name point :Asp*:x :Asp*:y

		run (se [make "noname] :linetype ": :point1name ": :point2name)
		repaint
	]
	if :phase=2
	[
		run (se [make "noname] :commands)
		repaint
	]
end

to onmouseup_s2 :x :y
	if :phase=2
	[ 
		if :object3name<>[]
		[ 
			delete :object3name 
		]
		[ 
			delete :point1name
			delete :point2name
		]
		make "phase 4
	]
	if :phase=1
	[ 
		if :commands=[]
		[ 
			delete :point1name
			delete :point2name
			make "phase 4 
		]
		[
			if :object3name<>[]
			[ 
				make :object3name :noname 
				delete :point1name
				delete :point2name
			]
			make "phase 2
		]
	]
	repaint
	if :phase=4 
	[
		make "PicNo :PicNo+1
		make "Picture(:PicNo) :noname
		delete "noname
	]
end

to select2 :p1 :p2 :tp :cmd :o3

	make "point1name  :p1
	make "point2name  :p2
	make "linetype    :tp
	make "commands    :cmd

	if local? "o3
	[ make "object3name :o3 ]
	[ make "object3name []  ]

	make "onmousedown :onmousedown_s2
	make "onmousemove :onmousemove_s2
	make "onmouseup   :onmouseup_s2

	make "phase 0

	while :phase<4 []
end

make "button_line button 20 20+1*24 75 24 "Line

to button_line.onclick
	select2 "Initial "Final "line []
end

make "button_segment button 20 20+2*24 75 24 "Segment

to button_segment.onclick
	select2 "Initial "Final "segment []
end

make "button_ray button 20 20+3*24 75 24 "Ray

to button_ray.onclick
	select2 "Initial "Final "ray []
end

make "button_circle button 20 20+4*24 75 24 "Circle

to button_circle.onclick
	select2 "Center "Radius "circle []
end

make "button_ellipse button 20 20+5*24 75 24 "Ellipse

to button_ellipse.onclick
	select2 "Focus1 "Focus2 "segment [ellipse :Focus1 :Focus2 point :Asp*:x :Asp*:y]
end

make "button_hyperbola button 20 20+6*24 75 24 "Hyperbola

to button_hyperbola.onclick
	select2 "Focus1 "Focus2 "segment [hyperbola :Focus1 :Focus2 point :Asp*:x :Asp*:y]
end

make "button_parabola button 20 20+7*24 75 24 "Parabola

to button_parabola.onclick
	select2 "Initial "Final "line [parabola point :Asp*:x :Asp*:y :Directrissa] "Directrissa
end

make "button_angle button 20 20+8*24 75 24 "Angle

to button_angle.onclick
	select2 "Initial "Final "ray [angle point :Asp*:x :Asp*:y initial :BaseRay final :BaseRay] "BaseRay
end

SinCos Star (fractal)