Exemple #1
0
void scene_renderer_t::convert_to_path( const shape_t& s, agg::path_storage& path, const Imath::V2i& offset, int subsample) const
{
	path.remove_all();
	
	Imath::V2f p0, p1, p2;
	Imath::V2f shape_offset = s.offset();

	Imath::M33f m( s.global_xform());
	
	p0 = transform_point( s.triples()[0].p1(), shape_offset, m, subsample, offset);
	path.move_to( p0.x, p0.y);
	
	for( int i = 0; i < s.triples().size() - 1; ++i)
	{
		p2 = transform_point( s.triples()[i].p2(), shape_offset, m, subsample, offset);
		p0 = transform_point( s.triples()[i+1].p0(), shape_offset, m, subsample, offset);
		p1 = transform_point( s.triples()[i+1].p1(), shape_offset, m, subsample, offset);
		path.curve4( p2.x, p2.y, p0.x, p0.y, p1.x, p1.y);
	}

	// last segment
	p2 = transform_point( s.triples()[s.triples().size()-1].p2(), shape_offset, m, subsample, offset);
	p0 = transform_point( s.triples()[0].p0(), shape_offset, m, subsample, offset);
	p1 = transform_point( s.triples()[0].p1(), shape_offset, m, subsample, offset);
	path.curve4( p2.x, p2.y, p0.x, p0.y, p1.x, p1.y);
	path.close_polygon();
}