rays 0.1.48 → 0.1.49

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0da22dbb538f841d5c21371e0b0749479467b1c0746bbd459118b649c66678e0
4
- data.tar.gz: f55580763f45ce98198c59f6fe9ed86ac21f64aba8d16cf8b002923650c9b703
3
+ metadata.gz: 9a16981d77f0cc82e3020f1a80757dc7620da39d9b309823b47b8dc49883128a
4
+ data.tar.gz: 0bffdff4eceb4b60326882341d2fd3f0b2ff583dabfbab05f28127b276a4ab83
5
5
  SHA512:
6
- metadata.gz: d74814adfebbb7b9f0449abeebab017a475c76ae48a61c4f2f066e12a376fe52279db08cb6a27c3a3cadd26ae9179ce7fb204c59eff8440f9569121711d3a26e
7
- data.tar.gz: 74e423c7faa9747f34e7e37737882fffce493e127fb5870a7e6a2fb0d4cc6f122a3cac43d9afa96373a6ce69f147198007db9d958a93d478cd4d5f1a9441053b
6
+ metadata.gz: 2e417b9f4f751adeda1108ed76818171896caf4476188a7b3e9116e81f3d1a5d2c9e023e092b202a81c48f6a7a17faed7b388a5cf8211363350efe351f3b3df5
7
+ data.tar.gz: 33ff8e0b58b215a1e654fcc9aec4864e35a004a5470f412ce0cec7b0a81865b5d8dad003367ee6630fde11e34fb43b83e0c5f973d0d0f0fbe5cdd00795ef1255
@@ -103,6 +103,16 @@ VALUE get_alpha(VALUE self)
103
103
  return value(THIS->alpha);
104
104
  }
105
105
 
106
+ static
107
+ VALUE to_hsv(VALUE self)
108
+ {
109
+ CHECK;
110
+
111
+ float h, s, v;
112
+ Rays::get_hsv(&h, &s, &v, *THIS);
113
+ return array(h, s, v, THIS->alpha);
114
+ }
115
+
106
116
 
107
117
  typedef std::map<Rays::String, Rays::Color> ColorMap;
108
118
 
@@ -199,6 +209,7 @@ Init_rays_color ()
199
209
  rb_define_method(cColor, "blue", RUBY_METHOD_FUNC(get_blue), 0);
200
210
  rb_define_method(cColor, "alpha=", RUBY_METHOD_FUNC(set_alpha), 1);
201
211
  rb_define_method(cColor, "alpha", RUBY_METHOD_FUNC(get_alpha), 0);
212
+ rb_define_method(cColor, "to_hsv", RUBY_METHOD_FUNC(to_hsv), 0);
202
213
  rb_define_module_function(cColor, "hsv", RUBY_METHOD_FUNC(hsv), -1);
203
214
  rb_define_module_function(cColor, "set_palette_color", RUBY_METHOD_FUNC(set_palette_color), -1);
204
215
  }
@@ -104,10 +104,10 @@ VALUE painter(VALUE self)
104
104
  }
105
105
 
106
106
  static
107
- VALUE bitmap(VALUE self)
107
+ VALUE get_bitmap(VALUE self, VALUE modify)
108
108
  {
109
109
  CHECK;
110
- return value(THIS->bitmap());
110
+ return value(THIS->bitmap(modify));
111
111
  }
112
112
 
113
113
  static
@@ -134,7 +134,7 @@ Init_rays_image ()
134
134
  rb_define_method(cImage, "color_space", RUBY_METHOD_FUNC(color_space), 0);
135
135
  rb_define_method(cImage, "pixel_density", RUBY_METHOD_FUNC(pixel_density), 0);
136
136
  rb_define_method(cImage, "painter", RUBY_METHOD_FUNC(painter), 0);
137
- rb_define_method(cImage, "bitmap", RUBY_METHOD_FUNC(bitmap), 0);
137
+ rb_define_private_method(cImage, "get_bitmap", RUBY_METHOD_FUNC(get_bitmap), 1);
138
138
  rb_define_module_function(cImage, "load", RUBY_METHOD_FUNC(load), 1);
