int intersect(Real x,Real y) const
{
- if((y < aabb.miny) | (y > aabb.maxy) | (x < aabb.minx)) return 0;
+ if((y < aabb.miny) || (y > aabb.maxy) || (x < aabb.minx)) return 0;
if(x > aabb.maxx) return ydir;
//int i = 0;
//to the left, to the right and out of range y, or completely out of range y
if( x < xmin ) return 0;
- if( x > xmax & (y > ymax | y < ymin) ) return 0;
- if( (y > ymax & y > p[1][1]) | (y < ymin & y < p[1][1]) ) return 0;
+ if( x > xmax && (y > ymax || y < ymin) ) return 0;
+ if( (y > ymax && y > p[1][1]) || (y < ymin && y < p[1][1]) ) return 0;
//degenerate line max
if(ymin == ymax == p[1][1])
//degenerate accept - to the right and crossing the base line
if(x > xmax)
{
- return (y <= ymax & y >= ymin);
+ return (y <= ymax && y >= ymin);
}
//solve for curve = y
}
//calculate number of intersections
- if(t1 >= 0 & t1 <= 1)
+ if(t1 >= 0 && t1 <= 1)
{
const Real t = t1;
const Real invt = 1 - t;
}
}
- if(t2 >= 0 & t2 <= 1)
+ if(t2 >= 0 && t2 <= 1)
{
const Real t = t2;
const Real invt = 1 - t;
const Real cn[4] = {a,b,c,d};
Real p,dp,newt,oldpmag=FLT_MAX;
- //eval cubic eqn and it's derivative
+ //eval cubic eqn and its derivative
for(;;)
{
p = cn[0]*t + cn[1];
//right of curve (and outside base range)
if( x > xmax )
{
- if( (y > ymax) | (y < ymin) ) return 0;
+ if( (y > ymax) || (y < ymin) ) return 0;
//degenerate accept - to the right and inside the [ymin,ymax] range (already rejected if out of range)
const Real n = p[3][1] - p[0][1];
t3 = -2.0*sqrt(Q)*cos((theta-2*PI)/3.0) - an/3.0;
//don't need to reorder,l just need to eliminate double/triple roots
- //if(t3 == t2 & t1 == t2) t2 = t3 = INVALIDROOT;
+ //if(t3 == t2 && t1 == t2) t2 = t3 = INVALIDROOT;
if(t3 == t2) t2 = t3 = INVALIDROOT;
if(t1 == t2) t1 = t2 = INVALIDROOT;
if(t1 == t3) t1 = t3 = INVALIDROOT;
//if(t1 != INVALIDROOT)
{
t = t1;//polish_cubicroot(a,b,c,d,t1,&dydt);
- if(t >= 0 & t < 1)
+ if(t >= 0 && t < 1)
{
//const Real invt = 1 - t;
//if(t2 != INVALIDROOT)
{
t = t2;//polish_cubicroot(a,b,c,d,t2,&dydt);
- if(t >= 0 & t < 1)
+ if(t >= 0 && t < 1)
{
//const Real invt = 1 - t;
//if(t3 != INVALIDROOT)
{
t = t3;//polish_cubicroot(a,b,c,d,t3,&dydt);
- if(t >= 0 & t < 1)
+ if(t >= 0 && t < 1)
{
//const Real invt = 1 - t;
int intersect(Real x,Real y, Point *table) const
{
- if((y < aabb.miny) | (y > aabb.maxy) | (x < aabb.minx)) return 0;
+ if((y < aabb.miny) || (y > aabb.maxy) || (x < aabb.minx)) return 0;
int i, curdeg, intersects = 0;
const int numcurves = degrees.size();
bool notclosed()
{
- return (flags & NotClosed) | (cur_x != close_x) | (cur_y != close_y);
+ return (flags & NotClosed) || (cur_x != close_x) || (cur_y != close_y);
}
void move_to(Real x, Real y)
int dir = (y > cur_y)*1 + (-1)*(y < cur_y);
//check for context (if not line start a new segment)
- //if we're not in line mode (cover's 0 set case), or if directions are different (not valid for 0 direction)
+ //if we're not in line mode (covers 0 set case), or if directions are different (not valid for 0 direction)
if(prim != TYPE_LINE || (dir && segs.back().ydir != dir))
{
MonoSegment seg(dir,x,x,y,y);
cur_x = x;
cur_y = y;
- aabb.expand(x,y); //expand the entire things bounding box
+ aabb.expand(x,y); //expand the entire thing's bounding box
tangent[0] = x - cur_x;
tangent[1] = x - cur_y;
bool notclosed() const
{
- return (flags & NotClosed) | (cur_x != close_x) | (cur_y != close_y);
+ return (flags & NotClosed) || (cur_x != close_x) || (cur_y != close_y);
}
//0 out all the variables involved in processing
//move to the next cell (cover values 0 initially), keeping the current if necessary
void move_pen(int x, int y)
{
- if(y != current.y | x != current.x)
+ if(y != current.y || x != current.x)
{
addcurrent();
current.set(x,y,0,0);
void draw_scanline(int y, Real x1, Real y1, Real x2, Real y2);
void draw_line(Real x1, Real y1, Real x2, Real y2);
- Real ExtractAlpha(Real area)
+ Real ExtractAlpha(Real area, WindingStyle winding_style)
{
- //non-zero winding style
- if(area < 0) area = -area;
- if(area > 1) area = 1;
+ if (area < 0)
+ area = -area;
- //even-odd winding style
- /*if(area < 0) area = -area;
+ if (winding_style == WINDING_NON_ZERO)
+ {
+ // non-zero winding style
+ if (area > 1)
+ return 1;
+ }
+ else // if (winding_style == WINDING_EVEN_ODD)
+ {
+ // even-odd winding style
+ while (area > 1)
+ area -= 2;
- while(area > 2) area -= 2;
- if(area > 1) area = 1-area; //want pyramid like thing
- */
- //broken? - yep broken
+ // want pyramid like thing
+ if (area < 0)
+ area = -area;
+ }
return area;
}
antialias (true),
blurtype (Blur::FASTGAUSSIAN),
feather (0),
+ winding_style (WINDING_NON_ZERO),
bytestream (0),
lastbyteop (Primitive::NONE),
lastoppos (-1)
IMPORT(antialias);
IMPORT(feather);
IMPORT(blurtype);
+ IMPORT(winding_style);
return Layer_Composite::set_param(param,value);
}
EXPORT(antialias);
EXPORT(feather);
EXPORT(blurtype);
+ EXPORT(winding_style);
EXPORT_NAME();
EXPORT_VERSION();
.add_enum_value(Blur::GAUSSIAN,"gaussian",_("Gaussian Blur"))
.add_enum_value(Blur::DISC,"disc",_("Disc Blur"))
);
+ ret.push_back(ParamDesc("winding_style")
+ .set_local_name(_("Winding Style"))
+ .set_description(_("Winding style to use"))
+ .set_hint("enum")
+ .add_enum_value(WINDING_NON_ZERO,"nonzero",_("Non Zero"))
+ .add_enum_value(WINDING_EVEN_ODD,"evenodd",_("Even/Odd"))
+ );
return ret;
}
//CLIP IT!!!!
try {
//outside y - ignore entirely
- if( (cur_y >= window.maxy & y >= window.maxy)
- |(cur_y < window.miny & y < window.miny) )
+ if( (cur_y >= window.maxy && y >= window.maxy)
+ ||(cur_y < window.miny && y < window.miny) )
{
cur_x = x;
cur_y = y;
const Real maxx = max(max(p[0][0],p[1][0]),p[2][0]);
const Real maxy = max(max(p[0][1],p[1][1]),p[2][1]);
- return (minx > r.maxx) |
- (maxx < r.minx) |
- (miny > r.maxy) |
+ return (minx > r.maxx) ||
+ (maxx < r.minx) ||
+ (miny > r.maxy) ||
(maxy < r.miny);
}
(miny > r.maxy) ||
(maxy < r.miny);*/
- return ((p[0][0] > r.maxx) & (p[1][0] > r.maxx) & (p[2][0] > r.maxx) & (p[3][0] > r.maxx)) |
- ((p[0][0] < r.minx) & (p[1][0] < r.minx) & (p[2][0] < r.minx) & (p[3][0] < r.minx)) |
- ((p[0][1] > r.maxy) & (p[1][1] > r.maxy) & (p[2][1] > r.maxy) & (p[3][1] > r.maxy)) |
- ((p[0][1] < r.miny) & (p[1][1] < r.miny) & (p[2][1] < r.miny) & (p[3][1] < r.miny));
+ return ((p[0][0] > r.maxx) && (p[1][0] > r.maxx) && (p[2][0] > r.maxx) && (p[3][0] > r.maxx)) ||
+ ((p[0][0] < r.minx) && (p[1][0] < r.minx) && (p[2][0] < r.minx) && (p[3][0] < r.minx)) ||
+ ((p[0][1] > r.maxy) && (p[1][1] > r.maxy) && (p[2][1] > r.maxy) && (p[3][1] > r.maxy)) ||
+ ((p[0][1] < r.miny) && (p[1][1] < r.miny) && (p[2][1] < r.miny) && (p[3][1] < r.miny));
}
static inline Real max_edges_cubic(const Point *const p)
op.operation = Primitive::END;
op.number = 0;
- if(lastbyteop == Primitive::END | lastbyteop == Primitive::NONE)
+ if(lastbyteop == Primitive::END || lastbyteop == Primitive::NONE)
{
}else
{
op.operation = Primitive::LINE_TO;
op.number = 1; //one point for now
- if(lastbyteop == Primitive::MOVE_TO | lastbyteop == Primitive::LINE_TO)
+ if(lastbyteop == Primitive::MOVE_TO || lastbyteop == Primitive::LINE_TO)
{
//only need to insert the point
bytestream.insert(bytestream.end(),(char*)&p,(char*)(&p+1));
//accumulate for the current pixel
while(++cur_mark != polyspan.covers.end())
{
- if(y != cur_mark->y | x != cur_mark->x)
+ if(y != cur_mark->y || x != cur_mark->x)
break;
area += cur_mark->area;
//draw pixel - based on covered area
if(area) //if we're ok, draw the current pixel
{
- alpha = polyspan.ExtractAlpha(cover - area);
+ alpha = polyspan.ExtractAlpha(cover - area, winding_style);
if(invert) alpha = 1 - alpha;
if(!antialias)
//draw span to next pixel - based on total amount of pixel cover
if(x < cur_mark->x)
{
- alpha = polyspan.ExtractAlpha(cover);
+ alpha = polyspan.ExtractAlpha(cover, winding_style);
if(invert) alpha = 1 - alpha;
if(!antialias)
//accumulate for the current pixel
while(++cur_mark != polyspan.covers.end())
{
- if(y != cur_mark->y | x != cur_mark->x)
+ if(y != cur_mark->y || x != cur_mark->x)
break;
area += cur_mark->area;
//draw pixel - based on covered area
if(area) //if we're ok, draw the current pixel
{
- alpha = 1 - polyspan.ExtractAlpha(cover - area);
+ alpha = 1 - polyspan.ExtractAlpha(cover - area, winding_style);
if(!antialias)
{
if(alpha >= .5) p.put_value();
//draw span to next pixel - based on total amount of pixel cover
if(x < cur_mark->x)
{
- alpha = 1 - polyspan.ExtractAlpha(cover);
+ alpha = 1 - polyspan.ExtractAlpha(cover, winding_style);
if(!antialias)
{
if(alpha >= .5) p.put_hline(cur_mark->x - x);
//accumulate for the current pixel
while(++cur_mark != polyspan.covers.end())
{
- if(y != cur_mark->y | x != cur_mark->x)
+ if(y != cur_mark->y || x != cur_mark->x)
break;
area += cur_mark->area;
//draw pixel - based on covered area
if(area) //if we're ok, draw the current pixel
{
- alpha = polyspan.ExtractAlpha(cover - area);
+ alpha = polyspan.ExtractAlpha(cover - area, winding_style);
if(!antialias)
{
if(alpha >= .5) p.put_value();
//draw span to next pixel - based on total amount of pixel cover
if(x < cur_mark->x)
{
- alpha = polyspan.ExtractAlpha(cover);
+ alpha = polyspan.ExtractAlpha(cover, winding_style);
if(!antialias)
{
if(alpha >= .5) p.put_hline(cur_mark->x - x);