This is the initial commit of a revamp of the sweep effects that goofster committed that was originally a sequence plugin from sirdude.

The changes from the original include the ability to add a blurred edge with a selectable width to the wipe and to rotate the effect.

Has these sweep types included already
-single
-double
-iris

These still need to be coded
-box
-cross
-clock
This commit is contained in:
2004-07-06 19:07:13 +00:00
parent 5b09bb1eb1
commit 9c94728d89
4 changed files with 218 additions and 138 deletions

View File

@@ -96,15 +96,10 @@ void do_mul_effect(float facf0, float facf1,
unsigned int *rect1, unsigned int *rect2, unsigned int *rect1, unsigned int *rect2,
unsigned int *out); unsigned int *out);
/* Sweep effect */ /* Sweep effect */
enum {DO_LEFT_RIGHT, DO_RIGHT_LEFT, DO_DOWN_UP, DO_UP_DOWN, enum {DO_SINGLE_WIPE, DO_DOUBLE_WIPE, DO_BOX_WIPE, DO_CROSS_WIPE,
DO_LOWER_LEFT_UPPER_RIGHT, DO_UPPER_RIGHT_LOWER_LEFT, DO_IRIS_WIPE};
DO_UPPER_LEFT_LOWER_RIGHT, DO_LOWER_RIGHT_UPPER_LEFT, float in_band(float width,float dist, float perc,int side,int dir);
DO_HORZ_OUT, DO_HORZ_IN, DO_VERT_OUT, DO_VERT_IN, float check_zone(int x, int y, int xo, int yo, struct Sequence *seq, float facf0);
DO_HORZ_VERT_OUT, DO_HORZ_VERT_IN, DO_LEFT_DOWN_RIGHT_UP_OUT,
DO_LEFT_DOWN_RIGHT_UP_IN, DO_LEFT_UP_RIGHT_DOWN_OUT,
DO_LEFT_UP_RIGHT_DOWN_IN, DO_DIAG_OUT, DO_DIAG_IN, DO_DIAG_OUT_2,
DO_DIAG_IN_2};
int check_zone(int x, int y, int xo, int yo, struct Sequence *seq, float facf0);
void init_sweep_effect(struct Sequence *seq); void init_sweep_effect(struct Sequence *seq);
void do_sweep_effect(struct Sequence *seq, float facf0, float facf1, int x, int y, unsigned int *rect1, unsigned int *rect2, unsigned int *out); void do_sweep_effect(struct Sequence *seq, float facf0, float facf1, int x, int y, unsigned int *rect1, unsigned int *rect2, unsigned int *out);

View File