139
139
  }
140
140
 
@@ -67,6 +67,14 @@ VALUE reset(VALUE self)
67
67
  return self;
68
68
  }
69
69
 
70
+ static
71
+ VALUE transpose(VALUE self)
72
+ {
73
+ CHECK;
74
+ THIS->transpose();
75
+ return self;
76
+ }
77
+
70
78
  static
71
79
  VALUE translate(VALUE self)
72
80
  {
@@ -108,10 +116,10 @@ VALUE to_a(VALUE self)
108
116
  {
109
117
  CHECK;
110
118
  return array(
111
- THIS->x0, THIS->y0, THIS->z0, THIS->w0,
112
- THIS->x1, THIS->y1, THIS->z1, THIS->w1,
113
- THIS->x2, THIS->y2, THIS->z2, THIS->w2,
114
- THIS->x3, THIS->y3, THIS->z3, THIS->w3);
119
+ THIS->x0, THIS->x1, THIS->x2, THIS->x3,
120
+ THIS->y0, THIS->y1, THIS->y2, THIS->y3,
121
+ THIS->z0, THIS->z1, THIS->z2, THIS->z3,
122
+ THIS->w0, THIS->w1, THIS->w2, THIS->w3);
115
123
  }
116
124
 
117
125
  static
@@ -190,6 +198,51 @@ VALUE s_rotate(VALUE self)
190
198
  return rotate(argc, argv, value(Rays::Matrix()));
191
199
  }
192
200
 
201
+ static
202
+ VALUE s_ortho(VALUE self)
203
+ {
204
+ check_arg_count(__FILE__, __LINE__, "Matrix#ortho", argc, 4, 6);
205
+
206
+ coord l = to<coord>(argv[0]);
207
+ coord r = to<coord>(argv[1]);
208
+ coord t = to<coord>(argv[2]);
209
+ coord b = to<coord>(argv[3]);
210
+ if (argc == 4)
211
+ return value(Rays::ortho(l, r, t, b));
212
+ else
213
+ return value(Rays::ortho(l, r, t, b, to<coord>(argv[4]), to<coord>(argv[5])));
214
+ }
215
+
216
+ static
217
+ VALUE s_perspective(VALUE self, VALUE fov_y, VALUE aspect_ratio, VALUE near, VALUE far)
218
+ {
219
+ return value(Rays::perspective(
220
+ to<float>(fov_y), to<float>(aspect_ratio), to<coord>(near), to<coord>(far)));
221
+ }
222
+
223
+ static
224
+ VALUE s_look_at(VALUE self)
225
+ {
226
+ check_arg_count(__FILE__, __LINE__, "Matrix#ortho", argc, 3, 6, 9);
227
+
228
+ if (argc == 3)
229
+ {
230
+ return value(Rays::look_at(
231
+ to<Rays::Point&>(argv[0]),
232
+ to<Rays::Point&>(argv[1]),
233
+ to<Rays::Point&>(argv[2])));
234
+ }
235
+ else
236
+ {
237
+ return value(Rays::look_at(
238
+ to<coord>(argv[0]), to<coord>(argv[1]), to<coord>(argv[2]),
239
+ to<coord>(argv[3]), to<coord>(argv[4]), to<coord>(argv[5]),
240
+ argc >= 7 ? to<coord>(argv[6]) : 0,
241
+ argc >= 8 ? to<coord>(argv[7]) : 1,
242
+ argc >= 9 ? to<coord>(argv[8]) : 0));
243
+ }
244
+ }
245
+
193
246
 
194
247
  static Class cMatrix;
195
248
 
@@ -203,9 +256,10 @@ Init_rays_matrix ()
203
256
  rb_define_private_method(cMatrix, "initialize", RUBY_METHOD_FUNC(initialize), -1);
