rays 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/rays/bitmap.cpp +6 -6
  3. data/.doc/ext/rays/bounds.cpp +4 -4
  4. data/.doc/ext/rays/color.cpp +4 -4
  5. data/.doc/ext/rays/color_space.cpp +4 -4
  6. data/.doc/ext/rays/font.cpp +6 -6
  7. data/.doc/ext/rays/image.cpp +6 -6
  8. data/.doc/ext/rays/matrix.cpp +4 -4
  9. data/.doc/ext/rays/painter.cpp +56 -21
  10. data/.doc/ext/rays/point.cpp +5 -4
  11. data/.doc/ext/rays/rays.cpp +2 -3
  12. data/.doc/ext/rays/shader.cpp +5 -5
  13. data/.doc/ext/rays/texture.cpp +5 -5
  14. data/README.md +2 -2
  15. data/VERSION +1 -1
  16. data/ext/rays/bitmap.cpp +6 -6
  17. data/ext/rays/bounds.cpp +4 -4
  18. data/ext/rays/color.cpp +4 -4
  19. data/ext/rays/color_space.cpp +4 -4
  20. data/ext/rays/font.cpp +6 -6
  21. data/ext/rays/image.cpp +6 -6
  22. data/ext/rays/matrix.cpp +4 -4
  23. data/ext/rays/painter.cpp +72 -35
  24. data/ext/rays/point.cpp +5 -4
  25. data/ext/rays/rays.cpp +2 -3
  26. data/ext/rays/shader.cpp +5 -5
  27. data/ext/rays/texture.cpp +5 -5
  28. data/include/rays/opengl.h +1 -1
  29. data/include/rays/painter.h +12 -0
  30. data/include/rays/point.h +35 -9
  31. data/include/rays/ruby/bitmap.h +14 -0
  32. data/include/rays/ruby/bounds.h +14 -0
  33. data/include/rays/ruby/color.h +14 -0
  34. data/include/rays/ruby/color_space.h +14 -0
  35. data/include/rays/ruby/font.h +14 -0
  36. data/include/rays/ruby/image.h +14 -0
  37. data/include/rays/ruby/matrix.h +14 -0
  38. data/include/rays/ruby/painter.h +14 -0
  39. data/include/rays/ruby/point.h +14 -0
  40. data/include/rays/ruby/shader.h +14 -0
  41. data/include/rays/ruby/texture.h +14 -0
  42. data/rays.gemspec +1 -1
  43. data/src/painter.cpp +132 -43
  44. data/src/point.cpp +65 -30
  45. metadata +3 -3
@@ -12,13 +12,11 @@ using namespace Rucy;
12
12
  using Rays::coord;
13
13
 
14
14
 
15
- static Class cTexture;
16
-
17
- RUCY_DEFINE_VALUE_FROM_TO(Rays::Texture, cTexture)
15
+ RUCY_DEFINE_VALUE_FROM_TO(Rays::Texture)
18
16
 
19
17
  #define THIS to<Rays::Texture*>(self)
20
18
 
21
- #define CHECK RUCY_CHECK_OBJECT(Rays::Texture, cTexture, self)
19
+ #define CHECK RUCY_CHECK_OBJECT(Rays::Texture, self)
22
20
 
23
21
 
24
22
  static
@@ -30,7 +28,7 @@ VALUE alloc(VALUE klass)
30
28
  static
31
29
  VALUE setup(VALUE self, VALUE width, VALUE height, VALUE color_space, VALUE alpha_only)
32
30
  {
33
- RUCY_CHECK_OBJ(Rays::Texture, cTexture, self);
31
+ RUCY_CHECK_OBJ(Rays::Texture, self);
34
32
 
35
33
  Rays::ColorSpace* cs = to<Rays::ColorSpace*>(color_space);
36
34
  if (!cs) argument_error(__FILE__, __LINE__);
@@ -104,6 +102,8 @@ VALUE to_bitmap(VALUE self)
104
102
  }
105
103
 
106
104
 
105
+ static Class cTexture;
106
+
107
107
  void
108
108
  Init_texture ()
