Пример #1
0
bool
get_path_storage(agg::path_storage& path, const control_point* points,
	int32 count, bool closed)
{
	if (count > 1) {
		path.move_to(points[0].point.x, points[0].point.y);

		for (int32 i = 1; i < count; i++) {
			path.curve4(points[i - 1].point_out.x, points[i - 1].point_out.y,
				points[i].point_in.x, points[i].point_in.y,
				points[i].point.x, points[i].point.y);
		}
		if (closed) {
			// curve from last to first control point
			path.curve4(
				points[count - 1].point_out.x, points[count - 1].point_out.y,
				points[0].point_in.x, points[0].point_in.y,
				points[0].point.x, points[0].point.y);
			path.close_polygon();
		}

		return true;
	}
	return false;
}
Пример #2
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();
}
Пример #3
0
void ASSDrawEngine::AddDrawCmdToAGGPathStorage(DrawCmd* cmd, agg::path_storage& path, DRAWCMDMODE mode)
{
	if (mode == HILITE && cmd->prev)
		path.move_to(cmd->prev->m_point->x(), cmd->prev->m_point->y());

	switch(cmd->type)
	{
	case M:
		path.move_to(cmd->m_point->x(),cmd->m_point->y());
		break;

	case B:
		if (cmd->initialized)
		{
			//path.move_to(cmd->prev->m_point->x(),cmd->prev->m_point->y());
			PointList::iterator iterate = cmd->controlpoints.begin();
			int x[2], y[2];
			x[0] = (*iterate)->x();
			y[0] = (*iterate)->y();
			iterate++;
			x[1] = (*iterate)->x();
			y[1] = (*iterate)->y();
			path.curve4(x[0], y[0], x[1], y[1], cmd->m_point->x(),cmd->m_point->y());
    		break;
		}

	case L:
		if (mode == CTRL_LN)
			path.move_to(cmd->m_point->x(),cmd->m_point->y());
		else
			path.line_to(cmd->m_point->x(),cmd->m_point->y());
		break;
		
	case S:
		unsigned np = cmd->controlpoints.size();
        agg::pod_array<double> m_polygon(np * 2);
        unsigned _pn = 0;
		PointList::iterator iterate = cmd->controlpoints.begin();
		while (iterate != cmd->controlpoints.end())
		{
	        m_polygon[_pn] = (*iterate)->x(); _pn++;
	        m_polygon[_pn] = (*iterate)->y(); _pn++;
	        iterate++;
		}
        //m_polygon[_pn++] = cmd->m_point->x();
        //m_polygon[_pn++] = cmd->m_point->y();
		//path.move_to(cmd->prev->m_point->x(),cmd->prev->m_point->y());
		if (mode == CTRL_LN)
		{
			_pn = 0;
			while (_pn < np * 2)
			{
				path.line_to((int) m_polygon[_pn],(int) m_polygon[_pn + 1]);
				_pn += 2;
			}
	        path.line_to(cmd->m_point->x(), cmd->m_point->y());
		}	
		else
		{	
			//path.line_to((int) m_polygon[0],(int) m_polygon[1]);
	        aggpolygon poly(&m_polygon[0], np, false, false);
	        agg::conv_bcspline<agg::simple_polygon_vertex_source>  bspline(poly);
	        bspline.interpolation_step(0.01);
	        agg::path_storage npath;
	        npath.join_path(bspline);
	        path.join_path(npath);
	        if (mode == HILITE)
	        	path.move_to((int) m_polygon[np * 2 - 2], (int) m_polygon[np * 2 - 1] );
	        path.line_to(cmd->m_point->x(), cmd->m_point->y());
		}
		break;
	}	

}