204
257
  rb_define_private_method(cMatrix, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
205
258
  rb_define_method(cMatrix, "reset", RUBY_METHOD_FUNC(reset), -1);
206
- rb_define_method(cMatrix, "translate", RUBY_METHOD_FUNC(translate), -1);
207
- rb_define_method(cMatrix, "scale", RUBY_METHOD_FUNC(scale), -1);
208
- rb_define_method(cMatrix, "rotate", RUBY_METHOD_FUNC(rotate), -1);
259
+ cMatrix.define_method("transpose!", transpose);
260
+ cMatrix.define_method("translate!", translate);
261
+ cMatrix.define_method("scale!", scale);
262
+ cMatrix.define_method("rotate!", rotate);
209
263
  rb_define_method(cMatrix, "to_a", RUBY_METHOD_FUNC(to_a), 0);
210
264
  cMatrix.define_method("*", mult);
211
265
  cMatrix.define_method("[]=", set_at);
@@ -216,6 +270,10 @@ Init_rays_matrix ()
216
270
  rb_define_singleton_method(cMatrix, "translate", RUBY_METHOD_FUNC(s_translate), -1);
217
271
  rb_define_singleton_method(cMatrix, "scale", RUBY_METHOD_FUNC(s_scale), -1);
218
272
  rb_define_singleton_method(cMatrix, "rotate", RUBY_METHOD_FUNC(s_rotate), -1);
273
+ rb_define_singleton_method(cMatrix, "ortho", RUBY_METHOD_FUNC(s_ortho), -1);
274
+ rb_define_singleton_method(cMatrix, "perspective", RUBY_METHOD_FUNC(s_perspective), 4);
275
+ rb_define_singleton_method(cMatrix, "look_at", RUBY_METHOD_FUNC(s_look_at), -1);
276
+
219
277
  }
220
278
 
221
279
 
@@ -147,6 +147,18 @@ VALUE polygon(VALUE self)
147
147
  return self;
148
148
  }
149
149
 
150
+ static
151
+ VALUE point(VALUE self)
152
+ {
153
+ CHECK;
154
+
155
+ std::vector<Rays::Point> points;
156
+ get_points(&points, argc, argv);
157
+
158
+ THIS->points(&points[0], points.size());
159
+ return self;
160
+ }
161
+
150
162
  static
151
163
  VALUE line(VALUE self, VALUE args, VALUE loop)
152
164
  {
@@ -458,6 +470,28 @@ VALUE get_nsegment(VALUE self)
458
470
  return value(THIS->nsegment());
459
471
  }
460
472
 
473
+ static
474
+ VALUE set_line_height(VALUE self, VALUE height)
475
+ {
476
+ CHECK;
477
+ THIS->set_line_height(height ? to<coord>(height) : -1);
478
+ return self;
479
+ }
480
+
481
+ static
482
+ VALUE get_line_height(VALUE self)
483
+ {
484
+ CHECK;
485
+ return value(THIS->line_height());
486
+ }
487
+
488
+ static
489
+ VALUE get_line_height_raw(VALUE self)
490
+ {
491
+ CHECK;
492
+ return value(THIS->line_height(true));
493
+ }
494
+
461
495
  static
462
496
  VALUE set_blend_mode(VALUE self, VALUE mode)
