rays 0.1.46 → 0.1.47
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/bitmap.cpp +258 -0
- data/.doc/ext/rays/defs.cpp +3 -3
- data/.doc/ext/rays/painter.cpp +38 -3
- data/.doc/ext/rays/polygon.cpp +81 -4
- data/.doc/ext/rays/rays.cpp +11 -11
- data/.github/workflows/test.yml +0 -1
- data/ChangeLog.md +15 -0
- data/Rakefile +4 -4
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +259 -0
- data/ext/rays/defs.cpp +3 -3
- data/ext/rays/painter.cpp +45 -8
- data/ext/rays/polygon.cpp +89 -4
- data/ext/rays/rays.cpp +11 -11
- data/include/rays/defs.h +26 -0
- data/include/rays/matrix.h +2 -0
- data/include/rays/painter.h +15 -1
- data/include/rays/polygon.h +6 -1
- data/include/rays/polyline.h +4 -0
- data/lib/rays/painter.rb +1 -1
- data/lib/rays/polygon.rb +36 -7
- data/rays.gemspec +2 -2
- data/src/color_space.cpp +2 -2
- data/src/matrix.cpp +8 -0
- data/src/painter.cpp +72 -5
- data/src/polygon.cpp +385 -91
- data/src/polyline.cpp +33 -18
- data/src/polyline.h +2 -2
- data/test/test_bitmap.rb +7 -0
- data/test/test_polygon.rb +2 -2
- data/test/test_polygon_line.rb +5 -5
- data/test/test_polyline.rb +7 -7
- metadata +6 -6
data/lib/rays/polygon.rb
CHANGED
@@ -24,29 +24,58 @@ module Rays
|
|
24
24
|
!(self & obj).empty?
|
25
25
|
end
|
26
26
|
|
27
|
-
def self.
|
28
|
-
|
27
|
+
def self.points(*args)
|
28
|
+
points! args
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.lines(*args)
|
32
|
+
lines! args
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.line_strip(*args, loop: false)
|
36
|
+
line_strip! args, loop
|
29
37
|
end
|
30
38
|
|
31
39
|
def self.rect(
|
32
|
-
*args, round: nil, lt: nil, rt: nil, lb: nil, rb: nil,
|
40
|
+
*args, round: nil, lt: nil, rt: nil, lb: nil, rb: nil,
|
41
|
+
nsegment: nil)
|
33
42
|
|
34
|
-
|
43
|
+
rect! args, round, lt, rt, lb, rb, nsegment
|
35
44
|
end
|
36
45
|
|
37
46
|
def self.ellipse(
|
38
47
|
*args, center: nil, radius: nil, hole: nil, from: nil, to: nil,
|
39
48
|
nsegment: nil)
|
40
49
|
|
41
|
-
|
50
|
+
ellipse! args, center, radius, hole, from, to, nsegment
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.triangles(*args, loop: true)
|
54
|
+
triangles! args, loop
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.triangle_strip(*args)
|
58
|
+
triangle_strip! args
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.triangle_fan(*args)
|
62
|
+
triangle_fan! args
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.quads(*args, loop: true)
|
66
|
+
quads! args, loop
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.quad_strip(*args)
|
70
|
+
quad_strip! args
|
42
71
|
end
|
43
72
|
|
44
73
|
def self.curve(*args, loop: false)
|
45
|
-
|
74
|
+
curve! args, loop
|
46
75
|
end
|
47
76
|
|
48
77
|
def self.bezier(*args, loop: false)
|
49
|
-
|
78
|
+
bezier! args, loop
|
50
79
|
end
|
51
80
|
|
52
81
|
end# Polygon
|
data/rays.gemspec
CHANGED
@@ -25,8 +25,8 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.platform = Gem::Platform::RUBY
|
26
26
|
s.required_ruby_version = '>= 3.0.0'
|
27
27
|
|
28
|
-
s.add_runtime_dependency 'xot', '~> 0.1.
|
29
|
-
s.add_runtime_dependency 'rucy', '~> 0.1.
|
28
|
+
s.add_runtime_dependency 'xot', '~> 0.1.41'
|
29
|
+
s.add_runtime_dependency 'rucy', '~> 0.1.42'
|
30
30
|
|
31
31
|
s.files = `git ls-files`.split $/
|
32
32
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
data/src/color_space.cpp
CHANGED
@@ -70,8 +70,8 @@ namespace Rays
|
|
70
70
|
static const int BPPS[] =
|
71
71
|
{
|
72
72
|
0, // UNKNOWN
|
73
|
-
8, 16,
|
74
|
-
8, 16,
|
73
|
+
8, 16, 24, 32, 32, // GRAY
|
74
|
+
8, 16, 24, 32, 32, // ALPHA
|
75
75
|
24, 32, 32, 32, 32, // RGB(A)
|
76
76
|
24, 32, 32, 32, 32, // BGR(A)
|
77
77
|
96, 128, 128, // RGB(A) float
|
data/src/matrix.cpp
CHANGED
data/src/painter.cpp
CHANGED
@@ -49,6 +49,8 @@ namespace Rays
|
|
49
49
|
|
50
50
|
coord stroke_width;
|
51
51
|
|
52
|
+
float stroke_outset;
|
53
|
+
|
52
54
|
CapType stroke_cap;
|
53
55
|
|
54
56
|
JoinType stroke_join;
|
@@ -71,6 +73,7 @@ namespace Rays
|
|
71
73
|
colors[FILL] .reset(1, 1);
|
72
74
|
colors[STROKE] .reset(1, 0);
|
73
75
|
stroke_width = 0;
|
76
|
+
stroke_outset = 0;
|
74
77
|
stroke_cap = CAP_DEFAULT;
|
75
78
|
stroke_join = JOIN_DEFAULT;
|
76
79
|
miter_limit = JOIN_DEFAULT_MITER_LIMIT;
|
@@ -797,25 +800,77 @@ namespace Rays
|
|
797
800
|
#endif
|
798
801
|
}
|
799
802
|
|
800
|
-
void
|
801
|
-
|
803
|
+
static void
|
804
|
+
draw_polygon (
|
805
|
+
Painter* painter, const Polygon& polygon,
|
806
|
+
coord x, coord y, coord width = 0, coord height = 0, bool resize = false)
|
802
807
|
{
|
808
|
+
Painter::Data* self = painter->self.get();
|
809
|
+
|
803
810
|
if (!self->painting)
|
804
811
|
invalid_state_error(__FILE__, __LINE__, "painting flag should be true.");
|
805
812
|
|
806
813
|
if (!self->state.has_color())
|
807
814
|
return;
|
808
815
|
|
816
|
+
bool translate = x != 0 || y != 0;
|
817
|
+
Matrix matrix(nullptr);
|
818
|
+
bool backup = false;
|
819
|
+
|
820
|
+
if (translate || resize)
|
821
|
+
{
|
822
|
+
matrix = self->position_matrix;
|
823
|
+
backup = true;
|
824
|
+
|
825
|
+
if (translate)
|
826
|
+
self->position_matrix.translate(x, y);
|
827
|
+
|
828
|
+
if (resize)
|
829
|
+
{
|
830
|
+
const Bounds& b = polygon.bounds();
|
831
|
+
self->position_matrix.scale(width / b.width, height / b.height);
|
832
|
+
}
|
833
|
+
}
|
834
|
+
|
809
835
|
Color color;
|
810
836
|
|
811
837
|
if (self->get_color(&color, FILL))
|
812
838
|
{
|
813
|
-
Polygon_fill(polygon,
|
814
|
-
debug_draw_triangulation(
|
839
|
+
Polygon_fill(polygon, painter, color);
|
840
|
+
debug_draw_triangulation(painter, polygon, color);
|
815
841
|
}
|
816
842
|
|
817
843
|
if (self->get_color(&color, STROKE))
|
818
|
-
Polygon_stroke(polygon,
|
844
|
+
Polygon_stroke(polygon, painter, color);
|
845
|
+
|
846
|
+
if (backup)
|
847
|
+
self->position_matrix = matrix;
|
848
|
+
}
|
849
|
+
|
850
|
+
void
|
851
|
+
Painter::polygon (const Polygon& polygon, const coord x, coord y)
|
852
|
+
{
|
853
|
+
draw_polygon(this, polygon, x, y);
|
854
|
+
}
|
855
|
+
|
856
|
+
void
|
857
|
+
Painter::polygon (const Polygon& polygon, const Point& position)
|
858
|
+
{
|
859
|
+
draw_polygon(this, polygon, position.x, position.y);
|
860
|
+
}
|
861
|
+
|
862
|
+
void
|
863
|
+
Painter::polygon (
|
864
|
+
const Polygon& polygon, coord x, coord y, coord width, coord height)
|
865
|
+
{
|
866
|
+
draw_polygon(this, polygon, x, y, width, height, true);
|
867
|
+
}
|
868
|
+
|
869
|
+
void
|
870
|
+
Painter::polygon (const Polygon& polygon, const Bounds& bounds)
|
871
|
+
{
|
872
|
+
draw_polygon(
|
873
|
+
this, polygon, bounds.x, bounds.y, bounds.width, bounds.height, true);
|
819
874
|
}
|
820
875
|
|
821
876
|
void
|
@@ -1310,6 +1365,18 @@ namespace Rays
|
|
1310
1365
|
return self->state.stroke_width;
|
1311
1366
|
}
|
1312
1367
|
|
1368
|
+
void
|
1369
|
+
Painter::set_stroke_outset (float outset)
|
1370
|
+
{
|
1371
|
+
self->state.stroke_outset = outset;
|
1372
|
+
}
|
1373
|
+
|
1374
|
+
float
|
1375
|
+
Painter::stroke_outset () const
|
1376
|
+
{
|
1377
|
+
return self->state.stroke_outset;
|
1378
|
+
}
|
1379
|
+
|
1313
1380
|
void
|
1314
1381
|
Painter::set_stroke_cap (CapType cap)
|
1315
1382
|
{
|