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); } }
int PolyLineSegment::GetPathSize () { PointCollection *points = GetPoints (); int n = points ? points->GetCount() : 0; return n * MOON_PATH_LINE_TO_LENGTH; }
int PolyBezierSegment::GetPathSize () { PointCollection *points = GetPoints (); int n = points ? points->GetCount() : 0; return (n / 3) * MOON_PATH_CURVE_TO_LENGTH; }
// virtual void Polyline::OnRender(Graphics* pGraphics) { PointCollection* points = get_Points(); if (points) { unsigned int count = points->GetCount(); if (count > 0) { __release<LDraw::GraphicsPathF> path = new LDraw::GraphicsPathF; Point point = points->get_Item(0); path->AddMove(point.X, point.Y); for (unsigned int i = 1; i < count; i++) { point = points->get_Item(i); path->AddLine(point.X, point.Y); } Brush* Fill = get_Fill(); if (Fill) { __release<LDraw::Brush> brush = Fill->CreateBrush(this, 1, 1); if (brush != NULL) { pGraphics->FillPath(brush, path); } } #if 0 double StrokeThickness; if (m_StrokeThickness) m_StrokeThickness->get_Value(&StrokeThickness); else StrokeThickness = 1; if (StrokeThickness > 0) { CComQIPtr<CLXUIElementImplImpl> Stroke(m_Stroke); if (Stroke) { Gdiplus::Brush* pBrush = Stroke->CreateBrush(this, 1, 1); if (pBrush) { Gdiplus::Pen pen(pBrush, StrokeThickness); pGraphics->DrawPath(pen, &path); delete pBrush; } } } #endif } } }
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); }
LDraw::SizeD Polyline::MeasureOverride(LDraw::SizeD availSize) { PointCollection* points = get_Points(); if (points) { int count = points->GetCount(); if (count > 0) { __release<LDraw::GraphicsPathF> path = new LDraw::GraphicsPathF; //CLXUIPoint* pOldPoint = static_cast<CLXUIPoint*>(points->m_items[0]); Point point = points->get_Item(0); path->AddMove(point.X, point.Y); for (int i = 1; i < count; i++) { point = points->get_Item(i); path->AddLine(point.X, point.Y); // CLXUIPoint* pPoint = static_cast<CLXUIPoint*>(points->m_items[i]); // path.AddLine(float(pOldPoint->m_X), float(pOldPoint->m_Y), float(pPoint->m_X), float(pPoint->m_Y)); // pOldPoint = pPoint; } LDraw::RectF rect; path->GetBounds(&rect, NULL, NULL); return LDraw::SizeD(rect.Width, rect.Height); } } return LDraw::SizeD(0, 0); }