[Title,"              Textures Thumbnails              "]

[pd][pd][fontSetSizeSmall][sectionBegin," How to use this ZScript ",0,"Click for a description of this ZScript."]
[pd][fontSetSizeMedium]
This ZScript displays all the textures in your [buttonFind,texture:,"Texture palette"].

It first clears the active layer, then fills it with square thumbnails for all textures in the palette. You can [buttonFind,document:exportimage,"Export"] the resulting image for your own reference, perhaps using another image editor to print it out.

To use this ZScript, simply press the "Execute" button. The other sliders enable you to specify formatting preferences such as drop shadow distance, and distance between thumbnails.

For more help on using the buttons and sliders, click the [buttonFind,2,"Help (?)"] buttons.
[sectionEnd][fontSetSizeSmall][penMove,12]Press 'Esc' to abort.[fontSetSizeMedium]
[pd]
[FontSetSizeSmall][VarSet,SliderWidth,[TextCalcWidth,"BackgroundIntensity     "]][FontSetSizeMedium]
[PageSetWidth,SliderWidth+45]

[ISlider,"Border              ",4,1,1,50,"Distance",,,SliderWidth][penMove,3][FontSetSizeSmall][sectionBegin,"?",0,"Help",
[Note,"Use this slider to set the minimum distance (in pixels) between thumbnails.",-1,-1][routineCall,ExitNote][iUnpress,0]][sectionEnd][fontSetSizeMedium]
[pd][ISlider,"Shadow Offset       ",8,1,0,50,"Shadow",,,SliderWidth]
[penMove,3][FontSetSizeSmall][sectionBegin,"?",0,"Help",
[Note,"Use this slider to set the distance between each thumbnail and its drop shadow.",-1,-1][routineCall,ExitNote][iUnpress,0]][sectionEnd][fontSetSizeMedium]
[pd][ISlider,"BackgroundIntensity ",.24,0,0,1,"0=Black, 1=White",,,SliderWidth]
[penMove,3][FontSetSizeSmall][sectionBegin,"?",0,"Help",
[Note,"Use this slider to set the gray intensity of the canvas background color.\n\n0 = black, 1 = white.",-1,-1][routineCall,ExitNote][iUnpress,0]][sectionEnd][fontSetSizeMedium]
[pd][ISlider,"Shadow Intensity    ",.2,0,0,1,"0=Black, 1=White",,,SliderWidth][penMove,3][FontSetSizeSmall][sectionBegin,"?",0,"Help",
[Note,"Use this slider to set the gray intensity of each drop shadow.\n\n0 = black, 1 = white.",-1,-1][routineCall,ExitNote][iUnpress,0]][sectionEnd][fontSetSizeMedium]


  [IButton,"         EXECUTE         ","Tile It Now\nClick to execute this script",
	[VarSet, RememberTRANSFORM:EditObject , TRANSFORM:EditObject ]
	[VarSet, RememberTRANSFORM:Move , TRANSFORM:Move ]
	[VarSet,RememberStrokeType,STROKE:ItemInfo]
	[IPress,TOOL:Plane3D]
	[IUNPRESS,TRANSFORM:EditObject]
	[IPRESS,STROKE:DragRect]				// make sure we have DragRectstroke type selected
 	[IPress,Draw:ZAdd][IUnPress,Draw:ZAdd]

	[VarSet,DocumentWidth,Document:Modifiers:Width]
	[VarSet,DocumentHeight,Document:Modifiers:Height]
	[VarSet,itemsCount,[IGetMax,TEXTURE:ItemInfo]] //get the number of avialable items

[VarSet,rowItems,Max(Int((sqrt(itemsCount*DocumentWidth/DocumentHeight))+.5),1)]
 	[VarSet,clmnItems,[Val,Max(Int((itemsCount+rowItems-1)/rowItems),1)] ]
	[VarSet,rowWidth,Int(DocumentWidth/rowItems)]
	[VarSet,clmnHeight,Int(DocumentHeight/clmnItems)]
	[VarSet,DrawSize,1+Int( (Min(rowWidth,clmnHeight)/1.5)-(ZScript:Border/2))]
	[VarSet,YPos,Int(clmnHeight/2)]
	[VarSet,ItemNumber,0]
	[VarSet,TempValue,ZScript:BackgroundIntensity*255]
	[ISet,COLOR:R,TempValue][ISet,COLOR:G,TempValue][ISet,COLOR:B,TempValue]
	[ISet,TEXTURE:ItemInfo,0]
 	[IPress,LAYER:MODIFIERS:Fill]
	[VarSet,TempValue,ZScript:ShadowIntensity*255]
	[ISet,COLOR:R,TempValue][ISet,COLOR:G,TempValue][ISet,COLOR:B,TempValue]
	[VarSet,ShadowOffset,ZScript:ShadowOffset]
	[Loop,clmnItems, //start  loop
		[VarSet,XPos,Int(rowWidth/2)]
		[Loop,rowItems, //start  loop
			 [If,ItemNumber<itemsCount,
				//[MessegeOK,[Var,XPos],XPos]
 				//[MessegeOK,[Var,YPos],YPos]
				[ISet,TEXTURE:ItemInfo,0]
 				 [ISet,DRAW:RGBIntensity,100]
[CanvasClick,XPos+ShadowOffset,YPos+ShadowOffset,XPos+ShadowOffset,YPos+DrawSize+ShadowOffset]
				[ISet,DRAW:RGBIntensity,100]
 				[ISet,TEXTURE:ItemInfo,ItemNumber]
 				[CanvasClick,XPos,YPos,XPos,YPos+DrawSize]
		 		[VarSet,XPos,XPos+rowWidth]
			 ]
			[VarSet,ItemNumber,ItemNumber+1]
		] //end of loop
		[VarSet,YPos,YPos+clmnHeight]
	] //end of loop
	[IPress,Draw:ZAdd]
	[ISet,TEXTURE:ItemInfo,0]
 	[ISet,TRANSFORM:EditObject,RememberTRANSFORM:EditObject]	// restoreoriginal edit mode
	[ISet,TRANSFORM:Move,RememberTRANSFORM:Move]	// restore original trans mode
	[ISet,STROKE:ItemInfo,RememberStrokeType]			// restore original stroke type
	[iPress,texture:r] // click the Thumbnail Reset button
]
[PageSetWidth,10000] // restore page width to maximum

[routineDef,ExitNote,
	[Note,"\n\n\C909090(Press Spacebar)\Cc0c0c0"]
]
