home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 20
/
AACD20.BIN
/
AACD
/
Graphics
/
PerfectPaint
/
rexx
/
circle
/
LensFlare.rx
< prev
next >
Wrap
Text File
|
2001-03-08
|
15KB
|
694 lines
/*
Draw and Anim Lens Flare
*/
call addlib("rexxmathlib.library", 5, -30, 0)
options results
parse ARG Port x1 y1 r2 b
ADDRESS value Port
pp_CountFrames
Total_Frame=result
if Total_Frame=0 then Total_Frame=1
Start_Frame=1
End_Frame=Total_Frame
pp_GetDepth
Dp=result
if Dp<24 then DO
pp_Warn 'This*script*is*only|for*24bits*Picture.'
pp_PermitRefresh
Exit
END
Anim=0;Path=0;Type=0
Light=0
Start_B1=100;End_B1=100
Start_B2=48;End_B2=48
Start_S=r2;End_S=r2
Arti=1
Glob=0
Pi=3.1415926/180
totalR=r2*2
RayShade=100-Start_B1
NbStar=8
ADDRESS COMMAND
file="Ram:T/pp_lens"
IF OPEN('b',file,'R') then DO
Anim=READLN('b')
Path=READLN('b')
Type=READLN('b')
Light=READLN('b')
Start_B1=READLN('b')
End_B1=READLN('b')
Start_B2=READLN('b')
End_B2=READLN('b')
Arti=READLN('b')
Glob=READLN('b')
CALL CLOSE('b')
END
ADDRESS value Port
R=-1
DO UNTIL R>-1
pp_DialogInit 250 270 "*LENS*FLARE*" 10
pp_Cycle 0 70 5 100 16 "Animation" 1 "No|Yes" Anim
pp_Cycle 1 70 35 100 16 "Path" 1 "None|Left|Right|Up|Down" Path
pp_Cycle 2 70 53 100 16 "Type" 1 "In|Out" Type
pp_Button 3 20 71 200 16 '*Frame*(*#'||Start_Frame||'->#'||End_Frame||'*)*'
pp_Cycle 4 70 100 100 16 "Light" 1 "Rays|Glow|Star" Light
pp_Button 5 20 118 200 16 '*Brightness*(*'||Start_B1||'*->*'||End_B1||'*)*'
pp_Button 6 20 136 200 16 '*Size*(*'||Start_S||'*->*'||End_S||'*)*'
pp_Cycle 7 70 165 100 16 "Artifacts" 1 "None|Standard|Spot|Spot2" Arti
pp_Cycle 8 70 194 100 16 "Globals" 1 "Red|Blue|Yellow|White" Glob
pp_Button 9 20 212 200 16 '*Brightness*(*'||Start_B2||'*->*'||End_B2||'*)*'
pp_Dialog
R=result
pp_GetDialog 0
Anim=result
pp_GetDialog 1
Path=result
pp_GetDialog 2
Type=result
pp_GetDialog 4
Light=result
pp_GetDialog 7
Arti=result
pp_GetDialog 8
Glob=result
if R=-3 then DO
pp_DialogInit 150 80 "*FRAME*" 2
pp_Integer 0 60 5 50 16 "Start" 1 Start_Frame
pp_Integer 1 60 25 50 16 "End" 1 End_Frame
pp_Dialog
rc=result
IF rc=1 then DO
pp_GetDialog 0
Start_Frame=result
pp_GetDialog 1
End_Frame=result
IF End_Frame>Total_Frame THEN DO
End_Frame=Total_Frame
END
IF Start_Frame>End_Frame THEN DO
Start_Frame=1
END
END
END
if R=-5 then DO
if Anim=1 then DO
pp_DialogInit 150 75 "*LIGHT.BRIGHTNESS*" 2
pp_Integer 0 60 5 50 16 "Start" 1 Start_B1
pp_Integer 1 60 25 50 16 "End" 1 End_B1
pp_Dialog
rc=result
IF rc=1 then DO
pp_GetDialog 0
Start_B1=result
pp_GetDialog 1
End_B1=result
END
END
ELSE DO
pp_DialogInit 150 55 "*LIGHT.BRIGHTNESS*" 1
pp_Integer 0 75 5 50 16 "Brightness" 1 Start_B1
pp_Dialog
rc=result
IF rc=1 then DO
pp_GetDialog 0
Start_B1=result
End_B1=result
END
END
END
if R=-6 then DO
if Anim=1 then DO
pp_DialogInit 150 75 "*LIGHT.SIZE*" 2
pp_Integer 0 60 5 50 16 "Start" 1 Start_S
pp_Integer 1 60 25 50 16 "End" 1 End_S
pp_Dialog
rc=result
IF rc=1 then DO
pp_GetDialog 0
Start_S=result
pp_GetDialog 1
End_S=result
END
END
ELSE DO
pp_DialogInit 150 55 "*LIGHT.SIZE*" 1
pp_Integer 0 60 5 50 16 "Size" 1 Start_S
pp_Dialog
rc=result
IF rc=1 then DO
pp_GetDialog 0
Start_S=result
End_S=result
END
END
END
if R=-9 then DO
if Anim=1 then DO
pp_DialogInit 150 75 "*GLOBAL.BRIGHTNESS*" 2
pp_Integer 0 60 5 50 16 "Start" 1 Start_B2
pp_Integer 1 60 25 50 16 "End" 1 End_B2
pp_Dialog
rc=result
IF rc=1 then DO
pp_GetDialog 0
Start_B2=result
pp_GetDialog 1
End_B2=result
END
END
ELSE DO
pp_DialogInit 150 55 "*GLOBAL.BRIGHTNESS*" 1
pp_Integer 0 75 5 50 16 "Brightness" 1 Start_B2
pp_Dialog
rc=result
IF rc=1 then DO
pp_GetDialog 0
Start_B2=result
End_B2=result
END
END
END
END
if R=0 then DO
EXIT
END
if End_Frame<2 then do
if Anim=1 then DO
pp_Warn 'Make*an*Anim*first.'
EXIT
end
end
ADDRESS COMMAND
file='ram:t/pp_lens'
IF EXISTS(file) THEN DO
'delete >nil: ram:t/pp_lens'
END
IF OPEN('c',file,'W') then DO
CALL WRITELN('c',Anim)
CALL WRITELN('c',Path)
CALL WRITELN('c',Type)
CALL WRITELN('c',Light)
CALL WRITELN('c',Start_B1)
CALL WRITELN('c',End_B1)
CALL WRITELN('c',Start_B2)
CALL WRITELN('c',End_B2)
CALL WRITELN('c',Arti)
CALL WRITELN('c',Glob)
CALL CLOSE('c')
END
ADDRESS value Port
pp_AliasOn
pp_PenType 0
pp_ComposeReqOff
pp_ClosestColor 0 0 0
color=result
pp_SetBpen color
pp_ClosestColor 255 255 255
color=result
pp_SetApen color
pp_Compose 0 100 0
IF Anim=0 THEN DO
pp_SpareOnOff
pp_Cls
r=Start_S
totalR=r*2
RayShade=100-Start_B1
if Light=0 then CALL DrawRays()
if Light=1 then CALL DrawGlow()
if Light=2 then CALL DrawStar()
pp_SpareOnOff
pp_UpdateUndo
pp_EffectOn
pp_Compose 1 100 0
pp_Gradient 0 2 x1 y1
pp_ClearRange 0
pp_setRange 0 4 0 0 0
if Glob=0 then pp_setRange 0 16 Start_B2 0 0
if Glob=1 then pp_setRange 0 16 0 0 Start_B2
if Glob=2 then pp_setRange 0 16 Start_B2 Start_B2 0
if Glob=3 then pp_setRange 0 16 Start_B2 Start_B2 Start_B2
pp_setRange 0 19 Start_B2 Start_B2 Start_B2
pp_CircleF x1 y1 TotalR
pp_Spare
pp_Compose 1 100 0
pp_BoxF x1-totalR-2 y1-totalR-2 x1+totalR+2 y1+totalR+2
if Arti>0 then CALL DrawArtefacts()
END
ELSE DO
pp_GetWidth
W=result
pp_GetHeight
H=result
HX=r2
HY=r2
Start_X=x1
End_X=x1
Start_Y=y1
End_Y=y1
IF Path=1 then DO
IF Type=0 then DO
Start_X=HX*-1
END
ELSE DO
End_X=HX*-1
END
END
IF Path=2 then DO
IF Type=0 then DO
Start_X=W+HX
END
ELSE DO
End_X=W+HX
END
END
IF Path=3 then DO
IF Type=0 then DO
Start_Y=HY*-1
END
ELSE DO
End_Y=HY*-1
END
END
IF Path=4 then DO
IF Type=0 then DO
Start_Y=H+HY
END
ELSE DO
End_Y=H+HY
END
END
step=(End_Frame-Start_Frame)
Step_B1=(End_B1-Start_B1)/Step
Step_B2=(End_B2-Start_B2)/Step
Step_S=(End_S-Start_S)/Step
Step_X=(End_X-Start_X)/Step
Step_Y=(End_Y-Start_Y)/Step
DO i=Start_Frame to End_Frame
pp_GotoFrame i
r=trunc(Start_S+Step_S*(i-Start_Frame)+0.5,0)
RayShade=100-trunc(Start_B1+Step_B1*(i-Start_Frame)+0.5,0)
B2=trunc(Start_B2+Step_B2*(i-Start_Frame)+0.5,0)
x1=trunc(Start_X+Step_X*(i-Start_Frame)+0.5,0)
y1=trunc(Start_Y+Step_Y*(i-Start_Frame)+0.5,0)
pp_SpareOnOff
pp_Cls
totalR=r*2
if Light=0 then CALL DrawRays()
if Light=1 then CALL DrawGlow()
if Light=2 then CALL DrawStar()
pp_SpareOnOff
pp_EffectOn
pp_Compose 1 100 0
pp_Gradient 0 2 x1 y1
pp_ClearRange 0
pp_setRange 0 4 0 0 0
if Glob=0 then pp_setRange 0 16 B2 0 0
if Glob=1 then pp_setRange 0 16 0 0 B2
if Glob=2 then pp_setRange 0 16 B2 B2 0
if Glob=3 then pp_setRange 0 16 B2 B2 B2
pp_setRange 0 19 B2 B2 B2
pp_CircleF x1 y1 TotalR
pp_Spare
pp_Compose 1 100 0
pp_BoxF x1-totalR-2 y1-totalR-2 x1+totalR+2 y1+totalR+2
if Arti>0 then CALL DrawArtefacts()
END
pp_GotoFrame Start_Frame
END
EXIT
/*********************************************************/
/* Draw Star */
/*********************************************************/
DrawStar: PROCEDURE EXPOSE x1 y1 r Pi totalR NbStar RayShade
pp_Compose 0 100 0
pp_EffectOff
r2=4
a=360/NbStar
a2=a/2
DO i=0 To 359 by a
r3=r
x = Sin(i*Pi)*r3+x1
y = Cos(i*Pi)*r3+y1
ii=i+a2
x2 = Sin(ii*Pi)*r2+x1
y2 = Cos(ii*Pi)*r2+y1
ii=i-a2
x3 = Sin(ii*Pi)*r2+x1
y3 = Cos(ii*Pi)*r2+y1
pp_StartPoly
pp_AddPoly trunc(x3+0.5) trunc(y3+0.5)
pp_AddPoly trunc(x2+0.5) trunc(y2+0.5)
pp_AddPoly trunc(x+0.5) trunc(y+0.5)
pp_EndPolyF
END
pp_EffectOn
rr=trunc(r/6)
if rr<3 then rr=3
pp_Airbrush 100 rr
pp_CircleF x1 y1 rr
pp_EffectOn
pp_ConvInit 1 25 0
pp_Conv 0 1 1 1 1 1
pp_Conv 1 1 1 1 1 1
pp_Conv 2 1 1 1 1 1
pp_Conv 3 1 1 1 1 1
pp_Conv 4 1 1 1 1 1
/*
pp_ConvInit 1 159 0
pp_Conv 0 2 4 5 4 2
pp_Conv 1 4 9 12 9 4
pp_Conv 2 5 12 15 12 5
pp_Conv 3 4 9 12 9 4
pp_Conv 4 2 4 5 4 2
*/
pp_BoxF x1-r-2 y1-r-2 x1+r+2 y1+r+2
pp_BoxF x1-r-2 y1-r-2 x1+r+2 y1+r+2
if RayShade >0 then DO
pp_Shade RayShade
pp_BoxF x1-r-2 y1-r-2 x1+r+2 y1+r+2
END
RETURN
/*********************************************************/
/* Draw Glow */
/*********************************************************/
DrawGlow: PROCEDURE EXPOSE x1 y1 r Pi totalR RayShade
pp_EffectOn
AB=r*0.5
if AB>20 then AB=20
if AB<2 then AB=2
pp_AirBrush 100 trunc(AB)
pp_CircleF x1 y1 r/2.5
if RayShade >0 then DO
pp_Shade RayShade
pp_BoxF x1-totalR-2 y1-totalR-2 x1+totalR+2 y1+totalR+2
END
RETURN
/*********************************************************/
/* Draw Ray */
/*********************************************************/
DrawRays: PROCEDURE EXPOSE x1 y1 r Pi totalR RayShade
RN=abs(x1*y1)+totalR*RayShade
pp_Compose 0 100 0
pp_EffectOff
aa=random(100,200,RN)
DO j=1 to 5
aa=aa/2
a=360/aa
a2=a/2
DO i=aa To 359+aa by a
r3=totalR
x = Sin(i*Pi)*r3+x1
y = Cos(i*Pi)*r3+y1
pp_line x1 y1 x y
END
pp_EffectOn
pp_ConvInit 0 9 0
pp_Conv 0 1 1 1 1 1
pp_Conv 1 1 1 1 1 1
pp_Conv 2 1 1 1 1 1
pp_Conv 3 1 1 1 1 1
pp_Conv 4 1 1 1 1 1
pp_BoxF x1-totalR-2 y1-totalR-2 x1+totalR+2 y1+totalR+2
pp_EffectOff
END
pp_EffectOn
pp_Gradient 0 2 x1 y1
pp_ClearRange 0
pp_setRange 0 10 0 0 0
pp_setRange 0 16 255 255 255
pp_setRange 0 19 255 255 255
pp_Compose 4 100 0
pp_BoxF x1-totalR-2 y1-totalR-2 x1+totalR+2 y1+totalR+2
if RayShade >0 then DO
pp_Shade RayShade
pp_BoxF x1-totalR-2 y1-totalR-2 x1+totalR+2 y1+totalR+2
END
pp_EffectOff
RETURN
/*********************************************************/
/* Draw Rings */
/*********************************************************/
DrawRings: PROCEDURE EXPOSE x1 y1 r
pp_EffectOn
pp_Compose 1 100 0
pp_Gradient 0 2 x1 y1
pp_ClearRange 0
pp_setRange 0 0 0 0 0
pp_setRange 0 5 0 0 0
pp_setRange 0 6 48 0 0
pp_setRange 0 7 0 0 0
pp_setRange 0 13 48 0 0
pp_setRange 0 19 0 0 0
pp_CircleF x1 y1 r
RETURN
/*********************************************************/
/* Draw artifact */
/*********************************************************/
DrawArtefacts: PROCEDURE EXPOSE x1 y1 r totalR Arti
pp_GetWidth
cx=trunc(result/2)
pp_GetHeight
cy=trunc(result/2)
if Arti=1 then do
Nb_Spot=15
t.1=1;s.1=25;d.1=123;c.1=15;r.1=255;g.1=255;b.1=255
t.2=3;s.2=60;d.2=100;c.2=15;r.2=255;g.2=20;b.2=0
t.3=1;s.3=13;d.3=58;c.3=10;r.3=160;g.3=160;b.3=255
t.4=2;s.4=33;d.4=54;c.4=5;r.4=160;g.4=160;b.4=255
t.5=2;s.5=16;d.5=50;c.5=10;r.5=160;g.5=160;b.5=255
t.6=2;s.6=10;d.6=30;c.6=20;r.6=255;g.6=160;b.6=25
t.7=4;s.7=4;d.7=18;c.7=50;r.7=255;g.7=255;b.7=255
t.8=4;s.8=6;d.8=-4;c.8=50;r.8=255;g.8=255;b.8=255
t.9=1;s.9=23;d.9=-15;c.9=12;r.9=255;g.9=160;b.9=25
t.10=1;s.10=44;d.10=-18;c.10=12;r.10=255;g.10=160;b.10=25
t.11=1;s.11=10;d.11=-21;c.11=12;r.11=255;g.11=160;b.11=25
t.12=1;s.12=15;d.12=-36;c.12=15;r.12=145;g.12=255;b.12=145
t.13=2;s.13=8;d.13=-40;c.13=20;r.13=100;g.13=120;b.13=255
t.14=3;s.14=63;d.14=-67;c.14=12;r.14=145;g.14=255;b.14=145
t.15=5;s.15=133;d.15=-100;c.15=10;r.15=255;g.15=255;b.15=255
end
if Arti=2 then do
Nb_Spot=25
t.1=1;s.1=21;d.1=86;c.1=16;r.1=210;g.1=250;b.1=255
t.2=4;s.2=18;d.2=77;c.2=20;r.2=60;g.2=50;b.2=230
t.3=1;s.3=16;d.3=69;c.3=25;r.3=220;g.3=220;b.3=235
t.4=4;s.4=18;d.4=61;c.4=12;r.4=220;g.4=245;b.4=245
t.5=1;s.5=17;d.5=51;c.5=18;r.5=50;g.5=80;b.5=250
t.6=1;s.6=18;d.6=42;c.6=26;r.6=225;g.6=210;b.6=250
t.7=4;s.7=16;d.7=33;c.7=18;r.7=55;g.7=55;b.7=245
t.8=1;s.8=12;d.8=23;c.8=21;r.8=60;g.8=50;b.8=255
t.9=1;s.9=9;d.9=15;c.9=30;r.9=210;g.9=227;b.9=250
t.10=4;s.10=6;d.10=7;c.10=18;r.10=55;g.10=55;b.10=255
t.11=4;s.11=7;d.11=1;c.11=23;r.11=250;g.11=225;b.11=255
t.12=1;s.12=5;d.12=-9;c.12=14;r.12=60;g.12=50;b.12=255
t.13=1;s.13=6;d.13=-17;c.13=21;r.13=50;g.13=50;b.13=235
t.14=1;s.14=9;d.14=-27;c.14=24;r.14=210;g.14=230;b.14=250
t.15=4;s.15=11;d.15=-32;c.15=23;r.15=225;g.15=225;b.15=255
t.16=1;s.16=16;d.16=-41;c.16=13;r.16=60;g.16=50;b.16=245
t.17=4;s.17=17;d.17=-53;c.17=21;r.17=80;g.17=50;b.17=230
t.18=4;s.18=15;d.18=-60;c.18=25;r.18=215;g.18=210;b.18=235
t.19=1;s.19=19;d.19=-71;c.19=15;r.19=60;g.19=55;b.19=225
t.20=1;s.20=19;d.20=-84;c.20=19;r.20=240;g.20=240;b.20=245
t.21=4;s.21=19;d.21=-92;c.21=22;r.21=90;g.21=55;b.21=225
t.22=1;s.22=27;d.22=-103;c.22=20;r.22=60;g.22=60;b.22=255
t.23=4;s.23=30;d.23=-115;c.23=16;r.23=210;g.23=225;b.23=255
t.24=1;s.24=26;d.24=-123;c.24=21;r.24=55;g.24=55;b.24=245
t.25=1;s.25=34;d.25=-135;c.25=23;r.25=50;g.25=50;b.25=255
end
if Arti=3 then do
Nb_Spot=25
t.1=1;s.1=21;d.1=86;c.1=16;r.1=210;g.1=250;b.1=255
t.2=4;s.2=18;d.2=77;c.2=20;r.2=60;g.2=150;b.2=230
t.3=1;s.3=16;d.3=69;c.3=25;r.3=220;g.3=220;b.3=235
t.4=4;s.4=18;d.4=61;c.4=12;r.4=220;g.4=245;b.4=245
t.5=1;s.5=17;d.5=51;c.5=18;r.5=50;g.5=180;b.5=250
t.6=1;s.6=18;d.6=42;c.6=26;r.6=225;g.6=210;b.6=250
t.7=4;s.7=16;d.7=33;c.7=18;r.7=55;g.7=155;b.7=245
t.8=1;s.8=12;d.8=23;c.8=21;r.8=50;g.8=250;b.8=255
t.9=1;s.9=9;d.9=15;c.9=30;r.9=210;g.9=227;b.9=250
t.10=4;s.10=6;d.10=7;c.10=18;r.10=55;g.10=155;b.10=255
t.11=4;s.11=7;d.11=1;c.11=23;r.11=250;g.11=225;b.11=255
t.12=1;s.12=5;d.12=-9;c.12=14;r.12=60;g.12=150;b.12=255
t.13=1;s.13=6;d.13=-17;c.13=21;r.13=150;g.13=150;b.13=235
t.14=2;s.14=9;d.14=-27;c.14=24;r.14=210;g.14=230;b.14=250
t.15=4;s.15=11;d.15=-32;c.15=23;r.15=225;g.15=225;b.15=255
t.16=1;s.16=16;d.16=-41;c.16=13;r.16=60;g.16=150;b.16=245
t.17=4;s.17=17;d.17=-53;c.17=21;r.17=80;g.17=150;b.17=230
t.18=4;s.18=15;d.18=-60;c.18=25;r.18=215;g.18=210;b.18=235
t.19=1;s.19=19;d.19=-71;c.19=15;r.19=60;g.19=155;b.19=225
t.20=1;s.20=19;d.20=-84;c.20=19;r.20=240;g.20=240;b.20=245
t.21=4;s.21=19;d.21=-92;c.21=22;r.21=90;g.21=155;b.21=225
t.22=1;s.22=27;d.22=-103;c.22=20;r.22=60;g.22=160;b.22=255
t.23=4;s.23=30;d.23=-115;c.23=16;r.23=210;g.23=225;b.23=255
t.24=1;s.24=26;d.24=-123;c.24=21;r.24=255;g.24=255;b.24=255
t.25=1;s.25=34;d.25=-135;c.25=23;r.25=50;g.25=150;b.25=255
end
pp_Compose 1 100 0
DO i=1 TO Nb_Spot
spot_size = trunc((r*s.i)/100)
spot_x = ((x1 - cx) * d.i)/100 + cx
spot_y = ((y1 - cy) * d.i)/100 + cy
spot_r = ((r.i*c.i)/100)
spot_g = ((g.i*c.i)/100)
spot_b = ((b.i*c.i)/100)
pp_Gradient 0 2 spot_x spot_y
pp_ClearRange 0
SELECT
WHEN t.i=1 then DO
pp_setRange 0 0 0 0 0
pp_setRange 0 5 0 0 0
pp_setRange 0 7 spot_r spot_g spot_b
pp_setRange 0 15 0 0 0
pp_setRange 0 19 0 0 0
END
WHEN t.i=2 then DO
pp_setRange 0 5 0 0 0
pp_setRange 0 7 spot_r spot_g spot_b
pp_setRange 0 19 spot_r spot_g spot_b
END
WHEN t.i=3 then DO
pp_setRange 0 5 0 0 0
pp_setRange 0 6 spot_r spot_g spot_b
pp_setRange 0 8 0 0 0
END
WHEN t.i=4 then DO
pp_setRange 0 5 0 0 0
pp_setRange 0 16 spot_r spot_g spot_b
pp_setRange 0 19 spot_r spot_g spot_b
END
WHEN t.i=5 then DO
spot_r = ((255*c.i)/100)
pp_setRange 0 5 0 0 0
pp_setRange 0 6 spot_r 0 0
pp_setRange 0 7 0 spot_r 0
pp_setRange 0 8 0 0 spot_r
pp_setRange 0 9 0 0 0
END
END
pp_CircleF spot_x spot_y spot_size
END
RETURN