Code:
//===========================================================================
//===========================================================================
// ArtRage Script File.
//===========================================================================
//===========================================================================
//===========================================================================
// Version Block - Script version and ArtRage version:
//===========================================================================
<Version>
ArtRage Version: ArtRage 3 Studio Pro
ArtRage Build: 3.5.1
Professional Edition: No
Script Version: 1
</Version>
//===========================================================================
// Header block - Info about the painting/person who generated this script:
//===========================================================================
<Header>
// === Project data
Painting Name: "SlideShow"
Painting Width: 900
Painting Height: 321
Painting DPI: 299
Mask Edge Map Width: 954
Mask Edge Map Height: 862
// === Author data
Author Name: "Ti-Chen Feng"
Script Name: "Slide Show"
Comment: "Shows each layer of an ArtRage file one at a time, as in a slideshow."
Script Type: ""
Script Feature Flags: 0
</Header>
//===========================================================================
// Script data follows:
//===========================================================================
//Function: fade old layer out and new layer in
void Transition( int nStepSize, int nOldLayer, int nNewLayer ) {
int i = 0
real rOpacity = 0.0
if ( nStepSize==11 ) nStepSize=100
for ( i=nStepSize; i<100; i+=nStepSize ) {
rOpacity = i/100.0
Wait: 0 EvType: Command CommandID: CID_SetSpecificLayerOpacity ParamType: LayerProp Value: { nNewLayer, rOpacity }
Wait: 0 EvType: Command CommandID: CID_SetSpecificLayerOpacity ParamType: LayerProp Value: { nOldLayer, 1.0-rOpacity }
}
//Ensure that final opacities are 0% and 100%
Wait: 0 EvType: Command CommandID: CID_SetSpecificLayerOpacity ParamType: LayerProp Value: { nNewLayer, 1 }
Wait: 0 EvType: Command CommandID: CID_SetSpecificLayerOpacity ParamType: LayerProp Value: { nOldLayer, 0 }
}
//Function: randomize slide array. Remember to exclude the Blank slide and only shuffle elements [1] through [nSlideCountF]
intarray RandomizeSlides( intarray naSlidesF, int nSlideCountF ) {
int i = 0
int nRandom = 0
int nHolder = 0
Randomize()
NoteBox("Randomizing... this may take a while, depending on the number of slides.", 270, 50, 100, 100, 0, 0.5, 0)
for( i=nSlideCountF; i>2; i-- ) {
nRandom = Random(1, i)
nHolder = naSlidesF[nRandom]
naSlidesF[nRandom] = naSlidesF[i]
naSlidesF[i] = nHolder
// MessageBox("%%nSlideCountF slides, i=%%i, random number=%%nRandom")
}
DismissNoteBox(0)
return(naSlidesF)
}
//Function: remove the background layer that was added, restore the pods and panels
void Cleanup() {
Wait: 0 EvType: Command CommandID: CID_DeleteSpecificLayer ParamType: uint32 Value: { 0 }
Wait: 0 EvType: Command CommandID: CID_SetClearCanvas ParamType: flag Value: { false }
exit
}
<Events>
flag fRandomize = NO
int i = 0
int j = 0
int nTransition = 5
int nLayerID = 0
int nLayerCount = 0
int nReps = 0
int nSlideCount = 0
intarray naSlides = { 0 }
real rPause = 10.0
//Visual appeal: hide pods and panels, add a bottom background layer, and make the background opaque
Wait: 0 EvType: Command CommandID: CID_SetClearCanvas ParamType: flag Value: { true }
Wait: 0 EvType: Command CommandID: Add New Layer
nLayerID = CurrentLayerIndex()
Wait: 0 EvType: Command CommandID: CID_MoveSpecificLayer ParamType: LayerTwoOp Value: { nLayerID, 0 }
Wait: 0 EvType: Command CommandID: LayerName Idx: 0 Name: "Blank"
//All this work to make a white background!
Wait: 0 EvType: Command CommandID: CID_SelectSpecificLayer ParamType: uint32 Value: { 0 }
Wait: 0 EvType: Command CommandID: SetForeColour ParamType: Pixel Value: { 0x0FFFFFFFF }
Wait: 0 EvType: Command CommandID: CID_ToolSelect ParamType: ToolID Value: { 4921 (Fill Tool ) }
Wait: 0 EvType: Command CommandID: SetToolProperty ParamType: ToolProp Value: { 0x0B2D05E65 (Opacity), 1 }
Wait: 0 EvType: Command CommandID: SetToolProperty ParamType: ToolProp Value: { 0x0B2D05E57 (Spread), 0 }
Wait: 0 EvType: Command CommandID: SetToolProperty ParamType: ToolProp Value: { 0x0B2D05E47 (Blend Mode), 0 }
Wait: 0 EvType: Command CommandID: SetToolProperty ParamType: ToolProp Value: { 0x0B2D05E58 (Antialias Edge ), 0 }
Wait: 0 EvType: Command CommandID: SetToolProperty ParamType: ToolProp Value: { 0x0B2D05E44 (Single Layer), 1 }
<StrokeEvent>
<StrokeHeader>
<EventPt> Wait: 0 Loc: (1, 1) Pr: 1 Ti: 1 Ro: 0 Rv: NO Iv: NO </EventPt>
<Recorded> No </Recorded>
</StrokeHeader>
Wait: 0 Loc: (1, 1) Pr: 1 Ti: 1 Ro: 0 Rv: NO Iv: NO
</StrokeEvent>
//Initalization: (group-type layers and hidden layers do not count as slides)
// set opacity of slides to 0%, index slide IDs to an array (naSlides) for easy reference
NoteBox("Initializing... this may take a while, depending on the number of layers.", 270, 50, 100, 100, 0, 0.5, 0)
nLayerCount = LayerCount()
for ( i=1; i<nLayerCount; i++ ) {
if ( (LayerType(i)==0 || LayerType(i)>3) && LayerVisible(i) ) {
if ( LayerOpacity(i) > 0 ) {
Wait: 0 EvType: Command CommandID: CID_SetSpecificLayerOpacity ParamType: LayerProp Value: { i, 0 }
}
naSlides.Add(i)
}
// Wait: 0 EvType: Command CommandID: CID_SelectSpecificLayer ParamType: uint32 Value: { i }
}
DismissNoteBox(0)
//If there is only 1 slide, what's the point? Exit the script.
nSlideCount = naSlides.GetSize()
if ( nSlideCount < 3 ) {
MessageBox("It's not a very good slide show with only one picture!\nImport images to more layers.")
Cleanup()
//The script should never see this 'exit', but it's in here just to be sure!
exit
}
//Ask for and verify user input
InputBox("Pause time on each slide (0.0-300.0): $$rPause\nTransition time between slides (0-10): $$nTransition\nNumber of times to repeat the show: $$nReps\nRandomize slides? $$fRandomize")
if (rPause<0) rPause=0; if (rPause>300) rPause=300
if (nTransition<0) nTransition=0; if (nTransition>10) nTransition=10
if (nReps<0) nReps=0
//Display current slide for 'rPause' time, then call the Transition function to display next slide
Wait: 0 EvType: Command CommandID: CID_SetSpecificLayerOpacity ParamType: LayerProp Value: { naSlides[1], 1 }
for ( i=0; i<=nReps; i++ ) {
if(fRandomize) { naSlides = RandomizeSlides(naSlides, nSlideCount-1) } //exclude the Blank slide
for ( j=1; j<nSlideCount-1; j++ ) {
Wait: (rPause)
Transition( 11-nTransition, naSlides[j], naSlides[j+1] )
}
//Special treatment needed for looping back to the beginning
Wait: (rPause)
Transition( 11-nTransition, naSlides[j], naSlides[1] )
}
Cleanup()
//110727