rays 0.2.1 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/rays/bitmap.cpp +99 -32
  3. data/.doc/ext/rays/bounds.cpp +16 -12
  4. data/.doc/ext/rays/camera.cpp +1 -1
  5. data/.doc/ext/rays/color.cpp +2 -2
  6. data/.doc/ext/rays/color_space.cpp +3 -3
  7. data/.doc/ext/rays/defs.cpp +4 -4
  8. data/.doc/ext/rays/font.cpp +4 -3
  9. data/.doc/ext/rays/image.cpp +32 -18
  10. data/.doc/ext/rays/matrix.cpp +6 -6
  11. data/.doc/ext/rays/painter.cpp +1 -1
  12. data/.doc/ext/rays/point.cpp +10 -6
  13. data/.doc/ext/rays/polygon.cpp +11 -9
  14. data/.doc/ext/rays/polyline.cpp +6 -4
  15. data/.doc/ext/rays/rays.cpp +25 -15
  16. data/.doc/ext/rays/shader.cpp +3 -3
  17. data/.github/workflows/release-gem.yml +1 -1
  18. data/.github/workflows/test.yml +3 -0
  19. data/ChangeLog.md +11 -0
  20. data/Gemfile.lock +1 -1
  21. data/LICENSE +1 -1
  22. data/Rakefile +17 -3
  23. data/VERSION +1 -1
  24. data/ext/rays/bitmap.cpp +99 -32
  25. data/ext/rays/bounds.cpp +16 -12
  26. data/ext/rays/camera.cpp +1 -1
  27. data/ext/rays/color.cpp +2 -2
  28. data/ext/rays/color_space.cpp +3 -3
  29. data/ext/rays/defs.cpp +4 -4
  30. data/ext/rays/defs.h +2 -0
  31. data/ext/rays/extconf.rb +4 -2
  32. data/ext/rays/font.cpp +4 -3
  33. data/ext/rays/image.cpp +34 -18
  34. data/ext/rays/matrix.cpp +6 -6
  35. data/ext/rays/painter.cpp +1 -1
  36. data/ext/rays/point.cpp +10 -6
  37. data/ext/rays/polygon.cpp +11 -9
  38. data/ext/rays/polyline.cpp +6 -4
  39. data/ext/rays/rays.cpp +25 -15
  40. data/ext/rays/shader.cpp +3 -3
  41. data/include/rays/defs.h +7 -0
  42. data/include/rays/image.h +8 -2
  43. data/include/rays/ruby/bitmap.h +2 -2
  44. data/include/rays/ruby/bounds.h +2 -2
  45. data/include/rays/ruby/camera.h +2 -2
  46. data/include/rays/ruby/color.h +2 -2
  47. data/include/rays/ruby/color_space.h +2 -2
  48. data/include/rays/ruby/exception.h +3 -3
  49. data/include/rays/ruby/font.h +2 -2
  50. data/include/rays/ruby/image.h +2 -2
  51. data/include/rays/ruby/matrix.h +2 -2
  52. data/include/rays/ruby/painter.h +2 -2
  53. data/include/rays/ruby/point.h +2 -2
  54. data/include/rays/ruby/polygon.h +2 -2
  55. data/include/rays/ruby/polyline.h +2 -2
  56. data/include/rays/ruby/rays.h +6 -6
  57. data/include/rays/ruby/shader.h +2 -2
  58. data/lib/rays/bitmap.rb +7 -0
  59. data/lib/rays/extension.rb +4 -0
  60. data/lib/rays/image.rb +4 -0
  61. data/rays.gemspec +2 -2
  62. data/src/bounds.cpp +6 -2
  63. data/src/color.cpp +12 -4
  64. data/src/coord.h +2 -2
  65. data/src/font.cpp +1 -0
  66. data/src/image.cpp +32 -4
  67. data/src/ios/bitmap.mm +40 -33
  68. data/src/ios/font.mm +6 -1
  69. data/src/ios/rays.mm +2 -2
  70. data/src/matrix.h +1 -1
  71. data/src/opengl.h +1 -2
  72. data/src/osx/bitmap.mm +40 -33
  73. data/src/osx/font.mm +6 -1
  74. data/src/osx/rays.mm +2 -2
  75. data/src/painter.cpp +4 -1
  76. data/src/point.cpp +15 -3
  77. data/src/polygon.cpp +3 -5
  78. data/src/render_buffer.cpp +11 -3
  79. data/src/shader.cpp +3 -0
  80. data/src/shader_program.cpp +19 -9
  81. data/src/shader_source.cpp +5 -1
  82. data/src/texture.cpp +33 -11
  83. data/src/texture.h +6 -2
  84. data/src/win32/bitmap.cpp +178 -66
  85. data/src/win32/camera.cpp +119 -0
  86. data/src/win32/font.cpp +181 -40
  87. data/src/win32/gdi.h +1 -1
  88. data/src/win32/opengl.cpp +127 -0
  89. data/src/win32/rays.cpp +16 -9
  90. data/test/helper.rb +2 -0
  91. data/test/test_bitmap.rb +3 -1
  92. data/test/test_image.rb +8 -14
  93. data/test/test_painter.rb +4 -4
  94. data/test/test_painter_shape.rb +6 -5
  95. metadata +8 -7
  96. data/src/win32/font.h +0 -24
