src/ldObject.cpp

changeset 1004
ba4200437179
parent 1003
31873c3cbdbc
child 1006
a6b462051ae0
equal deleted inserted replaced
1003:31873c3cbdbc 1004:ba4200437179
1085 return Vertex(); 1085 return Vertex();
1086 } 1086 }
1087 1087
1088 LDObjectList LDBezierCurve::rasterize (int segments) 1088 LDObjectList LDBezierCurve::rasterize (int segments)
1089 { 1089 {
1090 QVector<LDPolygon> polygons = rasterizePolygons (segments);
1090 LDObjectList result; 1091 LDObjectList result;
1092
1093 for (LDPolygon& poly : polygons)
1094 {
1095 LDLine* line = LDSpawn<LDLine> (poly.vertices[0], poly.vertices[1]);
1096 line->setColor (poly.color);
1097 result << line;
1098 }
1099
1100 return result;
1101 }
1102
1103 QVector<LDPolygon> LDBezierCurve::rasterizePolygons (int segments)
1104 {
1105 QVector<LDPolygon> result;
1091 QVector<Vertex> parms; 1106 QVector<Vertex> parms;
1092 parms.append (pointAt (0.0)); 1107 parms.append (pointAt (0.0));
1093 1108
1094 for (int i = 1; i < segments; ++i) 1109 for (int i = 1; i < segments; ++i)
1095 parms.append (pointAt (double (i) / segments)); 1110 parms.append (pointAt (double (i) / segments));
1096 1111
1097 parms.append (pointAt (1.0)); 1112 parms.append (pointAt (1.0));
1113 LDPolygon poly;
1114 poly.color = color().index();
1115 poly.id = id();
1116 poly.num = 2;
1098 1117
1099 for (int i = 0; i < segments; ++i) 1118 for (int i = 0; i < segments; ++i)
1100 { 1119 {
1101 LDLine* line = LDSpawn<LDLine> (parms[i], parms[i + 1]); 1120 poly.vertices[0] = parms[i];
1102 line->setColor (color()); 1121 poly.vertices[1] = parms[i + 1];
1103 result << line; 1122 result << poly;
1104 } 1123 }
1105 1124
1106 return result; 1125 return result;
1107 } 1126 }
1108 1127

mercurial