rays 0.1.13 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.doc/ext/rays/camera.cpp +171 -0
- data/.doc/ext/rays/color.cpp +2 -3
- data/.doc/ext/rays/color_space.cpp +22 -14
- data/.doc/ext/rays/font.cpp +30 -0
- data/.doc/ext/rays/image.cpp +1 -1
- data/.doc/ext/rays/native.cpp +4 -4
- data/.doc/ext/rays/painter.cpp +83 -0
- data/.doc/ext/rays/point.cpp +14 -0
- data/.doc/ext/rays/polygon.cpp +33 -7
- data/.doc/ext/rays/polyline.cpp +12 -6
- data/.doc/ext/rays/rays.cpp +105 -1
- data/LICENSE +21 -0
- data/Rakefile +3 -0
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +1 -1
- data/ext/rays/camera.cpp +186 -0
- data/ext/rays/color.cpp +2 -3
- data/ext/rays/color_space.cpp +22 -14
- data/ext/rays/extconf.rb +1 -1
- data/ext/rays/font.cpp +35 -2
- data/ext/rays/image.cpp +2 -2
- data/ext/rays/native.cpp +4 -4
- data/ext/rays/painter.cpp +94 -3
- data/ext/rays/point.cpp +16 -0
- data/ext/rays/polygon.cpp +34 -6
- data/ext/rays/polyline.cpp +11 -5
- data/ext/rays/rays.cpp +105 -1
- data/include/rays/camera.h +74 -0
- data/include/rays/color_space.h +4 -2
- data/include/rays/defs.h +33 -0
- data/include/rays/exception.h +6 -2
- data/include/rays/image.h +1 -1
- data/include/rays/painter.h +38 -0
- data/include/rays/polygon.h +35 -1
- data/include/rays/polyline.h +7 -1
- data/include/rays/ruby/camera.h +41 -0
- data/include/rays/ruby/rays.h +8 -0
- data/lib/rays.rb +2 -2
- data/lib/rays/camera.rb +24 -0
- data/lib/rays/image.rb +1 -1
- data/lib/rays/painter.rb +23 -1
- data/lib/rays/polygon.rb +8 -0
- data/rays.gemspec +2 -2
- data/src/color_space.cpp +2 -2
- data/src/image.cpp +1 -1
- data/src/ios/bitmap.h +23 -0
- data/src/ios/bitmap.mm +32 -11
- data/src/ios/camera.mm +517 -0
- data/src/ios/font.mm +2 -2
- data/src/ios/helper.h +2 -2
- data/src/osx/bitmap.h +23 -0
- data/src/osx/bitmap.mm +28 -10
- data/src/osx/camera.mm +452 -0
- data/src/osx/font.mm +2 -2
- data/src/painter.cpp +100 -10
- data/src/polygon.cpp +203 -37
- data/src/polyline.cpp +4 -2
- data/src/polyline.h +3 -1
- data/test/test_font.rb +5 -0
- data/test/test_painter.rb +65 -5
- data/test/test_painter_shape.rb +48 -3
- data/test/test_point.rb +8 -0
- data/test/test_polyline.rb +26 -0
- metadata +20 -9
data/src/osx/font.mm
CHANGED
@@ -71,8 +71,8 @@ namespace Rays
|
|
71
71
|
RawFont::RawFont (const char* name, coord size)
|
72
72
|
{
|
73
73
|
self->font = name
|
74
|
-
?
|
75
|
-
:
|
74
|
+
? CTFontCreateWithName(cfstring(name).get(), size, NULL)
|
75
|
+
: CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, size, NULL);
|
76
76
|
}
|
77
77
|
|
78
78
|
RawFont::~RawFont ()
|
data/src/painter.cpp
CHANGED
@@ -48,6 +48,12 @@ namespace Rays
|
|
48
48
|
|
49
49
|
coord stroke_width;
|
50
50
|
|
51
|
+
CapType stroke_cap;
|
52
|
+
|
53
|
+
JoinType stroke_join;
|
54
|
+
|
55
|
+
coord miter_limit;
|
56
|
+
|
51
57
|
uint nsegment;
|
52
58
|
|
53
59
|
Bounds clip;
|
@@ -62,6 +68,9 @@ namespace Rays
|
|
62
68
|
colors[FILL] .reset(1, 1);
|
63
69
|
colors[STROKE] .reset(1, 0);
|
64
70
|
stroke_width = 0;
|
71
|
+
stroke_cap = CAP_DEFAULT;
|
72
|
+
stroke_join = JOIN_DEFAULT;
|
73
|
+
miter_limit = JOIN_DEFAULT_MITER_LIMIT;
|
65
74
|
nsegment = 0;
|
66
75
|
clip .reset(-1);
|
67
76
|
font = default_font();
|
@@ -641,6 +650,11 @@ namespace Rays
|
|
641
650
|
|
642
651
|
self->opengl_state.push();
|
643
652
|
|
653
|
+
//glEnable(GL_CULL_FACE);
|
654
|
+
glEnable(GL_BLEND);
|
655
|
+
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
|
656
|
+
OpenGL_check_error(__FILE__, __LINE__);
|
657
|
+
|
644
658
|
FrameBuffer& fb = self->frame_buffer;
|
645
659
|
if (fb) FrameBuffer_bind(fb.id());
|
646
660
|
|
@@ -649,6 +663,7 @@ namespace Rays
|
|
649
663
|
glViewport(
|
650
664
|
(int) (vp.x * density), (int) (vp.y * density),
|
651
665
|
(int) (vp.width * density), (int) (vp.height * density));
|
666
|
+
OpenGL_check_error(__FILE__, __LINE__);
|
652
667
|
|
653
668
|
coord x1 = vp.x, x2 = vp.x + vp.width;
|
654
669
|
coord y1 = vp.y, y2 = vp.y + vp.height;
|
@@ -656,20 +671,13 @@ namespace Rays
|
|
656
671
|
if (z1 == 0 && z2 == 0) {z1 = -100; z2 = 200;}
|
657
672
|
if (!fb) std::swap(y1, y2);
|
658
673
|
|
659
|
-
self->state.init();
|
660
|
-
|
661
674
|
self->position_matrix.reset(1);
|
662
675
|
self->position_matrix *= to_rays(glm::ortho(x1, x2, y1, y2));
|
663
676
|
//self->position_matrix.translate(0.375f, 0.375f);
|
664
677
|
|
665
|
-
|
666
|
-
glEnable(GL_BLEND);
|
667
|
-
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
668
|
-
OpenGL_check_error(__FILE__, __LINE__);
|
678
|
+
self->update_clip();
|
669
679
|
|
670
680
|
self->painting = true;
|
671
|
-
|
672
|
-
no_clip();
|
673
681
|
}
|
674
682
|
|
675
683
|
void
|
@@ -847,6 +855,52 @@ namespace Rays
|
|
847
855
|
center, radius, hole_radius, angle_from, angle_to, nsegment()));
|
848
856
|
}
|
849
857
|
|
858
|
+
void
|
859
|
+
Painter::curve (
|
860
|
+
coord x1, coord y1, coord x2, coord y2,
|
861
|
+
coord x3, coord y3, coord x4, coord y4,
|
862
|
+
bool loop)
|
863
|
+
{
|
864
|
+
polygon(create_curve(x1, y1, x2, y2, x3, y3, x4, y4, loop));
|
865
|
+
}
|
866
|
+
|
867
|
+
void
|
868
|
+
Painter::curve (
|
869
|
+
const Point& p1, const Point& p2, const Point& p3, const Point& p4,
|
870
|
+
bool loop)
|
871
|
+
{
|
872
|
+
polygon(create_curve(p1, p2, p3, p4, loop));
|
873
|
+
}
|
874
|
+
|
875
|
+
void
|
876
|
+
Painter::curve (const Point* points, size_t size, bool loop)
|
877
|
+
{
|
878
|
+
polygon(create_curve(points, size, loop));
|
879
|
+
}
|
880
|
+
|
881
|
+
void
|
882
|
+
Painter::bezier (
|
883
|
+
coord x1, coord y1, coord x2, coord y2,
|
884
|
+
coord x3, coord y3, coord x4, coord y4,
|
885
|
+
bool loop)
|
886
|
+
{
|
887
|
+
polygon(create_bezier(x1, y1, x2, y2, x3, y3, x4, y4, loop));
|
888
|
+
}
|
889
|
+
|
890
|
+
void
|
891
|
+
Painter::bezier (
|
892
|
+
const Point& p1, const Point& p2, const Point& p3, const Point& p4,
|
893
|
+
bool loop)
|
894
|
+
{
|
895
|
+
polygon(create_bezier(p1, p2, p3, p4, loop));
|
896
|
+
}
|
897
|
+
|
898
|
+
void
|
899
|
+
Painter::bezier (const Point* points, size_t size, bool loop)
|
900
|
+
{
|
901
|
+
polygon(create_bezier(points, size, loop));
|
902
|
+
}
|
903
|
+
|
850
904
|
static void
|
851
905
|
draw_image (
|
852
906
|
Painter* painter, const Image& image,
|
@@ -1202,6 +1256,42 @@ namespace Rays
|
|
1202
1256
|
return self->state.stroke_width;
|
1203
1257
|
}
|
1204
1258
|
|
1259
|
+
void
|
1260
|
+
Painter::set_stroke_cap (CapType cap)
|
1261
|
+
{
|
1262
|
+
self->state.stroke_cap = cap;
|
1263
|
+
}
|
1264
|
+
|
1265
|
+
CapType
|
1266
|
+
Painter::stroke_cap () const
|
1267
|
+
{
|
1268
|
+
return self->state.stroke_cap;
|
1269
|
+
}
|
1270
|
+
|
1271
|
+
void
|
1272
|
+
Painter::set_stroke_join (JoinType join)
|
1273
|
+
{
|
1274
|
+
self->state.stroke_join = join;
|
1275
|
+
}
|
1276
|
+
|
1277
|
+
JoinType
|
1278
|
+
Painter::stroke_join () const
|
1279
|
+
{
|
1280
|
+
return self->state.stroke_join;
|
1281
|
+
}
|
1282
|
+
|
1283
|
+
void
|
1284
|
+
Painter::set_miter_limit (coord limit)
|
1285
|
+
{
|
1286
|
+
self->state.miter_limit = limit;
|
1287
|
+
}
|
1288
|
+
|
1289
|
+
coord
|
1290
|
+
Painter::miter_limit () const
|
1291
|
+
{
|
1292
|
+
return self->state.miter_limit;
|
1293
|
+
}
|
1294
|
+
|
1205
1295
|
void
|
1206
1296
|
Painter::set_nsegment (int nsegment)
|
1207
1297
|
{
|
@@ -1279,7 +1369,7 @@ namespace Rays
|
|
1279
1369
|
void
|
1280
1370
|
Painter::push_state ()
|
1281
1371
|
{
|
1282
|
-
self->state_stack.
|
1372
|
+
self->state_stack.emplace_back(self->state);
|
1283
1373
|
}
|
1284
1374
|
|
1285
1375
|
void
|
@@ -1370,7 +1460,7 @@ namespace Rays
|
|
1370
1460
|
void
|
1371
1461
|
Painter::push_matrix ()
|
1372
1462
|
{
|
1373
|
-
self->position_matrix_stack.
|
1463
|
+
self->position_matrix_stack.emplace_back(self->position_matrix);
|
1374
1464
|
}
|
1375
1465
|
|
1376
1466
|
void
|
data/src/polygon.cpp
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
#include <assert.h>
|
6
6
|
#include <utility>
|
7
7
|
#include <poly2tri.h>
|
8
|
+
#include <Splines.h>
|
8
9
|
#include "xot/util.h"
|
9
10
|
#include "rays/color.h"
|
10
11
|
#include "rays/exception.h"
|
@@ -13,7 +14,7 @@
|
|
13
14
|
#include "painter.h"
|
14
15
|
|
15
16
|
|
16
|
-
|
17
|
+
namespace clip = ClipperLib;
|
17
18
|
|
18
19
|
|
19
20
|
namespace Rays
|
@@ -155,6 +156,10 @@ namespace Rays
|
|
155
156
|
|
156
157
|
if (!polygon || polygon.empty()) return;
|
157
158
|
|
159
|
+
CapType cap = painter->stroke_cap();
|
160
|
+
JoinType join = painter->stroke_join();
|
161
|
+
coord ml = painter->miter_limit();
|
162
|
+
|
158
163
|
bool has_loop = false;
|
159
164
|
for (const auto& polyline : polygon)
|
160
165
|
{
|
@@ -168,7 +173,7 @@ namespace Rays
|
|
168
173
|
}
|
169
174
|
|
170
175
|
Polygon stroke;
|
171
|
-
if (!polyline.expand(&stroke, stroke_width / 2))
|
176
|
+
if (!polyline.expand(&stroke, stroke_width / 2, cap, join, ml))
|
172
177
|
continue;
|
173
178
|
|
174
179
|
Polygon_fill(stroke, painter, color);
|
@@ -177,7 +182,7 @@ namespace Rays
|
|
177
182
|
if (has_loop)
|
178
183
|
{
|
179
184
|
Polygon hole;
|
180
|
-
if (polygon.expand(&hole, -stroke_width))
|
185
|
+
if (polygon.expand(&hole, -stroke_width, cap, join, ml))
|
181
186
|
Polygon_fill(polygon - hole, painter, color);
|
182
187
|
}
|
183
188
|
}
|
@@ -251,11 +256,11 @@ namespace Rays
|
|
251
256
|
|
252
257
|
static void
|
253
258
|
add_polygon_to_clipper (
|
254
|
-
Clipper* clipper, const Polygon& polygon, PolyType type)
|
259
|
+
clip::Clipper* clipper, const Polygon& polygon, clip::PolyType type)
|
255
260
|
{
|
256
261
|
assert(clipper);
|
257
262
|
|
258
|
-
Path path;
|
263
|
+
clip::Path path;
|
259
264
|
for (const auto& line : polygon)
|
260
265
|
{
|
261
266
|
if (!line) continue;
|
@@ -267,42 +272,72 @@ namespace Rays
|
|
267
272
|
}
|
268
273
|
}
|
269
274
|
|
270
|
-
static
|
271
|
-
|
275
|
+
static clip::JoinType
|
276
|
+
get_join_type (JoinType join)
|
277
|
+
{
|
278
|
+
switch (join)
|
279
|
+
{
|
280
|
+
case JOIN_MITER: return clip::jtMiter;
|
281
|
+
case JOIN_ROUND: return clip::jtRound;
|
282
|
+
case JOIN_SQUARE: return clip::jtSquare;
|
283
|
+
default:
|
284
|
+
argument_error(__FILE__, __LINE__, "invalid join type -- %d", join);
|
285
|
+
}
|
286
|
+
|
287
|
+
return clip::jtMiter;// to avoid compiler warning
|
288
|
+
}
|
289
|
+
|
290
|
+
static clip::EndType
|
291
|
+
get_end_type (const Polyline& polyline, CapType cap, bool fill)
|
272
292
|
{
|
273
293
|
if (polyline.loop())
|
274
|
-
return fill ? etClosedPolygon : etClosedLine;
|
275
|
-
else
|
276
|
-
|
294
|
+
return fill ? clip::etClosedPolygon : clip::etClosedLine;
|
295
|
+
else switch (cap)
|
296
|
+
{
|
297
|
+
case CAP_BUTT: return clip::etOpenButt;
|
298
|
+
case CAP_ROUND: return clip::etOpenRound;
|
299
|
+
case CAP_SQUARE: return clip::etOpenSquare;
|
300
|
+
default:
|
301
|
+
argument_error(__FILE__, __LINE__, "invalid cap type -- %d", cap);
|
302
|
+
}
|
303
|
+
|
304
|
+
return clip::etOpenButt;// to avoid compiler warning
|
277
305
|
}
|
278
306
|
|
279
307
|
static bool
|
280
308
|
add_polyline_to_offsetter (
|
281
|
-
ClipperOffset* offsetter, const Polyline& polyline,
|
309
|
+
clip::ClipperOffset* offsetter, const Polyline& polyline,
|
310
|
+
CapType cap, JoinType join, bool hole, bool fill)
|
282
311
|
{
|
283
312
|
assert(offsetter);
|
284
313
|
|
285
314
|
if (!polyline) return false;
|
286
315
|
|
287
|
-
Path path;
|
316
|
+
clip::Path path;
|
288
317
|
Polyline_get_path(&path, polyline, hole);
|
289
|
-
offsetter->AddPath(
|
318
|
+
offsetter->AddPath(
|
319
|
+
path, get_join_type(join), get_end_type(polyline, cap, fill));
|
290
320
|
return true;
|
291
321
|
}
|
292
322
|
|
293
323
|
static bool
|
294
|
-
add_polygon_to_offsetter (
|
324
|
+
add_polygon_to_offsetter (
|
325
|
+
clip::ClipperOffset* offsetter, const Polygon& polygon,
|
326
|
+
CapType cap, JoinType join)
|
295
327
|
{
|
296
328
|
assert(offsetter);
|
297
329
|
|
298
330
|
bool added = false;
|
299
331
|
for (const auto& line : polygon.self->lines)
|
300
|
-
|
332
|
+
{
|
333
|
+
added |= add_polyline_to_offsetter(
|
334
|
+
offsetter, line, cap, join, line.hole(), true);
|
335
|
+
}
|
301
336
|
return added;
|
302
337
|
}
|
303
338
|
|
304
339
|
static bool
|
305
|
-
append_outline (Polygon* polygon, const PolyNode& node)
|
340
|
+
append_outline (Polygon* polygon, const clip::PolyNode& node)
|
306
341
|
{
|
307
342
|
assert(polygon);
|
308
343
|
|
@@ -319,7 +354,7 @@ namespace Rays
|
|
319
354
|
}
|
320
355
|
|
321
356
|
static void
|
322
|
-
append_hole (Polygon* polygon, const PolyNode& node)
|
357
|
+
append_hole (Polygon* polygon, const clip::PolyNode& node)
|
323
358
|
{
|
324
359
|
assert(polygon);
|
325
360
|
|
@@ -338,7 +373,7 @@ namespace Rays
|
|
338
373
|
}
|
339
374
|
|
340
375
|
static void
|
341
|
-
get_polygon (Polygon* polygon, const PolyNode& node)
|
376
|
+
get_polygon (Polygon* polygon, const clip::PolyNode& node)
|
342
377
|
{
|
343
378
|
assert(polygon);
|
344
379
|
|
@@ -350,15 +385,16 @@ namespace Rays
|
|
350
385
|
}
|
351
386
|
|
352
387
|
static Polygon
|
353
|
-
clip_polygons (
|
388
|
+
clip_polygons (
|
389
|
+
const Polygon& subject, const Polygon& clip, clip::ClipType type)
|
354
390
|
{
|
355
|
-
Clipper c;
|
391
|
+
clip::Clipper c;
|
356
392
|
c.StrictlySimple(true);
|
357
393
|
|
358
|
-
add_polygon_to_clipper(&c, subject, ptSubject);
|
359
|
-
add_polygon_to_clipper(&c, clip, ptClip);
|
394
|
+
add_polygon_to_clipper(&c, subject, clip::ptSubject);
|
395
|
+
add_polygon_to_clipper(&c, clip, clip::ptClip);
|
360
396
|
|
361
|
-
PolyTree tree;
|
397
|
+
clip::PolyTree tree;
|
362
398
|
c.Execute(type, tree);
|
363
399
|
assert(tree.Contour.empty());
|
364
400
|
|
@@ -369,16 +405,19 @@ namespace Rays
|
|
369
405
|
}
|
370
406
|
|
371
407
|
static bool
|
372
|
-
expand_polygon (
|
408
|
+
expand_polygon (
|
409
|
+
Polygon* result, const Polygon& polygon,
|
410
|
+
coord width, CapType cap, JoinType join, coord miter_limit)
|
373
411
|
{
|
374
412
|
if (width == 0)
|
375
413
|
return false;
|
376
414
|
|
377
|
-
ClipperOffset co;
|
378
|
-
|
415
|
+
clip::ClipperOffset co;
|
416
|
+
co.MiterLimit = miter_limit;
|
417
|
+
if (!add_polygon_to_offsetter(&co, polygon, cap, join))
|
379
418
|
return false;
|
380
419
|
|
381
|
-
PolyTree tree;
|
420
|
+
clip::PolyTree tree;
|
382
421
|
co.Execute(tree, to_clipper(width));
|
383
422
|
assert(tree.Contour.empty());
|
384
423
|
|
@@ -387,16 +426,19 @@ namespace Rays
|
|
387
426
|
}
|
388
427
|
|
389
428
|
bool
|
390
|
-
Polyline_expand (
|
429
|
+
Polyline_expand (
|
430
|
+
Polygon* result, const Polyline& polyline,
|
431
|
+
coord width, CapType cap, JoinType join, coord miter_limit)
|
391
432
|
{
|
392
433
|
if (width == 0)
|
393
434
|
return false;
|
394
435
|
|
395
|
-
ClipperOffset co;
|
396
|
-
|
436
|
+
clip::ClipperOffset co;
|
437
|
+
co.MiterLimit = miter_limit;
|
438
|
+
if (!add_polyline_to_offsetter(&co, polyline, cap, join, false, false))
|
397
439
|
return false;
|
398
440
|
|
399
|
-
PolyTree tree;
|
441
|
+
clip::PolyTree tree;
|
400
442
|
co.Execute(tree, to_clipper(width));
|
401
443
|
assert(tree.Contour.empty());
|
402
444
|
|
@@ -865,6 +907,128 @@ namespace Rays
|
|
865
907
|
hole_radius * 2, angle_from, angle_to, nsegment);
|
866
908
|
}
|
867
909
|
|
910
|
+
static inline const SplineLib::Vec3f&
|
911
|
+
to_splinelib (const Point& val)
|
912
|
+
{
|
913
|
+
return *(const SplineLib::Vec3f*) &val;
|
914
|
+
}
|
915
|
+
|
916
|
+
static inline const Point&
|
917
|
+
to_rays (const SplineLib::Vec3f& val)
|
918
|
+
{
|
919
|
+
return *(const Point*) &val;
|
920
|
+
}
|
921
|
+
|
922
|
+
enum SplineType {BEZIER, HERMITE, CATMULLROM};
|
923
|
+
|
924
|
+
typedef SplineLib::cSpline3 (*SplineFun) (
|
925
|
+
const SplineLib::Vec3f&, const SplineLib::Vec3f&,
|
926
|
+
const SplineLib::Vec3f&, const SplineLib::Vec3f&);
|
927
|
+
|
928
|
+
static SplineFun
|
929
|
+
get_spline_fun (SplineType type)
|
930
|
+
{
|
931
|
+
switch (type)
|
932
|
+
{
|
933
|
+
case BEZIER: return SplineLib::BezierSpline;
|
934
|
+
case HERMITE: return SplineLib::HermiteSpline;
|
935
|
+
case CATMULLROM: return SplineLib::CatmullRomSpline;
|
936
|
+
default:
|
937
|
+
argument_error(__FILE__, __LINE__, "unknown spline type %d.", type);
|
938
|
+
}
|
939
|
+
}
|
940
|
+
|
941
|
+
static Polygon
|
942
|
+
create_spline (
|
943
|
+
SplineType type,
|
944
|
+
const Point* points, size_t size, bool loop,
|
945
|
+
uint nsegment = 16)
|
946
|
+
{
|
947
|
+
if (size % 4 != 0)
|
948
|
+
argument_error(__FILE__, __LINE__);
|
949
|
+
|
950
|
+
size_t count = size / 4;
|
951
|
+
auto spline_fun = get_spline_fun(type);
|
952
|
+
|
953
|
+
std::vector<Point> result;
|
954
|
+
result.reserve(nsegment * count);
|
955
|
+
for (size_t i = 0; i < count; ++i)
|
956
|
+
{
|
957
|
+
SplineLib::cSpline3 spline = spline_fun(
|
958
|
+
to_splinelib(points[i * 4 + 0]),
|
959
|
+
to_splinelib(points[i * 4 + 1]),
|
960
|
+
to_splinelib(points[i * 4 + 2]),
|
961
|
+
to_splinelib(points[i * 4 + 3]));
|
962
|
+
for (uint j = 0; j <= nsegment; ++j)
|
963
|
+
{
|
964
|
+
float t = (float) j / nsegment;
|
965
|
+
result.emplace_back(to_rays(SplineLib::Position(spline, t)));
|
966
|
+
}
|
967
|
+
}
|
968
|
+
|
969
|
+
return create_line(&result[0], result.size(), loop);
|
970
|
+
}
|
971
|
+
|
972
|
+
Polygon
|
973
|
+
create_curve (
|
974
|
+
coord x1, coord y1, coord x2, coord y2,
|
975
|
+
coord x3, coord y3, coord x4, coord y4,
|
976
|
+
bool loop)
|
977
|
+
{
|
978
|
+
const Point points[] = {
|
979
|
+
Point(x1, y1),
|
980
|
+
Point(x2, y2),
|
981
|
+
Point(x3, y3),
|
982
|
+
Point(x4, y4)
|
983
|
+
};
|
984
|
+
return create_spline(CATMULLROM, points, 4, loop);
|
985
|
+
}
|
986
|
+
|
987
|
+
Polygon
|
988
|
+
create_curve (
|
989
|
+
const Point& p1, const Point& p2, const Point& p3, const Point& p4,
|
990
|
+
bool loop)
|
991
|
+
{
|
992
|
+
const Point points[] = {p1, p2, p3, p4};
|
993
|
+
return create_spline(CATMULLROM, points, 4, loop);
|
994
|
+
}
|
995
|
+
|
996
|
+
Polygon
|
997
|
+
create_curve (const Point* points, size_t size, bool loop)
|
998
|
+
{
|
999
|
+
return create_spline(CATMULLROM, points, size, loop);
|
1000
|
+
}
|
1001
|
+
|
1002
|
+
Polygon
|
1003
|
+
create_bezier (
|
1004
|
+
coord x1, coord y1, coord x2, coord y2,
|
1005
|
+
coord x3, coord y3, coord x4, coord y4,
|
1006
|
+
bool loop)
|
1007
|
+
{
|
1008
|
+
const Point points[] = {
|
1009
|
+
Point(x1, y1),
|
1010
|
+
Point(x2, y2),
|
1011
|
+
Point(x3, y3),
|
1012
|
+
Point(x4, y4)
|
1013
|
+
};
|
1014
|
+
return create_spline(BEZIER, points, 4, loop);
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
Polygon
|
1018
|
+
create_bezier (
|
1019
|
+
const Point& p1, const Point& p2, const Point& p3, const Point& p4,
|
1020
|
+
bool loop)
|
1021
|
+
{
|
1022
|
+
const Point points[] = {p1, p2, p3, p4};
|
1023
|
+
return create_spline(BEZIER, points, 4, loop);
|
1024
|
+
}
|
1025
|
+
|
1026
|
+
Polygon
|
1027
|
+
create_bezier (const Point* points, size_t size, bool loop)
|
1028
|
+
{
|
1029
|
+
return create_spline(BEZIER, points, size, loop);
|
1030
|
+
}
|
1031
|
+
|
868
1032
|
void
|
869
1033
|
Polygon_fill (const Polygon& polygon, Painter* painter, const Color& color)
|
870
1034
|
{
|
@@ -935,9 +1099,11 @@ namespace Rays
|
|
935
1099
|
}
|
936
1100
|
|
937
1101
|
bool
|
938
|
-
Polygon::expand (
|
1102
|
+
Polygon::expand (
|
1103
|
+
Polygon* result,
|
1104
|
+
coord width, CapType cap, JoinType join, coord miter_limit) const
|
939
1105
|
{
|
940
|
-
return expand_polygon(result, *this, width);
|
1106
|
+
return expand_polygon(result, *this, width, cap, join, miter_limit);
|
941
1107
|
}
|
942
1108
|
|
943
1109
|
Bounds
|
@@ -1029,7 +1195,7 @@ namespace Rays
|
|
1029
1195
|
{
|
1030
1196
|
if (lhs.self == rhs.self) return Polygon();
|
1031
1197
|
|
1032
|
-
return clip_polygons(lhs, rhs, ctDifference);
|
1198
|
+
return clip_polygons(lhs, rhs, clip::ctDifference);
|
1033
1199
|
}
|
1034
1200
|
|
1035
1201
|
Polygon
|
@@ -1037,7 +1203,7 @@ namespace Rays
|
|
1037
1203
|
{
|
1038
1204
|
if (lhs.self == rhs.self) return lhs;
|
1039
1205
|
|
1040
|
-
return clip_polygons(lhs, rhs, ctIntersection);
|
1206
|
+
return clip_polygons(lhs, rhs, clip::ctIntersection);
|
1041
1207
|
}
|
1042
1208
|
|
1043
1209
|
Polygon
|
@@ -1045,7 +1211,7 @@ namespace Rays
|
|
1045
1211
|
{
|
1046
1212
|
if (lhs.self == rhs.self) return lhs;
|
1047
1213
|
|
1048
|
-
return clip_polygons(lhs, rhs, ctUnion);
|
1214
|
+
return clip_polygons(lhs, rhs, clip::ctUnion);
|
1049
1215
|
}
|
1050
1216
|
|
1051
1217
|
Polygon
|
@@ -1053,7 +1219,7 @@ namespace Rays
|
|
1053
1219
|
{
|
1054
1220
|
if (lhs.self == rhs.self) return Polygon();
|
1055
1221
|
|
1056
|
-
return clip_polygons(lhs, rhs, ctXor);
|
1222
|
+
return clip_polygons(lhs, rhs, clip::ctXor);
|
1057
1223
|
}
|
1058
1224
|
|
1059
1225
|
|