463
497
  {
@@ -721,12 +755,13 @@ Init_rays_painter ()
721
755
  cPainter.define_method( "painting?", is_painting);
722
756
  rb_define_method(cPainter, "clear", RUBY_METHOD_FUNC(clear), 0);
723
757
  rb_define_method(cPainter, "polygon", RUBY_METHOD_FUNC(polygon), -1);
724
- rb_define_private_method(cPainter, "draw_line", RUBY_METHOD_FUNC(line), 2);
725
- rb_define_private_method(cPainter, "draw_polyline", RUBY_METHOD_FUNC(polyline), 1);
726
- rb_define_private_method(cPainter, "draw_rect", RUBY_METHOD_FUNC(rect), 6);
727
- rb_define_private_method(cPainter, "draw_ellipse", RUBY_METHOD_FUNC(ellipse), 6);
728
- rb_define_private_method(cPainter, "draw_curve", RUBY_METHOD_FUNC(curve), 2);
729
- rb_define_private_method(cPainter, "draw_bezier", RUBY_METHOD_FUNC(bezier), 2);
758
+ rb_define_method(cPainter, "point", RUBY_METHOD_FUNC(point), -1);
759
+ cPainter.define_private_method("line!", line);
760
+ cPainter.define_private_method("polyline!", polyline);
761
+ cPainter.define_private_method("rect!", rect);
762
+ cPainter.define_private_method("ellipse!", ellipse);
763
+ cPainter.define_private_method("curve!", curve);
764
+ cPainter.define_private_method("bezier!", bezier);
730
765
  rb_define_method(cPainter, "image", RUBY_METHOD_FUNC(image), -1);
731
766
  rb_define_method(cPainter, "text", RUBY_METHOD_FUNC(text), -1);
732
767
 
@@ -751,6 +786,9 @@ Init_rays_painter ()
751
786
  rb_define_method(cPainter, "miter_limit", RUBY_METHOD_FUNC(get_miter_limit), 0);
752
787
  rb_define_method(cPainter, "nsegment=", RUBY_METHOD_FUNC(set_nsegment), 1);
753
788
  rb_define_method(cPainter, "nsegment", RUBY_METHOD_FUNC(get_nsegment), 0);
789
+ rb_define_method(cPainter, "line_height=", RUBY_METHOD_FUNC(set_line_height), 1);
790
+ rb_define_method(cPainter, "line_height", RUBY_METHOD_FUNC(get_line_height), 0);
791
+ cPainter.define_method("line_height!", get_line_height_raw);
754
792
  rb_define_method(cPainter, "blend_mode=", RUBY_METHOD_FUNC(set_blend_mode), 1);
755
793
  rb_define_method(cPainter, "blend_mode", RUBY_METHOD_FUNC(get_blend_mode), 0);
756
794
  rb_define_method(cPainter, "clip=", RUBY_METHOD_FUNC(set_clip), -1);
@@ -79,15 +79,6 @@ VALUE move_by(VALUE self)
79
79
 
80
80
  static
81
81
  VALUE rotate(VALUE self, VALUE degree)
82
- {
83
- CHECK;
84
- Rays::Point p = *THIS;
85
- p.rotate(to<float>(degree));
86
- return value(p);
87
- }
88
-
89
- static
90
- VALUE rotate_self(VALUE self, VALUE degree)
91
82
  {
92
83
  CHECK;
93
84
  THIS->rotate(to<float>(degree));
@@ -258,8 +249,7 @@ Init_rays_point ()
258
249
  rb_define_private_method(cPoint, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
259
250
  cPoint.define_method("move_to!", move_to);
260
251
  cPoint.define_method("move_by!", move_by);
261
- rb_define_method(cPoint, "rotate", RUBY_METHOD_FUNC(rotate), 1);
262
- cPoint.define_method("rotate!", rotate_self);
252
+ cPoint.define_method("rotate!", rotate);
263
253
  rb_define_method(cPoint, "length", RUBY_METHOD_FUNC(length), 0);
264
254
  rb_define_method(cPoint, "normalize", RUBY_METHOD_FUNC(normalize), 0);
265
255
  rb_define_method(cPoint, "normal", RUBY_METHOD_FUNC(normal), 0);
@@ -319,17 +319,19 @@ VALUE create_ellipse(VALUE self, VALUE
319
319
  }
320
320
 
321
321
  static
322
- VALUE create_curve(VALUE self, VALUE points, VALUE loop)
322
+ VALUE create_curve(VALUE self, VALUE points, VALUE loop, VALUE nsegment)
323
323
  {
324
324
  CreateParams params(points, nil(), nil());
325
- return value(Rays::create_curve(params.ppoints(), params.size(), loop));
325
+ uint nseg = nsegment ? 0 : to<uint>(nsegment);
326
+ return value(Rays::create_curve(params.ppoints(), params.size(), loop, nseg));
326
327
  }
327
328
 
328
329
  static
329
- VALUE create_bezier(VALUE self, VALUE points, VALUE loop)
330
+ VALUE create_bezier(VALUE self, VALUE points, VALUE loop, VALUE nsegment)
330
331
  {
331
332
  CreateParams params(points, nil(), nil());
332
- return value(Rays::create_bezier(params.ppoints(), params.size(), loop));
333
+ uint nseg = nsegment ? 0 : to<uint>(nsegment);
334
+ return value(Rays::create_bezier(params.ppoints(), params.size(), loop, nseg));
333
335
  }
334
336
 
335
337
 
data/ChangeLog.md CHANGED
@@ -1,6 +1,29 @@
1
1
  # rays ChangeLog
2
2
 
3
3
 
4
+ ## [v0.1.49] - 2024-02-07
5
+
6
+ - Add point(), line_height(), and line_height!() to Painter
7
+ - Add translate!(), scale!(), rotate!(), transpose(), and transpose!() to Rays::Matrix class
8
+ - Add ortho(), perspective(), and look_at() to Rays::Matrix
9
+ - Add Color#to_hsv
10
+ - Add get_hsv()
11
+ - hsb as an alias for hsv
12
+
13
+ - Font::get_width() handles multiple lines if there is a newline character
14
+ - Painter::curve() and Painter::bezier() use nsegment state
15
+ - Polygon.curve() and Polygon.bezier() can take 'nsegment' parameter
16
+ - When updating a texture with a bitmap, the texture is reused, not created anew
17
+ - If the texture is bound to the frame buffer, replacing it with a new texture will cause the drawing target to shift
18
+ - Set the modified flag on the texture in the framebuffer at the beginning of painting
19
+ - Set modified flag for bitmap if needed
20
+ - Throw error on conflict between bitmap and texture
21
+
22
+ - Fix a bug that dust was drawn on the right edge when drawing text
23
+ - Fix that Painter#point ignores stroke_cap
24
+ - Fix Matrix::to_a order
25
+
26
+
4
27
  ## [v0.1.48] - 2024-01-08
5
28
 
6
29
  - Add Bitmap#pixels=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.48
1
+ 0.1.49
data/ext/rays/color.cpp CHANGED
@@ -114,6 +114,17 @@ RUCY_DEF0(get_alpha)
114
114
  }
115
115
  RUCY_END
116
116
 
117
+ static
118
+ RUCY_DEF0(to_hsv)
119
+ {
120
+ CHECK;
121
+
122
+ float h, s, v;
123
+ Rays::get_hsv(&h, &s, &v, *THIS);
124
+ return array(h, s, v, THIS->alpha);
125
+ }
126
+ RUCY_END
127
+
117
128
 
118
129
  typedef std::map<Rays::String, Rays::Color> ColorMap;
119
130
 
@@ -212,7 +223,8 @@ Init_rays_color ()
212
223
  cColor.define_method("blue", get_blue);
213
224
  cColor.define_method("alpha=", set_alpha);
214
225
  cColor.define_method("alpha", get_alpha);
215
- cColor.define_module_function("hsv", hsv);
226
+ cColor.define_method( "to_hsv", to_hsv);
227
+ cColor.define_module_function("hsv", hsv);
216
228
  cColor.define_module_function("set_palette_color", set_palette_color);
217
229
  }
218
230
 
data/ext/rays/image.cpp CHANGED
@@ -113,10 +113,10 @@ RUCY_DEF0(painter)
113
113
  RUCY_END
114
114
 
115
115
  static
116
- RUCY_DEF0(bitmap)
116
+ RUCY_DEF1(get_bitmap, modify)
117
117
  {
118
118
  CHECK;
119
- return value(THIS->bitmap());
119
+ return value(THIS->bitmap(modify));
120
120
  }
121
121
  RUCY_END
122
122
 
@@ -145,7 +145,7 @@ Init_rays_image ()
145
145
  cImage.define_method("color_space", color_space);
146
146
  cImage.define_method("pixel_density", pixel_density);
147
147
  cImage.define_method("painter", painter);
148
- cImage.define_method("bitmap", bitmap);
148
+ cImage.define_private_method("get_bitmap", get_bitmap);
149
149
  cImage.define_module_function("load", load);
150
150
  }
