[varDef,Hval1,320]
[varDef,Vval1,258]
[varDef,Hval2,320]
[varDef,Vval2,258]
[varDef,buttonTool,0]
[varDef,limbStart,0]


[iButton," Anemone ",test,
	
	[delay,.09]
	
	[iKeyPress,13,[iReset,2]][iPress,picker:selectedcolor]

	[iColorSet,0,0,160]
 	[iClick,render:modifiers:fog:fogcolor1]
	[iClick,render:modifiers:fog:fogcolor2]
	[iPress,document:modifiers:documentbacgroundcolor]
	[iSet,render:modifiers:fog:depth1,-.26]
	[iSet,render:modifiers:fog:depth2,-.1]
	[iPress,render:modifiers:renderFog]
	[routineCall,drawTheButtons]

	[iPress,tool:sphere3d]
	[iSet,material:itemInfo,2]
	[icolorSet,255,255,0]
	[canvasClick,320,258,320,264]
	[transformSet,320,258,0,140,140,140,90,0,0]
	[iPress,transform:editobject]
	[iSet,tool:modifiers:initialize:hdivide,512]
	[iSet,tool:modifiers:initialize:vdivide,512]
	[iColorSet,255,255,0]
	[iPress,color:fillobject]
	[iSet,texture:itemInfo,18]
	[iPress,tool:modifiers:selection:fromtextureintensity]
	[iSet,texture:itemInfo,0]
	[iColorSet,255,0,0]
	[iPress,color:fillobject]
	[iPress,tool:modifiers:selection:clear]
	[iUnPress,transform:editobject]
	
	[iPress,tool:snakeHookBrush]
	[iSet,tool:modifiers:colorblend,80]
	[varSet,shbTool,texture:itemInfo]
	[iSet,draw:drawSize,12]


[Note,"You're now looking at a simplified drawing session.",,-1]
[Note,"\n\nUse your mouse or tablet to add tentacles to this scene. Click once to add a tentacle, or click+drag to set the length of the tentacle before drawing.",,-1]
[Note,"\n\nUse only the buttons at the top of the canvas to change color and size.",,-1]
[Note,"\n\nClick the Left Arrow button to undo, and click the X button to exit the session.",,-1]
[routineCall,exitNote]

[loop,999999, // "endless" loop, user keeps clicking

[loop,999999, // wait for mouse click
	[if,[mouseLbutton] = 1,
		[varSet,Hval1,[mouseHpos]]
		[varSet,Vval1,[mouseVpos]]
		[loopexit]
	] // end if
] // end wait for mouse click loop
[loop,999999, // now wait for mouse up
	[if,[mouseLbutton] = 0,
		[varSet,Hval2,[mouseHpos]]
		[varSet,Vval2,[mouseVpos]]
		[loopexit]
	] // end if
] // end wait for mouse up loop

[if,(Vval1 > 35), //(top button clicked/not clicked)


	[if,(abs(Hval2-Hval1)<3) && (abs(Vval2-Vval1)<3),
	
	// single click
	[varSet,theAngle,acos([pixolPick,6,Hval1,Vval1])]
	[if,[pixolPick,7,Hval1,Vval1] < 0,[varSet,theAngle,360-theAngle]]
	[varSet,theBothScale,1-abs([pixolPick,8,Hval1,Vval1])]
	[varSet,theBothScale,theBothScale*2]
	
	, // else = click + drag
	[varSet,theAngle,atan((vval2-vval1)/(hval2-hval1))]
	[if,(hval2<hval1),[varAdd,theAngle,180]]
	[varSet,theBothScale,((Hval2-Hval1)^^2)+((Vval2-Vval1)^^2)]
	[varSet,theBothScale,(sqrt(theBothScale)/138)]
	
	] // end if click or drag
	
	[varSet,theHScale,theBothScale]
	[varSet,theVScale,theBothScale]
	[varSet,theHOffset,Hval1-297]
	[varSet,theVOffset,Vval1-248]
	
	[canvasStroke,theStroke,0,theAngle,theHScale,theVScale,theHOffset,theVOffset]
	[varSet,limbStart,1]

, // else (one of the top buttons has been clicked

[if,(hval1 < 87),[if,limbStart,[iPress,document:undo][note,"Undo",1004,.75]]]

[if,(hval1 > 86) && (hval1 < 126),[icolorSet,255,0,0][note,"\Cff0000Red Color\Cc0c0c0",1004,.75]
	[iPress,picker:selectedcolor]]	
[if,(hval1 > 125) && (hval1 < 165),[icolorSet,255,128,0][note,"\Cff8000Orange Color\Cc0c0c0",1004,.75]
	[iPress,picker:selectedcolor]]	
[if,(hval1 > 164) && (hval1 < 204),[icolorSet,255,235,0][note,"\Cffeb00Yellow Color\Cc0c0c0",1004,.75]
	[iPress,picker:selectedcolor]]	
[if,(hval1 > 203) && (hval1 < 243),[icolorSet,0,255,80][note,"\C00ff50Green Color\Cc0c0c0",1004,.75]
	[iPress,picker:selectedcolor]]	
[if,(hval1 > 242) && (hval1 < 282),[icolorSet,0,80,255][note,"\C0000aaBlue Color\Cc0c0c0",1004,.75]
	[iPress,picker:selectedcolor]]	
[if,(hval1 > 281) && (hval1 < 321),[iPress,picker:continuouscolor][note,"Picked Color",1004,.75]]

[if,(hval1 > 320) && (hval1 < 399),[iSet,draw:drawSize,20][note,"Large Size",1004,.75]]
[if,(hval1 > 398) && (hval1 < 477),[iSet,draw:drawSize,12][note,"Medium Size",1004,.75]]
[if,(hval1 > 476) && (hval1 < 555),[iSet,draw:drawSize,6][note,"Small Size",1004,.75]]

[if,(hval1 > 554),[note,"                                               
\n\Cffc800        Drawing Finished.        \Cc0c0c0
\n                                               ",,1.75][exit]]


] // end if (top button clicked/not clicked)

[loop,99999, // ensure mouse button is up before continuing
	[if,[mouseLbutton] = 0,
		[loopExit]
	] // end if
] // end ensure loop

] // end "endless" loop

] // end iButton

[routineDef,REMOVED FOR NOW,
[if,[pixolPick,2,Hval1,Vval1] = 255,
	[iSet,draw:drawSize,16]
	[icolorSet,0,0,255]
, // else
	[iSet,draw:drawSize,7]
	[varSet,theBothScale,theBothScale*.5]
	[icolorSet,160,0,0]
] // end if
]

[varDef,theStroke,(ZObjStrokeV02n31=
XH129VF8H12DVF6H12FVF4H132VF3H139VEEH13DVECH144VE9H146VE9H14BVEBH14EVEEH152VF4H153VF6H15AVFDH160V105H161V106H167V108H16FV105H171V104H177V100H181VF8H187VF4H18AVF3H18EVF2H195VF7H196VF8H19BVFFH1A3V102H1A8V101H1B1VFEH1B3VFEH1B3VFE)]

[routineDef,drawThebuttons,
	[iSet,texture:itemInfo,0][iSet,material:itemInfo,3]
	[iColorSet,0,0,110][routineCall,drawButton,47,39]

	[iColorSet,255,0,0][routineCall,drawButton,105,19]
	[iColorSet,255,128,0][routineCall,drawButton,105+39,19]
	[iColorSet,255,235,0][routineCall,drawButton,105+78,19]
	[iColorSet,0,255,80][routineCall,drawButton,105+78+39,19]
	[iColorSet,0,80,255][routineCall,drawButton,105+78+78,19]
	[iSet,texture:itemInfo,40][iSet,tool:modifiers:texture:hrepeat,4]
	[iColorSet,0,0,160][routineCall,drawButton,105+78+78+39,19]
	[iSet,texture:itemInfo,0]


	[iColorSet,0,70,110][routineCall,drawButton,359,39]
	[iColorSet,0,70,110][routineCall,drawButton,359+78,39]
	[iColorSet,0,70,110][routineCall,drawButton,359+78+78,39]

	[iColorSet,0,0,110][routineCall,drawButton,593,39]
	
	[iColorSet,0,220,255]
	[iPress,tool:arrow3d][iUnPress,draw:zadd]
	[canvasClick,47,20,47,24][transformSet,47,20,-2040,24,24,24,0,-90,0]
	[iPress,draw:zadd]
	
	[IPress,tool:snakeHookBrush][iSet,tool:modifiers:colorblend,100]
	[iUnPress,draw:LockRGBZ][iSet,draw:zintensity,2]
	[iSet,draw:drawSize,18][canvasStroke,theStroke,1,0,.35,.8,(338-297),(19-248)]
	[iSet,draw:drawSize,10][canvasStroke,theStroke,1,0,.35,.8,(414-297),(19-248)]
	[iSet,draw:drawSize,4][canvasStroke,theStroke,1,0,.35,.8,(492-297),(19-248)]

	[iPress,tool:plane3D]
	[canvasClick,593,20,593,24][transformSet,593,20,-2040,4,17,17,0,0,45]
	[iPress,transform:snapshotObject][transformSet,593,20,-2040,4,17,17,0,0,-45]


] // end routineDef
[routineDef,ExitNote,
	[Note,"\n\n\C909090(Click to continue, press 'Esc' to exit.)\Cc0c0c0",,0]
]
[routineDef,drawButton,
[if,buttonTool=0,
	[iPress,tool:cube3d]
	[iModSet,tool:modifiers:deformation:taper,5]
	[iSet,tool:modifiers:deformation:taper,10]
	[varSet,buttonTool,tool:itemInfo]
] // end if
	[canvasClick,24,24,24,28]
	[transformSet,LbuttonH,20,-2000,LbuttonWidth,18,20,-90,0,0]
	[canvasGyroHide]
	[iPress,transform:move]
	[iPress,transform:drawpointer]

[canvasGyroShow]
,LbuttonH,LbuttonWidth] // end routineDef
