SYNFIG_LAYER_SET_LOCAL_NAME(Outline,_("Outline"));
SYNFIG_LAYER_SET_CATEGORY(Outline,_("Geometry"));
SYNFIG_LAYER_SET_VERSION(Outline,"0.2");
SYNFIG_LAYER_SET_LOCAL_NAME(Outline,_("Outline"));
SYNFIG_LAYER_SET_CATEGORY(Outline,_("Geometry"));
SYNFIG_LAYER_SET_VERSION(Outline,"0.2");
// compute slopes, note the cludge for infinity, however, this will
// be close enough
// compute slopes, note the cludge for infinity, however, this will
// be close enough
return Point(
((b1*c2 - b2*c1)*det_inv),
((a2*c1 - a1*c2)*det_inv)
return Point(
((b1*c2 - b2*c1)*det_inv),
((a2*c1 - a1*c2)*det_inv)
vector<BLinePoint> bline_point_list;
bline_point_list.push_back(BLinePoint());
bline_point_list.push_back(BLinePoint());
bline_point_list.push_back(BLinePoint());
vector<BLinePoint> bline_point_list;
bline_point_list.push_back(BLinePoint());
bline_point_list.push_back(BLinePoint());
bline_point_list.push_back(BLinePoint());
- bline_point_list[0].set_vertex(Point(0,1));
- bline_point_list[1].set_vertex(Point(0,-1));
+ bline_point_list[0].set_vertex(Point(0,1));
+ bline_point_list[1].set_vertex(Point(0,-1));
- bline_point_list[0].set_tangent(bline_point_list[1].get_vertex()-bline_point_list[2].get_vertex()*0.5f);
- bline_point_list[1].set_tangent(bline_point_list[2].get_vertex()-bline_point_list[0].get_vertex()*0.5f);
- bline_point_list[2].set_tangent(bline_point_list[0].get_vertex()-bline_point_list[1].get_vertex()*0.5f);
- bline_point_list[0].set_width(1.0f);
- bline_point_list[1].set_width(1.0f);
- bline_point_list[2].set_width(1.0f);
+ bline_point_list[0].set_tangent(bline_point_list[1].get_vertex()-bline_point_list[2].get_vertex()*0.5f);
+ bline_point_list[1].set_tangent(bline_point_list[2].get_vertex()-bline_point_list[0].get_vertex()*0.5f);
+ bline_point_list[2].set_tangent(bline_point_list[0].get_vertex()-bline_point_list[1].get_vertex()*0.5f);
+ bline_point_list[0].set_width(1.0f);
+ bline_point_list[1].set_width(1.0f);
+ bline_point_list[2].set_width(1.0f);
const bool loop(bline.get_loop());
const vector<synfig::BLinePoint> bline_(bline.get_list().begin(),bline.get_list().end());
#define bline bline_
const bool loop(bline.get_loop());
const vector<synfig::BLinePoint> bline_(bline.get_list().begin(),bline.get_list().end());
#define bline bline_
for(bool first=!loop;next!=end;iter=next++,first=false)
{
Vector prev_t(iter->get_tangent1());
Vector iter_t(iter->get_tangent2());
Vector next_t(next->get_tangent1());
for(bool first=!loop;next!=end;iter=next++,first=false)
{
Vector prev_t(iter->get_tangent1());
Vector iter_t(iter->get_tangent2());
Vector next_t(next->get_tangent1());
if(iter_t.is_equal_to(Vector::zero()) && next_t.is_equal_to(Vector::zero()))
{
iter_t=next_t=next->get_vertex()-iter->get_vertex();
split_flag=true;
}
if(iter_t.is_equal_to(Vector::zero()) && next_t.is_equal_to(Vector::zero()))
{
iter_t=next_t=next->get_vertex()-iter->get_vertex();
split_flag=true;
}
const float
iter_w((iter->get_width()*width)*0.5f+expand),
next_w((next->get_width()*width)*0.5f+expand);
const derivative< hermite<Vector> > deriv(curve);
const float
iter_w((iter->get_width()*width)*0.5f+expand),
next_w((next->get_width()*width)*0.5f+expand);
const derivative< hermite<Vector> > deriv(curve);
// Make cusps as necessary
if(!first && sharp_cusps && split_flag && (!prev_t.is_equal_to(iter_t) || iter_t.is_equal_to(Vector::zero())) && !last_tangent.is_equal_to(Vector::zero()))
{
Vector curr_tangent(deriv(CUSP_TANGENT_ADJUST));
// Make cusps as necessary
if(!first && sharp_cusps && split_flag && (!prev_t.is_equal_to(iter_t) || iter_t.is_equal_to(Vector::zero())) && !last_tangent.is_equal_to(Vector::zero()))
{
Vector curr_tangent(deriv(CUSP_TANGENT_ADJUST));
side_a.push_back(line_intersection(p1,last_tangent,p2,curr_tangent));
}
else if(cross<-CUSP_THRESHOLD)
{
const Point p1(iter->get_vertex()-t1*iter_w);
const Point p2(iter->get_vertex()-t2*iter_w);
side_a.push_back(line_intersection(p1,last_tangent,p2,curr_tangent));
}
else if(cross<-CUSP_THRESHOLD)
{
const Point p1(iter->get_vertex()-t1*iter_w);
const Point p2(iter->get_vertex()-t2*iter_w);
side_b.push_back(line_intersection(p1,last_tangent,p2,curr_tangent));
}
else if(cross>0 && perp>1)
side_b.push_back(line_intersection(p1,last_tangent,p2,curr_tangent));
}
else if(cross>0 && perp>1)
float amount(max(0.0f,(float)(-cross/CUSP_THRESHOLD))*(SPIKE_AMOUNT-1)+1);
side_b.push_back(iter->get_vertex()-(t1+t2).norm()*iter_w*amount);
float amount(max(0.0f,(float)(-cross/CUSP_THRESHOLD))*(SPIKE_AMOUNT-1)+1);
side_b.push_back(iter->get_vertex()-(t1+t2).norm()*iter_w*amount);
const Vector d(deriv(n>CUSP_TANGENT_ADJUST?n:CUSP_TANGENT_ADJUST).perp().norm());
const Vector p(curve(n));
const float w(((next_w-iter_w)*n+iter_w));
const Vector d(deriv(n>CUSP_TANGENT_ADJUST?n:CUSP_TANGENT_ADJUST).perp().norm());
const Vector p(curve(n));
const float w(((next_w-iter_w)*n+iter_w));
side_a.push_back(curve(1.0)+last_tangent.perp().norm()*next_w);
side_b.push_back(curve(1.0)-last_tangent.perp().norm()*next_w);
}
side_a.push_back(curve(1.0)+last_tangent.perp().norm()*next_w);
side_b.push_back(curve(1.0)-last_tangent.perp().norm()*next_w);
}
const Point vertex(bline.back().get_vertex());
const Vector tangent(last_tangent.norm());
const float w((bline.back().get_width()*width)*0.5f+expand);
const Point vertex(bline.back().get_vertex());
const Vector tangent(last_tangent.norm());
const float w((bline.back().get_width()*width)*0.5f+expand);
for(;!side_b.empty();side_b.pop_back())
side_a.push_back(side_b.back());
// Insert code for adding begin tip
for(;!side_b.empty();side_b.pop_back())
side_a.push_back(side_b.back());
// Insert code for adding begin tip
const Point vertex(bline.front().get_vertex());
const Vector tangent(bline.front().get_tangent2().norm());
const float w((bline.front().get_width()*width)*0.5f+expand);
const Point vertex(bline.front().get_vertex());
const Vector tangent(bline.front().get_tangent2().norm());
const float w((bline.front().get_width()*width)*0.5f+expand);
while(width_list.size()<segment_list.size()+1)
width_list.push_back(default_width);
while(width_list.size()>segment_list.size()+1)
width_list.pop_back();
while(width_list.size()<segment_list.size()+1)
width_list.push_back(default_width);
while(width_list.size()>segment_list.size()+1)
width_list.pop_back();
vector<Real>::iterator iter;
vector<Real> scaled_width_list;
for(iter=width_list.begin();iter!=width_list.end();++iter)
vector<Real>::iterator iter;
vector<Real> scaled_width_list;
for(iter=width_list.begin();iter!=width_list.end();++iter)
if(iter->t1.mag_squared()<=EPSILON && iter->t2.mag_squared()<=EPSILON)
{
vector_list.push_back(iter->p1-(iter->p2-iter->p1).perp().norm()*witer[0]);
if(iter->t1.mag_squared()<=EPSILON && iter->t2.mag_squared()<=EPSILON)
{
vector_list.push_back(iter->p1-(iter->p2-iter->p1).perp().norm()*witer[0]);
// without this if statement, the broken tangents would
// have boxed edges
if(sharp_cusps && last_tangent!=NO_LOOP_COOKIE && !last_tangent.is_equal_to(iter->t1))
{
//Vector curr_tangent(iter->t1);
Vector curr_tangent(deriv(CUSP_TANGENT_ADJUST));
// without this if statement, the broken tangents would
// have boxed edges
if(sharp_cusps && last_tangent!=NO_LOOP_COOKIE && !last_tangent.is_equal_to(iter->t1))
{
//Vector curr_tangent(iter->t1);
Vector curr_tangent(deriv(CUSP_TANGENT_ADJUST));
vector_list.push_back(line_intersection(p1,last_tangent,p2,curr_tangent));
else if(cross>0)
{
vector_list.push_back(line_intersection(p1,last_tangent,p2,curr_tangent));
else if(cross>0)
{
for(n=0.0f;n<1.0f;n+=1.0f/SAMPLES)
vector_list.push_back(curve(n)+deriv(n>CUSP_TANGENT_ADJUST?n:CUSP_TANGENT_ADJUST).perp().norm()*((witer[1]-witer[0])*n+witer[0]) );
vector_list.push_back(curve(1.0)+deriv(1.0-CUSP_TANGENT_ADJUST).perp().norm()*witer[1]);
for(n=0.0f;n<1.0f;n+=1.0f/SAMPLES)
vector_list.push_back(curve(n)+deriv(n>CUSP_TANGENT_ADJUST?n:CUSP_TANGENT_ADJUST).perp().norm()*((witer[1]-witer[0])*n+witer[0]) );
vector_list.push_back(curve(1.0)+deriv(1.0-CUSP_TANGENT_ADJUST).perp().norm()*witer[1]);
if(iter->t1.mag_squared()<=EPSILON && iter->t2.mag_squared()<=EPSILON)
{
vector_list.push_back(iter->p2+(iter->p2-iter->p1).perp().norm()*witer[0]);
if(iter->t1.mag_squared()<=EPSILON && iter->t2.mag_squared()<=EPSILON)
{
vector_list.push_back(iter->p2+(iter->p2-iter->p1).perp().norm()*witer[0]);
etl::derivative<etl::hermite<Vector> > deriv(curve);
// without this if statement, the broken tangents would
etl::derivative<etl::hermite<Vector> > deriv(curve);
// without this if statement, the broken tangents would
const Vector t1(last_tangent.perp().norm());
const Vector t2(curr_tangent.perp().norm());
Point p1(iter->p2-t1*witer[-1]);
Point p2(iter->p2-t2*witer[-1]);
const Vector t1(last_tangent.perp().norm());
const Vector t2(curr_tangent.perp().norm());
Point p1(iter->p2-t1*witer[-1]);
Point p2(iter->p2-t2*witer[-1]);
vector_list.push_back(line_intersection(p1,last_tangent,p2,curr_tangent));
else if(cross>0)
{
vector_list.push_back(line_intersection(p1,last_tangent,p2,curr_tangent));
else if(cross>0)
{
for(n=1.0f;n>CUSP_TANGENT_ADJUST;n-=1.0f/SAMPLES)
vector_list.push_back(curve(n)-deriv(1-n>CUSP_TANGENT_ADJUST?n:1-CUSP_TANGENT_ADJUST).perp().norm()*((witer[-1]-witer[0])*n+witer[0]) );
vector_list.push_back(curve(0.0f)-deriv(CUSP_TANGENT_ADJUST).perp().norm()*witer[0]);
for(n=1.0f;n>CUSP_TANGENT_ADJUST;n-=1.0f/SAMPLES)
vector_list.push_back(curve(n)-deriv(1-n>CUSP_TANGENT_ADJUST?n:1-CUSP_TANGENT_ADJUST).perp().norm()*((witer[-1]-witer[0])*n+witer[0]) );
vector_list.push_back(curve(0.0f)-deriv(CUSP_TANGENT_ADJUST).perp().norm()*witer[0]);
curve.p1()=iter->p1+Vector(last_tangent[1],-last_tangent[0]).norm()*(*witer);
curve.p2()=iter->p1-(Vector(last_tangent[1],-last_tangent[0]).norm()*(*witer));
curve.t1()=-(curve.t2()=last_tangent/last_tangent.mag()*(*witer)*ROUND_END_FACTOR);
curve.p1()=iter->p1+Vector(last_tangent[1],-last_tangent[0]).norm()*(*witer);
curve.p2()=iter->p1-(Vector(last_tangent[1],-last_tangent[0]).norm()*(*witer));
curve.t1()=-(curve.t2()=last_tangent/last_tangent.mag()*(*witer)*ROUND_END_FACTOR);
}
//synfig::info("BLEHH__________--- x:%f, y:%f",vector_list.front()[0],vector_list.front()[1]);
}
}
//synfig::info("BLEHH__________--- x:%f, y:%f",vector_list.front()[0],vector_list.front()[1]);
}