151
151
 
data/ext/rays/matrix.cpp CHANGED
@@ -71,6 +71,15 @@ RUCY_DEFN(reset)
71
71
  }
72
72
  RUCY_END
73
73
 
74
+ static
75
+ RUCY_DEFN(transpose)
76
+ {
77
+ CHECK;
78
+ THIS->transpose();
79
+ return self;
80
+ }
81
+ RUCY_END
82
+
74
83
  static
75
84
  RUCY_DEFN(translate)
76
85
  {
@@ -115,10 +124,10 @@ RUCY_DEF0(to_a)
115
124
  {
116
125
  CHECK;
117
126
  return array(
118
- THIS->x0, THIS->y0, THIS->z0, THIS->w0,
119
- THIS->x1, THIS->y1, THIS->z1, THIS->w1,
120
- THIS->x2, THIS->y2, THIS->z2, THIS->w2,
121
- THIS->x3, THIS->y3, THIS->z3, THIS->w3);
127
+ THIS->x0, THIS->x1, THIS->x2, THIS->x3,
128
+ THIS->y0, THIS->y1, THIS->y2, THIS->y3,
129
+ THIS->z0, THIS->z1, THIS->z2, THIS->z3,
130
+ THIS->w0, THIS->w1, THIS->w2, THIS->w3);
122
131
  }
