home *** CD-ROM | disk | FTP | other *** search
/ The Best of Mecomp Multimedia 2 / MECOMP-CD-II.iso / amiga / grafix / visualanim / arexx / visualanim.rexx
Encoding:
OS/2 REXX Batch file  |  1998-03-08  |  10.2 KB  |  581 lines

  1. /*
  2.  
  3.  
  4.    Visual Anim v2.00
  5.  
  6.     Marko Seppänen
  7.     marko.seppanen@wwnet.fi
  8.  
  9. */
  10.  
  11.  
  12. call addlib('rexxmathlib.library',0,-30,0)
  13. address IMAGEENGINEER
  14.  
  15. Options results
  16. signal on error            /* Setup a place for errors to go */
  17.  
  18. if arg()=0 then exit
  19. pic=arg(1)
  20.  
  21. MARK pic PRIMARY
  22. PROJECT_INFO pic WIDTH
  23. width=result
  24. PROJECT_INFO pic HEIGHT
  25. height=result
  26.  
  27. 'PALETTE_SAVE' pic 'ram:tempfileforiepalette'
  28.  
  29.  
  30.  
  31. /*
  32.     . THE BEGINNING .
  33.                         */
  34.  
  35.  
  36. if exists("ie:prefs/visualengineer.cfg") == "1" then
  37.   do
  38.     call open("temp","ie:prefs/visualengineer.cfg","R")
  39.     values=readln("temp")
  40.     parse var values ok visual bg savedir space
  41.     call close("temp")
  42.   end
  43. else
  44.   do
  45.     visual=0
  46.     bg=1
  47.     savedir="ram:"
  48.     space=25
  49.   end
  50.  
  51. 'FORM "Visual-Engineer" "Use|Cancel"',
  52. ' CYCLE,"Visual","Bulge|Ripple|Twirl",'visual'',
  53. ' RADIO,"BG-color","Black|White",'bg'',
  54. ' DIR,"SaveDir",'savedir'',
  55. ' INTEGER,"Space around",0,100,'space',SLIDER'
  56.  
  57. values=result
  58. parse var values ok visual bg savedir space
  59. savedir=strip(savedir,B,'"')
  60.  
  61. if ok = 0 then exit
  62.  
  63. call open("temp","ie:prefs/visualengineer.cfg","W")
  64. res=writeln("temp",values)
  65. call close("temp")
  66.  
  67.  
  68.  
  69.  
  70.  
  71. /*
  72.     . BACKGROUND COLOR .
  73.                            */
  74.  
  75.  
  76. if bg == 1 then
  77. do
  78.   if exists("ie:alpha/purewhite.alpha") == "1" then
  79.   do
  80.     OPEN "ie:alpha/purewhite.alpha" COLOUR
  81.     colortexture=result
  82.     RESIZE colortexture width+space*2 height+space*2 TILE
  83.     colortexture2=result
  84.     MARK colortexture2 SECONDARY
  85.     CLOSE colortexture
  86.     COMPOSITE space space MIN
  87.     pic2=result
  88.   end
  89.   else
  90.   do
  91.     'REQUEST "Please copy purewhite.alpha to dir IE:Alpha/" "Ups, sorry!"'
  92.     exit
  93.   end
  94. end
  95. else
  96. do
  97.   if exists("ie:alpha/pureblack.alpha") == "1" then
  98.   do
  99.     OPEN "ie:alpha/pureblack.alpha" COLOUR
  100.     colortexture=result
  101.     RESIZE colortexture width+space*2 height+space*2 TILE
  102.     colortexture2=result
  103.     MARK colortexture2 SECONDARY
  104.     CLOSE colortexture
  105.     COMPOSITE space space MAX
  106.     pic2=result
  107.   end
  108.   else
  109.   do
  110.     'REQUEST "Please copy pureblack.alpha to dir IE:Alpha/" "Ups, sorry!"'
  111.     exit
  112.   end
  113. end
  114.  
  115. CLOSE colortexture2
  116.  
  117.  
  118.  
  119.  
  120. /* ..HOW MANY FRAMES?.. */
  121.  
  122.  
  123. 'REQUEST "How many frames?" "8|12|18|24|Cancel"'
  124.  
  125. select
  126.  
  127.   when result=1 then framecount=8
  128.   when result=2 then framecount=12
  129.   when result=3 then framecount=18
  130.   when result=4 then framecount=24
  131.  
  132.   otherwise exit
  133.  
  134. end
  135.  
  136.  
  137.  
  138.  
  139.  
  140. /* ----------------HERE IT STARTS----------------*/
  141.  
  142. select
  143.  
  144.  
  145.  
  146.  
  147.  
  148. /*..VISUAL BULGE..*/
  149.  
  150.   when visual == 0 then
  151.   do
  152.  
  153.     if exists("ie:prefs/visualbulge.cfg") == "1" then
  154.       do
  155.         call open("temp","ie:prefs/visualbulge.cfg","R")
  156.         values=readln("temp")
  157.         parse var values ok type origamount radius
  158.         call close("temp")
  159.       end
  160.     else
  161.       do
  162.         type=0
  163.         origamount=25
  164.         radius=trunc(width/4)
  165.       end
  166.  
  167.     'FORM "Visual Bulge settings" "Use|Cancel"',
  168.     ' CYCLE,"Type","Boom|Rubber|In|Out",'type'',
  169.     ' INTEGER,"Bulge",1,100,'origamount',SLIDER',
  170.     ' INTEGER,"Radius",0,'width','radius',SLIDER'
  171.  
  172.     values=result
  173.     parse var values ok type origamount radius
  174.  
  175.     if ok = 0 then
  176.     do
  177.       close pic2
  178.       exit
  179.     end
  180.  
  181.     call open("temp","ie:prefs/visualbulge.cfg","W")
  182.     res=writeln("temp",values)
  183.     call close("temp")
  184.  
  185.  
  186.     x=width/2+space
  187.     y=height/2+space
  188.     over=0
  189.  
  190.     origamount="-"origamount
  191.     radius=0
  192.     radiusmax=(max(width,height))/2
  193.     rad=radiusmax/framecount*2
  194.     am=abs(origamount)/framecount*4
  195.     amount=origamount-am
  196.  
  197.  
  198.     do counter=1 to framecount
  199.  
  200.       sini=sin((360/framecount*counter-1)*(3.14/180))
  201.       cosi=cos((360/framecount*counter-1)*(3.14/180))
  202.  
  203.       select
  204.  
  205.         when type == 0 then
  206.           do
  207.  
  208.             if over ~== "1" then
  209.             do
  210.               radius=radius+rad
  211.             end
  212.             else
  213.             do
  214.               radius=radius-rad
  215.             end
  216.  
  217.             if radius>radiusmax then over=1
  218.  
  219.             BULGE pic2 x y radius abs(amount) BEST
  220.  
  221.           end
  222.  
  223.         when type == 1 then
  224.           do
  225.  
  226.             if over ~== "1" then
  227.             do
  228.               amount=amount+am
  229.             end
  230.             else
  231.             do
  232.               amount=amount-am
  233.             end
  234.  
  235.             if amount>abs(origamount)-1 then over=1
  236.  
  237.             BULGE pic2 x y radiusmax amount BEST
  238.  
  239.           end
  240.  
  241.         when type == 2 then
  242.           do
  243.  
  244.             BULGE pic2 cosi*(width/4)+(width/2+space) sini*(height/4)+(height/2+space) radiusmax amount BEST
  245.  
  246.           end
  247.  
  248.         when type == 3 then
  249.           do
  250.  
  251.             BULGE pic2 cosi*(width/4)+(width/2+space) sini*(height/4)+(height/2+space) radiusmax abs(amount) BEST
  252.  
  253.           end
  254.  
  255.         otherwise exit
  256.  
  257.       end
  258.  
  259.       x1=result
  260.       visual="bulge"
  261.       call save()
  262.  
  263.     end
  264.  
  265.   end
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279. /*..VISUAL RIPPLE..*/
  280.  
  281.   when visual == 1 then
  282.   do
  283.  
  284.     if exists("ie:prefs/visualripple.cfg") == "1" then
  285.       do
  286.         call open("temp","ie:prefs/visualripple.cfg","R")
  287.         values=readln("temp")
  288.         parse var values ok type amp period
  289.         call close("temp")
  290.       end
  291.     else
  292.       do
  293.         type=0
  294.         amp=5
  295.         period=trunc(width/2)
  296.       end
  297.  
  298.     'FORM "Visual Ripple settings" "Use|Cancel"',
  299.     ' CYCLE,"Type","Simple|SimpleC|Boom|BoomC|Ripple|Swirl",'type'',
  300.     ' INTEGER,"Amplitude",1,359,'amp',SLIDER',
  301.     ' INTEGER,"Period",0,'width','period',SLIDER'
  302.  
  303.     values=result
  304.     parse var values ok type amp period
  305.  
  306.     ampadd=trunc((amp/framecount)*2)
  307.  
  308.     if ok = 0 then
  309.     do
  310.       close pic2
  311.       exit
  312.     end
  313.  
  314.     call open("temp","ie:prefs/visualripple.cfg","W")
  315.     res=writeln("temp",values)
  316.     call close("temp")
  317.  
  318.  
  319.     do counter=1 to framecount
  320.  
  321.       select
  322.  
  323.         when type == 0 then
  324.           do
  325.             RIPPLE pic2 width/2+space-5 0 amp period 360/framecount*counter-1 OUT BEST
  326.           end
  327.  
  328.         when type == 1 then
  329.           do
  330.             RIPPLE pic2 0 0 amp period 360/framecount*counter-1 OUT BEST
  331.           end
  332.  
  333.         when type == 2 then
  334.           do
  335.  
  336.  
  337.             if counter<(framecount/2)+2 then
  338.               amp=amp+ampadd
  339.             else
  340.               amp=amp-ampadd
  341.  
  342.             RIPPLE pic2 width/2+20 0 amp period 360/framecount*counter-1 OUT BEST
  343.           end
  344.  
  345.         when type == 3 then
  346.  
  347.           do
  348.             if counter<framecount/2+2 then
  349.               amp=amp+ampadd
  350.             else
  351.               amp=amp-ampadd
  352.  
  353.             RIPPLE pic2 0 0 amp period 360/framecount*counter-1 OUT BEST
  354.           end
  355.  
  356.         when type == 4 then
  357.           do
  358.             if counter<framecount/2+2 then
  359.               amp=amp+ampadd
  360.             else
  361.               amp=amp-ampadd
  362.  
  363.             RIPPLE pic2 width/2+20 0 amp period 360/framecount*counter-1 AROUND BEST
  364.           end
  365.  
  366.         when type == 5 then
  367.           do
  368.             RIPPLE pic2 width/2+20 height/2+space amp period 360/framecount*counter-1 AROUND BEST
  369.           end
  370.  
  371.         otherwise exit
  372.  
  373.       end
  374.  
  375.       x1=result
  376.       visual="ripple"
  377.       call save()
  378.  
  379.     end
  380.  
  381.   end
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389. /*..VISUAL TWIRL..*/
  390.  
  391.  
  392.   when visual == 2 then
  393.   do
  394.  
  395.     if exists("ie:prefs/visualtwirl.cfg") == "1" then
  396.       do
  397.         call open("temp","ie:prefs/visualtwirl.cfg","R")
  398.         values=readln("temp")
  399.         parse var values ok type radius origdegree
  400.         call close("temp")
  401.       end
  402.     else
  403.       do
  404.         type=0
  405.         radius=trunc(width/2)
  406.         origdegree=20
  407.       end
  408.  
  409.     'FORM "Visual Twirl settings" "Use|Cancel"',
  410.     ' CYCLE,"Type","Swing|Swing2|ShakeIt|ShakeIt2",'type'',
  411.     ' INTEGER,"Radius",1,'width','radius',SLIDER',
  412.     ' INTEGER,"Degree",1,'359','origdegree',SLIDER'
  413.  
  414.     values=result
  415.     parse var values ok type radius origdegree
  416.  
  417.     if ok = 0 then
  418.     do
  419.       close pic2
  420.       exit
  421.     end
  422.  
  423.     call open("temp","ie:prefs/visualtwirl.cfg","W")
  424.     res=writeln("temp",values)
  425.     call close("temp")
  426.  
  427.  
  428.     x=width/2+space
  429.     y=height/2+space
  430.     origdegree="-"origdegree
  431.  
  432.     radius=(max(width,height))/2
  433.     radiusmin=(min(width,height))/2
  434.     radius2=0
  435.     radiusmax=trunc(sqr(width**2+height**2))
  436.     rad=radiusmax/framecount
  437.  
  438.     deg=abs(4*origdegree)/(framecount)
  439.     degree=origdegree-deg
  440.     deg2=abs(2*origdegree)/(framecount)
  441.     degree2=0
  442.  
  443.  
  444.     do counter=1 to framecount
  445.  
  446.       sini=sin((360/framecount*counter-1)*(3.14/180))
  447.       cosi=cos((360/framecount*counter-1)*(3.14/180))
  448.  
  449.       select
  450.  
  451.         when type == 0 then
  452.           do
  453.  
  454.             if over ~== "1" then
  455.             do
  456.               degree=degree+deg
  457.             end
  458.             else
  459.             do
  460.               degree=degree-deg
  461.             end
  462.  
  463.             if degree>abs(origdegree)-deg then over=1
  464.  
  465.             TWIRL pic2 x y radius+50 degree BEST
  466.  
  467.           end
  468.  
  469.         when type == 1 then
  470.           do
  471.  
  472.             if over ~== "1" then
  473.             do
  474.               degree2=degree2+deg2
  475.             end
  476.             else
  477.             do
  478.               degree2=degree2-deg2
  479.             end
  480.  
  481.             if degree2>abs(origdegree)-deg2 then over=1
  482.  
  483.             radius2=radius2+rad
  484.  
  485.             TWIRL pic2 space space radius2 degree2 BEST
  486.  
  487.           end
  488.  
  489.         when type == 2 then
  490.           do
  491.  
  492.             TWIRL pic2 cosi*(width/4)+(width/2+space) sini*(height/4)+(height/2+space) radius abs(origdegree) BEST
  493.  
  494.           end
  495.  
  496.         when type == 3 then
  497.           do
  498.  
  499.             TWIRL pic2 cosi*(width/4)+(width/2+space) sini*(height/4)+(height/2+space) radiusmin abs(origdegree) BEST
  500.  
  501.           end
  502.  
  503.  
  504.         otherwise exit
  505.  
  506.       end
  507.  
  508.       x1=result
  509.       visual="twirl"
  510.       call save()
  511.  
  512.     end
  513.  
  514.   end
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525. /* THE END */
  526.  
  527.  
  528.   otherwise exit
  529.  
  530. end
  531.  
  532. CLOSE pic2
  533.  
  534. exit
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543. /* ..SAVING.. */
  544.  
  545.  
  546. save:
  547.  
  548.       'PALETTE_LOAD' x1 'ram:tempfileforiepalette'
  549.  
  550.       'RENDER_SET' x1 "0 167940 8 255 0 1"
  551.  
  552.       RENDER x1
  553.  
  554.       if counter <10 then counter=insert("0",counter)
  555.       filename=savedir''visual''"."counter
  556.  
  557.       SAVE x1 '"'filename'"' '"'ILBM CmpByteRun1'"'
  558.  
  559.       CLOSE x1
  560.  
  561.       return
  562.  
  563.  
  564. /*******************************************************************/
  565. /* This is where control goes when an error code is returned by IE */
  566. /* It puts up a message saying what happened and on which line     */
  567. /*******************************************************************/
  568. error:
  569. if RC=5 then do            /* Did the user just cancel us? */
  570.     IE_TO_FRONT
  571.     LAST_ERROR
  572.     'REQUEST "'||RESULT||'"'
  573.     exit
  574. end
  575. else do
  576.     IE_TO_FRONT
  577.     LAST_ERROR
  578.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  579.     exit
  580. end
  581.