home *** CD-ROM | disk | FTP | other *** search
- /*
- ** DisplacePixel.fred
- **
- ** $VER: DisplacePixel.fred 1.1.0 (23.10.93)
- **
- ** This program can be run from an InvokeADPro list to displace the
- ** pixels within an image, either "exploding" or "imploding" (or both).
- **
- ** Clips Imported:
- ** FREDDispCurrRad - Current displacement radius
- ** FREDDispIncrRad - Radius increment per frame
- ** FREDDispMaxRad - Maximum radius displacement
- ** FREDDispUTurnFrame - Frame number at which to
- ** "change directions"
- ** FREDDispFrameNum - Current frame number (starting @ 1)
- ** FREDDispNumberOfFrames - Number of frames
- **
- ** Clips Exported:
- ** FREDDisplaceCurrRad - Current displacement radius
- ** FREDDispIncrRad - Radius increment per frame
- ** FREDDispMaxRad - Maximum radius displacement
- ** FREDDispUTurnFrame - Frame number at which to
- ** FREDDispFrameNum - Current frame number (starting @ 1)
- **
- ** NOTE: Clip names are case sensitive.
- **
- ** This script requires FRED v1.4.0 (or higher) to run. Also required is
- ** ADPro v2.5.0 (or higher).
- **
- ** Copyright © 1992-1993 ASDG, Incorporated
- ** All Rights Reserved
- */
-
-
- ADDRESS "ADPro"
- OPTIONS RESULTS
-
- PARSE ARG FrameNum FrameFName Length LoadFlag FirstCallSeq FirstCallCell
-
- NL = '0A'X
- SQ = '27'X
- DQ = '22'X
- TRUE = 1
- FALSE = 0
-
-
- /*
- ** Get the required clips. Error if any are missing.
- */
-
- IF (FirstCallSeq = 0) THEN DO
- CurrRad = GETCLIP( "FREDDispCurrRad" )
- IF (CurrRad = "") THEN DO
- ADPRO_TO_FRONT
- OKAY1 "Required clip, FREDDispCurrRad," || NL ||,
- "is not specified."
- SCREEN_TO_FRONT "FRED"
- EXIT 10
- END
-
- IncrRad = GETCLIP( "FREDDispIncrRad" )
- IF (IncrRad = "") THEN DO
- ADPRO_TO_FRONT
- OKAY1 "Required clip, FREDDispIncrRad," || NL ||,
- "is not specified."
- SCREEN_TO_FRONT "FRED"
- EXIT 10
- END
-
- MaxRad = GETCLIP( "FREDDispMaxRad" )
- IF (MaxRad = "") THEN DO
- ADPRO_TO_FRONT
- OKAY1 "Required clip, FREDDispMaxRad," || NL ||,
- "is not specified."
- SCREEN_TO_FRONT "FRED"
- EXIT 10
- END
-
- UTurnFrame = GETCLIP( "FREDDispUTurnFrame" )
- IF (UTurnFrame = "") THEN DO
- ADPRO_TO_FRONT
- OKAY1 "Required clip, FREDDispUTurnFrame," || NL ||,
- "is not specified."
- SCREEN_TO_FRONT "FRED"
- EXIT 10
- END
- END
- ELSE DO
- NumberOfFrames = GETCLIP( "FREDDispNumberOfFrames" )
- IF (NumberOfFrames = "") THEN DO
- ADPRO_TO_FRONT
- OKAY1 "Required clip, FREDDispNumberOfFrames," || NL ||,
- "is not specified."
- SCREEN_TO_FRONT "FRED"
- EXIT 10
- END
- END
-
- DispFrameNum = GETCLIP( "FREDDispFrameNum" )
- IF (DispFrameNum = "") THEN DO
- ADPRO_TO_FRONT
- OKAY1 "Required clip, FREDDispFrameNum," || NL ||,
- "is not specified."
- SCREEN_TO_FRONT "FRED"
- EXIT 10
- END
-
-
- /*
- ** See what type of data is loaded in ADPro/MorphPlus.
- */
-
- CALL "FREDSCRIPTS:FREDFunctions/CheckForRawImageData" TRUE
- IF (RESULT ~= 0) THEN
- EXIT 10
-
- IF (FirstCallSeq ~= 0) THEN DO
- XSIZE
- ImageWidth = ADPRO_RESULT
-
- YSIZE
- ImageHeight = ADPRO_RESULT
-
- MaxRad = TRUNC( 0.1 * MAX( ImageWidth, ImageHeight ) )
-
- /*
- ** Ask the user how the displacement should occur.
- */
-
- DisplaceMethod.0 = "Explode"
- DisplaceMethod.1 = "Implode"
- DisplaceMethod.2 = "Explode, then Implode"
- DisplaceMethod.3 = "Implode, then Explode"
- MinDisplaceMethod = 0
- MaxDisplaceMethod = 3
- DefDisplaceMethod = 0
-
- String = '"' || DisplaceMethod.DefDisplaceMethod || '"'
- DO LoopCounter = MinDisplaceMethod TO MaxDisplaceMethod
- String = String '"' || DisplaceMethod.LoopCounter || '"'
- END
-
- continue = 0
- DO UNTIL (continue = 1)
- ADPRO_TO_FRONT
-
- LISTVIEW '"Pixel Movement:"' (MaxDisplaceMethod - MinDisplaceMethod + 1) ITEMS String
- LISTVIEW_RC = RC
- PARSE VAR ADPRO_RESULT '"'DisplaceMethodStr'"' scratch
-
- DisplaceType = MinDisplaceMethod
- DO WHILE (DisplaceType <= MaxDisplaceMethod) & (COMPARE( DisplaceMethodStr, DisplaceMethod.DisplaceType ) ~= 0)
- DisplaceType = DisplaceType + 1
- END
-
- IF (LISTVIEW_RC ~= 0) & (LISTVIEW_RC ~= 1) THEN DO
- ADPRO_TO_FRONT
-
- OKAYN '"DisplacePixel.fred"' '"This value is required."' '"Retry|Cancel"'
- IF (RC = 0) THEN
- EXIT 10
- END
- ELSE
- continue = 1
- END
-
- SCREEN_TO_FRONT "FRED"
-
- IF (DisplaceType = 0) THEN DO /* if explode */
- CurrRad = 1
- IncrRad = MaxRad / (NumberOfFrames - 1)
- UTurnFrame = NumberOfFrames
- END
- ELSE IF (DisplaceType = 2) THEN DO /* else if explode/implode */
- CurrRad = 1
- IncrRad = MaxRad / ((NumberOfFrames + 1) / 2 - 1)
- UTurnFrame = TRUNC( NumberOfFrames / 2 )
- END
- ELSE IF (DisplaceType = 1) THEN DO /* else if implode */
- CurrRad = MaxRad /* switch explode vars */
- IncrRad = (-MaxRad) / (NumberOfFrames - 1)
- UTurnFrame = NumberOfFrames
- END
- ELSE IF (DisplaceType = 3) THEN DO /* else if implode/explode */
- CurrRad = MaxRad /* switch explode/implode vars */
- IncrRad = (-MaxRad) / ((NumberOfFrames + 1) / 2 - 1)
- UTurnFrame = TRUNC( NumberOfFrames / 2 )
- END
- END
-
-
- /*
- ** Do the Displace_Pixel operation, incrementing the current displacement
- ** radius with each iteration.
- */
-
- OPERATOR "DISPLACE_PIXEL" CurrRad 100
- IF (RC ~= 0) THEN DO
- Why = ADPRO_RESULT
- ADPRO_TO_FRONT
- OKAY1 "The operator Displace_Pixel" || NL ||,
- "failed to execute." || NL ||,
- Why
- SCREEN_TO_FRONT "FRED"
- EXIT 10
- END
-
- CurrRad = CurrRad + IncrRad
- IF (CurrRad < 1) THEN
- CurrRad = 1
- ELSE IF (CurrRad > MaxRad) THEN
- CurrRad = MaxRad
-
- IF (DispFrameNum = UTurnFrame) THEN
- IncrRad = (IncrRad * (-1))
-
-
- /*
- ** Update the clips.
- */
-
- SETCLIP( "FREDDispCurrRad", CurrRad )
- SETCLIP( "FREDDispIncrRad", IncrRad )
- SETCLIP( "FREDDispMaxRad", MaxRad )
- SETCLIP( "FREDDispUTurnFrame", UTurnFrame )
- SETCLIP( "FREDDispFrameNum", DispFrameNum + 1 )
-
- EXIT 0
-