123
132
  RUCY_END
124
133
 
@@ -206,6 +215,54 @@ RUCY_DEFN(s_rotate)
206
215
  }
207
216
  RUCY_END
208
217
 
218
+ static
219
+ RUCY_DEFN(s_ortho)
220
+ {
221
+ check_arg_count(__FILE__, __LINE__, "Matrix#ortho", argc, 4, 6);
222
+
223
+ coord l = to<coord>(argv[0]);
224
+ coord r = to<coord>(argv[1]);
225
+ coord t = to<coord>(argv[2]);
226
+ coord b = to<coord>(argv[3]);
227
+ if (argc == 4)
228
+ return value(Rays::ortho(l, r, t, b));
229
+ else
230
+ return value(Rays::ortho(l, r, t, b, to<coord>(argv[4]), to<coord>(argv[5])));
231
+ }
232
+ RUCY_END
233
+
234
+ static
235
+ RUCY_DEF4(s_perspective, fov_y, aspect_ratio, near, far)
236
+ {
237
+ return value(Rays::perspective(
238
+ to<float>(fov_y), to<float>(aspect_ratio), to<coord>(near), to<coord>(far)));
239
+ }
240
+ RUCY_END
241
+
242
+ static
243
+ RUCY_DEFN(s_look_at)
244
+ {
245
+ check_arg_count(__FILE__, __LINE__, "Matrix#ortho", argc, 3, 6, 9);
246
+
247
+ if (argc == 3)
248
+ {
249
+ return value(Rays::look_at(
250
+ to<Rays::Point&>(argv[0]),
251
+ to<Rays::Point&>(argv[1]),
252
+ to<Rays::Point&>(argv[2])));
253
+ }
254
+ else
255
+ {
256
+ return value(Rays::look_at(
257
+ to<coord>(argv[0]), to<coord>(argv[1]), to<coord>(argv[2]),
258
+ to<coord>(argv[3]), to<coord>(argv[4]), to<coord>(argv[5]),
259
+ argc >= 7 ? to<coord>(argv[6]) : 0,
260
+ argc >= 8 ? to<coord>(argv[7]) : 1,
261
+ argc >= 9 ? to<coord>(argv[8]) : 0));
262
+ }
263
+ }
264
+ RUCY_END
265
+
209
266
 
210
267
  static Class cMatrix;
211
268
 
@@ -219,9 +276,10 @@ Init_rays_matrix ()
219
276
  cMatrix.define_private_method("initialize", initialize);
220
277
  cMatrix.define_private_method("initialize_copy", initialize_copy);
221
278
  cMatrix.define_method("reset", reset);
