rays 0.1.11 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.doc/ext/rays/bitmap.cpp +22 -76
- data/.doc/ext/rays/bounds.cpp +95 -125
- data/.doc/ext/rays/camera.cpp +88 -0
- data/.doc/ext/rays/color.cpp +223 -45
- data/.doc/ext/rays/color_space.cpp +146 -46
- data/.doc/ext/rays/defs.cpp +183 -0
- data/.doc/ext/rays/font.cpp +69 -21
- data/.doc/ext/rays/image.cpp +26 -37
- data/.doc/ext/rays/matrix.cpp +186 -29
- data/.doc/ext/rays/native.cpp +14 -8
- data/.doc/ext/rays/noise.cpp +53 -0
- data/.doc/ext/rays/painter.cpp +187 -292
- data/.doc/ext/rays/point.cpp +96 -77
- data/.doc/ext/rays/polygon.cpp +313 -0
- data/.doc/ext/rays/polygon_line.cpp +96 -0
- data/.doc/ext/rays/polyline.cpp +167 -0
- data/.doc/ext/rays/rays.cpp +103 -12
- data/.doc/ext/rays/shader.cpp +83 -9
- data/LICENSE +21 -0
- data/README.md +1 -1
- data/Rakefile +24 -9
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +22 -80
- data/ext/rays/bounds.cpp +100 -128
- data/ext/rays/camera.cpp +94 -0
- data/ext/rays/color.cpp +231 -51
- data/ext/rays/color_space.cpp +149 -47
- data/ext/rays/defs.cpp +183 -0
- data/ext/rays/defs.h +26 -2
- data/ext/rays/extconf.rb +2 -3
- data/ext/rays/font.cpp +74 -24
- data/ext/rays/image.cpp +28 -40
- data/ext/rays/matrix.cpp +198 -30
- data/ext/rays/native.cpp +14 -8
- data/ext/rays/noise.cpp +55 -0
- data/ext/rays/painter.cpp +203 -298
- data/ext/rays/point.cpp +105 -81
- data/ext/rays/polygon.cpp +329 -0
- data/ext/rays/polygon_line.cpp +99 -0
- data/ext/rays/polyline.cpp +176 -0
- data/ext/rays/rays.cpp +103 -13
- data/ext/rays/shader.cpp +84 -9
- data/include/rays.h +10 -2
- data/include/rays/bitmap.h +14 -26
- data/include/rays/bounds.h +21 -4
- data/include/rays/camera.h +49 -0
- data/include/rays/color.h +25 -14
- data/include/rays/color_space.h +15 -10
- data/include/rays/coord.h +114 -0
- data/include/rays/debug.h +22 -0
- data/include/rays/defs.h +36 -0
- data/include/rays/exception.h +6 -2
- data/include/rays/font.h +4 -4
- data/include/rays/image.h +12 -18
- data/include/rays/matrix.h +50 -24
- data/include/rays/noise.h +42 -0
- data/include/rays/opengl.h +2 -50
- data/include/rays/painter.h +89 -93
- data/include/rays/point.h +44 -51
- data/include/rays/polygon.h +198 -0
- data/include/rays/polyline.h +71 -0
- data/include/rays/rays.h +3 -0
- data/include/rays/ruby.h +7 -1
- data/include/rays/ruby/bounds.h +1 -1
- data/include/rays/ruby/camera.h +41 -0
- data/include/rays/ruby/color.h +1 -1
- data/include/rays/ruby/color_space.h +1 -1
- data/include/rays/ruby/font.h +1 -1
- data/include/rays/ruby/matrix.h +1 -1
- data/include/rays/ruby/point.h +1 -1
- data/include/rays/ruby/polygon.h +52 -0
- data/include/rays/ruby/polyline.h +41 -0
- data/include/rays/ruby/rays.h +8 -0
- data/include/rays/ruby/shader.h +1 -1
- data/include/rays/shader.h +36 -8
- data/lib/rays.rb +7 -2
- data/lib/rays/bitmap.rb +0 -15
- data/lib/rays/bounds.rb +17 -23
- data/lib/rays/camera.rb +21 -0
- data/lib/rays/color.rb +20 -47
- data/lib/rays/color_space.rb +13 -13
- data/lib/rays/image.rb +3 -7
- data/lib/rays/matrix.rb +28 -0
- data/lib/rays/module.rb +4 -19
- data/lib/rays/painter.rb +78 -93
- data/lib/rays/point.rb +13 -21
- data/lib/rays/polygon.rb +58 -0
- data/lib/rays/polygon_line.rb +36 -0
- data/lib/rays/polyline.rb +32 -0
- data/lib/rays/shader.rb +20 -1
- data/rays.gemspec +5 -7
- data/src/bitmap.h +36 -0
- data/src/bounds.cpp +74 -11
- data/src/color.cpp +58 -23
- data/src/color_space.cpp +52 -34
- data/src/color_space.h +22 -0
- data/src/coord.cpp +170 -0
- data/src/coord.h +35 -0
- data/src/font.cpp +118 -0
- data/src/font.h +64 -0
- data/src/frame_buffer.cpp +37 -71
- data/src/frame_buffer.h +4 -4
- data/src/image.cpp +172 -98
- data/src/image.h +25 -0
- data/src/ios/bitmap.h +21 -0
- data/src/ios/bitmap.mm +129 -110
- data/src/ios/camera.mm +236 -0
- data/src/ios/font.mm +50 -62
- data/src/ios/helper.h +2 -2
- data/src/ios/opengl.mm +19 -4
- data/src/ios/rays.mm +3 -0
- data/src/matrix.cpp +111 -26
- data/src/matrix.h +30 -0
- data/src/noise.cpp +74 -0
- data/src/opengl.cpp +9 -27
- data/src/opengl.h +37 -0
- data/src/osx/bitmap.h +21 -0
- data/src/osx/bitmap.mm +129 -110
- data/src/osx/camera.mm +236 -0
- data/src/osx/font.mm +49 -62
- data/src/osx/helper.h +2 -2
- data/src/osx/opengl.mm +19 -83
- data/src/osx/rays.mm +3 -0
- data/src/painter.cpp +845 -671
- data/src/painter.h +24 -0
- data/src/point.cpp +140 -119
- data/src/polygon.cpp +1266 -0
- data/src/polygon.h +32 -0
- data/src/polyline.cpp +160 -0
- data/src/polyline.h +69 -0
- data/src/render_buffer.cpp +11 -4
- data/src/render_buffer.h +2 -2
- data/src/shader.cpp +163 -106
- data/src/shader.h +38 -0
- data/src/shader_program.cpp +533 -0
- data/src/{program.h → shader_program.h} +28 -16
- data/src/shader_source.cpp +140 -0
- data/src/shader_source.h +52 -0
- data/src/texture.cpp +136 -160
- data/src/texture.h +65 -0
- data/src/win32/bitmap.cpp +62 -52
- data/src/win32/font.cpp +11 -13
- data/src/win32/font.h +24 -0
- data/src/win32/gdi.h +6 -6
- data/test/helper.rb +0 -3
- data/test/test_bitmap.rb +31 -7
- data/test/test_bounds.rb +36 -0
- data/test/test_color.rb +59 -19
- data/test/test_color_space.rb +95 -0
- data/test/test_font.rb +5 -0
- data/test/test_image.rb +24 -20
- data/test/test_matrix.rb +106 -0
- data/test/test_painter.rb +157 -51
- data/test/test_painter_shape.rb +102 -0
- data/test/test_point.rb +29 -0
- data/test/test_polygon.rb +234 -0
- data/test/test_polygon_line.rb +167 -0
- data/test/test_polyline.rb +171 -0
- data/test/test_shader.rb +9 -9
- metadata +102 -70
- data/.doc/ext/rays/texture.cpp +0 -138
- data/ext/rays/texture.cpp +0 -149
- data/include/rays/ruby/texture.h +0 -41
- data/include/rays/texture.h +0 -71
- data/lib/rays/texture.rb +0 -24
- data/src/program.cpp +0 -648
- data/test/test_texture.rb +0 -27
data/include/rays/point.h
CHANGED
@@ -4,105 +4,98 @@
|
|
4
4
|
#define __RAYS_POINT_H__
|
5
5
|
|
6
6
|
|
7
|
-
#include <rays/
|
7
|
+
#include <rays/coord.h>
|
8
8
|
|
9
9
|
|
10
10
|
namespace Rays
|
11
11
|
{
|
12
12
|
|
13
13
|
|
14
|
-
struct
|
14
|
+
struct Point : public Coord3
|
15
15
|
{
|
16
16
|
|
17
|
-
|
18
|
-
{
|
19
|
-
struct {coord x, y;};
|
20
|
-
coord array[2];
|
21
|
-
};
|
17
|
+
typedef Point This;
|
22
18
|
|
23
|
-
|
19
|
+
typedef Coord3 Super;
|
24
20
|
|
25
|
-
|
21
|
+
Point (coord value = 0);
|
26
22
|
|
27
|
-
|
23
|
+
Point (coord x, coord y, coord z = 0);
|
28
24
|
|
29
|
-
|
25
|
+
This dup () const;
|
30
26
|
|
31
|
-
|
27
|
+
This& reset (coord value = 0);
|
32
28
|
|
29
|
+
This& reset (coord x, coord y, coord z = 0);
|
33
30
|
|
34
|
-
|
35
|
-
{
|
31
|
+
This& move_to (coord x, coord y, coord z = 0);
|
36
32
|
|
37
|
-
|
38
|
-
{
|
39
|
-
struct {coord x, y, z;};
|
40
|
-
coord array[3];
|
41
|
-
};
|
33
|
+
This& move_to (const This& point);
|
42
34
|
|
43
|
-
|
35
|
+
This& move_by (coord x, coord y, coord z = 0);
|
44
36
|
|
45
|
-
|
37
|
+
This& move_by (const This& point);
|
46
38
|
|
47
|
-
|
39
|
+
void rotate (float degree);
|
48
40
|
|
49
|
-
|
41
|
+
coord length () const;
|
50
42
|
|
51
|
-
|
43
|
+
This normal () const;
|
52
44
|
|
45
|
+
void normalize ();
|
53
46
|
|
54
|
-
|
55
|
-
{
|
47
|
+
This operator - () const;
|
56
48
|
|
57
|
-
|
49
|
+
This& operator += (coord rhs);
|
58
50
|
|
59
|
-
|
51
|
+
This& operator += (const This& rhs);
|
60
52
|
|
61
|
-
|
53
|
+
This& operator -= (coord rhs);
|
62
54
|
|
63
|
-
|
55
|
+
This& operator -= (const This& rhs);
|
64
56
|
|
65
|
-
|
57
|
+
This& operator *= (coord rhs);
|
66
58
|
|
67
|
-
|
59
|
+
This& operator *= (const This& rhs);
|
68
60
|
|
69
|
-
|
61
|
+
This& operator /= (coord rhs);
|
70
62
|
|
71
|
-
|
63
|
+
This& operator /= (const This& rhs);
|
72
64
|
|
73
|
-
|
65
|
+
friend bool operator == (const This& lhs, const This& rhs);
|
74
66
|
|
75
|
-
|
67
|
+
friend bool operator != (const This& lhs, const This& rhs);
|
76
68
|
|
77
|
-
|
69
|
+
friend This operator + (coord lhs, const This& rhs);
|
78
70
|
|
79
|
-
|
71
|
+
friend This operator + (const This& lhs, coord rhs);
|
80
72
|
|
81
|
-
|
73
|
+
friend This operator + (const This& lhs, const This& rhs);
|
82
74
|
|
83
|
-
|
75
|
+
friend This operator - (coord lhs, const This& rhs);
|
84
76
|
|
85
|
-
|
77
|
+
friend This operator - (const This& lhs, coord rhs);
|
86
78
|
|
87
|
-
|
79
|
+
friend This operator - (const This& lhs, const This& rhs);
|
88
80
|
|
89
|
-
|
81
|
+
friend This operator * (coord lhs, const This& rhs);
|
90
82
|
|
91
|
-
friend
|
83
|
+
friend This operator * (const This& lhs, coord rhs);
|
92
84
|
|
93
|
-
friend
|
85
|
+
friend This operator * (const This& lhs, const This& rhs);
|
94
86
|
|
95
|
-
friend
|
87
|
+
friend This operator / (coord lhs, const This& rhs);
|
96
88
|
|
97
|
-
friend
|
89
|
+
friend This operator / (const This& lhs, coord rhs);
|
98
90
|
|
99
|
-
friend
|
91
|
+
friend This operator / (const This& lhs, const This& rhs);
|
100
92
|
|
101
|
-
|
93
|
+
};// Point
|
102
94
|
|
103
|
-
friend Point operator / (const Point& lhs, coord rhs);
|
104
95
|
|
105
|
-
|
96
|
+
coord dot (const Point& p1, const Point& p2);
|
97
|
+
|
98
|
+
Point cross (const Point& p1, const Point& p2);
|
106
99
|
|
107
100
|
|
108
101
|
}// Rays
|
@@ -0,0 +1,198 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_POLYGON_H__
|
4
|
+
#define __RAYS_POLYGON_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <vector>
|
8
|
+
#include <xot/pimpl.h>
|
9
|
+
#include <rays/defs.h>
|
10
|
+
#include <rays/bounds.h>
|
11
|
+
#include <rays/polyline.h>
|
12
|
+
|
13
|
+
|
14
|
+
namespace Rays
|
15
|
+
{
|
16
|
+
|
17
|
+
|
18
|
+
class Polygon
|
19
|
+
{
|
20
|
+
|
21
|
+
public:
|
22
|
+
|
23
|
+
struct Line : public Polyline
|
24
|
+
{
|
25
|
+
|
26
|
+
typedef Polyline Super;
|
27
|
+
|
28
|
+
public:
|
29
|
+
|
30
|
+
Line ();
|
31
|
+
|
32
|
+
Line (
|
33
|
+
const Point* points, size_t size,
|
34
|
+
bool loop = true,
|
35
|
+
bool hole = false);
|
36
|
+
|
37
|
+
Line (const Polyline& polyline, bool hole = false);
|
38
|
+
|
39
|
+
bool hole () const;
|
40
|
+
|
41
|
+
operator bool () const;
|
42
|
+
|
43
|
+
bool operator ! () const;
|
44
|
+
|
45
|
+
private:
|
46
|
+
|
47
|
+
bool hole_;
|
48
|
+
|
49
|
+
};// Line
|
50
|
+
|
51
|
+
typedef std::vector<Line> LineList;
|
52
|
+
|
53
|
+
typedef LineList::const_iterator const_iterator;
|
54
|
+
|
55
|
+
Polygon ();
|
56
|
+
|
57
|
+
Polygon (const Point* points, size_t size, bool loop = true);
|
58
|
+
|
59
|
+
Polygon (const Polyline& polyline);
|
60
|
+
|
61
|
+
Polygon (const Line* lines, size_t size);
|
62
|
+
|
63
|
+
~Polygon ();
|
64
|
+
|
65
|
+
bool expand (
|
66
|
+
Polygon* result,
|
67
|
+
coord width,
|
68
|
+
CapType cap = CAP_DEFAULT,
|
69
|
+
JoinType join = JOIN_DEFAULT,
|
70
|
+
coord miter_limit = JOIN_DEFAULT_MITER_LIMIT) const;
|
71
|
+
|
72
|
+
Bounds bounds () const;
|
73
|
+
|
74
|
+
size_t size () const;
|
75
|
+
|
76
|
+
bool empty (bool deep = false) const;
|
77
|
+
|
78
|
+
const_iterator begin () const;
|
79
|
+
|
80
|
+
const_iterator end () const;
|
81
|
+
|
82
|
+
const Line& operator [] (size_t index) const;
|
83
|
+
|
84
|
+
operator bool () const;
|
85
|
+
|
86
|
+
bool operator ! () const;
|
87
|
+
|
88
|
+
friend Polygon operator + (const Polygon& lhs, const Polygon& rhs);
|
89
|
+
|
90
|
+
friend Polygon operator - (const Polygon& lhs, const Polygon& rhs);
|
91
|
+
|
92
|
+
friend Polygon operator & (const Polygon& lhs, const Polygon& rhs);
|
93
|
+
|
94
|
+
friend Polygon operator | (const Polygon& lhs, const Polygon& rhs);
|
95
|
+
|
96
|
+
friend Polygon operator ^ (const Polygon& lhs, const Polygon& rhs);
|
97
|
+
|
98
|
+
struct Data;
|
99
|
+
|
100
|
+
Xot::PSharedImpl<Data> self;
|
101
|
+
|
102
|
+
typedef std::vector<Point> TrianglePointList;
|
103
|
+
|
104
|
+
Polygon (Data* data);
|
105
|
+
|
106
|
+
protected:
|
107
|
+
|
108
|
+
bool triangulate (TrianglePointList* triangles) const;
|
109
|
+
|
110
|
+
};// Polygon
|
111
|
+
|
112
|
+
|
113
|
+
Polygon create_line (coord x1, coord y1, coord x2, coord y2);
|
114
|
+
|
115
|
+
Polygon create_line (const Point& p1, const Point& p2);
|
116
|
+
|
117
|
+
Polygon create_line (const Point* points, size_t size, bool loop = false);
|
118
|
+
|
119
|
+
Polygon create_line (const Polyline& polyline);
|
120
|
+
|
121
|
+
|
122
|
+
Polygon create_rect (
|
123
|
+
coord x, coord y, coord width, coord height,
|
124
|
+
coord round = 0,
|
125
|
+
uint nsegment = 0);
|
126
|
+
|
127
|
+
Polygon create_rect (
|
128
|
+
coord x, coord y, coord width, coord height,
|
129
|
+
coord round_left_top, coord round_right_top,
|
130
|
+
coord round_left_bottom, coord round_right_bottom,
|
131
|
+
uint nsegment = 0);
|
132
|
+
|
133
|
+
Polygon create_rect (
|
134
|
+
const Bounds& bounds,
|
135
|
+
coord round = 0,
|
136
|
+
uint nsegment = 0);
|
137
|
+
|
138
|
+
Polygon create_rect (
|
139
|
+
const Bounds& bounds,
|
140
|
+
coord round_left_top, coord round_right_top,
|
141
|
+
coord round_left_bottom, coord round_right_bottom,
|
142
|
+
uint nsegment = 0);
|
143
|
+
|
144
|
+
|
145
|
+
Polygon create_ellipse (
|
146
|
+
coord x, coord y, coord width, coord height = 0,
|
147
|
+
const Point& hole_size = 0,
|
148
|
+
float angle_from = 0,
|
149
|
+
float angle_to = 360,
|
150
|
+
uint nsegment = 0);
|
151
|
+
|
152
|
+
Polygon create_ellipse (
|
153
|
+
const Bounds& bounds,
|
154
|
+
const Point& hole_size = 0,
|
155
|
+
float angle_from = 0,
|
156
|
+
float angle_to = 360,
|
157
|
+
uint nsegment = 0);
|
158
|
+
|
159
|
+
Polygon create_ellipse (
|
160
|
+
const Point& center, const Point& radius,
|
161
|
+
const Point& hole_radius = 0,
|
162
|
+
float angle_from = 0,
|
163
|
+
float angle_to = 360,
|
164
|
+
uint nsegment = 0);
|
165
|
+
|
166
|
+
|
167
|
+
Polygon create_curve (
|
168
|
+
coord x1, coord y1, coord x2, coord y2,
|
169
|
+
coord x3, coord y3, coord x4, coord y4,
|
170
|
+
bool loop = false);
|
171
|
+
|
172
|
+
Polygon create_curve (
|
173
|
+
const Point& p1, const Point& p2, const Point& p3, const Point& p4,
|
174
|
+
bool loop = false);
|
175
|
+
|
176
|
+
Polygon create_curve (
|
177
|
+
const Point* points, size_t size,
|
178
|
+
bool loop = false);
|
179
|
+
|
180
|
+
|
181
|
+
Polygon create_bezier (
|
182
|
+
coord x1, coord y1, coord x2, coord y2,
|
183
|
+
coord x3, coord y3, coord x4, coord y4,
|
184
|
+
bool loop = false);
|
185
|
+
|
186
|
+
Polygon create_bezier (
|
187
|
+
const Point& p1, const Point& p2, const Point& p3, const Point& p4,
|
188
|
+
bool loop = false);
|
189
|
+
|
190
|
+
Polygon create_bezier (
|
191
|
+
const Point* points, size_t size,
|
192
|
+
bool loop = false);
|
193
|
+
|
194
|
+
|
195
|
+
}// Rays
|
196
|
+
|
197
|
+
|
198
|
+
#endif//EOH
|
@@ -0,0 +1,71 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_POLYLINE_H__
|
4
|
+
#define __RAYS_POLYLINE_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <vector>
|
8
|
+
#include <xot/pimpl.h>
|
9
|
+
#include <rays/defs.h>
|
10
|
+
#include <rays/point.h>
|
11
|
+
#include <rays/bounds.h>
|
12
|
+
|
13
|
+
|
14
|
+
namespace Rays
|
15
|
+
{
|
16
|
+
|
17
|
+
|
18
|
+
class Polygon;
|
19
|
+
|
20
|
+
|
21
|
+
class Polyline
|
22
|
+
{
|
23
|
+
|
24
|
+
public:
|
25
|
+
|
26
|
+
typedef std::vector<Point> PointList;
|
27
|
+
|
28
|
+
typedef PointList::const_iterator const_iterator;
|
29
|
+
|
30
|
+
Polyline ();
|
31
|
+
|
32
|
+
Polyline (const Point* points, size_t size, bool loop = false);
|
33
|
+
|
34
|
+
~Polyline ();
|
35
|
+
|
36
|
+
bool expand (
|
37
|
+
Polygon* result,
|
38
|
+
coord width,
|
39
|
+
CapType cap = CAP_DEFAULT,
|
40
|
+
JoinType join = JOIN_DEFAULT,
|
41
|
+
coord miter_limit = JOIN_DEFAULT_MITER_LIMIT) const;
|
42
|
+
|
43
|
+
Bounds bounds () const;
|
44
|
+
|
45
|
+
bool loop () const;
|
46
|
+
|
47
|
+
size_t size () const;
|
48
|
+
|
49
|
+
bool empty () const;
|
50
|
+
|
51
|
+
const_iterator begin () const;
|
52
|
+
|
53
|
+
const_iterator end () const;
|
54
|
+
|
55
|
+
const Point& operator [] (size_t index) const;
|
56
|
+
|
57
|
+
operator bool () const;
|
58
|
+
|
59
|
+
bool operator ! () const;
|
60
|
+
|
61
|
+
struct Data;
|
62
|
+
|
63
|
+
Xot::PSharedImpl<Data> self;
|
64
|
+
|
65
|
+
};// Polyline
|
66
|
+
|
67
|
+
|
68
|
+
}// Rays
|
69
|
+
|
70
|
+
|
71
|
+
#endif//EOH
|
data/include/rays/rays.h
CHANGED
data/include/rays/ruby.h
CHANGED
@@ -5,14 +5,20 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
#include <rays/ruby/rays.h>
|
8
|
+
|
8
9
|
#include <rays/ruby/point.h>
|
9
10
|
#include <rays/ruby/bounds.h>
|
10
11
|
#include <rays/ruby/color.h>
|
12
|
+
#include <rays/ruby/color_space.h>
|
13
|
+
#include <rays/ruby/matrix.h>
|
14
|
+
|
15
|
+
#include <rays/ruby/polyline.h>
|
16
|
+
#include <rays/ruby/polygon.h>
|
11
17
|
#include <rays/ruby/bitmap.h>
|
12
|
-
#include <rays/ruby/texture.h>
|
13
18
|
#include <rays/ruby/image.h>
|
14
19
|
#include <rays/ruby/font.h>
|
15
20
|
#include <rays/ruby/shader.h>
|
21
|
+
|
16
22
|
#include <rays/ruby/painter.h>
|
17
23
|
|
18
24
|
|