@@ -140,6 +140,10 @@ typedef struct Editing {
/* ************* Effect Variable Structs ********* */ /* ************* Effect Variable Structs ********* */
typedef struct SweepVars { typedef struct SweepVars {
float edgeWidth,angle;
short forward,spad1,spad2,spad3;
int ipad1;
float fpad1,fpad2;
short sweeptype; short sweeptype;
} SweepVars; } SweepVars;

View File

@@ -713,10 +713,12 @@ static void seq_panel_properties(short cntrl) // SEQ_HANDLER_PROPERTIES
if(last_seq->type==SEQ_SWEEP){ if(last_seq->type==SEQ_SWEEP){
SweepVars *sweep = (SweepVars *)last_seq->effectdata; SweepVars *sweep = (SweepVars *)last_seq->effectdata;
char formatstring[1024]; char formatstring[1024];
strcpy(formatstring, "Select Sweep Type %t|Single Wipe%x0|Double Wipe %x1|Iris Wipe %x4");
strcpy(formatstring, "Select Sweep Type %t|Left to Right %x0|Right to Left %x1|Bottom to Top %x2|Top to Bottom %x3|Top left to Bottom right%x4|Bottom right to Top left %x5|Bottom left to Top right %x6|Top right to Bottom left %x7|Horizontal out %x8|Horizontal in %x9|Vertical out %x10|Vertical in %x11|Hor/Vert out %x12|Hor/Vert in %x13|Bottom left to Top right out %x14|Top left to Bottom right in %x15|Top left to Bottom right out %x16|Bottom left to Top right in %x17|Diagonal out %x18|Diagonal in %x19|Diagonal out 2 %x20|Diagonal in 2 %x21|");
uiDefButS(block, MENU,SEQ_BUT_EFFECT, formatstring, 10,90,220,22, &sweep->sweeptype, 0, 0, 0, 0, "What type of sweep should be performed"); uiDefButS(block, MENU,SEQ_BUT_EFFECT, formatstring, 10,90,220,22, &sweep->sweeptype, 0, 0, 0, 0, "What type of sweep should be performed");
uiDefButF(block, NUM,SEQ_BUT_EFFECT,"Blur:", 10,65,220,22, &sweep->edgeWidth,0.0,1.0, 1, 2, "The percent width of the blur edge");
if(sweep->sweeptype != DO_IRIS_WIPE)
uiDefButF(block, NUM,SEQ_BUT_EFFECT,"Angle:", 10,40,220,22, &sweep->angle,-90.0,90.0, 1, 2, "The Angle of the Edge");
uiDefButS(block, TOG,SEQ_BUT_EFFECT,"Wipe In", 10,15,220,22, &sweep->forward,0,0, 0, 0, "Controls Primary Direction of Sweep");
} }
else if(last_seq->type==SEQ_GLOW){ else if(last_seq->type==SEQ_GLOW){
GlowVars *glow = (GlowVars *)last_seq->effectdata; GlowVars *glow = (GlowVars *)last_seq->effectdata;

View File

@@ -956,136 +956,215 @@ void do_mul_effect(float facf0, float facf1, int x, int y, unsigned int *rect1,
} }
} }
// This function calculates the blur band for the wipe effects
float in_band(float width,float dist, float perc,int side,int dir){
float t1,t2,alpha,percwidth;
if(width == 0)
return (float)side;
if(side == 1)
percwidth = width * perc;
else
percwidth = width * (1 - perc);
int check_zone(int x, int y, int xo, int yo, Sequence *seq, float facf0) { if(width < dist)
return side;
float posx, posy; t1 = dist / width; //percentange of width that is
t2 = 1 / width; //amount of alpha per % point
if(side == 1)
alpha = (t1*t2*100) + (1-perc); // add point's alpha contrib to current position in wipe
else
alpha = (1-perc) - (t1*t2*100);
if(dir == 0)
alpha = 1-alpha;
return alpha;
}
float check_zone(int x, int y, int xo, int yo, Sequence *seq, float facf0) {
float posx, posy,hyp,hyp2,angle,hwidth,b1,b2,b3,pointdist;
/*some future stuff
float hyp3,hyp4,b4,b5
*/
float temp1,temp2; //some placeholder variables
float halfx = xo/2; float halfx = xo/2;
float halfy = yo/2; float halfy = yo/2;
float output=0;
SweepVars *sweep = (SweepVars *)seq->effectdata; SweepVars *sweep = (SweepVars *)seq->effectdata;
int width,invert = 0;
//printf("facf0: %f xo: %d\n", facf0, x); angle = sweep->angle;
if(angle < 0){
x = xo-x;
//y = yo-y
}
angle = pow(fabs(angle)/45,log(xo,2));
posy = facf0 * yo;
if(sweep->forward){
posx = facf0 * xo; posx = facf0 * xo;
posy = facf0 * yo; posy = facf0 * yo;
} else{
posx = xo - facf0 * xo;
posy = yo - facf0 * yo;
}
switch (sweep->sweeptype) { switch (sweep->sweeptype) {
case DO_LEFT_RIGHT: case DO_SINGLE_WIPE:
if (x > posx) return 1; width = (int)(sweep->edgeWidth*((xo+yo)/2.0));
return 0; hwidth = (float)width/2.0;
if (angle == 0.0)angle = 0.000001;
b1 = posy - (-angle)*posx;
b2 = y - (-angle)*x;
hyp = abs(angle*x+y+(-posy-angle*posx))/sqrt(angle*angle+1);
if(angle < 0){
temp1 = b1;
b1 = b2;
b2 = temp1;
}
if(sweep->forward){
if(b1 < b2)
output = in_band(width,hyp,facf0,1,1);
else
output = in_band(width,hyp,facf0,0,1);
}
else{
if(b1 < b2)
output = in_band(width,hyp,facf0,0,1);
else
output = in_band(width,hyp,facf0,1,1);
}
break; break;
case DO_RIGHT_LEFT:
if (x < (xo - posx)) return 1;
return 0; case DO_DOUBLE_WIPE:
if(!sweep->forward)facf0 = 1-facf0; // Go the other direction
width = (int)(sweep->edgeWidth*((xo+yo)/2.0)); // calculate the blur width
hwidth = (float)width/2.0;
if (angle == 0)angle = 0.000001;
b1 = posy/2 - (-angle)*posx/2;
b3 = (yo-posy/2) - (-angle)*(xo-posx/2);
b2 = y - (-angle)*x;
hyp = abs(angle*x+y+(-posy/2-angle*posx/2))/sqrt(angle*angle+1);
hyp2 = abs(angle*x+y+(-(yo-posy/2)-angle*(xo-posx/2)))/sqrt(angle*angle+1);
temp1 = xo*(1-facf0/2)-xo*facf0/2;
temp2 = yo*(1-facf0/2)-yo*facf0/2;
pointdist = sqrt(temp1*temp1 + temp2*temp2);
if(b2 < b1 && b2 < b3 ){
if(hwidth < pointdist)
output = in_band(hwidth,hyp,facf0,0,1);
}
else if(b2 > b1 && b2 > b3 ){
if(hwidth < pointdist)
output = in_band(hwidth,hyp2,facf0,0,1);
}
else{
if( hyp < hwidth && hyp2 > hwidth )
output = in_band(hwidth,hyp,facf0,1,1);
else if( hyp > hwidth && hyp2 < hwidth )
output = in_band(hwidth,hyp2,facf0,1,1);
else
output = in_band(hwidth,hyp2,facf0,1,1) * in_band(hwidth,hyp,facf0,1,1);
}
if(!sweep->forward)output = 1-output;
break; break;
case DO_DOWN_UP: /* BOX WIPE IS NOT WORKING YET */
if (y > posy ) return 1; /* case DO_CROSS_WIPE: */
return 0; /* BOX WIPE IS NOT WORKING YET */
break; /* case DO_BOX_WIPE:
case DO_UP_DOWN: if(invert)facf0 = 1-facf0;
if (y < (yo - posy)) return 1;
return 0; width = (int)(sweep->edgeWidth*((xo+yo)/2.0));
break; hwidth = (float)width/2.0;
case DO_LOWER_LEFT_UPPER_RIGHT: if (angle == 0)angle = 0.000001;
if (posy < posx) posx = posy; b1 = posy/2 - (-angle)*posx/2;
if ((x + yo - y) < posx*2) return 0; b3 = (yo-posy/2) - (-angle)*(xo-posx/2);
return 1; b2 = y - (-angle)*x;
break;
case DO_UPPER_RIGHT_LOWER_LEFT: hyp = abs(angle*x+y+(-posy/2-angle*posx/2))/sqrt(angle*angle+1);
if (posy < posx) posx = posy; hyp2 = abs(angle*x+y+(-(yo-posy/2)-angle*(xo-posx/2)))/sqrt(angle*angle+1);
if ((xo - x + y) < posx*2) return 0;
return 1; temp1 = xo*(1-facf0/2)-xo*facf0/2;
break; temp2 = yo*(1-facf0/2)-yo*facf0/2;
case DO_UPPER_LEFT_LOWER_RIGHT: pointdist = sqrt(temp1*temp1 + temp2*temp2);
if (posy < posx) posx = posy;
if ((x + y) < posx*2 ) return 0; if(b2 < b1 && b2 < b3 ){
return 1; if(hwidth < pointdist)
break; output = in_band(hwidth,hyp,facf0,0,1);
case DO_LOWER_RIGHT_UPPER_LEFT: }
if (posy < posx) posx = posy; else if(b2 > b1 && b2 > b3 ){
if ((xo - x + yo - y) < posx*2) return 0; if(hwidth < pointdist)
return 1; output = in_band(hwidth,hyp2,facf0,0,1);
break; }
case DO_HORZ_OUT: else{
if ((x < (halfx - (posx/2)) ) || (x > (halfx + posx/2) )) return 1; if( hyp < hwidth && hyp2 > hwidth )
return 0; output = in_band(hwidth,hyp,facf0,1,1);
break; else if( hyp > hwidth && hyp2 < hwidth )
case DO_HORZ_IN: output = in_band(hwidth,hyp2,facf0,1,1);
if ((x >posx/2) && (x < (xo - posx/2))) return 1; else
return 0; output = in_band(hwidth,hyp2,facf0,1,1) * in_band(hwidth,hyp,facf0,1,1);
break; }
case DO_VERT_OUT: if(invert)facf0 = 1-facf0;
if ((y < (halfy - posy/2)) || (y > (halfy + posy/2))) return 1; angle = -1/angle;
return 0; b1 = posy/2 - (-angle)*posx/2;
break; b3 = (yo-posy/2) - (-angle)*(xo-posx/2);
case DO_VERT_IN: b2 = y - (-angle)*x;
if ((y >posy/2) && (y < (yo - posy/2))) return 1;
return 0; hyp = abs(angle*x+y+(-posy/2-angle*posx/2))/sqrt(angle*angle+1);
break; hyp2 = abs(angle*x+y+(-(yo-posy/2)-angle*(xo-posx/2)))/sqrt(angle*angle+1);
case DO_HORZ_VERT_OUT:
if (posy < posx) posx = posy; if(b2 < b1 && b2 < b3 ){
if (((x > (halfx - posx/2)) && (x < (halfx + posx/2))) || if(hwidth < pointdist)
((y > (halfy - posx/2)) && (y < (halfy + posx/2)))) return 0; output *= in_band(hwidth,hyp,facf0,0,1);
return 1; }
break; else if(b2 > b1 && b2 > b3 ){
case DO_HORZ_VERT_IN: if(hwidth < pointdist)
if (posy < posx) posx = posy; output *= in_band(hwidth,hyp2,facf0,0,1);
if ((x <posx/2) || ((xo - x) < posx/2) || (y < posx/2) || }
((yo - y) < posx/2)) return 0; else{
return 1; if( hyp < hwidth && hyp2 > hwidth )
break; output *= in_band(hwidth,hyp,facf0,1,1);
case DO_LEFT_DOWN_RIGHT_UP_OUT: else if( hyp > hwidth && hyp2 < hwidth )
if (posy < posx) posx = posy; output *= in_band(hwidth,hyp2,facf0,1,1);
if (((x - halfx + y - halfy) < posx) && else
((halfx -x + halfy -y ) < posx)) return 0; output *= in_band(hwidth,hyp2,facf0,1,1) * in_band(hwidth,hyp,facf0,1,1);
return 1; }
break;
case DO_LEFT_DOWN_RIGHT_UP_IN: break;*/
if (posy < posx) posx = posy; case DO_IRIS_WIPE:
if (((y + xo - x) < posx) || ((yo - y + x) < posx)) return 0; if(xo > yo) yo = xo;
return 1; else xo = yo;
break;
case DO_LEFT_UP_RIGHT_DOWN_OUT: if(!sweep->forward)
if (posy < posx) posx = posy; facf0 = 1-facf0;
if (((x - halfx + yo - y - halfy) < posx) &&
((halfx - x + halfy - yo + y ) < posx)) return 0; width = (int)(sweep->edgeWidth*((xo+yo)/2.0));
return 1; hwidth = (float)width/2.0;
break;
case DO_LEFT_UP_RIGHT_DOWN_IN: temp1 = (halfx-(halfx)*facf0);
if (posy < posx) posx = posy; pointdist = sqrt(temp1*temp1 + temp1*temp1);
if (((x+ y) < posx) || ((xo -x + yo - y) < posx )) return 0;
return 1; temp2 = sqrt((halfx-x)*(halfx-x) + (halfy-y)*(halfy-y));
break; if(temp2 > pointdist)
case DO_DIAG_OUT: output = in_band(hwidth,fabs(temp2-pointdist),facf0,0,1);
if (posy < posx) posx = posy; else
if ((((x - halfx + y - halfy) < posx) && output = in_band(hwidth,fabs(temp2-pointdist),facf0,1,1);
((halfx -x + halfy -y ) < posx)) &&
(((x - halfx + yo - y - halfy) < posx)) && if(!sweep->forward)
((halfx -x + halfy -yo + y) < posx)) return 0; output = 1-output;
return 1;
break;
case DO_DIAG_IN:
if (posy < posx) posx = posy;
if ((x + y) < posx || ((xo -x + yo - y) < posx) ||
((x + yo -y) < posx) || ((y + xo - x) < posx)) return 0;
return 1;
break;
case DO_DIAG_OUT_2:
if (posy < posx) posx = posy;
if ((((x - halfx + y - halfy) < posx/2) &&
((halfx -x + halfy -y ) < posx/2)) ||
((((x - halfx + yo - y - halfy) < posx/2)) &&
((halfx - x + halfy - yo + y) < posx/2))) return 0;
return 1;
break;
case DO_DIAG_IN_2:
if (posy < posx) posx = posy;
if ((((y + xo - x) < posx) || ((yo - y + x) < posx)) &&
(((x+ y) < posx) || ((xo -x + yo - y) < posx ))) return 0;
return 1;
break; break;
} }
return 0; if (output < 0) output = 0;
else if(output > 1) output = 1;
return output;
} }
void init_sweep_effect(Sequence *seq) void init_sweep_effect(Sequence *seq)
@@ -1107,13 +1186,13 @@ void do_sweep_effect(Sequence *seq, float facf0, float facf1, int x, int y, unsi
for(y=0;y<yo;y++) { for(y=0;y<yo;y++) {
for(x=0;x<xo;x++) { for(x=0;x<xo;x++) {
float check = check_zone(x,y,xo,yo,seq,facf0);
if (check_zone(x,y,xo,yo,seq,facf0)) { if (check) {
if (rt1) { if (rt1) {
rt[0] = rt1[0]; rt[0] = (int)(rt1[0]*check)+ (int)(rt2[0]*(1-check));
rt[1] = rt1[1]; rt[1] = (int)(rt1[1]*check)+ (int)(rt2[1]*(1-check));
rt[2] = rt1[2]; rt[2] = (int)(rt1[2]*check)+ (int)(rt2[2]*(1-check));
rt[3] = rt1[3]; rt[3] = (int)(rt1[3]*check)+ (int)(rt2[3]*(1-check));
} else { } else {
rt[0] = 0; rt[0] = 0;
rt[1] = 0; rt[1] = 0;