}
case BEZIER:
{
- Rect child_node_bounds = TransformFromQuadChild({0,0,1,1}, type);
- std::vector<Bezier> new_curves = m_objects.beziers[m_objects.data_indices[object_id]].ClipToRectangle(child_node_bounds);
Rect obj_bounds = TransformToQuadChild(m_objects.bounds[object_id], type);
+ if (obj_bounds.x < 0)
+ {
+ obj_bounds.w += obj_bounds.x;
+ obj_bounds.x = 0;
+ }
+ if (obj_bounds.y < 0)
+ {
+ obj_bounds.h += obj_bounds.y;
+ obj_bounds.y = 0;
+ }
+ if (obj_bounds.x + obj_bounds.w > 1)
+ {
+ obj_bounds.w += (1 - (obj_bounds.x + obj_bounds.w));
+ }
+ if (obj_bounds.y + obj_bounds.h > 1)
+ {
+ obj_bounds.h += (1 - (obj_bounds.y + obj_bounds.h));
+ }
+ Rect child_node_bounds = TransformFromQuadChild(obj_bounds, type);
+ Rect clip_bezier_bounds;
+ clip_bezier_bounds.x = (child_node_bounds.x - m_objects.bounds[object_id].x) / m_objects.bounds[object_id].w;
+ clip_bezier_bounds.y = (child_node_bounds.y - m_objects.bounds[object_id].y) / m_objects.bounds[object_id].h;
+ clip_bezier_bounds.w = child_node_bounds.w / m_objects.bounds[object_id].w;
+ clip_bezier_bounds.h = child_node_bounds.h / m_objects.bounds[object_id].h;
+ std::vector<Bezier> new_curves = Bezier(m_objects.beziers[m_objects.data_indices[object_id]], child_node_bounds).ClipToRectangle(clip_bezier_bounds);
for (size_t i = 0; i < new_curves.size(); ++i)
{
- unsigned index = AddBezierData(new_curves[i]);
- m_objects.bounds.push_back(obj_bounds);
+ Rect new_bounds = TransformToQuadChild(m_objects.bounds[object_id], type);
+ new_bounds = TransformToQuadChild(new_curves[i].SolveBounds(), type);
+ Bezier new_curve_data = new_curves[i].ToRelative(new_bounds);
+ unsigned index = AddBezierData(new_curve_data);
+ m_objects.bounds.push_back(new_bounds);
m_objects.types.push_back(BEZIER);
m_objects.data_indices.push_back(index);
}
#endif
}
-unsigned Document::AddGroup(unsigned start_index, unsigned end_index, const Colour & shading)
+unsigned Document::AddGroup(unsigned start_index, unsigned end_index, const Colour & fill)
{
Real xmin = 0; Real ymin = 0;
Real xmax = 0; Real ymax = 0;
Rect bounds(xmin,ymin, xmax-xmin, ymax-ymin);
- Group group = {start_index, end_index, shading};
+ Group group(start_index, end_index, 0U, fill);
unsigned data_index = AddGroupData(group);
unsigned result = Add(GROUP, bounds,data_index);