rays 0.1.12 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +5 -5
  2. data/.doc/ext/rays/bitmap.cpp +22 -76
  3. data/.doc/ext/rays/bounds.cpp +95 -125
  4. data/.doc/ext/rays/camera.cpp +171 -0
  5. data/.doc/ext/rays/color.cpp +223 -45
  6. data/.doc/ext/rays/color_space.cpp +146 -46
  7. data/.doc/ext/rays/defs.cpp +183 -0
  8. data/.doc/ext/rays/font.cpp +69 -21
  9. data/.doc/ext/rays/image.cpp +26 -37
  10. data/.doc/ext/rays/matrix.cpp +186 -29
  11. data/.doc/ext/rays/native.cpp +14 -8
  12. data/.doc/ext/rays/noise.cpp +53 -0
  13. data/.doc/ext/rays/painter.cpp +187 -292
  14. data/.doc/ext/rays/point.cpp +96 -77
  15. data/.doc/ext/rays/polygon.cpp +313 -0
  16. data/.doc/ext/rays/polygon_line.cpp +96 -0
  17. data/.doc/ext/rays/polyline.cpp +167 -0
  18. data/.doc/ext/rays/rays.cpp +103 -12
  19. data/.doc/ext/rays/shader.cpp +83 -9
  20. data/LICENSE +21 -0
  21. data/README.md +1 -1
  22. data/Rakefile +24 -9
  23. data/VERSION +1 -1
  24. data/ext/rays/bitmap.cpp +23 -81
  25. data/ext/rays/bounds.cpp +100 -128
  26. data/ext/rays/camera.cpp +186 -0
  27. data/ext/rays/color.cpp +231 -51
  28. data/ext/rays/color_space.cpp +149 -47
  29. data/ext/rays/defs.cpp +183 -0
  30. data/ext/rays/defs.h +26 -2
  31. data/ext/rays/extconf.rb +2 -3
  32. data/ext/rays/font.cpp +74 -24
  33. data/ext/rays/image.cpp +28 -40
  34. data/ext/rays/matrix.cpp +198 -30
  35. data/ext/rays/native.cpp +14 -8
  36. data/ext/rays/noise.cpp +55 -0
  37. data/ext/rays/painter.cpp +203 -298
  38. data/ext/rays/point.cpp +105 -81
  39. data/ext/rays/polygon.cpp +329 -0
  40. data/ext/rays/polygon_line.cpp +99 -0
  41. data/ext/rays/polyline.cpp +176 -0
  42. data/ext/rays/rays.cpp +103 -13
  43. data/ext/rays/shader.cpp +84 -9
  44. data/include/rays.h +10 -2
  45. data/include/rays/bitmap.h +14 -26
  46. data/include/rays/bounds.h +21 -4
  47. data/include/rays/camera.h +74 -0
  48. data/include/rays/color.h +25 -14
  49. data/include/rays/color_space.h +15 -10
  50. data/include/rays/coord.h +114 -0
  51. data/include/rays/debug.h +22 -0
  52. data/include/rays/defs.h +36 -0
  53. data/include/rays/exception.h +6 -2
  54. data/include/rays/font.h +4 -4
  55. data/include/rays/image.h +12 -18
  56. data/include/rays/matrix.h +50 -24
  57. data/include/rays/noise.h +42 -0
  58. data/include/rays/opengl.h +2 -50
  59. data/include/rays/painter.h +89 -93
  60. data/include/rays/point.h +44 -51
  61. data/include/rays/polygon.h +198 -0
  62. data/include/rays/polyline.h +71 -0
  63. data/include/rays/rays.h +3 -0
  64. data/include/rays/ruby.h +7 -1
  65. data/include/rays/ruby/bounds.h +1 -1
  66. data/include/rays/ruby/camera.h +41 -0
  67. data/include/rays/ruby/color.h +1 -1
  68. data/include/rays/ruby/color_space.h +1 -1
  69. data/include/rays/ruby/font.h +1 -1
  70. data/include/rays/ruby/matrix.h +1 -1
  71. data/include/rays/ruby/point.h +1 -1
  72. data/include/rays/ruby/polygon.h +52 -0
  73. data/include/rays/ruby/polyline.h +41 -0
  74. data/include/rays/ruby/rays.h +8 -0
  75. data/include/rays/ruby/shader.h +1 -1
  76. data/include/rays/shader.h +36 -8
  77. data/lib/rays.rb +7 -2
  78. data/lib/rays/bitmap.rb +0 -15
  79. data/lib/rays/bounds.rb +17 -23
  80. data/lib/rays/camera.rb +24 -0
  81. data/lib/rays/color.rb +20 -47
  82. data/lib/rays/color_space.rb +13 -13
  83. data/lib/rays/image.rb +3 -7
  84. data/lib/rays/matrix.rb +28 -0
  85. data/lib/rays/module.rb +4 -19
  86. data/lib/rays/painter.rb +78 -93
  87. data/lib/rays/point.rb +13 -21
  88. data/lib/rays/polygon.rb +58 -0
  89. data/lib/rays/polygon_line.rb +36 -0
  90. data/lib/rays/polyline.rb +32 -0
  91. data/lib/rays/shader.rb +20 -1
  92. data/rays.gemspec +5 -7
  93. data/src/bitmap.h +36 -0
  94. data/src/bounds.cpp +74 -11
  95. data/src/color.cpp +58 -23
  96. data/src/color_space.cpp +52 -34
  97. data/src/color_space.h +22 -0
  98. data/src/coord.cpp +170 -0
  99. data/src/coord.h +35 -0
  100. data/src/font.cpp +118 -0
  101. data/src/font.h +64 -0
  102. data/src/frame_buffer.cpp +37 -71
  103. data/src/frame_buffer.h +4 -4
  104. data/src/image.cpp +172 -98
  105. data/src/image.h +25 -0
  106. data/src/ios/bitmap.h +23 -0
  107. data/src/ios/bitmap.mm +133 -110
  108. data/src/ios/camera.mm +510 -0
  109. data/src/ios/font.mm +50 -62
  110. data/src/ios/helper.h +4 -4
  111. data/src/ios/opengl.mm +19 -4
  112. data/src/ios/rays.mm +3 -0
  113. data/src/matrix.cpp +111 -26
  114. data/src/matrix.h +30 -0
  115. data/src/noise.cpp +74 -0
  116. data/src/opengl.cpp +9 -27
  117. data/src/opengl.h +37 -0
  118. data/src/osx/bitmap.h +23 -0
  119. data/src/osx/bitmap.mm +133 -110
  120. data/src/osx/camera.mm +451 -0
  121. data/src/osx/font.mm +49 -62
  122. data/src/osx/helper.h +2 -2
  123. data/src/osx/opengl.mm +19 -83
  124. data/src/osx/rays.mm +3 -0
  125. data/src/painter.cpp +845 -671
  126. data/src/painter.h +24 -0
  127. data/src/point.cpp +140 -119
  128. data/src/polygon.cpp +1266 -0
  129. data/src/polygon.h +32 -0
  130. data/src/polyline.cpp +160 -0
  131. data/src/polyline.h +69 -0
  132. data/src/render_buffer.cpp +11 -4
  133. data/src/render_buffer.h +2 -2
  134. data/src/shader.cpp +163 -106
  135. data/src/shader.h +38 -0
  136. data/src/shader_program.cpp +533 -0
  137. data/src/{program.h → shader_program.h} +28 -16
  138. data/src/shader_source.cpp +140 -0
  139. data/src/shader_source.h +52 -0
  140. data/src/texture.cpp +136 -160
  141. data/src/texture.h +65 -0
  142. data/src/win32/bitmap.cpp +62 -52
  143. data/src/win32/font.cpp +11 -13
  144. data/src/win32/font.h +24 -0
  145. data/src/win32/gdi.h +6 -6
  146. data/test/helper.rb +0 -3
  147. data/test/test_bitmap.rb +31 -7
  148. data/test/test_bounds.rb +36 -0
  149. data/test/test_color.rb +59 -19
  150. data/test/test_color_space.rb +95 -0
  151. data/test/test_font.rb +5 -0
  152. data/test/test_image.rb +24 -20
  153. data/test/test_matrix.rb +106 -0
  154. data/test/test_painter.rb +157 -51
  155. data/test/test_painter_shape.rb +102 -0
  156. data/test/test_point.rb +29 -0
  157. data/test/test_polygon.rb +234 -0
  158. data/test/test_polygon_line.rb +167 -0
  159. data/test/test_polyline.rb +171 -0
  160. data/test/test_shader.rb +9 -9
  161. metadata +102 -70
  162. data/.doc/ext/rays/texture.cpp +0 -138
  163. data/ext/rays/texture.cpp +0 -149
  164. data/include/rays/ruby/texture.h +0 -41
  165. data/include/rays/texture.h +0 -71
  166. data/lib/rays/texture.rb +0 -24
  167. data/src/program.cpp +0 -648
  168. data/test/test_texture.rb +0 -27
