home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / GFX / ADPro251-3.DMS / ADPro251-3.adf / FREDScripts.lha / FREDOperators / DisplacePixel.fred < prev    next >
Encoding:
Text File  |  1994-01-31  |  5.4 KB  |  229 lines

  1. /*
  2. ** DisplacePixel.fred
  3. **
  4. ** $VER: DisplacePixel.fred 1.1.0 (23.10.93)
  5. **
  6. ** This program can be run from an InvokeADPro list to displace the
  7. ** pixels within an image, either "exploding" or "imploding" (or both).
  8. **
  9. ** Clips Imported:
  10. **    FREDDispCurrRad        -    Current displacement radius
  11. **    FREDDispIncrRad        -    Radius increment per frame
  12. **    FREDDispMaxRad        -    Maximum radius displacement
  13. **    FREDDispUTurnFrame    -    Frame number at which to
  14. **                    "change directions"
  15. **    FREDDispFrameNum    -    Current frame number (starting @ 1)
  16. **    FREDDispNumberOfFrames    -    Number of frames
  17. **
  18. ** Clips Exported:
  19. **    FREDDisplaceCurrRad    -    Current displacement radius
  20. **    FREDDispIncrRad        -    Radius increment per frame
  21. **    FREDDispMaxRad        -    Maximum radius displacement
  22. **    FREDDispUTurnFrame    -    Frame number at which to
  23. **    FREDDispFrameNum    -    Current frame number (starting @ 1)
  24. **
  25. ** NOTE: Clip names are case sensitive.
  26. **
  27. ** This script requires FRED v1.4.0 (or higher) to run.  Also required is
  28. ** ADPro v2.5.0 (or higher).
  29. **
  30. ** Copyright © 1992-1993 ASDG, Incorporated
  31. ** All Rights Reserved
  32. */
  33.  
  34.  
  35. ADDRESS "ADPro"
  36. OPTIONS RESULTS
  37.  
  38. PARSE ARG FrameNum FrameFName Length LoadFlag FirstCallSeq FirstCallCell
  39.  
  40. NL = '0A'X
  41. SQ = '27'X
  42. DQ = '22'X
  43. TRUE  = 1
  44. FALSE = 0
  45.  
  46.  
  47. /*
  48. ** Get the required clips.  Error if any are missing.
  49. */
  50.  
  51. IF (FirstCallSeq = 0) THEN DO
  52.     CurrRad = GETCLIP( "FREDDispCurrRad" )
  53.     IF (CurrRad = "") THEN DO
  54.         ADPRO_TO_FRONT
  55.         OKAY1 "Required clip, FREDDispCurrRad," || NL ||,
  56.             "is not specified."
  57.         SCREEN_TO_FRONT "FRED"
  58.         EXIT 10
  59.     END
  60.  
  61.     IncrRad = GETCLIP( "FREDDispIncrRad" )
  62.     IF (IncrRad = "") THEN DO
  63.         ADPRO_TO_FRONT
  64.         OKAY1 "Required clip, FREDDispIncrRad," || NL ||,
  65.             "is not specified."
  66.         SCREEN_TO_FRONT "FRED"
  67.         EXIT 10
  68.     END
  69.  
  70.     MaxRad = GETCLIP( "FREDDispMaxRad" )
  71.     IF (MaxRad = "") THEN DO
  72.         ADPRO_TO_FRONT
  73.         OKAY1 "Required clip, FREDDispMaxRad," || NL ||,
  74.             "is not specified."
  75.         SCREEN_TO_FRONT "FRED"
  76.         EXIT 10
  77.     END
  78.  
  79.     UTurnFrame = GETCLIP( "FREDDispUTurnFrame" )
  80.     IF (UTurnFrame = "") THEN DO
  81.         ADPRO_TO_FRONT
  82.         OKAY1 "Required clip, FREDDispUTurnFrame," || NL ||,
  83.             "is not specified."
  84.         SCREEN_TO_FRONT "FRED"
  85.         EXIT 10
  86.     END
  87. END
  88. ELSE DO
  89.     NumberOfFrames = GETCLIP( "FREDDispNumberOfFrames" )
  90.     IF (NumberOfFrames = "") THEN DO
  91.         ADPRO_TO_FRONT
  92.         OKAY1 "Required clip, FREDDispNumberOfFrames," || NL ||,
  93.             "is not specified."
  94.         SCREEN_TO_FRONT "FRED"
  95.         EXIT 10
  96.     END
  97. END
  98.  
  99. DispFrameNum = GETCLIP( "FREDDispFrameNum" )
  100. IF (DispFrameNum = "") THEN DO
  101.     ADPRO_TO_FRONT
  102.     OKAY1 "Required clip, FREDDispFrameNum," || NL ||,
  103.         "is not specified."
  104.     SCREEN_TO_FRONT "FRED"
  105.     EXIT 10
  106. END
  107.  
  108.  
  109. /*
  110. ** See what type of data is loaded in ADPro/MorphPlus.
  111. */
  112.  
  113. CALL "FREDSCRIPTS:FREDFunctions/CheckForRawImageData" TRUE
  114. IF (RESULT ~= 0) THEN
  115.     EXIT 10
  116.  
  117. IF (FirstCallSeq ~= 0) THEN DO
  118.     XSIZE
  119.     ImageWidth = ADPRO_RESULT
  120.  
  121.     YSIZE
  122.     ImageHeight = ADPRO_RESULT
  123.  
  124.     MaxRad = TRUNC( 0.1 * MAX( ImageWidth, ImageHeight ) )
  125.  
  126.     /*
  127.     ** Ask the user how the displacement should occur.
  128.     */
  129.  
  130.     DisplaceMethod.0  = "Explode"
  131.     DisplaceMethod.1  = "Implode"
  132.     DisplaceMethod.2  = "Explode, then Implode"
  133.     DisplaceMethod.3  = "Implode, then Explode"
  134.     MinDisplaceMethod = 0
  135.     MaxDisplaceMethod = 3
  136.     DefDisplaceMethod = 0
  137.  
  138.     String = '"' || DisplaceMethod.DefDisplaceMethod || '"'
  139.     DO LoopCounter = MinDisplaceMethod TO MaxDisplaceMethod
  140.         String = String '"' || DisplaceMethod.LoopCounter || '"'
  141.     END
  142.  
  143.     continue = 0
  144.     DO UNTIL (continue = 1)
  145.         ADPRO_TO_FRONT
  146.  
  147.         LISTVIEW '"Pixel Movement:"' (MaxDisplaceMethod - MinDisplaceMethod + 1) ITEMS String
  148.         LISTVIEW_RC = RC
  149.         PARSE VAR ADPRO_RESULT '"'DisplaceMethodStr'"' scratch
  150.  
  151.         DisplaceType = MinDisplaceMethod
  152.         DO WHILE (DisplaceType <= MaxDisplaceMethod) & (COMPARE( DisplaceMethodStr, DisplaceMethod.DisplaceType ) ~= 0)
  153.             DisplaceType = DisplaceType + 1
  154.         END
  155.  
  156.         IF (LISTVIEW_RC ~= 0) & (LISTVIEW_RC ~= 1) THEN DO
  157.             ADPRO_TO_FRONT
  158.  
  159.             OKAYN '"DisplacePixel.fred"' '"This value is required."' '"Retry|Cancel"'
  160.             IF (RC = 0) THEN
  161.                 EXIT 10
  162.         END
  163.         ELSE
  164.             continue = 1
  165.     END
  166.  
  167.     SCREEN_TO_FRONT "FRED"
  168.  
  169.     IF (DisplaceType = 0) THEN DO            /* if explode */
  170.         CurrRad = 1
  171.         IncrRad = MaxRad / (NumberOfFrames - 1)
  172.         UTurnFrame = NumberOfFrames
  173.     END
  174.     ELSE IF (DisplaceType = 2) THEN DO        /* else if explode/implode */
  175.         CurrRad = 1
  176.         IncrRad = MaxRad / ((NumberOfFrames + 1) / 2 - 1)
  177.         UTurnFrame = TRUNC( NumberOfFrames / 2 )
  178.     END
  179.     ELSE IF (DisplaceType = 1) THEN DO        /* else if implode */
  180.         CurrRad = MaxRad            /* switch explode vars */
  181.         IncrRad = (-MaxRad) / (NumberOfFrames - 1)
  182.         UTurnFrame = NumberOfFrames
  183.     END
  184.     ELSE IF (DisplaceType = 3) THEN DO        /* else if implode/explode */
  185.         CurrRad = MaxRad            /* switch explode/implode vars */
  186.         IncrRad = (-MaxRad) / ((NumberOfFrames + 1) / 2 - 1)
  187.         UTurnFrame = TRUNC( NumberOfFrames / 2 )
  188.     END
  189. END
  190.  
  191.  
  192. /*
  193. ** Do the Displace_Pixel operation, incrementing the current displacement
  194. ** radius with each iteration.
  195. */
  196.  
  197. OPERATOR "DISPLACE_PIXEL" CurrRad 100
  198. IF (RC ~= 0) THEN DO
  199.     Why = ADPRO_RESULT
  200.     ADPRO_TO_FRONT
  201.     OKAY1 "The operator Displace_Pixel" || NL ||,
  202.         "failed to execute." || NL ||,
  203.         Why
  204.     SCREEN_TO_FRONT "FRED"
  205.     EXIT 10
  206. END
  207.  
  208. CurrRad = CurrRad + IncrRad
  209. IF (CurrRad < 1) THEN
  210.     CurrRad = 1
  211. ELSE IF (CurrRad > MaxRad) THEN
  212.     CurrRad = MaxRad
  213.  
  214. IF (DispFrameNum = UTurnFrame) THEN
  215.     IncrRad = (IncrRad * (-1))
  216.  
  217.  
  218. /*
  219. ** Update the clips.
  220. */
  221.  
  222. SETCLIP( "FREDDispCurrRad", CurrRad )
  223. SETCLIP( "FREDDispIncrRad", IncrRad )
  224. SETCLIP( "FREDDispMaxRad", MaxRad )
  225. SETCLIP( "FREDDispUTurnFrame", UTurnFrame )
  226. SETCLIP( "FREDDispFrameNum", DispFrameNum + 1 )
  227.  
  228. EXIT 0
  229.