+ syntaxerror("Invalid point: \"%s\".", name);
+ }
+ return *(SPOINT*)&mpoints.buffer[l-1];
+}
+
+
+static int texture2(char*name, char*object, map_t*args, int errors)
+{
+ SPOINT pos,size;
+ char*xstr = map_lookup(args, "x");
+ char*ystr = map_lookup(args, "y");
+ char*widthstr = map_lookup(args, "width");
+ char*heightstr = map_lookup(args, "height");
+ char*scalestr = map_lookup(args, "scale");
+ char*scalexstr = map_lookup(args, "scalex");
+ char*scaleystr = map_lookup(args, "scaley");
+ char*rotatestr = map_lookup(args, "rotate");
+ char* shearstr = map_lookup(args, "shear");
+ char* radiusstr = map_lookup(args, "r");
+ float x=0,y=0;
+ float scalex = 1.0, scaley = 1.0;
+ float rotate=0, shear=0;
+ float r = 0;
+ if(!*xstr && !*ystr) {
+ if(errors)
+ syntaxerror("x and y must be set");
+ return 0;
+ }
+ if(*scalestr && (*scalexstr || *scaleystr)) {
+ syntaxerror("scale and scalex/scaley can't both be set");
+ return 0;
+ }
+ if((*widthstr || *heightstr) && *radiusstr) {
+ syntaxerror("width/height and radius can't both be set");
+ }
+ if(*radiusstr) {
+ widthstr = radiusstr;
+ heightstr = radiusstr;
+ }
+ if(!*xstr) xstr="0";
+ if(!*ystr) ystr="0";
+ if(!*rotatestr) rotatestr="0";
+ if(!*shearstr) shearstr="0";
+
+ if(*scalestr) {
+ scalex = scaley = parsePercent(scalestr);
+ } else if(*scalexstr || *scaleystr) {
+ if(scalexstr) scalex = parsePercent(scalexstr);
+ if(scaleystr) scaley = parsePercent(scaleystr);
+ } else if(*widthstr || *heightstr) {
+ int width=0;
+ int height=0;
+ s_getBitmapSize(object, &width, &height);
+ if(*widthstr)
+ scalex = (float)parseTwip(widthstr)/(float)width;
+ if(*heightstr)
+ scaley = (float)parseTwip(heightstr)/(float)height;
+ }
+ x = parseTwip(xstr);
+ y = parseTwip(ystr);
+ rotate = parseFloat(rotatestr);
+ shear = parseFloat(shearstr);
+
+ s_texture(name, object, x,y,scalex,scaley,rotate, shear);
+
+ return 0;
+}
+
+static int c_texture(map_t*args)
+{
+ char*name = lu(args, "instance");
+ char*object = lu(args, "character");
+ return texture2(name, object, args, 1);
+}
+
+static int c_gradient(map_t*args)
+{
+ char*name = lu(args, "name");
+ int radial= strcmp(lu(args, "radial"), "radial")?0:1;
+ int rotate = parseInt(lu(args, "rotate"));
+
+ readToken();
+ if(type != RAWDATA)
+ syntaxerror("colon (:) expected");
+
+ if(dictionary_lookup(&gradients, name))
+ syntaxerror("gradient %s defined twice", name);
+
+ s_gradient(name, text, radial, rotate);
+
+ /* check whether we also have placement information,
+ which would make this a positioned gradient.
+ If there is placement information, texture2() will
+ add a texture, which has priority over the gradient.
+ */
+ texture2(name, name, args, 0);
+ return 0;
+}
+
+static char* checkFiltername(map_t* args)
+{
+ char* name = lu(args, "name");
+ if (strchr(name, ','))
+ syntaxerror("the comma (,) is used to separate filters in filterlists. Please do not use in filternames.");
+ return name;
+}
+
+static int c_blur(map_t*args)
+{
+ char*name = checkFiltername(args);
+ char*blurstr = lu(args, "blur");
+ char*blurxstr = lu(args, "blurx");
+ char*blurystr = lu(args, "blury");
+ float blurx=1.0, blury=1.0;
+ if(blurstr[0]) {
+ blurx = parseFloat(blurstr);
+ blury = parseFloat(blurstr);
+ }
+ if(blurxstr[0])
+ blurx = parseFloat(blurxstr);
+ if(blurystr[0])
+ blury = parseFloat(blurystr);
+ int passes = parseInt(lu(args, "passes"));
+ s_blur(name, blurx, blury, passes);
+ return 0;
+}
+
+static int c_gradientglow(map_t*args)
+{
+ char*name = checkFiltername(args);
+ char*gradient = lu(args, "gradient");
+ char*blurstr = lu(args, "blur");
+ char*blurxstr = lu(args, "blurx");
+ char*blurystr = lu(args, "blury");
+ float blurx=1.0, blury=1.0;
+ if(blurstr[0]) {
+ blurx = parseFloat(blurstr);
+ blury = parseFloat(blurstr);
+ }
+ if(blurxstr[0])
+ blurx = parseFloat(blurxstr);
+ if(blurystr[0])
+ blury = parseFloat(blurystr);
+
+ float angle = parseFloat(lu(args, "angle")) / 180 * M_PI;
+ float distance = parseFloat(lu(args, "distance"));
+ float strength = parseFloat(lu(args, "strength"));
+ char innershadow = strcmp(lu(args, "innershadow"),"innershadow")?0:1;
+ char knockout = strcmp(lu(args, "knockout"),"knockout")?0:1;
+ char composite = strcmp(lu(args, "composite"),"composite")?0:1;
+ char ontop = strcmp(lu(args, "ontop"),"ontop")?0:1;
+ int passes = parseInt(lu(args, "passes"));
+
+ s_gradientglow(name, gradient, blurx, blury, angle, distance, strength, innershadow, knockout, composite, ontop, passes);
+ return 0;
+}
+
+static int c_dropshadow(map_t*args)
+{
+ char*name = checkFiltername(args);
+ RGBA color = parseColor(lu(args, "color"));
+ char*blurstr = lu(args, "blur");
+ char*blurxstr = lu(args, "blurx");
+ char*blurystr = lu(args, "blury");
+ float blurx=1.0, blury=1.0;
+ if(blurstr[0]) {
+ blurx = parseFloat(blurstr);
+ blury = parseFloat(blurstr);
+ }
+ if(blurxstr[0])
+ blurx = parseFloat(blurxstr);
+ if(blurystr[0])
+ blury = parseFloat(blurystr);
+
+ float angle = parseFloat(lu(args, "angle")) / 180 * M_PI;
+ float distance = parseFloat(lu(args, "distance"));
+ float strength = parseFloat(lu(args, "strength"));
+ char innershadow = strcmp(lu(args, "innershadow"),"innershadow")?0:1;
+ char knockout = strcmp(lu(args, "knockout"),"knockout")?0:1;
+ char composite = strcmp(lu(args, "composite"),"composite")?0:1;
+ int passes = parseInt(lu(args, "passes"));
+
+ s_dropshadow(name, color, blurx, blury, angle, distance, strength, innershadow, knockout, composite, passes);
+ return 0;
+}
+
+static int c_bevel(map_t*args)
+{
+ char*name = checkFiltername(args);
+ RGBA shadow = parseColor(lu(args, "shadow"));
+ RGBA highlight = parseColor(lu(args, "highlight"));
+ char*blurstr = lu(args, "blur");
+ char*blurxstr = lu(args, "blurx");
+ char*blurystr = lu(args, "blury");
+ float blurx=1.0, blury=1.0;
+ if(blurstr[0]) {
+ blurx = parseFloat(blurstr);
+ blury = parseFloat(blurstr);