rays 0.1.12 → 0.1.13

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.
Files changed (155) 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/color.cpp +224 -45
  5. data/.doc/ext/rays/color_space.cpp +137 -45
  6. data/.doc/ext/rays/defs.cpp +183 -0
  7. data/.doc/ext/rays/font.cpp +39 -21
  8. data/.doc/ext/rays/image.cpp +26 -37
  9. data/.doc/ext/rays/matrix.cpp +186 -29
  10. data/.doc/ext/rays/native.cpp +12 -6
  11. data/.doc/ext/rays/noise.cpp +53 -0
  12. data/.doc/ext/rays/painter.cpp +120 -308
  13. data/.doc/ext/rays/point.cpp +82 -77
  14. data/.doc/ext/rays/polygon.cpp +287 -0
  15. data/.doc/ext/rays/polygon_line.cpp +96 -0
  16. data/.doc/ext/rays/polyline.cpp +161 -0
  17. data/.doc/ext/rays/rays.cpp +0 -13
  18. data/.doc/ext/rays/shader.cpp +83 -9
  19. data/README.md +1 -1
  20. data/Rakefile +21 -9
  21. data/VERSION +1 -1
  22. data/ext/rays/bitmap.cpp +22 -80
  23. data/ext/rays/bounds.cpp +100 -128
  24. data/ext/rays/color.cpp +232 -51
  25. data/ext/rays/color_space.cpp +140 -46
  26. data/ext/rays/defs.cpp +183 -0
  27. data/ext/rays/defs.h +26 -2
  28. data/ext/rays/extconf.rb +1 -2
  29. data/ext/rays/font.cpp +39 -22
  30. data/ext/rays/image.cpp +27 -39
  31. data/ext/rays/matrix.cpp +198 -30
  32. data/ext/rays/native.cpp +12 -6
  33. data/ext/rays/noise.cpp +55 -0
  34. data/ext/rays/painter.cpp +129 -315
  35. data/ext/rays/point.cpp +89 -81
  36. data/ext/rays/polygon.cpp +301 -0
  37. data/ext/rays/polygon_line.cpp +99 -0
  38. data/ext/rays/polyline.cpp +170 -0
  39. data/ext/rays/rays.cpp +0 -14
  40. data/ext/rays/shader.cpp +84 -9
  41. data/include/rays.h +10 -2
  42. data/include/rays/bitmap.h +14 -26
  43. data/include/rays/bounds.h +21 -4
  44. data/include/rays/color.h +25 -14
  45. data/include/rays/color_space.h +11 -8
  46. data/include/rays/coord.h +114 -0
  47. data/include/rays/debug.h +22 -0
  48. data/include/rays/defs.h +3 -0
  49. data/include/rays/font.h +4 -4
  50. data/include/rays/image.h +11 -17
  51. data/include/rays/matrix.h +50 -24
  52. data/include/rays/noise.h +42 -0
  53. data/include/rays/opengl.h +2 -50
  54. data/include/rays/painter.h +57 -99
  55. data/include/rays/point.h +44 -51
  56. data/include/rays/polygon.h +164 -0
  57. data/include/rays/polyline.h +65 -0
  58. data/include/rays/rays.h +3 -0
  59. data/include/rays/ruby.h +7 -1
  60. data/include/rays/ruby/bounds.h +1 -1
  61. data/include/rays/ruby/color.h +1 -1
  62. data/include/rays/ruby/color_space.h +1 -1
  63. data/include/rays/ruby/font.h +1 -1
  64. data/include/rays/ruby/matrix.h +1 -1
  65. data/include/rays/ruby/point.h +1 -1
  66. data/include/rays/ruby/polygon.h +52 -0
  67. data/include/rays/ruby/polyline.h +41 -0
  68. data/include/rays/ruby/shader.h +1 -1
  69. data/include/rays/shader.h +36 -8
  70. data/lib/rays.rb +6 -1
  71. data/lib/rays/bitmap.rb +0 -15
  72. data/lib/rays/bounds.rb +17 -23
  73. data/lib/rays/color.rb +20 -47
  74. data/lib/rays/color_space.rb +13 -13
  75. data/lib/rays/image.rb +2 -6
  76. data/lib/rays/matrix.rb +28 -0
  77. data/lib/rays/module.rb +4 -19
  78. data/lib/rays/painter.rb +60 -97
  79. data/lib/rays/point.rb +13 -21
  80. data/lib/rays/polygon.rb +50 -0
  81. data/lib/rays/polygon_line.rb +36 -0
  82. data/lib/rays/polyline.rb +32 -0
  83. data/lib/rays/shader.rb +20 -1
  84. data/rays.gemspec +5 -7
  85. data/src/bitmap.h +36 -0
  86. data/src/bounds.cpp +74 -11
  87. data/src/color.cpp +58 -23
  88. data/src/color_space.cpp +50 -32
  89. data/src/color_space.h +22 -0
  90. data/src/coord.cpp +170 -0
  91. data/src/coord.h +35 -0
  92. data/src/font.cpp +118 -0
  93. data/src/font.h +64 -0
  94. data/src/frame_buffer.cpp +37 -71
  95. data/src/frame_buffer.h +4 -4
  96. data/src/image.cpp +171 -97
  97. data/src/image.h +25 -0
  98. data/src/ios/bitmap.mm +107 -105
  99. data/src/ios/font.mm +48 -60
  100. data/src/ios/helper.h +2 -2
  101. data/src/ios/opengl.mm +19 -4
  102. data/src/ios/rays.mm +3 -0
  103. data/src/matrix.cpp +111 -26
  104. data/src/matrix.h +30 -0
  105. data/src/noise.cpp +74 -0
  106. data/src/opengl.cpp +9 -27
  107. data/src/opengl.h +37 -0
  108. data/src/osx/bitmap.mm +111 -106
  109. data/src/osx/font.mm +48 -61
  110. data/src/osx/helper.h +2 -2
  111. data/src/osx/opengl.mm +19 -83
  112. data/src/osx/rays.mm +3 -0
  113. data/src/painter.cpp +780 -696
  114. data/src/painter.h +24 -0
  115. data/src/point.cpp +140 -119
  116. data/src/polygon.cpp +1100 -0
  117. data/src/polygon.h +32 -0
  118. data/src/polyline.cpp +158 -0
  119. data/src/polyline.h +67 -0
  120. data/src/render_buffer.cpp +11 -4
  121. data/src/render_buffer.h +2 -2
  122. data/src/shader.cpp +163 -106
  123. data/src/shader.h +38 -0
  124. data/src/shader_program.cpp +533 -0
  125. data/src/{program.h → shader_program.h} +28 -16
  126. data/src/shader_source.cpp +140 -0
  127. data/src/shader_source.h +52 -0
  128. data/src/texture.cpp +136 -160
  129. data/src/texture.h +65 -0
  130. data/src/win32/bitmap.cpp +62 -52
  131. data/src/win32/font.cpp +11 -13
  132. data/src/win32/font.h +24 -0
  133. data/src/win32/gdi.h +6 -6
  134. data/test/helper.rb +0 -3
  135. data/test/test_bitmap.rb +31 -7
  136. data/test/test_bounds.rb +36 -0
  137. data/test/test_color.rb +59 -19
  138. data/test/test_color_space.rb +95 -0
  139. data/test/test_image.rb +24 -20
  140. data/test/test_matrix.rb +106 -0
  141. data/test/test_painter.rb +92 -46
  142. data/test/test_painter_shape.rb +57 -0
  143. data/test/test_point.rb +21 -0
  144. data/test/test_polygon.rb +234 -0
  145. data/test/test_polygon_line.rb +167 -0
  146. data/test/test_polyline.rb +145 -0
  147. data/test/test_shader.rb +9 -9
  148. metadata +88 -67
  149. data/.doc/ext/rays/texture.cpp +0 -138
  150. data/ext/rays/texture.cpp +0 -149
  151. data/include/rays/ruby/texture.h +0 -41
  152. data/include/rays/texture.h +0 -71
  153. data/lib/rays/texture.rb +0 -24
  154. data/src/program.cpp +0 -648
  155. 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,164 @@
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/bounds.h>
10
+ #include <rays/polyline.h>
11
+
12
+
13
+ namespace Rays
14
+ {
15
+
16
+
17
+ class Polygon
18
+ {
19
+
20
+ public:
21
+
22
+ struct Line : public Polyline
23
+ {
24
+
25
+ typedef Polyline Super;
26
+
27
+ public:
28
+
29
+ Line ();
30
+
31
+ Line (
32
+ const Point* points, size_t size,
33
+ bool loop = true,
34
+ bool hole = false);
35
+
36
+ Line (const Polyline& polyline, bool hole = false);
37
+
38
+ bool hole () const;
39
+
40
+ operator bool () const;
41
+
42
+ bool operator ! () const;
43
+
44
+ private:
45
+
46
+ bool hole_;
47
+
48
+ };// Line
49
+
50
+ typedef std::vector<Line> LineList;
51
+
52
+ typedef LineList::const_iterator const_iterator;
53
+
54
+ Polygon ();
55
+
56
+ Polygon (const Point* points, size_t size, bool loop = true);
57
+
58
+ Polygon (const Polyline& polyline);
59
+
60
+ Polygon (const Line* lines, size_t size);
61
+
62
+ ~Polygon ();
63
+
64
+ bool expand (Polygon* result, coord width) const;
65
+
66
+ Bounds bounds () const;
67
+
68
+ size_t size () const;
69
+
70
+ bool empty (bool deep = false) const;
71
+
72
+ const_iterator begin () const;
73
+
74
+ const_iterator end () const;
75
+
76
+ const Line& operator [] (size_t index) const;
77
+
78
+ operator bool () const;
79
+
80
+ bool operator ! () const;
81
+
82
+ friend Polygon operator + (const Polygon& lhs, const Polygon& rhs);
83
+
84
+ friend Polygon operator - (const Polygon& lhs, const Polygon& rhs);
85
+
86
+ friend Polygon operator & (const Polygon& lhs, const Polygon& rhs);
87
+
88
+ friend Polygon operator | (const Polygon& lhs, const Polygon& rhs);
89
+
90
+ friend Polygon operator ^ (const Polygon& lhs, const Polygon& rhs);
91
+
92
+ struct Data;
93
+
94
+ Xot::PSharedImpl<Data> self;
95
+
96
+ typedef std::vector<Point> TrianglePointList;
97
+
98
+ Polygon (Data* data);
99
+
100
+ protected:
101
+
102
+ bool triangulate (TrianglePointList* triangles) const;
103
+
104
+ };// Polygon
105
+
106
+
107
+ Polygon create_line (coord x1, coord y1, coord x2, coord y2);
108
+
109
+ Polygon create_line (const Point& p1, const Point& p2);
110
+
111
+ Polygon create_line (const Point* points, size_t size, bool loop = false);
112
+
113
+ Polygon create_line (const Polyline& polyline);
114
+
115
+
116
+ Polygon create_rect (
117
+ coord x, coord y, coord width, coord height,
118
+ coord round = 0,
119
+ uint nsegment = 0);
120
+
121
+ Polygon create_rect (
122
+ coord x, coord y, coord width, coord height,
123
+ coord round_left_top, coord round_right_top,
124
+ coord round_left_bottom, coord round_right_bottom,
125
+ uint nsegment = 0);
126
+
127
+ Polygon create_rect (
128
+ const Bounds& bounds,
129
+ coord round = 0,
130
+ uint nsegment = 0);
131
+
132
+ Polygon create_rect (
133
+ const Bounds& bounds,
134
+ coord round_left_top, coord round_right_top,
135
+ coord round_left_bottom, coord round_right_bottom,
136
+ uint nsegment = 0);
137
+
138
+
139
+ Polygon create_ellipse (
140
+ coord x, coord y, coord width, coord height = 0,
141
+ const Point& hole_size = 0,
142
+ float angle_from = 0,
143
+ float angle_to = 360,
144
+ uint nsegment = 0);
145
+
146
+ Polygon create_ellipse (
147
+ const Bounds& bounds,
148
+ const Point& hole_size = 0,
149
+ float angle_from = 0,
150
+ float angle_to = 360,
151
+ uint nsegment = 0);
152
+
153
+ Polygon create_ellipse (
154
+ const Point& center, const Point& radius,
155
+ const Point& hole_radius = 0,
156
+ float angle_from = 0,
157
+ float angle_to = 360,
158
+ uint nsegment = 0);
159
+
160
+
161
+ }// Rays
162
+
163
+
164
+ #endif//EOH
@@ -0,0 +1,65 @@
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/point.h>
10
+ #include <rays/bounds.h>
11
+
12
+
13
+ namespace Rays
14
+ {
15
+
16
+
17
+ class Polygon;
18
+
19
+
20
+ class Polyline
21
+ {
22
+
23
+ public:
24
+
25
+ typedef std::vector<Point> PointList;
26
+
27
+ typedef PointList::const_iterator const_iterator;
28
+
29
+ Polyline ();
30
+
31
+ Polyline (const Point* points, size_t size, bool loop = false);
32
+
33
+ ~Polyline ();
34
+
35
+ bool expand (Polygon* result, coord width) const;
36
+
37
+ Bounds bounds () const;
38
+
39
+ bool loop () const;
40
+
41
+ size_t size () const;
42
+
43
+ bool empty () const;
44
+
45
+ const_iterator begin () const;
46
+
47
+ const_iterator end () const;
48
+
49
+ const Point& operator [] (size_t index) const;
50
+
51
+ operator bool () const;
52
+
53
+ bool operator ! () const;
54
+
55
+ struct Data;
56
+
57
+ Xot::PSharedImpl<Data> self;
58
+
59
+ };// Polyline
60
+
61
+
62
+ }// Rays
63
+
64
+
65
+ #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
 
@@ -23,7 +23,7 @@ namespace Rays
23
23
  }// Rays
24
24
 
25
25
 
26
- RUCY_DECLARE_VALUE_FROM_TO(Rays::Bounds)
26
+ RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Bounds)
27
27
 
28
28
 
29
29
  namespace Rucy
@@ -22,7 +22,7 @@ namespace Rays
22
22
  }// Rays
23
23
 
24
24
 
25
- RUCY_DECLARE_VALUE_FROM_TO(Rays::Color)
25
+ RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Color)
26
26
 
27
27
 
28
28
  namespace Rucy
@@ -21,7 +21,7 @@ namespace Rays
21
21
  }// Rays
22
22
 
23
23
 
24
- RUCY_DECLARE_VALUE_FROM_TO(Rays::ColorSpace)
24
+ RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::ColorSpace)
25
25
 
26
26
 
27
27
  namespace Rucy
@@ -21,7 +21,7 @@ namespace Rays
21
21
  }// Rays
22
22
 
23
23
 
24
- RUCY_DECLARE_VALUE_FROM_TO(Rays::Font)
24
+ RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Font)
25
25
 
26
26
 
27
27
  namespace Rucy