109
109
  {
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
- = Rays - A Drawing Engine using OpenGL
2
+ # Rays - A Drawing Engine using OpenGL
3
3
 
4
- == by snori@xord.org
4
+ ## by snori@xord.org
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.1.8
@@ -18,13 +18,11 @@ using Rays::uint;
18
18
  using Rays::coord;
19
19
 
20
20
 
21
- static Class cBitmap;
22
-
23
- RUCY_DEFINE_VALUE_FROM_TO(Rays::Bitmap, cBitmap)
21
+ RUCY_DEFINE_VALUE_FROM_TO(Rays::Bitmap)
24
22
 
25
23
  #define THIS to<Rays::Bitmap*>(self)
26
24
 
27
- #define CHECK RUCY_CHECK_OBJECT(Rays::Bitmap, cBitmap, self)
25
+ #define CHECK RUCY_CHECK_OBJECT(Rays::Bitmap, self)
28
26
 
29
27
 
30
28
  static
@@ -37,7 +35,7 @@ RUCY_END
37
35
  static
38
36
  RUCY_DEF1(initialize_copy, obj)
39
37
  {
40
- RUCY_CHECK_OBJ(Rays::Bitmap, cBitmap, self);
38
+ RUCY_CHECK_OBJ(Rays::Bitmap, self);
41
39
 
42
40
  *THIS = to<Rays::Bitmap&>(obj).copy();
43
41
  return self;
@@ -47,7 +45,7 @@ RUCY_END
47
45
  static
48
46
  RUCY_DEF3(setup, width, height, color_space)
49
47
  {
50
- RUCY_CHECK_OBJ(Rays::Bitmap, cBitmap, self);
48
+ RUCY_CHECK_OBJ(Rays::Bitmap, self);
51
49
 
52
50
  Rays::ColorSpace* cs = to<Rays::ColorSpace*>(color_space);
53
51
  if (!cs)
@@ -155,6 +153,8 @@ RUCY_DEF1(load, path)
155
153
  RUCY_END
156
154
 
157
155
 
156
+ static Class cBitmap;
157
+
158
158
  void
159
159
  Init_bitmap ()
160
160
  {
@@ -11,13 +11,11 @@ using namespace Rucy;
11
11
  using Rays::coord;
12
12
 
13
13
 
14
- static Class cBounds;
15
-
16
- RUCY_DEFINE_VALUE_FROM_TO(Rays::Bounds, cBounds)
14
+ RUCY_DEFINE_VALUE_FROM_TO(Rays::Bounds)
17
15
 
18
16
  #define THIS to<Rays::Bounds*>(self)
19
17
 
20
- #define CHECK RUCY_CHECK_OBJ(Rays::Bounds, cBounds, self)
18
+ #define CHECK RUCY_CHECK_OBJ(Rays::Bounds, self)
21
19
 
22
20
 
23
21
  static
@@ -593,6 +591,8 @@ RUCY_DEF0(inspect)
593
591
  RUCY_END
594
592
 
595
593
 
594
+ static Class cBounds;
595
+
596
596
  void
597
597
  Init_bounds ()
598
598
  {
@@ -8,13 +8,11 @@
8
8
  using namespace Rucy;
9
9
 
10
10
 
11
- static Class cColor;
12
-
13
- RUCY_DEFINE_VALUE_FROM_TO(Rays::Color, cColor)
11
+ RUCY_DEFINE_VALUE_FROM_TO(Rays::Color)
14
12
 
15
13
  #define THIS to<Rays::Color*>(self)
16
14
 
17
- #define CHECK RUCY_CHECK_OBJ(Rays::Color, cColor, self)
15
+ #define CHECK RUCY_CHECK_OBJ(Rays::Color, self)
18
16
 
19
17
 
20
18
  static
@@ -140,6 +138,8 @@ RUCY_DEF0(get_alpha)
140
138
  RUCY_END
141
139
 
142
140
 
141
+ static Class cColor;
142
+
143
143
  void
144
144
  Init_color ()
145
145
  {
@@ -8,13 +8,11 @@
8
8
  using namespace Rucy;
9
9
 
10
10
 
11
- static Class cColorSpace;
12
-
13
- RUCY_DEFINE_VALUE_FROM_TO(Rays::ColorSpace, cColorSpace)
11
+ RUCY_DEFINE_VALUE_FROM_TO(Rays::ColorSpace)
14
12
 
15
13
  #define THIS to<Rays::ColorSpace*>(self)
16
14
 
17
- #define CHECK RUCY_CHECK_OBJ(Rays::ColorSpace, cColorSpace, self)
15
+ #define CHECK RUCY_CHECK_OBJ(Rays::ColorSpace, self)
18
16
 
19
17
 
20
18
  static
@@ -118,6 +116,8 @@ RUCY_DEF0(is_premult)
118
116
  RUCY_END
119
117
 
120
118
 
119
+ static Class cColorSpace;
120
+
121
121
  void
122
122
  Init_color_space ()
123
123
  {
@@ -10,13 +10,11 @@ using namespace Rucy;
10
10
  using Rays::coord;
11
11
 
12
12
 
13
- static Class cFont;
14
-
15
- RUCY_DEFINE_VALUE_FROM_TO(Rays::Font, cFont)
13
+ RUCY_DEFINE_VALUE_FROM_TO(Rays::Font)
16
14
 
17
15
  #define THIS to<Rays::Font*>(self)
18
16
 
19
- #define CHECK RUCY_CHECK_OBJECT(Rays::Font, cFont, self)
17
+ #define CHECK RUCY_CHECK_OBJECT(Rays::Font, self)
20
18
 
21
19
 
22
20
  static
@@ -29,7 +27,7 @@ RUCY_END
29
27
  static
30
28
  RUCY_DEFN(initialize)
31
29
  {
32
- RUCY_CHECK_OBJ(Rays::Font, cFont, self);
30
+ RUCY_CHECK_OBJ(Rays::Font, self);
33
31
  check_arg_count(__FILE__, __LINE__, "Font#initialize", argc, 0, 1, 2);
34
32
 
35
33
  const char* name = (argc >= 1) ? argv[0].c_str() : NULL;
@@ -43,7 +41,7 @@ RUCY_END
43
41
  static
44
42
  RUCY_DEF1(initialize_copy, obj)
45
43
  {
46
- RUCY_CHECK_OBJ(Rays::Font, cFont, self);
44
+ RUCY_CHECK_OBJ(Rays::Font, self);
47
45
 
48
46
  *THIS = to<Rays::Font&>(obj).copy();
49
47
  return self;
@@ -83,6 +81,8 @@ RUCY_DEF0(height)
83
81
  RUCY_END
84
82
 
85
83
 
84
+ static Class cFont;
85
+
86
86
  void
87
87
  Init_font ()
88
88
  {
@@ -14,13 +14,11 @@ using namespace Rucy;
14
14
  using Rays::coord;
15
15
 
16
16
 
17
- static Class cImage;
18
-
19
- RUCY_DEFINE_VALUE_FROM_TO(Rays::Image, cImage)
17
+ RUCY_DEFINE_VALUE_FROM_TO(Rays::Image)
20
18
 
21
19
  #define THIS to<Rays::Image*>(self)
22
20
 
23
- #define CHECK RUCY_CHECK_OBJECT(Rays::Image, cImage, self)
21
+ #define CHECK RUCY_CHECK_OBJECT(Rays::Image, self)
24
22
 
25
23
 
26
24
  static
@@ -33,7 +31,7 @@ RUCY_END
33
31
  static
34
32
  RUCY_DEFN(initialize)
35
33
  {
36
- RUCY_CHECK_OBJ(Rays::Image, cImage, self);
34
+ RUCY_CHECK_OBJ(Rays::Image, self);
37
35
  check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2, 3);
38
36
 
39
37
  if (argc == 0) return self;
@@ -63,7 +61,7 @@ RUCY_END
63
61
  static
64
62
  RUCY_DEF1(initialize_copy, obj)
65
63
  {
66
- RUCY_CHECK_OBJ(Rays::Image, cImage, self);
64
+ RUCY_CHECK_OBJ(Rays::Image, self);
67
65
 
68
66
  *THIS = to<Rays::Image&>(obj).copy();
69
67
  return self;
@@ -144,6 +142,8 @@ RUCY_DEF2(load, path, alpha_only)
144
142
  RUCY_END
145
143
 
146
144
 
145
+ static Class cImage;
146
+
147
147
  void
148
148
  Init_image ()
149
149
  {
@@ -8,13 +8,11 @@
8
8
  using namespace Rucy;
9
9
 
10
10
 
11
- static Class cMatrix;
12
-
13
- RUCY_DEFINE_VALUE_FROM_TO(Rays::Matrix, cMatrix)
11
+ RUCY_DEFINE_VALUE_FROM_TO(Rays::Matrix)
14
12
 
15
13
  #define THIS to<Rays::Matrix*>(self)
16
14
 
17
- #define CHECK RUCY_CHECK_OBJ(Rays::Matrix, cMatrix, self)
15
+ #define CHECK RUCY_CHECK_OBJ(Rays::Matrix, self)
18
16
 
19
17
 
20
18
  static
@@ -98,6 +96,8 @@ RUCY_DEF2(at, row, column)
98
96
  RUCY_END
99
97
 
100
98
 
99
+ static Class cMatrix;
100
+
101
101
  void
102
102
  Init_matrix ()
103
103
  {
@@ -1,6 +1,7 @@
1
1
  #include "rays/ruby/painter.h"
2
2
 
3
3
 
4
+ #include <vector>
4
5
  #include <rucy.h>
5
6
  #include "rays/ruby/point.h"
6
7
  #include "rays/ruby/bounds.h"
@@ -17,13 +18,11 @@ using namespace Rucy;
17
18
  using Rays::coord;
18
19
 
19
20
 
20
- static Class cPainter;
21
-
22
- RUCY_DEFINE_VALUE_FROM_TO(Rays::Painter, cPainter)
21
+ RUCY_DEFINE_VALUE_FROM_TO(Rays::Painter)
23
22
 
24
23
  #define THIS to<Rays::Painter*>(self)
25
24
 
26
- #define CHECK RUCY_CHECK_OBJECT(Rays::Painter, cPainter, self)
25
+ #define CHECK RUCY_CHECK_OBJECT(Rays::Painter, self)
27
26
 
28
27
 
29
28
  static
@@ -48,6 +47,15 @@ RUCY_DEF4(canvas, x, y, width, height)
48
47
  }
49
48
  RUCY_END
50
49
 
50
+ static
51
+ RUCY_DEF0(bounds)
52
+ {
53
+ CHECK;
54
+ return value(THIS->bounds());
55
+ }
56
+ RUCY_END
57
+
58
+
51
59
  static
52
60
  RUCY_DEF0(begin_paint)
53
61
  {
@@ -66,6 +74,13 @@ RUCY_DEF0(end_paint)
66
74
  }
67
75
  RUCY_END
68
76
 
77
+ static
78
+ RUCY_DEF0(clear)
79
+ {
80
+ CHECK;
81
+ THIS->clear();
82
+ }
83
+ RUCY_END
69
84
 
70
85
  static
71
86
  RUCY_DEFN(line)
@@ -88,6 +103,40 @@ RUCY_DEFN(line)
88
103
  }
89
104
  RUCY_END
90
105
 
106
+ static
107
+ RUCY_DEFN(lines)
108
+ {
109
+ CHECK;
110
+ if (argc <= 0)
111
+ argument_error(__FILE__, __LINE__, "Painter#lines");
112
+
113
+ std::vector<Rays::Coord3> points;
114
+ points.reserve(argc);
115
+ for (int i = 0; i < argc; ++i)
116
+ points.push_back(to<Rays::Point&>(argv[i]));
117
+
118
+ THIS->lines((Rays::Point*) &points[0], points.size());
119
+ return self;
120
+ }
121
+ RUCY_END
122
+
123
+ static
124
+ RUCY_DEFN(polygon)
125
+ {
126
+ CHECK;
127
+ if (argc <= 0)
128
+ argument_error(__FILE__, __LINE__, "Painter#polygon");
129
+
130
+ std::vector<Rays::Coord3> points;
131
+ points.reserve(argc);
132
+ for (int i = 0; i < argc; ++i)
133
+ points.push_back(to<Rays::Point&>(argv[i]));
134
+
135
+ THIS->polygon((Rays::Point*) &points[0], points.size());
136
+ return self;
137
+ }
138
+ RUCY_END
139
+
91
140
  static
92
141
  RUCY_DEFN(rect)
93
142
  {
@@ -256,22 +305,6 @@ RUCY_DEFN(text)
256
305
  }
257
306
  RUCY_END
258
307
 
259
- static
260
- RUCY_DEF0(clear)
261
- {
262
- CHECK;
263
- THIS->clear();
264
- }
265
- RUCY_END
266
-
267
- static
268
- RUCY_DEF0(bounds)
269
- {
270
- CHECK;
271
- return value(THIS->bounds());
272
- }
273
- RUCY_END
274
-
275
308
  static
276
309
  RUCY_DEFN(set_background)
277
310
  {
@@ -659,27 +692,31 @@ RUCY_DEF0(pop_matrix)
659
692
  RUCY_END
660
693
 
661
694
 
695
+ static Class cPainter;
696
+
662
697
  void
663
698
  Init_painter ()
664
699
  {
665
700
  Module mRays = define_module("Rays");
666
701
 
667
- cPainter= mRays.define_class("Painter");
702
+ cPainter = mRays.define_class("Painter");
668
703
  cPainter.define_alloc_func(alloc);
669
704
 
670
705
  cPainter.define_method("canvas", canvas);
671
- cPainter.define_private_method("begin_paint", begin_paint);
672
- cPainter.define_private_method("end_paint", end_paint);
706
+ cPainter.define_method("bounds", bounds);
673
707
 
674
- cPainter.define_method("line", line);
675
- cPainter.define_method("rect", rect);
708
+ cPainter.define_private_method("begin_paint", begin_paint);
709
+ cPainter.define_private_method( "end_paint", end_paint);
710
+ cPainter.define_method("clear", clear);
711
+ cPainter.define_method("line", line);
712
+ cPainter.define_method("lines", lines);
713
+ cPainter.define_method("polygon", polygon);
714
+ cPainter.define_method("rect", rect);
676
715
  cPainter.define_method("ellipse", ellipse);
677
- cPainter.define_method("arc", arc);
678
- cPainter.define_method("image", image);
679
- cPainter.define_method("text", text);
716
+ cPainter.define_method("arc", arc);
717
+ cPainter.define_method("image", image);
718
+ cPainter.define_method("text", text);
680
719
 
681
- cPainter.define_method("clear", clear);
682
- cPainter.define_method("bounds", bounds);
683
720
  cPainter.define_private_method("set_background", set_background);
684
721
  cPainter.define_private_method("get_background", get_background);
685
722
  cPainter.define_method( "no_background", no_background);
@@ -695,21 +732,21 @@ Init_painter ()
695
732
  cPainter.define_private_method("set_font", set_font);
696
733
  cPainter.define_private_method("get_font", get_font);
697
734
  cPainter.define_method("push_attr", push_attr);
698
- cPainter.define_method("pop_attr", pop_attr);
735
+ cPainter.define_method( "pop_attr", pop_attr);
699
736
 
700
737
  cPainter.define_private_method("attach_shader", attach_shader);
701
738
  cPainter.define_private_method("detach_shader", detach_shader);
702
739
  cPainter.define_private_method("set_uniform", set_uniform);
703
740
  cPainter.define_method("push_shader", push_shader);
704
- cPainter.define_method("pop_shader", pop_shader);
741
+ cPainter.define_method( "pop_shader", pop_shader);
705
742
 
706
743
  cPainter.define_method("translate", translate);
707
- cPainter.define_method("scale", scale);
708
- cPainter.define_method("rotate", rotate);
744
+ cPainter.define_method("scale", scale);
745
+ cPainter.define_method("rotate", rotate);
709
746
  cPainter.define_private_method("set_matrix", set_matrix);
710
747
  cPainter.define_private_method("get_matrix", get_matrix);
711
748
  cPainter.define_method("push_matrix", push_matrix);
712
- cPainter.define_method("pop_matrix", pop_matrix);
749
+ cPainter.define_method( "pop_matrix", pop_matrix);
713
750
  }
714
751
 
715
752