PDA

View Full Version : Slideshow script



terrygillooly
07-15-2011, 10:00 AM
Here's a script I dorked out for creating a slide show from the layers in an ArtRage file.

You can specify for how long to show each picture, and how long it takes to transition between pictures (so you could set up reference pictures for 3-minute sketching, for example, or make a doofy animation).

It will show Sticker and Text layers, but ignores hidden layers.

I've tried it with up to 100 layers (now that was a big file) with a smallish jpg image imported to each layer. It didn't eat any layers or anything when I tested it, but please do use with caution :)

Please let me know if you encounter any problems or have any suggestions!

Update: Now includes options to loop and randomize!



//================================================== =========================
//================================================== =========================
// 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

AndyRage
07-15-2011, 10:29 AM
Ooo, nice idea.

Juz
07-16-2011, 06:43 AM
Great Job Terry :eek::)
Hehehe to 'dorked' out :D

This would be a great asset to anyone wanting to show off a painting in different stages, Placing each stage on a new layer.

terrygillooly
07-19-2011, 11:26 AM
Thanks guys!

I added looping and randomizing and fixed a couple of errors (no doubt introducing more in the process).

mykyl1966
07-26-2011, 10:33 PM
I need to learn to check the forums first. This may be exactly what I am looking for... If I can figure out how to use the script. lol

Right I have no idea how to run the scripts. I use play script and it pops up something it goes then nothing. Any info somewhere on actually using them.

Normally recorded scripts play fine just none of these tools from this part of the forum.

Cheers

Mike

DaveRage
07-26-2011, 11:59 PM
After copying the script text into a text editor, make sure to save it as a UTF 16 format file ( with extension .arscript ). Check this post for info:

http://www2.ambientdesign.com/forums/showthread.php?t=35944

If you still have problems, let us know.

mykyl1966
07-27-2011, 02:11 AM
I saw that post and followed the instructions with no change. None of the scripts work for me other than those I record direct. SO for example I copy and paste into text edit the info and save it as Slideshow.arscript and make sure UTF 16 is chosen.

As a side note text edit in lion is crap. Once you have saved it once you no longer have the option to save as any more. stupid stupid stupid annoying crazy idiotic piece of trash. Steve Jobs stay away from my system and let me keep working like we have done for years that actually allows us to bloomin well work...... GRRRRRRRRR

Just tried using text wrangler with the same result. Nothing happens.

Ok after much fiddling around. Text edit does not save a compatable file somehow in Lion. I switched to Text wrangler and saved using UTF 16 with classic mac line breaks and it works although this script fails on transitions.

So no idea why textedit no longer works but it is a problem.

Any ideas why the transitions would fail on this?

For me I want to use it more like a frame player where each frame is on a separate layer to see how it looks so personally I dont need transitions.

Mike

terrygillooly
07-27-2011, 08:24 AM
I copy and paste into text edit the info and save it as Slideshow.arscript and make sure UTF 16 is chosen.

I don't actually bother with that. I take a script that works (a recorded one, for instance), then rename it and delete the contents. That gives me a blank file, in UTF-16 format, to build a new script on.



I switched to Text wrangler and saved using UTF 16 with classic mac line breaks and it works although this script fails on transitions.
....
Any ideas why the transitions would fail on this?

For me I want to use it more like a frame player where each frame is on a separate layer to see how it looks so personally I dont need transitions.


The way transitioning works in this script is by reducing the opacity of one layer while increasing the opacity of the next. As long as your ArtRage handles opacity adjustments normally, I'm not sure what the problem might be. I'd be interested in seeing your error message from ArtRage.

Since you don't need transitions, does the script work if you set transition time to 0?

mykyl1966
07-27-2011, 09:44 AM
The actual error leaving it at defaults is

Script error

(then it shows the location of the script)

Line: 176 String: Transition( 11-nTransition, naSlides[j], naSlides[j+1])

Then a button that says ok. The player box shows 97%.

If I set transition to 0 I get the same error.

(I just tried your trick of editing a previously working script file but that also fails using textedit now. So I will be using text wrangler in future.

Cheers

Mike

terrygillooly
07-27-2011, 10:27 AM
Argh, I accidentally deleted whatever I wrote here before this edit.

Anyway, here is a version of the Slideshow script with transitions removed. Hopefully it will be less crashy on Macs.


//================================================== =========================
//================================================== =========================
// 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: "Animator"
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: "Animator"
Comment: "Shows each layer of an ArtRage file one at a time, as in an animation."
Script Type: ""
Script Feature Flags: 0
</Header>



//================================================== =========================
// Script data follows:
//================================================== =========================



//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 nLayerID = 0
int nLayerCount = 0
int nReps = 0
int nSlideCount = 0
intarray naSlides = { 0 }
real rPause = 0.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\nNumber of times to repeat: $$nReps")
if (rPause<0) rPause=0; if (rPause>300) rPause=300
if (nReps<0) nReps=0



//Display current slide for 'rPause' seconds, then display next slide
Wait: 0 EvType: Command CommandID: CID_SetSpecificLayerOpacity ParamType: LayerProp Value: { naSlides[1], 1 }
for ( i=0; i<=nReps; i++ ) {
for ( j=1; j<nSlideCount-1; j++ ) {
Wait: (rPause)
//Set opacities to 0% and 100%
Wait: 0 EvType: Command CommandID: CID_SetSpecificLayerOpacity ParamType: LayerProp Value: { naSlides[j+1], 1 }
Wait: 0 EvType: Command CommandID: CID_SetSpecificLayerOpacity ParamType: LayerProp Value: { naSlides[j], 0 }
}
//Special treatment needed for looping back to the beginning
Wait: (rPause)
Wait: 0 EvType: Command CommandID: CID_SetSpecificLayerOpacity ParamType: LayerProp Value: { naSlides[1], 1 }
Wait: 0 EvType: Command CommandID: CID_SetSpecificLayerOpacity ParamType: LayerProp Value: { naSlides[j], 0 }
}



Cleanup()


//110727

mykyl1966
07-27-2011, 10:58 AM
That last one runs at least but crashes on line 142 string cleanup. But at least it runs all the way through until the end. So if I ask it to run 5 times it will run 5 times etc.

Very nice actually and could help a lot.

Now we just need the artrage folks to allow a new tool bar to assign scripts to buttons. :D

I wonder what is different between the pc version and mac version.

Something like this is the beginnings of a very useful tool for animators within Artrage. Only thing missing would be a way to slow it down or a delay between frames.

I am trying to work out why cleanup would fail. If I am reading your script correctly, it is trying to clear out the blank layer that was created at the beginning. Is that right?

Ignore that. I just read your comment and that is exactly what it is trying to do. So it fails on the deletion of that layer. I need to read up on this scripting a bit more.

Mike

terrygillooly
07-27-2011, 12:11 PM
Mike, I revised the code to put the pauses back in. Give that a try.

It occurs to me that both crashes happen during function calls. Coincidence? You can try deleting that final call and replacing it with the actual commands from the function.

mykyl1966
07-27-2011, 01:29 PM
That works perfectly with no errors at all.

Thank you.

Mike R

leechie
08-10-2011, 06:22 AM
comment on not a very good slide show with one layer got a good laugh out of me ha ha