void PolyBezierSegment::Append (moon_path *path) { PointCollection *col; GPtrArray *points; col = GetPoints (); int points_count = col->GetCount (); // we need at least 3 points if (!col || (points_count % 3) != 0) return; points = col->Array(); for (int i = 0; i < points_count - 2; i += 3) { moon_curve_to (path, ((Value*)g_ptr_array_index(points, i))->AsPoint()->x, ((Value*)g_ptr_array_index(points, i))->AsPoint()->y, ((Value*)g_ptr_array_index(points, i+1))->AsPoint()->x, ((Value*)g_ptr_array_index(points, i+1))->AsPoint()->y, ((Value*)g_ptr_array_index(points, i+2))->AsPoint()->x, ((Value*)g_ptr_array_index(points, i+2))->AsPoint()->y); } }
void PolyQuadraticBezierSegment::Append (moon_path *path) { PointCollection *col; GPtrArray *points; int count; col = GetPoints (); if (!col) return; count = col->GetCount (); if ((count % 2) != 0) return; // origin double x0 = 0.0; double y0 = 0.0; moon_get_current_point (path, &x0, &y0); points = col->Array(); // we need at least 2 points for (int i = 0; i < count - 1; i+=2) { double x1 = ((Value*)g_ptr_array_index(points, i))->AsPoint()->x; double y1 = ((Value*)g_ptr_array_index(points, i))->AsPoint()->y; double x2 = ((Value*)g_ptr_array_index(points, i+1))->AsPoint()->x; double y2 = ((Value*)g_ptr_array_index(points, i+1))->AsPoint()->y; double x3 = x2; double y3 = y2; x2 = x1 + (x2 - x1) / 3; y2 = y1 + (y2 - y1) / 3; x1 = x0 + 2 * (x1 - x0) / 3; y1 = y0 + 2 * (y1 - y0) / 3; moon_curve_to (path, x1, y1, x2, y2, x3, y3); // set new origin x0 = x3; y0 = y3; } }
void PolyLineSegment::Append (moon_path *path) { PointCollection *col; GPtrArray *points; int count; col = GetPoints (); if (!col) return; points = col->Array(); count = col->GetCount (); for (int i = 0; i < count; i++) moon_line_to (path, ((Value*)g_ptr_array_index(points, i))->AsPoint()->x, ((Value*)g_ptr_array_index(points, i))->AsPoint()->y); }