X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fswfc.c;h=23f632fd69796f04873b951a17915ba450d45ee5;hb=e972043c5171f8ecf7b78cfd4d0e127fb6b77c77;hp=c0e8ec153478d297d138ff0cd555366739939158;hpb=73168a7f7ca3a242980071be43b5454456374aae;p=swftools.git diff --git a/src/swfc.c b/src/swfc.c index c0e8ec1..23f632f 100644 --- a/src/swfc.c +++ b/src/swfc.c @@ -28,6 +28,7 @@ static char * filename = 0; static char * outputname = "output.swf"; static int verbose = 2; +static int override_outputname = 0; static struct options_t options[] = { @@ -45,6 +46,7 @@ int args_callback_option(char*name,char*val) } else if(!strcmp(name, "o")) { outputname = val; + override_outputname = 1; return 1; } else if(!strcmp(name, "v")) { @@ -181,6 +183,7 @@ typedef struct _parameters { float scalex, scaley; CXFORM cxform; float rotate; + float shear; SPOINT pivot; SPOINT pin; } parameters_t; @@ -262,12 +265,13 @@ static instance_t* s_addinstance(char*name, character_t*c, U16 depth) return i; } -static void parameters_set(parameters_t*p, int x,int y, float scalex, float scaley, float rotate, SPOINT pivot, SPOINT pin, CXFORM cxform) +static void parameters_set(parameters_t*p, int x,int y, float scalex, float scaley, float rotate, float shear, SPOINT pivot, SPOINT pin, CXFORM cxform) { p->x = x; p->y = y; p->scalex = scalex; p->scaley = scaley; p->pin = pin; p->pivot = pivot; p->rotate = rotate; p->cxform = cxform; + p->shear = shear; } static void parameters_clear(parameters_t*p) @@ -277,16 +281,29 @@ static void parameters_clear(parameters_t*p) p->pin.x = 1; p->pin.y = 0; p->pivot.x = 0; p->pivot.y = 0; p->rotate = 0; + p->shear = 0; swf_GetCXForm(0, &p->cxform, 1); } static void makeMatrix(MATRIX*m, parameters_t*p) { SPOINT h; - m->sx = p->scalex*cos(p->rotate/360*2*3.14159265358979)*65535; - m->r1 = -p->scalex*sin(p->rotate/360*2*3.14159265358979)*65535; - m->r0 = p->scaley*sin(p->rotate/360*2*3.14159265358979)*65535; - m->sy = p->scaley*cos(p->rotate/360*2*3.14159265358979)*65535; + float sx,r1,r0,sy; + + /* /sx r1\ /x\ + * \r0 sy/ \y/ + */ + + sx = p->scalex*cos(p->rotate/360*2*3.14159265358979); + r1 = -p->scalex*sin(p->rotate/360*2*3.14159265358979)+sx*p->shear; + r0 = p->scaley*sin(p->rotate/360*2*3.14159265358979); + sy = p->scaley*cos(p->rotate/360*2*3.14159265358979)+r0*p->shear; + + m->sx = (int)(sx*65536+0.5); + m->r1 = (int)(r1*65536+0.5); + m->r0 = (int)(r0*65536+0.5); + m->sy = (int)(sy*65536+0.5); + m->tx = m->ty = 0; h = swf_TurnPoint(p->pin, m); @@ -807,6 +824,7 @@ parameters_t s_interpolate(parameters_t*p1, parameters_t*p2, int pos, int num) p.scalex = (p2->scalex-p1->scalex)*ratio + p1->scalex; p.scaley = (p2->scaley-p1->scaley)*ratio + p1->scaley; p.rotate = (p2->rotate-p1->rotate)*ratio + p1->rotate; + p.shear = (p2->shear-p1->shear)*ratio + p1->shear; p.cxform.r0 = ((float)p2->cxform.r0-(float)p1->cxform.r0)*ratio + p1->cxform.r0; p.cxform.g0 = ((float)p2->cxform.g0-(float)p1->cxform.g0)*ratio + p1->cxform.g0; @@ -1025,7 +1043,7 @@ int parseColor2(char*str, RGBA*color) int r,g,b,a; int t; char*names[8] = {"black", "blue", "green", "cyan", - "red", "violet", "yellow", "white"}; + "red", "magenta", "yellow", "white"}; a=255; r=g=b=0; if(str[0]=='#' && (l==7 || l==9)) { @@ -1152,7 +1170,7 @@ static int c_swf(map_t*args) int version = parseInt(lu(args, "version")); int fps = (int)(parseFloat(lu(args, "fps"))*256); int compress = 0; - if(!strcmp(name, "!default!")) + if(!strcmp(name, "!default!") || override_outputname) name = outputname; if(!strcmp(compressstr, "default")) @@ -1239,6 +1257,7 @@ static int c_placement(map_t*args, int type) char* scalexstr = lu(args, "scalex"); char* scaleystr = lu(args, "scaley"); char* rotatestr = lu(args, "rotate"); + char* shearstr = lu(args, "shear"); char* xstr="", *pivotstr=""; char* ystr="", *anglestr=""; char*above = lu(args, "above"); /*FIXME*/ @@ -1335,6 +1354,15 @@ static int c_placement(map_t*args, int type) } } + /* shearing */ + if(shearstr[0]) { + if(isRelative(shearstr)) { + p.shear += parseFloat(getOffset(shearstr))*getSign(shearstr); + } else { + p.shear = parseFloat(shearstr); + } + } + if(pivotstr[0]) { if(isPoint(pivotstr)) p.pivot = parsePoint(pivotstr); @@ -1601,16 +1629,16 @@ static struct { {"stop", c_stop, "sound"}, // object placement tags - {"put", c_put, " x=0 y=0 red=+0 green=+0 blue=+0 alpha=+0 luminance= scale= scalex= scaley= pivot= pin= rotate= above= below="}, - {"startclip", c_startclip, " x=0 y=0 red=+0 green=+0 blue=+0 alpha=+0 luminance= scale= scalex= scaley= pivot= pin= rotate= above= below="}, - {"change", c_change, "name x= y= red= green= blue= alpha= luminance= scale= scalex= scaley= pivot= pin= rotate= above= below="}, - {"arcchange", c_arcchange, "name pivot= angle= red= green= blue= alpha= luminance= scale= scalex= scaley= pivot= pin= rotate= above= below="}, - {"qchange", c_qchange, "name x= y= red= green= blue= alpha= luminance= scale= scalex= scaley= pivot= pin= rotate= above= below="}, - {"jump", c_jump, "name x= y= red= green= blue= alpha= luminance= scale= scalex= scaley= pivot= pin= rotate= above= below="}, + {"put", c_put, " x=0 y=0 red=+0 green=+0 blue=+0 alpha=+0 luminance= scale= scalex= scaley= pivot= pin= shear= rotate= above= below="}, + {"startclip", c_startclip, " x=0 y=0 red=+0 green=+0 blue=+0 alpha=+0 luminance= scale= scalex= scaley= pivot= pin= shear= rotate= above= below="}, + {"change", c_change, "name x= y= red= green= blue= alpha= luminance= scale= scalex= scaley= pivot= pin= shear= rotate= above= below="}, + {"arcchange", c_arcchange, "name pivot= angle= red= green= blue= alpha= luminance= scale= scalex= scaley= pivot= pin= shear= rotate= above= below="}, + {"qchange", c_qchange, "name x= y= red= green= blue= alpha= luminance= scale= scalex= scaley= pivot= pin= shear= rotate= above= below="}, + {"jump", c_jump, "name x= y= red= green= blue= alpha= luminance= scale= scalex= scaley= pivot= pin= shear= rotate= above= below="}, {"del", c_del, "name"}, // virtual object placement - {"buttonput", c_buttonput, " x=0 y=0 red=+0 green=+0 blue=+0 alpha=+0 luminance= scale= scalex=100% scaley=100% rotate=0 above= below="}, - {"texture", c_texture, " x=0 y=0 scale= scalex=100% scaley=100% rotate=0"}, + {"buttonput", c_buttonput, " x=0 y=0 red=+0 green=+0 blue=+0 alpha=+0 luminance= scale= scalex=100% scaley=100% shear=0 rotate=0 above= below="}, + {"texture", c_texture, " x=0 y=0 scale= scalex=100% scaley=100% shear=0 rotate=0"}, {"point", c_point, "name x=0 y=0"}, // commands which start a block