projects
/
synfig.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Ignore generated files, such as PNG files.
[synfig.git]
/
synfig-core
/
trunk
/
src
/
synfig
/
layer_shape.cpp
diff --git
a/synfig-core/trunk/src/synfig/layer_shape.cpp
b/synfig-core/trunk/src/synfig/layer_shape.cpp
index
269eaf1
..
8c4a818
100644
(file)
--- a/
synfig-core/trunk/src/synfig/layer_shape.cpp
+++ b/
synfig-core/trunk/src/synfig/layer_shape.cpp
@@
-6,7
+6,7
@@
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2007 Chris Moore
+** Copyright (c) 2007
, 2008
Chris Moore
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
@@
-245,11
+245,13
@@
struct MonoSegment
//assumes that the rect culled away anything that would be beyond the edges
if(ydir > 0)
{
//assumes that the rect culled away anything that would be beyond the edges
if(ydir > 0)
{
- while(y > (*++p)[1]);
+ while(y > (*++p)[1])
+ ;
}
else
{
}
else
{
- while(y < (*++p)[1]);
+ while(y < (*++p)[1])
+ ;
}
//for the loop to break there must have been a slope (straight line would do nothing)
}
//for the loop to break there must have been a slope (straight line would do nothing)
@@
-335,7
+337,7
@@
struct CurveArray
if( (y > ymax && y > p[1][1]) || (y < ymin && y < p[1][1]) ) return 0;
//degenerate line max
if( (y > ymax && y > p[1][1]) || (y < ymin && y < p[1][1]) ) return 0;
//degenerate line max
- if(ymin == ymax == p[1][1])
+ if(ymin == ymax
&& ymax
== p[1][1])
return 0;
//degenerate accept - to the right and crossing the base line
return 0;
//degenerate accept - to the right and crossing the base line
@@
-945,7
+947,7
@@
struct PenMark
void setcover(Real c, Real a) { cover = c; area = a; }
void addcover(Real c, Real a) { cover += c; area += a; }
void setcover(Real c, Real a) { cover = c; area = a; }
void addcover(Real c, Real a) { cover += c; area += a; }
- bool operator
<
(const PenMark &rhs) const
+ bool operator
<
(const PenMark &rhs) const
{
return y == rhs.y ? x < rhs.x : y < rhs.y;
}
{
return y == rhs.y ? x < rhs.x : y < rhs.y;
}
@@
-1122,7
+1124,7
@@
Layer_Shape::Layer_Shape(const Real &a, const Color::BlendMethod m):
Layer_Composite (a,m),
edge_table (new Intersector),
color (Color::black()),
Layer_Composite (a,m),
edge_table (new Intersector),
color (Color::black()),
- o
ffset
(0,0),
+ o
rigin
(0,0),
invert (false),
antialias (true),
blurtype (Blur::FASTGAUSSIAN),
invert (false),
antialias (true),
blurtype (Blur::FASTGAUSSIAN),
@@
-1149,16
+1151,18
@@
Layer_Shape::clear()
bool
Layer_Shape::set_param(const String & param, const ValueBase &value)
{
bool
Layer_Shape::set_param(const String & param, const ValueBase &value)
{
- IMPORT_PLUS(color, { if (color.get_a() == 0) if (converted_blend_) {
+ IMPORT_PLUS(color, { if (color.get_a() == 0)
{
if (converted_blend_) {
set_blend_method(Color::BLEND_ALPHA_OVER);
set_blend_method(Color::BLEND_ALPHA_OVER);
- color.set_a(1); } else transparent_color_ = true; });
- IMPORT(o
ffset
);
+ color.set_a(1); } else transparent_color_ = true; }
}
);
+ IMPORT(o
rigin
);
IMPORT(invert);
IMPORT(antialias);
IMPORT(invert);
IMPORT(antialias);
- IMPORT
(feather
);
+ IMPORT
_PLUS(feather, if(feather<0)feather=0;
);
IMPORT(blurtype);
IMPORT(winding_style);
IMPORT(blurtype);
IMPORT(winding_style);
+ IMPORT_AS(origin,"offset");
+
return Layer_Composite::set_param(param,value);
}
return Layer_Composite::set_param(param,value);
}
@@
-1166,7
+1170,7
@@
ValueBase
Layer_Shape::get_param(const String ¶m)const
{
EXPORT(color);
Layer_Shape::get_param(const String ¶m)const
{
EXPORT(color);
- EXPORT(o
ffset
);
+ EXPORT(o
rigin
);
EXPORT(invert);
EXPORT(antialias);
EXPORT(feather);
EXPORT(invert);
EXPORT(antialias);
EXPORT(feather);
@@
-1188,8
+1192,8
@@
Layer_Shape::get_param_vocab()const
.set_local_name(_("Color"))
.set_description(_("Layer_Shape Color"))
);
.set_local_name(_("Color"))
.set_description(_("Layer_Shape Color"))
);
- ret.push_back(ParamDesc("o
ffset
")
- .set_local_name(_("
Positio
n"))
+ ret.push_back(ParamDesc("o
rigin
")
+ .set_local_name(_("
Origi
n"))
);
ret.push_back(ParamDesc("invert")
.set_local_name(_("Invert"))
);
ret.push_back(ParamDesc("invert")
.set_local_name(_("Invert"))
@@
-1225,7
+1229,7
@@
Layer_Shape::get_param_vocab()const
synfig::Layer::Handle
Layer_Shape::hit_check(synfig::Context context, const synfig::Point &p)const
{
synfig::Layer::Handle
Layer_Shape::hit_check(synfig::Context context, const synfig::Point &p)const
{
- Point pos(p-o
ffset
);
+ Point pos(p-o
rigin
);
int intercepts = edge_table->intersect(pos[0],pos[1]);
int intercepts = edge_table->intersect(pos[0],pos[1]);
@@
-1272,7
+1276,7
@@
Layer_Shape::get_color(Context context, const Point &p)const
if(feather)
pp = Blur(feather,feather,blurtype)(p);
if(feather)
pp = Blur(feather,feather,blurtype)(p);
- Point pos(pp-o
ffset
);
+ Point pos(pp-o
rigin
);
int intercepts = edge_table->intersect(pos[0],pos[1]);
int intercepts = edge_table->intersect(pos[0],pos[1]);
@@
-2472,7
+2476,7
@@
Layer_Shape::accelerated_render(Context context,Surface *surface,int quality, co
if(is_solid_color() && invert)
{
Rect aabb = edge_table->aabb;
if(is_solid_color() && invert)
{
Rect aabb = edge_table->aabb;
- Point tl = renddesc.get_tl() - o
ffset
;
+ Point tl = renddesc.get_tl() - o
rigin
;
Real pw = renddesc.get_pw(),
ph = renddesc.get_ph();
Real pw = renddesc.get_pw(),
ph = renddesc.get_ph();
@@
-2721,9
+2725,9
@@
Layer_Shape::render_shape(Surface *surface,bool useblend,int /*quality*/,
case Primitive::MOVE_TO:
{
x = data[curnum][0];
case Primitive::MOVE_TO:
{
x = data[curnum][0];
- x = (x - tl[0] + o
ffset
[0])*pw;
+ x = (x - tl[0] + o
rigin
[0])*pw;
y = data[curnum][1];
y = data[curnum][1];
- y = (y - tl[1] + o
ffset
[1])*ph;
+ y = (y - tl[1] + o
rigin
[1])*ph;
if(curnum == 0)
{
if(curnum == 0)
{
@@
-2748,9
+2752,9
@@
Layer_Shape::render_shape(Surface *surface,bool useblend,int /*quality*/,
case Primitive::LINE_TO:
{
x = data[curnum][0];
case Primitive::LINE_TO:
{
x = data[curnum][0];
- x = (x - tl[0] + o
ffset
[0])*pw;
+ x = (x - tl[0] + o
rigin
[0])*pw;
y = data[curnum][1];
y = data[curnum][1];
- y = (y - tl[1] + o
ffset
[1])*ph;
+ y = (y - tl[1] + o
rigin
[1])*ph;
tangent[0] = x - span.cur_x;
tangent[1] = y - span.cur_y;
tangent[0] = x - span.cur_x;
tangent[1] = y - span.cur_y;
@@
-2763,14
+2767,14
@@
Layer_Shape::render_shape(Surface *surface,bool useblend,int /*quality*/,
case Primitive::CONIC_TO:
{
x = data[curnum+1][0];
case Primitive::CONIC_TO:
{
x = data[curnum+1][0];
- x = (x - tl[0] + o
ffset
[0])*pw;
+ x = (x - tl[0] + o
rigin
[0])*pw;
y = data[curnum+1][1];
y = data[curnum+1][1];
- y = (y - tl[1] + o
ffset
[1])*ph;
+ y = (y - tl[1] + o
rigin
[1])*ph;
x1 = data[curnum][0];
x1 = data[curnum][0];
- x1 = (x1 - tl[0] + o
ffset
[0])*pw;
+ x1 = (x1 - tl[0] + o
rigin
[0])*pw;
y1 = data[curnum][1];
y1 = data[curnum][1];
- y1 = (y1 - tl[1] + o
ffset
[1])*ph;
+ y1 = (y1 - tl[1] + o
rigin
[1])*ph;
tangent[0] = 2*(x - x1);
tangent[1] = 2*(y - y1);
tangent[0] = 2*(x - x1);
tangent[1] = 2*(y - y1);
@@
-2783,9
+2787,9
@@
Layer_Shape::render_shape(Surface *surface,bool useblend,int /*quality*/,
case Primitive::CONIC_TO_SMOOTH:
{
x = data[curnum][0];
case Primitive::CONIC_TO_SMOOTH:
{
x = data[curnum][0];
- x = (x - tl[0] + o
ffset
[0])*pw;
+ x = (x - tl[0] + o
rigin
[0])*pw;
y = data[curnum][1];
y = data[curnum][1];
- y = (y - tl[1] + o
ffset
[1])*ph;
+ y = (y - tl[1] + o
rigin
[1])*ph;
x1 = span.cur_x + tangent[0]/2;
y1 = span.cur_y + tangent[1]/2;
x1 = span.cur_x + tangent[0]/2;
y1 = span.cur_y + tangent[1]/2;
@@
-2802,19
+2806,19
@@
Layer_Shape::render_shape(Surface *surface,bool useblend,int /*quality*/,
case Primitive::CUBIC_TO:
{
x = data[curnum+2][0];
case Primitive::CUBIC_TO:
{
x = data[curnum+2][0];
- x = (x - tl[0] + o
ffset
[0])*pw;
+ x = (x - tl[0] + o
rigin
[0])*pw;
y = data[curnum+2][1];
y = data[curnum+2][1];
- y = (y - tl[1] + o
ffset
[1])*ph;
+ y = (y - tl[1] + o
rigin
[1])*ph;
x2 = data[curnum+1][0];
x2 = data[curnum+1][0];
- x2 = (x2 - tl[0] + o
ffset
[0])*pw;
+ x2 = (x2 - tl[0] + o
rigin
[0])*pw;
y2 = data[curnum+1][1];
y2 = data[curnum+1][1];
- y2 = (y2 - tl[1] + o
ffset
[1])*ph;
+ y2 = (y2 - tl[1] + o
rigin
[1])*ph;
x1 = data[curnum][0];
x1 = data[curnum][0];
- x1 = (x1 - tl[0] + o
ffset
[0])*pw;
+ x1 = (x1 - tl[0] + o
rigin
[0])*pw;
y1 = data[curnum][1];
y1 = data[curnum][1];
- y1 = (y1 - tl[1] + o
ffset
[1])*ph;
+ y1 = (y1 - tl[1] + o
rigin
[1])*ph;
tangent[0] = 2*(x - x2);
tangent[1] = 2*(y - y2);
tangent[0] = 2*(x - x2);
tangent[1] = 2*(y - y2);
@@
-2828,14
+2832,14
@@
Layer_Shape::render_shape(Surface *surface,bool useblend,int /*quality*/,
case Primitive::CUBIC_TO_SMOOTH:
{
x = data[curnum+1][0];
case Primitive::CUBIC_TO_SMOOTH:
{
x = data[curnum+1][0];
- x = (x - tl[0] + o
ffset
[0])*pw;
+ x = (x - tl[0] + o
rigin
[0])*pw;
y = data[curnum+1][1];
y = data[curnum+1][1];
- y = (y - tl[1] + o
ffset
[1])*ph;
+ y = (y - tl[1] + o
rigin
[1])*ph;
x2 = data[curnum][0];
x2 = data[curnum][0];
- x2 = (x2 - tl[0] + o
ffset
[0])*pw;
+ x2 = (x2 - tl[0] + o
rigin
[0])*pw;
y2 = data[curnum][1];
y2 = data[curnum][1];
- y2 = (y2 - tl[1] + o
ffset
[1])*ph;
+ y2 = (y2 - tl[1] + o
rigin
[1])*ph;
x1 = span.cur_x + tangent[0]/3.0;
y1 = span.cur_y + tangent[1]/3.0;
x1 = span.cur_x + tangent[0]/3.0;
y1 = span.cur_y + tangent[1]/3.0;
@@
-2950,9
+2954,9
@@
Layer_Shape::render_shape(etl::surface<float> *surface,int /*quality*/,
case Primitive::MOVE_TO:
{
x = data[curnum][0];
case Primitive::MOVE_TO:
{
x = data[curnum][0];
- x = (x - tl[0] + o
ffset
[0])*pw;
+ x = (x - tl[0] + o
rigin
[0])*pw;
y = data[curnum][1];
y = data[curnum][1];
- y = (y - tl[1] + o
ffset
[1])*ph;
+ y = (y - tl[1] + o
rigin
[1])*ph;
if(curnum == 0)
{
if(curnum == 0)
{
@@
-2977,9
+2981,9
@@
Layer_Shape::render_shape(etl::surface<float> *surface,int /*quality*/,
case Primitive::LINE_TO:
{
x = data[curnum][0];
case Primitive::LINE_TO:
{
x = data[curnum][0];
- x = (x - tl[0] + o
ffset
[0])*pw;
+ x = (x - tl[0] + o
rigin
[0])*pw;
y = data[curnum][1];
y = data[curnum][1];
- y = (y - tl[1] + o
ffset
[1])*ph;
+ y = (y - tl[1] + o
rigin
[1])*ph;
tangent[0] = x - span.cur_x;
tangent[1] = y - span.cur_y;
tangent[0] = x - span.cur_x;
tangent[1] = y - span.cur_y;
@@
-2992,14
+2996,14
@@
Layer_Shape::render_shape(etl::surface<float> *surface,int /*quality*/,
case Primitive::CONIC_TO:
{
x = data[curnum+1][0];
case Primitive::CONIC_TO:
{
x = data[curnum+1][0];
- x = (x - tl[0] + o
ffset
[0])*pw;
+ x = (x - tl[0] + o
rigin
[0])*pw;
y = data[curnum+1][1];
y = data[curnum+1][1];
- y = (y - tl[1] + o
ffset
[1])*ph;
+ y = (y - tl[1] + o
rigin
[1])*ph;
x1 = data[curnum][0];
x1 = data[curnum][0];
- x1 = (x1 - tl[0] + o
ffset
[0])*pw;
+ x1 = (x1 - tl[0] + o
rigin
[0])*pw;
y1 = data[curnum][1];
y1 = data[curnum][1];
- y1 = (y1 - tl[1] + o
ffset
[1])*ph;
+ y1 = (y1 - tl[1] + o
rigin
[1])*ph;
tangent[0] = 2*(x - x1);
tangent[1] = 2*(y - y1);
tangent[0] = 2*(x - x1);
tangent[1] = 2*(y - y1);
@@
-3012,9
+3016,9
@@
Layer_Shape::render_shape(etl::surface<float> *surface,int /*quality*/,
case Primitive::CONIC_TO_SMOOTH:
{
x = data[curnum][0];
case Primitive::CONIC_TO_SMOOTH:
{
x = data[curnum][0];
- x = (x - tl[0] + o
ffset
[0])*pw;
+ x = (x - tl[0] + o
rigin
[0])*pw;
y = data[curnum][1];
y = data[curnum][1];
- y = (y - tl[1] + o
ffset
[1])*ph;
+ y = (y - tl[1] + o
rigin
[1])*ph;
x1 = span.cur_x + tangent[0]/2;
y1 = span.cur_y + tangent[1]/2;
x1 = span.cur_x + tangent[0]/2;
y1 = span.cur_y + tangent[1]/2;
@@
-3031,19
+3035,19
@@
Layer_Shape::render_shape(etl::surface<float> *surface,int /*quality*/,
case Primitive::CUBIC_TO:
{
x = data[curnum+2][0];
case Primitive::CUBIC_TO:
{
x = data[curnum+2][0];
- x = (x - tl[0] + o
ffset
[0])*pw;
+ x = (x - tl[0] + o
rigin
[0])*pw;
y = data[curnum+2][1];
y = data[curnum+2][1];
- y = (y - tl[1] + o
ffset
[1])*ph;
+ y = (y - tl[1] + o
rigin
[1])*ph;
x2 = data[curnum+1][0];
x2 = data[curnum+1][0];
- x2 = (x2 - tl[0] + o
ffset
[0])*pw;
+ x2 = (x2 - tl[0] + o
rigin
[0])*pw;
y2 = data[curnum+1][1];
y2 = data[curnum+1][1];
- y2 = (y2 - tl[1] + o
ffset
[1])*ph;
+ y2 = (y2 - tl[1] + o
rigin
[1])*ph;
x1 = data[curnum][0];
x1 = data[curnum][0];
- x1 = (x1 - tl[0] + o
ffset
[0])*pw;
+ x1 = (x1 - tl[0] + o
rigin
[0])*pw;
y1 = data[curnum][1];
y1 = data[curnum][1];
- y1 = (y1 - tl[1] + o
ffset
[1])*ph;
+ y1 = (y1 - tl[1] + o
rigin
[1])*ph;
tangent[0] = 2*(x - x2);
tangent[1] = 2*(y - y2);
tangent[0] = 2*(x - x2);
tangent[1] = 2*(y - y2);
@@
-3057,14
+3061,14
@@
Layer_Shape::render_shape(etl::surface<float> *surface,int /*quality*/,
case Primitive::CUBIC_TO_SMOOTH:
{
x = data[curnum+1][0];
case Primitive::CUBIC_TO_SMOOTH:
{
x = data[curnum+1][0];
- x = (x - tl[0] + o
ffset
[0])*pw;
+ x = (x - tl[0] + o
rigin
[0])*pw;
y = data[curnum+1][1];
y = data[curnum+1][1];
- y = (y - tl[1] + o
ffset
[1])*ph;
+ y = (y - tl[1] + o
rigin
[1])*ph;
x2 = data[curnum][0];
x2 = data[curnum][0];
- x2 = (x2 - tl[0] + o
ffset
[0])*pw;
+ x2 = (x2 - tl[0] + o
rigin
[0])*pw;
y2 = data[curnum][1];
y2 = data[curnum][1];
- y2 = (y2 - tl[1] + o
ffset
[1])*ph;
+ y2 = (y2 - tl[1] + o
rigin
[1])*ph;
x1 = span.cur_x + tangent[0]/3.0;
y1 = span.cur_y + tangent[1]/3.0;
x1 = span.cur_x + tangent[0]/3.0;
y1 = span.cur_y + tangent[1]/3.0;
@@
-3096,7
+3100,7
@@
Layer_Shape::get_bounding_rect()const
if (edge_table->initaabb)
return Rect::zero();
if (edge_table->initaabb)
return Rect::zero();
- Rect bounds(edge_table->aabb+o
ffset
);
+ Rect bounds(edge_table->aabb+o
rigin
);
bounds.expand(max((bounds.get_min() - bounds.get_max()).mag()*0.01,
feather));
bounds.expand(max((bounds.get_min() - bounds.get_max()).mag()*0.01,
feather));