void CSG_Doc_SVG::Draw_LinkedPolygon(CSG_Points &Points, const SG_Char* Link, int Fill_Color, int Line_Color, double Line_Width) { if( Points.Get_Count() > 2 ) { int i; CSG_String sPoints; CSG_String sWidth; CSG_String sLink; for (i = 0; i < Points.Get_Count(); i++) { sPoints.Append(SG_Get_String(Points.Get_X(i),2)); sPoints.Append(SG_T(",")); sPoints.Append(SG_Get_String(Points.Get_Y(i),2)); sPoints.Append(SG_T(" ")); } m_sSVGCode.Append(SG_T("<polygon ")); _AddAttribute(SG_T("points"), sPoints); sWidth.Append(SG_Get_String(Line_Width,2)); sWidth.Append(g_Unit); _AddAttribute(SG_T("stroke-width"), sWidth); _AddAttribute(SG_T("stroke"), _Get_SVGColor(Line_Color)); _AddAttribute(SG_T("fill"), _Get_SVGColor(Fill_Color)); sLink = SG_T("window.open('"); sLink.Append(Link); sLink.Append(SG_T("')")); _AddAttribute(SG_T("onclick"), sLink); m_sSVGCode.Append(SG_T("/>\n")); } }
void CSG_Doc_SVG::Draw_Line(CSG_Points &Points, double Width, int Color) { int i; CSG_String sPoints; CSG_String sWidth; for (i = 0; i < Points.Get_Count(); i++) { sPoints.Append(SG_Get_String(Points.Get_X(i),2)); sPoints.Append(SG_T(",")); sPoints.Append(SG_Get_String(Points.Get_Y(i),2)); sPoints.Append(SG_T(" ")); } m_sSVGCode.Append(SG_T("<polyline ")); _AddAttribute(SG_T("points"), sPoints); sWidth.Append(SG_Get_String(Width,2)); sWidth.Append(g_Unit); _AddAttribute(SG_T("stroke-width"), sWidth); _AddAttribute(SG_T("stroke"), _Get_SVGColor(Color)); _AddAttribute(SG_T("fill"), SG_T("none")); m_sSVGCode.Append(SG_T("/>\n")); }
void CSG_Doc_SVG::Draw_Polygon(CSG_Points &Points, int Fill_Color, int Line_Color, double Line_Width) { if( Points.Get_Count() > 2 ) { int i; CSG_String sPoints; CSG_String sWidth; for (i = 0; i < Points.Get_Count(); i++) { sPoints.Append(SG_Get_String(Points.Get_X(i),2)); sPoints.Append(SG_T(",")); sPoints.Append(SG_Get_String(Points.Get_Y(i),2)); sPoints.Append(SG_T(" ")); } m_sSVGCode.Append(SG_T("<polygon ")); _AddAttribute(SG_T("points"), sPoints); sWidth.Append(SG_Get_String(Line_Width,2)); sWidth.Append(g_Unit); _AddAttribute(SG_T("stroke-width"), sWidth); _AddAttribute(SG_T("stroke"), _Get_SVGColor(Line_Color)); _AddAttribute(SG_T("fill"), _Get_SVGColor(Fill_Color)); m_sSVGCode.Append(SG_T("/>\n")); } }
//--------------------------------------------------------- double SG_Get_Polygon_Area(const CSG_Points &Points) { double Area = 0.0; if( Points.Get_Count() >= 3 ) { for(int i=0, j=Points.Get_Count()-1; i<Points.Get_Count(); j=i++) { Area += (Points.Get_X(j) * Points.Get_Y(i)) - (Points.Get_X(i) * Points.Get_Y(j)); } Area /= 2.0; } return( Area ); }