@@ -4,105 +4,98 @@
4
4
  #define __RAYS_POINT_H__
5
5
 
6
6
 
7
- #include <rays/defs.h>
7
+ #include <rays/coord.h>
8
8
 
9
9
 
10
10
  namespace Rays
11
11
  {
12
12
 
13
13
 
14
- struct Coord2
14
+ struct Point : public Coord3
15
15
  {
16
16
 
17
- union
18
- {
19
- struct {coord x, y;};
20
- coord array[2];
21
- };
17
+ typedef Point This;
22
18
 
23
- Coord2& reset (coord value = 0);
19
+ typedef Coord3 Super;
24
20
 
25
- Coord2& reset (coord x, coord y);
21
+ Point (coord value = 0);
26
22
 
27
- coord& operator [] (size_t index);
23
+ Point (coord x, coord y, coord z = 0);
28
24
 
29
- const coord& operator [] (size_t index) const;
25
+ This dup () const;
30
26
 
31
- };// Coord2
27
+ This& reset (coord value = 0);
32
28
 
29
+ This& reset (coord x, coord y, coord z = 0);
33
30
 
34
- struct Coord3
35
- {
31
+ This& move_to (coord x, coord y, coord z = 0);
36
32
 
37
- union
38
- {
39
- struct {coord x, y, z;};
40
- coord array[3];
41
- };
33
+ This& move_to (const This& point);
42
34
 
43
- Coord3& reset (coord value = 0);
35
+ This& move_by (coord x, coord y, coord z = 0);
44
36
 
45
- Coord3& reset (coord x, coord y, coord z = 0);
37
+ This& move_by (const This& point);
46
38
 
47
- coord& operator [] (size_t index);
39
+ void rotate (float degree);
48
40
 
49
- const coord& operator [] (size_t index) const;
41
+ coord length () const;
50
42
 
51
- };// Coord3
43
+ This normal () const;
52
44
 
45
+ void normalize ();
53
46
 
54
- struct Point : public Coord3
55
- {
47
+ This operator - () const;
56
48
 
57
- Point (coord value = 0);
49
+ This& operator += (coord rhs);
58
50
 
59
- Point (coord x, coord y, coord z = 0);
51
+ This& operator += (const This& rhs);
60
52
 
61
- Point dup () const;
53
+ This& operator -= (coord rhs);
62
54
 
63
- Point& move_to (coord x, coord y, coord z = 0);
55
+ This& operator -= (const This& rhs);
64
56
 
65
- Point& move_to (const Point& point);
57
+ This& operator *= (coord rhs);
66
58
 
67
- Point& move_by (coord x, coord y, coord z = 0);
59
+ This& operator *= (const This& rhs);
68
60
 
69
- Point& move_by (const Point& point);
61
+ This& operator /= (coord rhs);
70
62
 
71
- coord length () const;
63
+ This& operator /= (const This& rhs);
72
64
 
73
- void normalize ();
65
+ friend bool operator == (const This& lhs, const This& rhs);
74
66
 
75
- Point normal () const;
67
+ friend bool operator != (const This& lhs, const This& rhs);
76
68
 
77
- String inspect () const;
69
+ friend This operator + (coord lhs, const This& rhs);
78
70
 
79
- Point operator - () const;
71
+ friend This operator + (const This& lhs, coord rhs);
80
72
 
81
- Point& operator += (const Point& rhs);
73
+ friend This operator + (const This& lhs, const This& rhs);
82
74
 
83
- Point& operator -= (const Point& rhs);
75
+ friend This operator - (coord lhs, const This& rhs);
84
76
 
85
- Point& operator *= (const Point& rhs);
77
+ friend This operator - (const This& lhs, coord rhs);
86
78
 
87
- Point& operator /= (const Point& rhs);
79
+ friend This operator - (const This& lhs, const This& rhs);
88
80
 
89
- Point& operator /= (coord rhs);
81
+ friend This operator * (coord lhs, const This& rhs);
90
82
 
91
- friend bool operator == (const Point& lhs, const Point& rhs);
83
+ friend This operator * (const This& lhs, coord rhs);
92
84
 
93
- friend bool operator != (const Point& lhs, const Point& rhs);
85
+ friend This operator * (const This& lhs, const This& rhs);
94
86
 
95
- friend Point operator + (const Point& lhs, const Point& rhs);
87
+ friend This operator / (coord lhs, const This& rhs);
96
88
 
97
- friend Point operator - (const Point& lhs, const Point& rhs);
89
+ friend This operator / (const This& lhs, coord rhs);
98
90
 
99
- friend Point operator * (const Point& lhs, const Point& rhs);
91
+ friend This operator / (const This& lhs, const This& rhs);
100
92
 
101
- friend Point operator / (const Point& lhs, const Point& rhs);
93
+ };// Point
102
94
 
103
- friend Point operator / (const Point& lhs, coord rhs);
104
95
 
105
- };// Point
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
@@ -4,6 +4,9 @@
4
4
  #define __RAYS_RAYS_H__
5
5
 
6
6
 
7
+ #include <rays/defs.h>
8
+
9
+
7
10
  namespace Rays
8
11
  {
9
12
 
@@ -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