222
- cMatrix.define_method("translate", translate);
223
- cMatrix.define_method("scale", scale);
224
- cMatrix.define_method("rotate", rotate);
279
+ cMatrix.define_method("transpose!", transpose);
280
+ cMatrix.define_method("translate!", translate);
281
+ cMatrix.define_method("scale!", scale);
282
+ cMatrix.define_method("rotate!", rotate);
225
283
  cMatrix.define_method("to_a", to_a);
226
284
  cMatrix.define_method("*", mult);
227
285
  cMatrix.define_method("[]=", set_at);
@@ -232,6 +290,10 @@ Init_rays_matrix ()
232
290
  cMatrix.define_singleton_method("translate", s_translate);
233
291
  cMatrix.define_singleton_method("scale", s_scale);
234
292
  cMatrix.define_singleton_method("rotate", s_rotate);
293
+ cMatrix.define_singleton_method("ortho", s_ortho);
294
+ cMatrix.define_singleton_method("perspective", s_perspective);
295
+ cMatrix.define_singleton_method("look_at", s_look_at);
296
+
235
297
  }
236
298
 
237
299
 
data/ext/rays/painter.cpp CHANGED
@@ -156,6 +156,19 @@ RUCY_DEFN(polygon)
156
156
  }
157
157
  RUCY_END
158
158
 
159
+ static
160
+ RUCY_DEFN(point)
161
+ {
162
+ CHECK;
163
+
164
+ std::vector<Rays::Point> points;
165
+ get_points(&points, argc, argv);
166
+
167
+ THIS->points(&points[0], points.size());
168
+ return self;
169
+ }
170
+ RUCY_END
171
+
159
172
  static
160
173
  RUCY_DEF2(line, args, loop)
161
174
  {
@@ -496,6 +509,31 @@ RUCY_DEF0(get_nsegment)
496
509
  }
497
510
  RUCY_END
498
511
 
512
+ static
513
+ RUCY_DEF1(set_line_height, height)
514
+ {
515
+ CHECK;
516
+ THIS->set_line_height(height ? to<coord>(height) : -1);
517
+ return self;
518
+ }
519
+ RUCY_END
520
+
521
+ static
522
+ RUCY_DEF0(get_line_height)
523
+ {
524
+ CHECK;
525
+ return value(THIS->line_height());
526
+ }
527
+ RUCY_END
528
+
529
+ static
530
+ RUCY_DEF0(get_line_height_raw)
531
+ {
532
+ CHECK;
533
+ return value(THIS->line_height(true));
534
+ }
535
+ RUCY_END
536
+
499
537
  static
500
538
  RUCY_DEF1(set_blend_mode, mode)
501
539
  {
@@ -783,16 +821,17 @@ Init_rays_painter ()
783
821
  cPainter.define_private_method("begin_paint", begin_paint);
784
822
  cPainter.define_private_method( "end_paint", end_paint);
785
823
  cPainter.define_method( "painting?", is_painting);
786
- cPainter.define_method("clear", clear);
787
- cPainter.define_method("polygon", polygon);
788
- cPainter.define_private_method("draw_line", line);
789
- cPainter.define_private_method("draw_polyline", polyline);
790
- cPainter.define_private_method("draw_rect", rect);
791
- cPainter.define_private_method("draw_ellipse", ellipse);
792
- cPainter.define_private_method("draw_curve", curve);
793
- cPainter.define_private_method("draw_bezier", bezier);
794
- cPainter.define_method("image", image);
795
- cPainter.define_method("text", text);
824
+ cPainter.define_method("clear", clear);
825
+ cPainter.define_method( "polygon", polygon);
826
+ cPainter.define_method( "point", point);
827
+ cPainter.define_private_method("line!", line);
828
+ cPainter.define_private_method("polyline!", polyline);
829
+ cPainter.define_private_method("rect!", rect);
830
+ cPainter.define_private_method("ellipse!", ellipse);
831
+ cPainter.define_private_method("curve!", curve);
832
+ cPainter.define_private_method("bezier!", bezier);
833
+ cPainter.define_method( "image", image);
834
+ cPainter.define_method( "text", text);
796
835
 
797
836
  cPainter.define_method( "background=", set_background);
798
837
  cPainter.define_method( "background", get_background);
@@ -815,6 +854,9 @@ Init_rays_painter ()
815
854
  cPainter.define_method("miter_limit", get_miter_limit);
816
855
  cPainter.define_method("nsegment=", set_nsegment);
817
856
  cPainter.define_method("nsegment", get_nsegment);
857
+ cPainter.define_method("line_height=", set_line_height);
858
+ cPainter.define_method("line_height", get_line_height);
859
+ cPainter.define_method("line_height!", get_line_height_raw);
818
860
  cPainter.define_method("blend_mode=", set_blend_mode);
819
861
  cPainter.define_method("blend_mode", get_blend_mode);
820
862
  cPainter.define_method( "clip=", set_clip);
data/ext/rays/point.cpp CHANGED
@@ -84,16 +84,6 @@ RUCY_END
84
84
 
85
85
  static
86
86
  RUCY_DEF1(rotate, degree)
87
- {
88
- CHECK;
89
- Rays::Point p = *THIS;
90
- p.rotate(to<float>(degree));
91
- return value(p);
92
- }
93
- RUCY_END
94
-
95
- static
96
- RUCY_DEF1(rotate_self, degree)
97
87
  {
98
88
  CHECK;
99
89
  THIS->rotate(to<float>(degree));
@@ -283,8 +273,7 @@ Init_rays_point ()
283
273
  cPoint.define_private_method("initialize_copy", initialize_copy);
284
274
  cPoint.define_method("move_to!", move_to);
285
275
  cPoint.define_method("move_by!", move_by);
286
- cPoint.define_method("rotate", rotate);
287
- cPoint.define_method("rotate!", rotate_self);
276
+ cPoint.define_method("rotate!", rotate);
288
277
  cPoint.define_method("length", length);
289
278
  cPoint.define_method("normalize", normalize);
290
279
  cPoint.define_method("normal", normal);
data/ext/rays/polygon.cpp CHANGED
@@ -342,18 +342,20 @@ RUCY_DEF7(create_ellipse,
342
342
  RUCY_END
343
343
 
344
344
  static
345
- RUCY_DEF2(create_curve, points, loop)
345
+ RUCY_DEF3(create_curve, points, loop, nsegment)
346
346
  {
347
347
  CreateParams params(points, nil(), nil());
348
- return value(Rays::create_curve(params.ppoints(), params.size(), loop));
348
+ uint nseg = nsegment ? 0 : to<uint>(nsegment);
349
+ return value(Rays::create_curve(params.ppoints(), params.size(), loop, nseg));
349
350
  }
350
351
  RUCY_END
351
352
 
352
353
  static
353
- RUCY_DEF2(create_bezier, points, loop)
354
+ RUCY_DEF3(create_bezier, points, loop, nsegment)
354
355
  {
355
356
  CreateParams params(points, nil(), nil());
356
- return value(Rays::create_bezier(params.ppoints(), params.size(), loop));
357
+ uint nseg = nsegment ? 0 : to<uint>(nsegment);
358
+ return value(Rays::create_bezier(params.ppoints(), params.size(), loop, nseg));
357
359
  }
358
360
  RUCY_END
359
361
 
data/include/rays/color.h CHANGED
@@ -72,7 +72,9 @@ namespace Rays
72
72
 
73
73
  Color rgb8 (int red, int green, int blue, int alpha = 255);
74
74
 
75
- Color hsv (float hue, float saturation, float value, float alpha = 1);
75
+ Color hsv (float hue, float saturation, float value, float alpha = 1);
76
+
77
+ void get_hsv (float* hue, float* saturation, float* value, const Color& color);
76
78
 
77
79
 
78
80
  }// Rays
data/include/rays/image.h CHANGED
@@ -47,7 +47,7 @@ namespace Rays
47
47
 
48
48
  Painter painter ();
49
49
 
50
- Bitmap& bitmap ();
50
+ Bitmap& bitmap (bool modify = false);
51
51
 
52
52
  const Bitmap& bitmap () const;
53
53