data/src/win32/font.cpp CHANGED
@@ -1,97 +1,238 @@
1
- #include "font.h"
1
+ #include "../font.h"
2
+
3
+
4
+ #include <assert.h>
5
+ #include <set>
6
+ #include "rays/exception.h"
7
+ #include "gdi.h"
2
8
 
3
9
 
4
10
  namespace Rays
5
11
  {
6
12
 
7
13
 
8
- struct Font::Data
14
+ struct RawFont::Data
9
15
  {
10
16
 
11
17
  Win32::Font font;
12
18
 
13
- };// Window::Data
19
+ String path;
20
+
21
+ };// RawFont::Data
14
22
 
15
23
 
16
- Font::Font ()
24
+ typedef std::set<String> StringSet;
25
+
26
+ struct EnumFontFamiliesCallbackParams
17
27
  {
18
- }
19
28
 
20
- Font::Font (const char* name, coord size)
29
+ StringSet* names;
30
+
31
+ bool fullname;
32
+
33
+ EnumFontFamiliesCallbackParams (StringSet* names, bool fullname)
34
+ : names(names), fullname(fullname)
35
+ {
36
+ }
37
+
38
+ };// EnumFontFamiliesCallbackParams
39
+
40
+
41
+ static int CALLBACK
42
+ enum_callback (
43
+ const ENUMLOGFONT* elf, const NEWTEXTMETRIC* ntm, DWORD font_type, LPARAM lp)
21
44
  {
22
- self->font = Win32::Font(name, size);
45
+ const auto* params = (EnumFontFamiliesCallbackParams*) lp;
46
+ const char* name = params->fullname
47
+ ? (const char*) elf->elfFullName
48
+ : (const char*) elf->elfLogFont.lfFaceName;
49
+
50
+ if (name && *name != '\0' && *name != '@')
51
+ params->names->insert(name);
52
+
53
+ return TRUE;
23
54
  }
24
55
 
25
- Font::~Font ()
56
+ static void
57
+ get_font_names (
58
+ StringSet* names, HDC hdc, const char* query = NULL, bool fullname = false)
26
59
  {
60
+ assert(!query || strlen(query) < LF_FACESIZE);
61
+
62
+ LOGFONT lf = {0};
63
+ lf.lfCharSet = DEFAULT_CHARSET;
64
+
65
+ if (query) strcpy(lf.lfFaceName, query);
66
+
67
+ EnumFontFamiliesCallbackParams params(names, fullname);
68
+ EnumFontFamiliesEx(
69
+ hdc, &lf, (FONTENUMPROC) &enum_callback, (LPARAM) &params, 0);
27
70
  }
28
71
 
29
- String
30
- Font::name () const
72
+ const FontFamilyMap&
73
+ get_font_families ()
31
74
  {
32
- return self->font.name();
75
+ static const FontFamilyMap MAP = []() {
76
+ Win32::DC dc(GetDC(NULL), true, Win32::DC::RELEASE_DC);
77
+
78
+ StringSet families;
79
+ get_font_names(&families, dc.handle());
80
+
81
+ StringSet faces;
82
+ FontFamilyMap map;
83
+ for (const auto& family : families)
84
+ {
85
+ faces.clear();
86
+ get_font_names(&faces, dc.handle(), family, true);
87
+
88
+ auto& list = map[family];
89
+ list.insert(list.end(), faces.begin(), faces.end());
90
+ }
91
+
92
+ return map;
93
+ }();
94
+ return MAP;
33
95
  }
34
96
 
35
- coord
36
- Font::size () const
97
+ RawFont
98
+ RawFont_load (const char* path, coord size)
37
99
  {
38
- return self->font.size();
100
+ not_implemented_error(__FILE__, __LINE__);
39
101
  }
40
102
 
41
- bool
42
- Font::get_extent (coord* width, coord* height, const char* str) const
103
+
104
+ RawFont::RawFont ()
43
105
  {
44
- return self->font.get_extent(width, height, str);
45
106
  }
46
107
 
47
- Font::operator bool () const
108
+ RawFont::RawFont (const char* name, coord size)
48
109
  {
49
- return self && self->font;
110
+ self->font = Win32::Font(name, size);
50
111
  }
51
112
 
52
- bool
53
- Font::operator ! () const
113
+ RawFont::RawFont (const This& obj, coord size)
54
114
  {
55
- return !operator bool();
115
+ const char* path = obj.self->path.empty() ? NULL : obj.self->path.c_str();
116
+ if (path)
117
+ *this = RawFont_load(path, size);
118
+ else
119
+ self->font = Win32::Font(obj.name().c_str(), size);
56
120
  }
57
121
 
58
-
59
- const Font&
60
- get_default_font ()
122
+ RawFont::~RawFont ()
61
123
  {
62
- static const Font FONT(NULL);
63
- return FONT;
64
124
  }
65
125
 
66
-
67
126
  void
68
- Font_draw_string (
69
- const Font& font, HDC hdc, coord context_height,
70
- const char* str, coord x, coord y)
127
+ RawFont::draw_string (
128
+ void* context, coord context_height,
129
+ const char* str, coord x, coord y) const
71
130
  {
72
131
  using namespace Win32;
73
132
 
74
- if (!font || !hdc || !str)
133
+ HDC hdc = (HDC) context;
134
+
135
+ if (!hdc)
136
+ argument_error(__FILE__, __LINE__);
137
+ if (!str)
75
138
  argument_error(__FILE__, __LINE__);
76
139
 
77
140
  if (*str == '\0') return;
78
141
 
142
+ if (!*this)
143
+ invalid_state_error(__FILE__, __LINE__);
144
+
79
145
  coord width = 0, height = 0;
80
- if (!font.get_extent(&width, &height, str))
81
- rays_error(__FILE__, __LINE__, "getting font extent failed.");
146
+ if (!self->font.get_extent(&width, &height, str))
147
+ rays_error(__FILE__, __LINE__, "failed to get font extent.");
82
148
 
83
- DC dc = hdc;
84
- RECT rect = {x, y, x + (int) width, y + (int) height};
85
- FillRect(dc.handle(), &rect, Brush(0, 0, 0).handle());
149
+ DC dc = hdc;
150
+ Win32::Font font = dc.font();
151
+ COLORREF text_color = dc.text_color();
152
+ COLORREF back_color = dc.back_color();
153
+
154
+ dc.set_font(self->font.handle());
155
+ dc.set_text_color(RGB(255, 255, 255));
156
+ dc.set_back_color(RGB(0, 0, 0));
86
157
 
87
- Win32::Font old = dc.font();
88
- dc.set_font(font.self->font.handle());
89
158
  BOOL ret = TextOutA(dc.handle(), x, y, str, strlen(str));
90
- dc.set_font(old);
159
+
160
+ dc.set_font(font);
161
+ dc.set_text_color(text_color);
162
+ dc.set_back_color(back_color);
91
163
 
92
164
  if (ret == FALSE)
93
165
  rays_error(__FILE__, __LINE__, "drawing text failed.");
94
166
  }
95
167
 
168
+ String
169
+ RawFont::name () const
170
+ {
171
+ if (!*this) return "";
172
+ return self->font.name();
173
+ }
174
+
175
+ coord
176
+ RawFont::size () const
177
+ {
178
+ if (!*this) return 0;
179
+ return self->font.size();
180
+ }
181
+
182
+ coord
183
+ RawFont::get_width (const char* str) const
184
+ {
185
+ if (!str)
186
+ argument_error(__FILE__, __LINE__);
187
+
188
+ if (!*this)
189
+ invalid_state_error(__FILE__, __LINE__);
190
+
191
+ if (*str == '\0') return 0;
192
+
193
+ coord width;
194
+ if (!self->font.get_extent(&width, NULL, str))
195
+ rays_error(__FILE__, __LINE__, "failed to get font width");
196
+
197
+ return width;
198
+ }
199
+
200
+ coord
201
+ RawFont::get_height (coord* ascent, coord* descent, coord* leading) const
202
+ {
203
+ if (!*this)
204
+ invalid_state_error(__FILE__, __LINE__);
205
+
206
+ if (ascent || descent || leading)
207
+ {
208
+ Win32::DC dc(GetDC(NULL), true, Win32::DC::RELEASE_DC);
209
+ dc.set_font(self->font);
210
+
211
+ TEXTMETRIC tm;
212
+ GetTextMetrics(dc.handle(), &tm);
213
+
214
+ if (ascent) *ascent = tm.tmAscent;
215
+ if (descent) *descent = tm.tmDescent;
216
+ if (leading) *leading = tm.tmExternalLeading;
217
+ }
218
+
219
+ coord height;
220
+ if (!self->font.get_extent(NULL, &height, "X"))
221
+ rays_error(__FILE__, __LINE__, "failed to get font height");
222
+
223
+ return height;
224
+ }
225
+
226
+ RawFont::operator bool () const
227
+ {
228
+ return self->font;
229
+ }
230
+
231
+ bool
232
+ RawFont::operator ! () const
233
+ {
234
+ return !operator bool();
235
+ }
236
+
96
237
 
97
238
  }// Rays
data/src/win32/gdi.h CHANGED
@@ -4,8 +4,8 @@
4
4
  #define __RAYS_SRC_WIN32_GDI_H__
5
5
 
6
6
 
7
- #include <windows.h>
8
7
  #include <xot/pimpl.h>
8
+ #include <xot/windows.h>
9
9
  #include "rays/defs.h"
10
10
 
11
11
 
@@ -0,0 +1,127 @@
1
+ #include "../opengl.h"
2
+
3
+
4
+ #include <xot/windows.h>
5
+ #include "rays/rays.h"
6
+ #include "rays/exception.h"
7
+
8
+
9
+ namespace Rays
10
+ {
11
+
12
+
13
+ static const char* WINDOW_CLASS = "Rays:OffscreenWindow";
14
+
15
+
16
+ struct OffscreenContext
17
+ {
18
+
19
+ HWND hwnd = NULL;
20
+
21
+ HDC hdc = NULL;
22
+
23
+ HGLRC hrc = NULL;
24
+
25
+ OffscreenContext ()
26
+ {
27
+ static const PIXELFORMATDESCRIPTOR PFD =
28
+ {
29
+ sizeof(PIXELFORMATDESCRIPTOR), 1,
30
+ PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL,
31
+ PFD_TYPE_RGBA, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0,
32
+ PFD_MAIN_PLANE, 0, 0, 0, 0
33
+ };
34
+
35
+ WNDCLASS wc = {0};
36
+ wc.lpfnWndProc = DefWindowProc;
37
+ wc.hInstance = GetModuleHandle(NULL);
38
+ wc.lpszClassName = WINDOW_CLASS;
39
+ wc.style = CS_OWNDC;
40
+ if (!RegisterClass(&wc))
41
+ {
42
+ // It's OK to be registered by the duplicated Rays module
43
+ if (GetLastError() != ERROR_CLASS_ALREADY_EXISTS)
44
+ system_error(__FILE__, __LINE__);
45
+ }
46
+
47
+ hwnd = CreateWindowEx(
48
+ WS_EX_LAYERED, WINDOW_CLASS, "", WS_POPUP, 0, 0, 1, 1,
49
+ NULL, NULL, GetModuleHandle(NULL), NULL);
50
+ if (!hwnd)
51
+ system_error(__FILE__, __LINE__);
52
+
53
+ hdc = GetDC(hwnd);
54
+ int pf = ChoosePixelFormat(hdc, &PFD);
55
+ if (!SetPixelFormat(hdc, pf, &PFD))
56
+ system_error(__FILE__, __LINE__);
57
+
58
+ hrc = wglCreateContext(hdc);
59
+ if (!hrc)
60
+ system_error(__FILE__, __LINE__);
61
+ }
62
+
63
+ ~OffscreenContext ()
64
+ {
65
+
66
+ if (hrc && hrc == wglGetCurrentContext())
67
+ {
68
+ if (!wglMakeCurrent(NULL, NULL))
69
+ system_error(__FILE__, __LINE__);
70
+ }
71
+
72
+ if (!wglDeleteContext(hrc))
73
+ system_error(__FILE__, __LINE__);
74
+
75
+ if (!ReleaseDC(hwnd, hdc))
76
+ system_error(__FILE__, __LINE__);
77
+
78
+ if (!DestroyWindow(hwnd))
79
+ system_error(__FILE__, __LINE__);
80
+ }
81
+
82
+ };// OffscreenContext
83
+
84
+
85
+ static OffscreenContext*
86
+ get_opengl_offscreen_context ()
87
+ {
88
+ static OffscreenContext* context = NULL;
89
+ if (!context) context = new OffscreenContext();
90
+ return context;
91
+ }
92
+
93
+ void
94
+ OpenGL_init ()
95
+ {
96
+ activate_offscreen_context();
97
+
98
+ static bool glew_initialized = false;
99
+ if (!glew_initialized)
100
+ {
101
+ glew_initialized = true;
102
+ if (glewInit() != GLEW_OK)
103
+ opengl_error(__FILE__, __LINE__, "failed to initialize GLEW.");
104
+ }
105
+ }
106
+
107
+ void
108
+ OpenGL_fin ()
109
+ {
110
+ }
111
+
112
+
113
+ Context
114
+ get_offscreen_context ()
115
+ {
116
+ return get_opengl_offscreen_context();
117
+ }
118
+
119
+ void
120
+ activate_offscreen_context ()
121
+ {
122
+ const auto* c = get_opengl_offscreen_context();
123
+ wglMakeCurrent(c->hdc, c->hrc);
124
+ }
125
+
126
+
127
+ }// Rays
data/src/win32/rays.cpp CHANGED
@@ -1,7 +1,10 @@
1
- // -*- objc -*-
2
1
  #include "rays/rays.h"
3
2
 
4
3
 
4
+ #include "rays/exception.h"
5
+ #include "../opengl.h"
6
+
7
+
5
8
  namespace Rays
6
9
  {
7
10
 
@@ -9,27 +12,31 @@ namespace Rays
9
12
  namespace global
10
13
  {
11
14
 
12
-
13
15
  static bool initialized = false;
14
16
 
15
-
16
17
  }// global
17
18
 
18
19
 
19
- bool
20
+ void
20
21
  init ()
21
22
  {
22
- if (global::initialized) return false;
23
+ if (global::initialized)
24
+ rays_error(__FILE__, __LINE__, "already initialized.");
25
+
23
26
  global::initialized = true;
24
- return true;
27
+
28
+ OpenGL_init();
25
29
  }
26
30
 
27
- bool
31
+ void
28
32
  fin ()
29
33
  {
30
- if (!global::initialized) return false;
34
+ if (!global::initialized)
35
+ rays_error(__FILE__, __LINE__, "not initialized.");
36
+
37
+ OpenGL_fin();
38
+
31
39
  global::initialized = false;
32
- return true;
33
40
  }
34
41
 
35
42
 
data/test/helper.rb CHANGED
@@ -3,11 +3,13 @@
3
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
4
 
5
5
  require 'xot/test'
6
+ require 'xot/util'
6
7
  require 'rays'
7
8
 
8
9
  require 'test/unit'
9
10
 
10
11
  include Xot::Test
12
+ include Xot::Util
11
13
 
12
14
 
13
15
  def assert_equal_color(c1, c2, delta = 0.000001)
data/test/test_bitmap.rb CHANGED
@@ -37,13 +37,15 @@ class TestBitmap < Test::Unit::TestCase
37
37
 
38
38
  bmp.pixels = [0xffff0000, 0xff00ff00, 0xff0000ff, 0xffffff00]
39
39
  assert_equal [0xffff0000, 0xff00ff00, 0xff0000ff, 0xffffff00], bmp.pixels
40
+ end
40
41
 
42
+ def test_pixels_float()
41
43
  bmp = bitmap 2, 2, Rays::RGBA_float
42
44
  assert_equal [0,0,0,0] * 4, bmp.pixels
43
45
 
44
46
  bmp.pixels = [1,0,0,1, 0,1,0,1, 0,0,1,1, 1,1,0,1]
45
47
  assert_equal [1,0,0,1, 0,1,0,1, 0,0,1,1, 1,1,0,1], bmp.pixels
46
- end
48
+ end unless win32?
47
49
 
48
50
  def test_at()
49
51
  o = bitmap
data/test/test_image.rb CHANGED
@@ -99,33 +99,27 @@ class TestImage < Test::Unit::TestCase
99
99
  end
100
100
 
101
101
  def test_save_load()
102
- def get_image_type(filename)
102
+ get_image_type = -> filename {
103
103
  `file #{filename}`.match(/#{filename}: ([^,]+),/)[1]
104
- end
104
+ }
105
105
 
106
106
  img = image(10, 10).paint {fill 1, 0, 0; ellipse 0, 0, 10}
107
107
  pixels = img.bitmap.to_a
108
- paths = %w[png jpg jpeg gif bmp tif tiff].map {|ext| "#{__dir__}/testimage.#{ext}"}
108
+ paths = %w[png jpg jpeg bmp].map {|ext| "#{__dir__}/testimage.#{ext}"}
109
109
 
110
- png, jpg, jpeg, gif, bmp, tif, tiff = paths
110
+ png, jpg, jpeg, bmp = paths
111
111
 
112
112
  paths.each {|path| img.save path}
113
113
 
114
- assert_equal 'PNG image data', get_image_type(png)
115
- assert_equal 'JPEG image data', get_image_type(jpg)
116
- assert_equal 'JPEG image data', get_image_type(jpeg)
117
- assert_equal 'GIF image data', get_image_type(gif)
118
- assert_equal 'PC bitmap', get_image_type(bmp)
119
- assert_equal 'TIFF image data', get_image_type(tif)
120
- assert_equal 'TIFF image data', get_image_type(tiff)
114
+ assert_equal 'PNG image data', get_image_type[png]
115
+ assert_equal 'JPEG image data', get_image_type[jpg]
116
+ assert_equal 'JPEG image data', get_image_type[jpeg]
117
+ assert_equal 'PC bitmap', get_image_type[bmp]
121
118
 
122
119
  assert_equal pixels, load(png) .then {|o| o.bitmap.to_a}
123
120
  assert_equal [10, 10], load(jpg) .then {|o| [o.width, o.height]}
124
121
  assert_equal [10, 10], load(jpeg).then {|o| [o.width, o.height]}
125
- assert_equal pixels, load(gif) .then {|o| o.bitmap.to_a}
126
122
  assert_equal [10, 10], load(bmp) .then {|o| [o.width, o.height]}
127
- assert_equal pixels, load(tif) .then {|o| o.bitmap.to_a}
128
- assert_equal pixels, load(tiff).then {|o| o.bitmap.to_a}
129
123
 
130
124
  paths.each {|path| File.delete path}
131
125
 
data/test/test_painter.rb CHANGED
@@ -175,7 +175,7 @@ class TestPainter < Test::Unit::TestCase
175
175
  pa.line_height = nil
176
176
  assert_equal [h, -1], [pa.line_height, pa.line_height!]
177
177
 
178
- pa.font "Menlo", 100
178
+ pa.font "Arial", 100
179
179
  assert_equal pa.font.height, pa.line_height
180
180
  end
181
181
 
@@ -223,11 +223,11 @@ class TestPainter < Test::Unit::TestCase
223
223
 
224
224
  def test_font_name_size()
225
225
  pa = painter
226
- pa.font "Menlo", 10
227
- assert_equal "Menlo Regular", pa.font.name
226
+ pa.font "Arial", 10
227
+ assert_equal "Arial", pa.font.name
228
228
  assert_equal 10, pa.font.size
229
229
  pa.font nil
230
- assert_not_equal "Menlo Regular", pa.font.name
230
+ assert_not_equal "Arial", pa.font.name
231
231
  pa.font nil, 20
232
232
  assert_equal 20, pa.font.size
233
233
  end
@@ -8,11 +8,12 @@ class TestPainterShape < Test::Unit::TestCase
8
8
  end
9
9
 
10
10
  def image(fill = 1, stroke = 0, pixel_density = 1, &block)
11
- Rays::Image.new(100, 100, Rays::RGBA, pixel_density).paint {|p|
12
- p.fill fill > 0 ? color(fill) : nil
13
- p.stroke stroke > 0 ? color(stroke) : nil
14
- p.instance_eval(&block) if block
15
- }
11
+ Rays::Image.new(100, 100, Rays::RGBA, pixel_density: pixel_density)
12
+ .paint {|p|
13
+ p.fill fill > 0 ? color(fill) : nil
14
+ p.stroke stroke > 0 ? color(stroke) : nil
15
+ p.instance_eval(&block) if block
16
+ }
16
17
  end
17
18
 
18
19
  def test_line()
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.2.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-05 00:00:00.000000000 Z
11
+ date: 2025-01-12 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.2.1
19
+ version: 0.3.1
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.2.1
26
+ version: 0.3.1
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.2.1
33
+ version: 0.3.1
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.2.1
40
+ version: 0.3.1
41
41
  description: This library helps you to develop graphics application with OpenGL.
42
42
  email: xordog@gmail.com
43
43
  executables: []
@@ -220,10 +220,11 @@ files:
220
220
  - src/texture.h
221
221
  - src/util.cpp
222
222
  - src/win32/bitmap.cpp
223
+ - src/win32/camera.cpp
223
224
  - src/win32/font.cpp
224
- - src/win32/font.h
225
225
  - src/win32/gdi.cpp
226
226
  - src/win32/gdi.h
227
+ - src/win32/opengl.cpp
227
228
  - src/win32/rays.cpp
228
229
  - test/helper.rb
229
230
  - test/test_bitmap.rb
data/src/win32/font.h DELETED
@@ -1,24 +0,0 @@
1
- // -*- c++ -*-
2
- #pragma once
3
- #ifndef __RAYS_SRC_WIN32_FONT_H__
4
- #define __RAYS_SRC_WIN32_FONT_H__
5
-
6
-
7
- #include "rays/defs.h"
8
- #include "rays/font.h"
9
- #include "gdi.h"
10
-
11
-
12
- namespace Rays
13
- {
14
-
15
-
16
- bool RawFont_draw_string (
17
- const RawFont& font, HDC hdc, coord context_height,
18
- const char* str, coord x, coord y);
19
-
20
-
21
- }// Rays
22
-
23
-
24
- #endif//EOH