ArtRage 5 Product PageArtRage Lite Product PageArtRage for iOS Product PageArtRage for Android Product PageArtRage  Android Oil Painter Free Product PageArtRage  Free Demos Page

Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Slideshow script

  1. #1
    Join Date
    Feb 2010
    Location
    Nevada
    Posts
    139

    Slideshow script

    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!

    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
    Attached Files Attached Files
    Last edited by terrygillooly; 07-27-2011 at 07:12 PM. Reason: fix code
    Cat Boxes, a web comic

  2. #2
    Join Date
    Mar 2006
    Location
    Ambient Design
    Posts
    3,839
    Ooo, nice idea.
    AndyRage's mantra for graphics engine code:
    "Sure - how hard can it be?"

  3. #3
    Join Date
    May 2009
    Location
    3438 ft above sea level
    Posts
    2,951
    Great Job Terry
    Hehehe to 'dorked' out

    This would be a great asset to anyone wanting to show off a painting in different stages, Placing each stage on a new layer.
    "I paint because I love to cut mats" (Arthur Alexander)

  4. #4
    Join Date
    Feb 2010
    Location
    Nevada
    Posts
    139
    Thanks guys!

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

  5. #5
    Join Date
    Jul 2007
    Posts
    27
    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
    Last edited by mykyl1966; 07-26-2011 at 09:55 PM.

  6. #6
    Join Date
    Mar 2006
    Location
    Ambient Design
    Posts
    3,504
    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...ad.php?t=35944

    If you still have problems, let us know.
    Dave
    Resident Bug-Hunter
    Ambient Design

  7. #7
    Join Date
    Jul 2007
    Posts
    27
    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
    Last edited by mykyl1966; 07-27-2011 at 04:23 AM.

  8. #8
    Join Date
    Feb 2010
    Location
    Nevada
    Posts
    139
    Quote Originally Posted by mykyl1966 View Post
    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.


    Quote Originally Posted by mykyl1966 View Post
    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?
    Cat Boxes, a web comic

  9. #9
    Join Date
    Jul 2007
    Posts
    27
    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
    Last edited by mykyl1966; 07-27-2011 at 08:48 AM.

  10. #10
    Join Date
    Feb 2010
    Location
    Nevada
    Posts
    139
    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.

    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: "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
    Attached Files Attached Files
    Last edited by terrygillooly; 07-27-2011 at 07:14 PM. Reason: godzilla-like rampage through previous post, apparently
    Cat Boxes, a web comic

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •