rays 0.1.48 → 0.1.49

Sign up to get free protection for your applications and to get access to all the features.
data/src/painter.cpp CHANGED
@@ -59,6 +59,8 @@ namespace Rays
59
59
 
60
60
  uint nsegment;
61
61
 
62
+ coord line_height;
63
+
62
64
  BlendMode blend_mode;
63
65
 
64
66
  Bounds clip;
@@ -84,6 +86,7 @@ namespace Rays
84
86
  stroke_join = JOIN_DEFAULT;
85
87
  miter_limit = JOIN_DEFAULT_MITER_LIMIT;
86
88
  nsegment = 0;
89
+ line_height = -1;
87
90
  blend_mode = BLEND_NORMAL;
88
91
  clip .reset(-1);
89
92
  font = get_default_font();
@@ -723,7 +726,13 @@ namespace Rays
723
726
  set_blend_mode(self->state.blend_mode);
724
727
 
725
728
  FrameBuffer& fb = self->frame_buffer;
726
- if (fb) FrameBuffer_bind(fb.id());
729
+ if (fb)
730
+ {
731
+ FrameBuffer_bind(fb.id());
732
+
733
+ Texture& tex = fb.texture();
734
+ if (tex) tex.set_modified();
735
+ }
727
736
 
728
737
  const Bounds& vp = self->viewport;
729
738
  float density = self->pixel_density;
@@ -773,12 +782,7 @@ namespace Rays
773
782
  glFinish();
774
783
 
775
784
  if (self->frame_buffer)
776
- {
777
785
  FrameBuffer_unbind();
778
-
779
- Texture& tex = self->frame_buffer.texture();
780
- if (tex) tex.set_modified();
781
- }
782
786
  }
783
787
 
784
788
  bool
@@ -893,6 +897,24 @@ namespace Rays
893
897
  this, polygon, bounds.x, bounds.y, bounds.width, bounds.height, true);
894
898
  }
895
899
 
900
+ void
901
+ Painter::point (coord x, coord y)
902
+ {
903
+ polygon(create_point(x, y));
904
+ }
905
+
906
+ void
907
+ Painter::point (const Point& point)
908
+ {
909
+ polygon(create_point(point));
910
+ }
911
+
912
+ void
913
+ Painter::points (const Point* points, size_t size)
914
+ {
915
+ polygon(create_points(points, size));
916
+ }
917
+
896
918
  void
897
919
  Painter::line (coord x1, coord y1, coord x2, coord y2)
898
920
  {
@@ -990,7 +1012,7 @@ namespace Rays
990
1012
  coord x3, coord y3, coord x4, coord y4,
991
1013
  bool loop)
992
1014
  {
993
- polygon(create_curve(x1, y1, x2, y2, x3, y3, x4, y4, loop));
1015
+ polygon(create_curve(x1, y1, x2, y2, x3, y3, x4, y4, loop, nsegment()));
994
1016
  }
995
1017
 
996
1018
  void
@@ -998,13 +1020,13 @@ namespace Rays
998
1020
  const Point& p1, const Point& p2, const Point& p3, const Point& p4,
999
1021
  bool loop)
1000
1022
  {
1001
- polygon(create_curve(p1, p2, p3, p4, loop));
1023
+ polygon(create_curve(p1, p2, p3, p4, loop, nsegment()));
1002
1024
  }
1003
1025
 
1004
1026
  void
1005
1027
  Painter::curve (const Point* points, size_t size, bool loop)
1006
1028
  {
1007
- polygon(create_curve(points, size, loop));
1029
+ polygon(create_curve(points, size, loop, nsegment()));
1008
1030
  }
1009
1031
 
1010
1032
  void
@@ -1013,7 +1035,7 @@ namespace Rays
1013
1035
  coord x3, coord y3, coord x4, coord y4,
1014
1036
  bool loop)
1015
1037
  {
1016
- polygon(create_bezier(x1, y1, x2, y2, x3, y3, x4, y4, loop));
1038
+ polygon(create_bezier(x1, y1, x2, y2, x3, y3, x4, y4, loop, nsegment()));
1017
1039
  }
1018
1040
 
1019
1041
  void
@@ -1021,13 +1043,13 @@ namespace Rays
1021
1043
  const Point& p1, const Point& p2, const Point& p3, const Point& p4,
1022
1044
  bool loop)
1023
1045
  {
1024
- polygon(create_bezier(p1, p2, p3, p4, loop));
1046
+ polygon(create_bezier(p1, p2, p3, p4, loop, nsegment()));
1025
1047
  }
1026
1048
 
1027
1049
  void
1028
1050
  Painter::bezier (const Point* points, size_t size, bool loop)
1029
1051
  {
1030
- polygon(create_bezier(points, size, loop));
1052
+ polygon(create_bezier(points, size, loop, nsegment()));
1031
1053
  }
1032
1054
 
1033
1055
  static void
@@ -1176,7 +1198,7 @@ namespace Rays
1176
1198
  }
1177
1199
 
1178
1200
  static inline void
1179
- debug_draw_text (
1201
+ debug_draw_line (
1180
1202
  Painter* painter, const Font& font,
1181
1203
  coord x, coord y, coord str_width, coord str_height)
1182
1204
  {
@@ -1210,25 +1232,20 @@ namespace Rays
1210
1232
  }
1211
1233
 
1212
1234
  static void
1213
- draw_text (
1235
+ draw_line (
1214
1236
  Painter* painter, const Font& font,
1215
- const char* str, coord x, coord y, coord width = 0, coord height = 0)
1237
+ const char* line, coord x, coord y, coord width = 0, coord height = 0)
1216
1238
  {
1217
1239
  assert(painter && font && str && *str != '\0');
1218
1240
 
1219
1241
  Painter::Data* self = painter->self.get();
1220
1242
 
1221
- if (!self->painting)
1222
- invalid_state_error(__FILE__, __LINE__, "painting flag should be true.");
1223
-
1224
- if (!self->state.has_color())
1225
- return;
1226
-
1227
- float density = self->pixel_density;
1228
- coord str_w = Font_get_width(font, density, str);
1229
- coord str_h = Font_get_height(font, density);
1230
- int tex_w = ceil(str_w);
1231
- int tex_h = ceil(str_h);
1243
+ float density = self->pixel_density;
1244
+ const RawFont& rawfont = Font_get_raw(font, density);
1245
+ coord str_w = rawfont.get_width(line);
1246
+ coord str_h = rawfont.get_height();
1247
+ int tex_w = ceil(str_w);
1248
+ int tex_h = ceil(str_h);
1232
1249
  const Texture& texture = Image_get_texture(self->text_image);
1233
1250
  if (
1234
1251
  texture.width() < tex_w ||
@@ -1245,8 +1262,7 @@ namespace Rays
1245
1262
 
1246
1263
  assert(self->text_image.pixel_density() == density);
1247
1264
 
1248
- Bitmap_draw_string(
1249
- &self->text_image.bitmap(), Font_get_raw(font, density), str, 0, 0);
1265
+ Bitmap_draw_string(&self->text_image.bitmap(), rawfont, line, 0, 0);
1250
1266
 
1251
1267
  str_w /= density;
1252
1268
  str_h /= density;
@@ -1259,7 +1275,38 @@ namespace Rays
1259
1275
  x, y, str_w, str_h,
1260
1276
  false, true, &Shader_get_shader_for_text());
1261
1277
 
1262
- debug_draw_text(painter, font, x, y, str_w / density, str_h / density);
1278
+ debug_draw_line(painter, font, x, y, str_w / density, str_h / density);
1279
+ }
1280
+
1281
+ static void
1282
+ draw_text (
1283
+ Painter* painter, const Font& font,
1284
+ const char* str, coord x, coord y, coord width = 0, coord height = 0)
1285
+ {
1286
+ assert(painter && font && str && *str != '\0');
1287
+
1288
+ Painter::Data* self = painter->self.get();
1289
+
1290
+ if (!self->painting)
1291
+ invalid_state_error(__FILE__, __LINE__, "painting flag should be true.");
1292
+
1293
+ if (!self->state.has_color())
1294
+ return;
1295
+
1296
+ if (!strchr(str, '\n'))
1297
+ draw_line(painter, font, str, x, y, width, height);
1298
+ else
1299
+ {
1300
+ coord line_height = painter->line_height();
1301
+
1302
+ Xot::StringList lines;
1303
+ split(&lines, str, '\n');
1304
+ for (const auto& line : lines)
1305
+ {
1306
+ draw_line(painter, font, line.c_str(), x, y, width, height);
1307
+ y += line_height;
1308
+ }
1309
+ }
1263
1310
  }
1264
1311
 
1265
1312
  void
@@ -1454,6 +1501,21 @@ namespace Rays
1454
1501
  return self->state.nsegment;
1455
1502
  }
1456
1503
 
1504
+ void
1505
+ Painter::set_line_height (coord height)
1506
+ {
1507
+ if (height < 0) height = -1;
1508
+ self->state.line_height = height;
1509
+ }
1510
+
1511
+ coord
1512
+ Painter::line_height (bool raw) const
1513
+ {
1514
+ coord height = self->state.line_height;
1515
+ if (!raw && height < 0) height = self->state.font.get_height();
1516
+ return height;
1517
+ }
1518
+
1457
1519
  void
1458
1520
  Painter::set_blend_mode (BlendMode mode)
1459
1521
  {
data/src/polygon.cpp CHANGED
@@ -431,7 +431,7 @@ namespace Rays
431
431
  #endif
432
432
 
433
433
  static uint
434
- get_nsegment (
434
+ get_nsegment_for_angle (
435
435
  uint nsegment, uint nsegment_min, float angle_from, float angle_to)
436
436
  {
437
437
  float angle = angle_to - angle_from;
@@ -700,7 +700,7 @@ namespace Rays
700
700
  left_top != 0 || right_top != 0 ||
701
701
  left_bottom != 0 || right_bottom != 0);
702
702
 
703
- nsegment = get_nsegment(nsegment, 1, 0, 90);
703
+ nsegment = get_nsegment_for_angle(nsegment, 1, 0, 90);
704
704
 
705
705
  fix_rounds(
706
706
  &left_top, &right_top,
@@ -863,7 +863,7 @@ namespace Rays
863
863
  {
864
864
  assert(width != 0 && height != 0);
865
865
 
866
- nsegment = get_nsegment(nsegment, 3, 0, 360);
866
+ nsegment = get_nsegment_for_angle(nsegment, 3, 0, 360);
867
867
 
868
868
  bool has_hole = hole_size != 0;
869
869
  float radian_from = Xot::deg2rad(0);
@@ -904,7 +904,7 @@ namespace Rays
904
904
  {
905
905
  assert(width != 0 && height != 0 && angle_from != angle_to);
906
906
 
907
- nsegment = get_nsegment(nsegment, 3, angle_from, angle_to);
907
+ nsegment = get_nsegment_for_angle(nsegment, 3, angle_from, angle_to);
908
908
 
909
909
  bool has_hole = hole_size != 0;
910
910
  float radian_from = Xot::deg2rad(angle_from);
@@ -973,9 +973,17 @@ namespace Rays
973
973
  Polygon
974
974
  create_points (const Point* points, size_t size)
975
975
  {
976
+ static const coord DELTA = 0.01;
977
+
976
978
  Polygon p;
977
979
  for (size_t i = 0; i < size; ++i)
978
- p.self->append(Polyline(&points[i], 1, false, false));
980
+ {
981
+ // Polyline(&points[i], 1, false, false).expand() ignores CapType
982
+
983
+ coord x = points[i].x, y = points[i].y;
984
+ Point array[] = {{x, y}, {x + DELTA, y + DELTA}};
985
+ p.self->append(Polyline(array, 2, false, false));
986
+ }
979
987
  return p;
980
988
  }
981
989
 
@@ -1353,11 +1361,13 @@ namespace Rays
1353
1361
  create_spline (
1354
1362
  SplineType type,
1355
1363
  const Point* points, size_t size, bool loop,
1356
- uint nsegment = 16)
1364
+ uint nsegment = 0)
1357
1365
  {
1358
1366
  if (size % 4 != 0)
1359
1367
  argument_error(__FILE__, __LINE__);
1360
1368
 
1369
+ if (nsegment <= 0) nsegment = 16;
1370
+
1361
1371
  size_t count = size / 4;
1362
1372
  auto spline_fun = get_spline_fun(type);
1363
1373
 
@@ -1384,7 +1394,7 @@ namespace Rays
1384
1394
  create_curve (
1385
1395
  coord x1, coord y1, coord x2, coord y2,
1386
1396
  coord x3, coord y3, coord x4, coord y4,
1387
- bool loop)
1397
+ bool loop, uint nsegment)
1388
1398
  {
1389
1399
  const Point points[] = {
1390
1400
  Point(x1, y1),
@@ -1392,29 +1402,29 @@ namespace Rays
1392
1402
  Point(x3, y3),
1393
1403
  Point(x4, y4)
1394
1404
  };
1395
- return create_spline(CATMULLROM, points, 4, loop);
1405
+ return create_spline(CATMULLROM, points, 4, loop, nsegment);
1396
1406
  }
1397
1407
 
1398
1408
  Polygon
1399
1409
  create_curve (
1400
1410
  const Point& p1, const Point& p2, const Point& p3, const Point& p4,
1401
- bool loop)
1411
+ bool loop, uint nsegment)
1402
1412
  {
1403
1413
  const Point points[] = {p1, p2, p3, p4};
1404
- return create_spline(CATMULLROM, points, 4, loop);
1414
+ return create_spline(CATMULLROM, points, 4, loop, nsegment);
1405
1415
  }
1406
1416
 
1407
1417
  Polygon
1408
- create_curve (const Point* points, size_t size, bool loop)
1418
+ create_curve (const Point* points, size_t size, bool loop, uint nsegment)
1409
1419
  {
1410
- return create_spline(CATMULLROM, points, size, loop);
1420
+ return create_spline(CATMULLROM, points, size, loop, nsegment);
1411
1421
  }
1412
1422
 
1413
1423
  Polygon
1414
1424
  create_bezier (
1415
1425
  coord x1, coord y1, coord x2, coord y2,
1416
1426
  coord x3, coord y3, coord x4, coord y4,
1417
- bool loop)
1427
+ bool loop, uint nsegment)
1418
1428
  {
1419
1429
  const Point points[] = {
1420
1430
  Point(x1, y1),
@@ -1422,22 +1432,22 @@ namespace Rays
1422
1432
  Point(x3, y3),
1423
1433
  Point(x4, y4)
1424
1434
  };
1425
- return create_spline(BEZIER, points, 4, loop);
1435
+ return create_spline(BEZIER, points, 4, loop, nsegment);
1426
1436
  }
1427
1437
 
1428
1438
  Polygon
1429
1439
  create_bezier (
1430
1440
  const Point& p1, const Point& p2, const Point& p3, const Point& p4,
1431
- bool loop)
1441
+ bool loop, uint nsegment)
1432
1442
  {
1433
1443
  const Point points[] = {p1, p2, p3, p4};
1434
- return create_spline(BEZIER, points, 4, loop);
1444
+ return create_spline(BEZIER, points, 4, loop, nsegment);
1435
1445
  }
1436
1446
 
1437
1447
  Polygon
1438
- create_bezier (const Point* points, size_t size, bool loop)
1448
+ create_bezier (const Point* points, size_t size, bool loop, uint nsegment)
1439
1449
  {
1440
- return create_spline(BEZIER, points, size, loop);
1450
+ return create_spline(BEZIER, points, size, loop, nsegment);
1441
1451
  }
1442
1452
 
1443
1453
  void
data/src/texture.cpp CHANGED
@@ -145,7 +145,7 @@ namespace Rays
145
145
  }
146
146
 
147
147
  static void
148
- copy_bitmap (Bitmap* dest, const Bitmap& src)
148
+ copy_pixels (Bitmap* dest, const Bitmap& src)
149
149
  {
150
150
  assert(dest);
151
151
 
@@ -174,7 +174,7 @@ namespace Rays
174
174
  if (!*bmp)
175
175
  rays_error(__FILE__, __LINE__);
176
176
 
177
- copy_bitmap(bmp.get(), bitmap);
177
+ copy_pixels(bmp.get(), bitmap);
178
178
  return bmp;
179
179
  }
180
180
 
@@ -258,6 +258,25 @@ namespace Rays
258
258
  &bitmap);
259
259
  }
260
260
 
261
+ Texture&
262
+ Texture::operator = (const Bitmap& bitmap)
263
+ {
264
+ if (!bitmap)
265
+ argument_error(__FILE__, __LINE__);
266
+
267
+ int w = bitmap.width(), h = bitmap.height();
268
+ if (w != width() || h != height())
269
+ argument_error(__FILE__, __LINE__, "the size of bitmap does not match");
270
+
271
+ GLenum format, type;
272
+ ColorSpace_get_gl_format_and_type(&format, &type, bitmap.color_space());
273
+
274
+ glBindTexture(GL_TEXTURE_2D, self->id);
275
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, format, type, bitmap.pixels());
276
+
277
+ return *this;
278
+ }
279
+
261
280
  Texture::~Texture ()
262
281
  {
263
282
  }
data/src/texture.h CHANGED
@@ -28,6 +28,8 @@ namespace Rays
28
28
 
29
29
  Texture (const Bitmap& bitmap);
30
30
 
31
+ Texture& operator = (const Bitmap& bitmap);
32
+
31
33
  ~Texture ();
32
34
 
33
35
  int width () const;
data/test/test_color.rb CHANGED
@@ -66,19 +66,18 @@ class TestColor < Test::Unit::TestCase
66
66
  def test_set_rgb()
67
67
  o = color
68
68
  assert_equal [0, 0, 0, 1], o.to_a
69
- o.red = 1
69
+ o.red = 1
70
70
  assert_equal [1, 0, 0, 1], o.to_a
71
71
  o.green = 2
72
72
  assert_equal [1, 2, 0, 1], o.to_a
73
- o.blue = 3
73
+ o.blue = 3
74
74
  assert_equal [1, 2, 3, 1], o.to_a
75
75
  o.alpha = 4
76
76
  assert_equal [1, 2, 3, 4], o.to_a
77
77
  end
78
78
 
79
79
  def test_to_a()
80
- o = color 1, 2, 3, 4
81
- assert_equal [1, 2, 3, 4], o.to_a
80
+ assert_equal [1, 2, 3, 4], color(1, 2, 3, 4).to_a
82
81
  end
83
82
 
84
83
  def test_index()
@@ -121,6 +120,14 @@ class TestColor < Test::Unit::TestCase
121
120
  assert o > color(1, 2, 3, 3)
122
121
  end
123
122
 
123
+ def test_to_hsv()
124
+ h, s, v, a = hsv(0.1, 0.2, 0.3, 0.4).to_hsv
125
+ assert_in_delta 0.1, h
126
+ assert_in_delta 0.2, s
127
+ assert_in_delta 0.3, v
128
+ assert_in_delta 0.4, a
129
+ end
130
+
124
131
  def test_hsv_hue()
125
132
  assert_equal_color color(0.5, 0, 1), hsv(-0.25, 1, 1)
126
133
  assert_equal_color color(1, 0, 0), hsv( 0, 1, 1)
@@ -149,6 +156,16 @@ class TestColor < Test::Unit::TestCase
149
156
  assert_equal_color color(1, 0, 0, 1), hsv(1, 1, 1, 1)
150
157
  end
151
158
 
159
+ def test_hsb()
160
+ assert_equal(
161
+ Rays::Color.hsv(0.1, 0.2, 0.3, 0.4),
162
+ Rays::Color.hsb(0.1, 0.2, 0.3, 0.4))
163
+
164
+ assert_equal(
165
+ color(0.1, 0.2, 0.3, 0.4).to_hsv,
166
+ color(0.1, 0.2, 0.3, 0.4).to_hsb)
167
+ end
168
+
152
169
  def test_inspect()
153
170
  assert_equal "#<Rays::Color 1.0 2.0 3.0 1.0>", color(1, 2, 3).inspect
154
171
  end
data/test/test_font.rb CHANGED
@@ -34,6 +34,9 @@ class TestFont < Test::Unit::TestCase
34
34
  assert_equal 0, font.width('')
35
35
  w = font.width 'X'
36
36
  assert_equal w * 2, font.width('XX')
37
+ assert_equal w * 2, font.width("XX\nX")
38
+ assert_equal w * 2, font.width("XX\nXX")
39
+ assert_equal w * 3, font.width("XX\nXXX")
37
40
  end
38
41
 
39
42
  def test_height()
data/test/test_image.rb CHANGED
@@ -19,6 +19,10 @@ class TestImage < Test::Unit::TestCase
19
19
  Rays::Bounds.new(*args)
20
20
  end
21
21
 
22
+ def update_texture(img)
23
+ image(1, 1).paint {image img}
24
+ end
25
+
22
26
  def test_initialize()
23
27
  assert_equal 10, image(10, 20).width
24
28
  assert_equal 20, image(10, 20).height
@@ -42,6 +46,28 @@ class TestImage < Test::Unit::TestCase
42
46
  assert_equal 10, image(20, 10).bitmap.height
43
47
  end
44
48
 
49
+ def test_bitmap_with_modify_flag()
50
+ img1 = image 1, 1
51
+ update_texture img1
52
+ img1.bitmap(false).tap {|bmp| bmp[0, 0] = color 1, 0, 0, 1}
53
+
54
+ img2 = image 1, 1
55
+ update_texture img2
56
+ img2.bitmap(true) .tap {|bmp| bmp[0, 0] = color 0, 1, 0, 1}
57
+
58
+ assert_equal [0x00000000], image(1, 1).paint {image img1}.pixels
59
+ assert_equal [0xff00ff00], image(1, 1).paint {image img2}.pixels
60
+ end
61
+
62
+ def test_pixels()
63
+ img = image 2, 1
64
+ assert_equal [0x00000000, 0x00000000], img.pixels
65
+
66
+ img.pixels = [0xffff0000, 0xff00ff00]
67
+ assert_equal [0xffff0000, 0xff00ff00], img.pixels
68
+ assert_equal [0xffff0000, 0xff00ff00], image(2, 1).paint {image img}.pixels
69
+ end
70
+
45
71
  def test_painter()
46
72
  pa = image(10, 10).painter
47
73
  assert_equal color(0, 0, 0, 0), pa.background
data/test/test_matrix.rb CHANGED
@@ -87,6 +87,10 @@ class TestMatrix < Test::Unit::TestCase
87
87
  assert o > matrix(0)
88
88
  end
89
89
 
90
+ def test_transpose()
91
+ assert_equal mat_str('1594 2615 3726 4837'), mat_str('1234 5678 9123 4567').transpose
92
+ end
93
+
90
94
  def test_transform()
91
95
  assert_equal mat_str('1001 0102 0013 0001'), translate(1, 2, 3)
92
96
  assert_equal mat_str('2000 0300 0040 0001'), scale(2, 3, 4)
@@ -100,4 +104,22 @@ class TestMatrix < Test::Unit::TestCase
100
104
  assert (rotate(90, 1, 0, 0) * point(0, 1, 0)).z > 0.99
101
105
  end
102
106
 
107
+ def test_ortho()
108
+ m = Rays::Matrix
109
+ assert_equal m, m.ortho(1, 2, 3, 4) .class
110
+ assert_equal m, m.ortho(1, 2, 3, 4, 5, 6).class
111
+ end
112
+
113
+ def test_projection()
114
+ m = Rays::Matrix
115
+ assert_equal m, m.ortho(1, 2, 3, 4).class
116
+ end
117
+
118
+ def test_look_at()
119
+ m = Rays::Matrix
120
+ assert_equal m, m.look_at(1, 2, 3, 4, 5, 6) .class
121
+ assert_equal m, m.look_at(1, 2, 3, 4, 5, 6, 7, 8, 9) .class
122
+ assert_equal m, m.look_at(point(1, 2, 3), point(4, 5, 6), point(7, 8, 9)).class
123
+ end
124
+
103
125
  end# TestMatrix
data/test/test_painter.rb CHANGED
@@ -152,6 +152,33 @@ class TestPainter < Test::Unit::TestCase
152
152
  assert_equal 4, pa.miter_limit
153
153
  end
154
154
 
155
+ def test_line_height_accessor()
156
+ pa = painter
157
+
158
+ h = pa.line_height
159
+ assert h > 0
160
+ assert_not_equal 1, h
161
+
162
+ assert_equal [h, -1], [pa.line_height, pa.line_height!]
163
+ pa.line_height = 1
164
+ assert_equal [1, 1], [pa.line_height, pa.line_height!]
165
+ pa.line_height 2
166
+ assert_equal [2, 2], [pa.line_height, pa.line_height!]
167
+ pa.push line_height: 9 do |_|
168
+ assert_equal [9, 9], [pa.line_height, pa.line_height!]
169
+ end
170
+ assert_equal [2, 2], [pa.line_height, pa.line_height!]
171
+ pa.line_height = -1
172
+ assert_equal [h, -1], [pa.line_height, pa.line_height!]
173
+ pa.line_height 0
174
+ assert_equal [0, 0], [pa.line_height, pa.line_height!]
175
+ pa.line_height = nil
176
+ assert_equal [h, -1], [pa.line_height, pa.line_height!]
177
+
178
+ pa.font "Menlo", 100
179
+ assert_equal pa.font.height, pa.line_height
180
+ end
181
+
155
182
  def test_blend_mode_accessor()
156
183
  pa = painter
157
184
  assert_equal :normal, pa.blend_mode
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rays
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.48
4
+ version: 0.1.49
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-07 00:00:00.000000000 Z
11
+ date: 2024-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.41
19
+ version: 0.1.42
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.41
26
+ version: 0.1.42
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rucy
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.43
33
+ version: 0.1.44
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.1.43
40
+ version: 0.1.44
41
41
  description: This library helps you to develop graphics application with OpenGL.
42
42
  email: xordog@gmail.com
43
43
  executables: []
@@ -260,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
260
  - !ruby/object:Gem::Version
261
261
  version: '0'
262
262
  requirements: []
263
- rubygems_version: 3.4.10
263
+ rubygems_version: 3.4.19
264
264
  signing_key:
265
265
  specification_version: 4
266
266
  summary: A Drawing Engine using OpenGL.