rays 0.3.9 → 0.3.10
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.
- checksums.yaml +4 -4
- data/.doc/ext/rays/bounds.cpp +1 -1
- data/.doc/ext/rays/font.cpp +23 -5
- data/.doc/ext/rays/image.cpp +1 -1
- data/.doc/ext/rays/native.cpp +1 -5
- data/.doc/ext/rays/painter.cpp +1 -1
- data/CLAUDE.md +25 -0
- data/ChangeLog.md +10 -0
- data/Rakefile +4 -2
- data/VERSION +1 -1
- data/ext/rays/bounds.cpp +1 -1
- data/ext/rays/extconf.rb +4 -3
- data/ext/rays/font.cpp +27 -7
- data/ext/rays/image.cpp +1 -1
- data/ext/rays/native.cpp +1 -5
- data/ext/rays/painter.cpp +1 -1
- data/include/rays/font.h +5 -1
- data/include/rays/painter.h +1 -1
- data/lib/rays/ext.rb +1 -1
- data/lib/rays/image.rb +5 -0
- data/rays.gemspec +2 -2
- data/src/bitmap.h +2 -1
- data/src/font.cpp +17 -1
- data/src/ios/bitmap.mm +15 -3
- data/src/opengl.h +1 -1
- data/src/osx/bitmap.mm +15 -3
- data/src/painter.cpp +10 -8
- data/src/sdl/bitmap.cpp +332 -0
- data/src/sdl/camera.cpp +119 -0
- data/src/sdl/font.cpp +93 -0
- data/src/sdl/opengl.cpp +102 -0
- data/src/sdl/rays.cpp +50 -0
- data/src/win32/bitmap.cpp +2 -1
- data/src/win32/opengl.cpp +0 -1
- data/test/test_image.rb +1 -0
- metadata +12 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9945125d1f082492c730846c72a485b8fdcf055a571e9402dde1a704a0253057
|
|
4
|
+
data.tar.gz: dfe5c15614856cf100383b706f11b25a9fca0a32cb09443e606d470a8a8e093c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9ba9ee244cc1a6d800e417aa2406a05d646567b2358371f98fe0f8ec19402dc98864e19233979eafe2e6bb9e7dbafbc7d4d7266cfbb700d69cadf6f92609c38f
|
|
7
|
+
data.tar.gz: f88ea6b92aae82285bfaf7edd9d12af10da4e305f3d83e158737075747585f15ce7073fe4af90567d6948b089f6a5911d8c10324e585c61f167d4a74ca9d2a3d
|
data/.doc/ext/rays/bounds.cpp
CHANGED
|
@@ -58,7 +58,7 @@ VALUE include(VALUE self)
|
|
|
58
58
|
CHECK;
|
|
59
59
|
check_arg_count(__FILE__, __LINE__, "Bounds#include?", argc, 1, 2);
|
|
60
60
|
|
|
61
|
-
const Rays::Point& point = to<Rays::Point
|
|
61
|
+
const Rays::Point& point = to<Rays::Point>(argv[0]);
|
|
62
62
|
int dimension = argc >= 2 ? to<int>(argv[1]) : 2;
|
|
63
63
|
|
|
64
64
|
return value(THIS->is_include(point, dimension));
|
data/.doc/ext/rays/font.cpp
CHANGED
|
@@ -22,7 +22,7 @@ static
|
|
|
22
22
|
VALUE initialize(VALUE self)
|
|
23
23
|
{
|
|
24
24
|
RUCY_CHECK_OBJ(Rays::Font, self);
|
|
25
|
-
check_arg_count(__FILE__, __LINE__, "Font#initialize", argc, 0, 1, 2);
|
|
25
|
+
check_arg_count(__FILE__, __LINE__, "Font#initialize", argc, 0, 1, 2, 3);
|
|
26
26
|
|
|
27
27
|
*THIS = to<Rays::Font>(argc, argv);
|
|
28
28
|
return self;
|
|
@@ -59,6 +59,21 @@ VALUE size(VALUE self)
|
|
|
59
59
|
return value(THIS->size());
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
static
|
|
63
|
+
VALUE set_smooth(VALUE self, VALUE smooth)
|
|
64
|
+
{
|
|
65
|
+
CHECK;
|
|
66
|
+
THIS->set_smooth(to<bool>(smooth));
|
|
67
|
+
return smooth;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static
|
|
71
|
+
VALUE smooth(VALUE self)
|
|
72
|
+
{
|
|
73
|
+
CHECK;
|
|
74
|
+
return value(THIS->smooth());
|
|
75
|
+
}
|
|
76
|
+
|
|
62
77
|
static
|
|
63
78
|
VALUE width(VALUE self, VALUE str)
|
|
64
79
|
{
|
|
@@ -142,6 +157,8 @@ Init_rays_font ()
|
|
|
142
157
|
rb_define_method(cFont, "name", RUBY_METHOD_FUNC(name), 0);
|
|
143
158
|
rb_define_method(cFont, "size=", RUBY_METHOD_FUNC(set_size), 1);
|
|
144
159
|
rb_define_method(cFont, "size", RUBY_METHOD_FUNC(size), 0);
|
|
160
|
+
rb_define_method(cFont, "smooth=", RUBY_METHOD_FUNC(set_smooth), 1);
|
|
161
|
+
rb_define_method(cFont, "smooth", RUBY_METHOD_FUNC(smooth), 0);
|
|
145
162
|
rb_define_method(cFont, "width", RUBY_METHOD_FUNC(width), 1);
|
|
146
163
|
rb_define_method(cFont, "height", RUBY_METHOD_FUNC(height), 0);
|
|
147
164
|
rb_define_method(cFont, "ascent", RUBY_METHOD_FUNC(ascent), 0);
|
|
@@ -172,12 +189,13 @@ namespace Rucy
|
|
|
172
189
|
if (argc == 0)
|
|
173
190
|
return Rays::get_default_font();
|
|
174
191
|
|
|
175
|
-
coord size
|
|
176
|
-
|
|
192
|
+
coord size = argc >= 2 ? to<coord>(argv[1]) : (coord) Rays::Font::DEFAULT_SIZE;
|
|
193
|
+
bool smooth = argc >= 3 ? to<bool>(argv[2]) : true;
|
|
194
|
+
|
|
177
195
|
if (argv->is_nil())
|
|
178
|
-
return Rays::Font(NULL, size);
|
|
196
|
+
return Rays::Font(NULL, size, smooth);
|
|
179
197
|
else if (argv->is_s() || argv->is_sym())
|
|
180
|
-
return Rays::Font(argv[0].c_str(), size);
|
|
198
|
+
return Rays::Font(argv[0].c_str(), size, smooth);
|
|
181
199
|
}
|
|
182
200
|
|
|
183
201
|
if (argc != 1)
|
data/.doc/ext/rays/image.cpp
CHANGED
|
@@ -149,7 +149,7 @@ Init_rays_image ()
|
|
|
149
149
|
rb_define_private_method(cImage, "get_bitmap", RUBY_METHOD_FUNC(get_bitmap), 1);
|
|
150
150
|
rb_define_method(cImage, "smooth=", RUBY_METHOD_FUNC(set_smooth), 1);
|
|
151
151
|
rb_define_method(cImage, "smooth", RUBY_METHOD_FUNC(get_smooth), 0);
|
|
152
|
-
|
|
152
|
+
cImage.define_module_function("load!", load);
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
|
data/.doc/ext/rays/native.cpp
CHANGED
data/.doc/ext/rays/painter.cpp
CHANGED
|
@@ -540,7 +540,7 @@ static
|
|
|
540
540
|
VALUE set_font(VALUE self)
|
|
541
541
|
{
|
|
542
542
|
CHECK;
|
|
543
|
-
check_arg_count(__FILE__, __LINE__, "Painter#set_font", argc, 0, 1, 2);
|
|
543
|
+
check_arg_count(__FILE__, __LINE__, "Painter#set_font", argc, 0, 1, 2, 3);
|
|
544
544
|
|
|
545
545
|
THIS->set_font(to<Rays::Font>(argc, argv));
|
|
546
546
|
return self;
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Rays
|
|
2
|
+
|
|
3
|
+
OpenGL-based 2D drawing engine.
|
|
4
|
+
|
|
5
|
+
## External Libraries
|
|
6
|
+
|
|
7
|
+
Automatically fetched at build time:
|
|
8
|
+
- GLM 1.0.1 — Math library
|
|
9
|
+
- Clipper 6.4.2 — Polygon clipping
|
|
10
|
+
- Earcut.hpp v2.2.4 — Polygon triangulation
|
|
11
|
+
- Splines-lib — Filtering
|
|
12
|
+
- STB (Windows/Linux only) — Image loading
|
|
13
|
+
|
|
14
|
+
## Platform-Specific Code
|
|
15
|
+
|
|
16
|
+
Platform implementations under `src/`:
|
|
17
|
+
- `src/osx/` — macOS (AppKit, OpenGL)
|
|
18
|
+
- `src/ios/` — iOS
|
|
19
|
+
- `src/win32/` — Windows (GDI32, OpenGL32)
|
|
20
|
+
- `src/sdl/` — Linux (SDL2, GLEW)
|
|
21
|
+
|
|
22
|
+
## Testing
|
|
23
|
+
|
|
24
|
+
- `test_rays_init.rb` must run alone (`TESTS_ALONE`)
|
|
25
|
+
- `assert_equal_color` — Custom color comparison assertion
|
data/ChangeLog.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
# rays ChangeLog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## [v0.3.10] - 2026-04-09
|
|
5
|
+
|
|
6
|
+
- Add Font::smooth
|
|
7
|
+
- Add minimal support for SDL2
|
|
8
|
+
- Add 'apt' for install_packages()
|
|
9
|
+
- Image.load raises Errno::ENOENT when the file does not exist
|
|
10
|
+
- Change C-Extension name from 'native.so' to 'rays_ext.so'
|
|
11
|
+
- Update dependencies
|
|
12
|
+
|
|
13
|
+
|
|
4
14
|
## [v0.3.9] - 2025-07-06
|
|
5
15
|
|
|
6
16
|
- Add deepwiki badge
|
data/Rakefile
CHANGED
|
@@ -14,7 +14,9 @@ require 'rays/extension'
|
|
|
14
14
|
EXTENSIONS = [Xot, Rucy, Rays]
|
|
15
15
|
TESTS_ALONE = ['test/test_rays_init.rb']
|
|
16
16
|
|
|
17
|
-
install_packages
|
|
17
|
+
install_packages(
|
|
18
|
+
mingw: %w[MINGW_PACKAGE_PREFIX-glew],
|
|
19
|
+
apt: %w[libglew-dev libsdl2-dev])
|
|
18
20
|
|
|
19
21
|
use_external_library 'https://github.com/g-truc/glm',
|
|
20
22
|
tag: '1.0.1',
|
|
@@ -42,7 +44,7 @@ use_external_library 'https://github.com/andrewwillmott/splines-lib',
|
|
|
42
44
|
end
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
if win32?
|
|
47
|
+
if win32? || linux?
|
|
46
48
|
use_external_library 'https://github.com/nothings/stb',
|
|
47
49
|
commit: 'ae721c50eaf761660b4f90cc590453cdb0c2acd0',
|
|
48
50
|
srcdirs: 'NOSRC'
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.10
|
data/ext/rays/bounds.cpp
CHANGED
|
@@ -62,7 +62,7 @@ RUCY_DEFN(include)
|
|
|
62
62
|
CHECK;
|
|
63
63
|
check_arg_count(__FILE__, __LINE__, "Bounds#include?", argc, 1, 2);
|
|
64
64
|
|
|
65
|
-
const Rays::Point& point = to<Rays::Point
|
|
65
|
+
const Rays::Point& point = to<Rays::Point>(argv[0]);
|
|
66
66
|
int dimension = argc >= 2 ? to<int>(argv[1]) : 2;
|
|
67
67
|
|
|
68
68
|
return value(THIS->is_include(point, dimension));
|
data/ext/rays/extconf.rb
CHANGED
|
@@ -13,11 +13,12 @@ Xot::ExtConf.new Xot, Rucy, Rays do
|
|
|
13
13
|
setup do
|
|
14
14
|
headers << 'ruby.h'
|
|
15
15
|
libs.unshift 'gdi32', 'opengl32', 'glew32' if win32?
|
|
16
|
+
libs.unshift 'SDL2', 'GLEW', 'GL' if linux?
|
|
16
17
|
frameworks << 'AppKit' << 'OpenGL' << 'AVFoundation' if osx?
|
|
17
|
-
$LDFLAGS << ' -Wl,--out-implib=native.dll.a' if mingw? || cygwin?
|
|
18
18
|
|
|
19
|
-
$CPPFLAGS << ' -DRAYS_32BIT_PIXELS_STRING'
|
|
19
|
+
$CPPFLAGS << ' -DRAYS_32BIT_PIXELS_STRING' if RUBY_PLATFORM == 'x64-mingw-ucrt'
|
|
20
|
+
$LDFLAGS << ' -Wl,--out-implib=rays_ext.dll.a' if mingw? || cygwin?
|
|
20
21
|
end
|
|
21
22
|
|
|
22
|
-
create_makefile '
|
|
23
|
+
create_makefile 'rays_ext'
|
|
23
24
|
end
|
data/ext/rays/font.cpp
CHANGED
|
@@ -23,7 +23,7 @@ static
|
|
|
23
23
|
RUCY_DEFN(initialize)
|
|
24
24
|
{
|
|
25
25
|
RUCY_CHECK_OBJ(Rays::Font, self);
|
|
26
|
-
check_arg_count(__FILE__, __LINE__, "Font#initialize", argc, 0, 1, 2);
|
|
26
|
+
check_arg_count(__FILE__, __LINE__, "Font#initialize", argc, 0, 1, 2, 3);
|
|
27
27
|
|
|
28
28
|
*THIS = to<Rays::Font>(argc, argv);
|
|
29
29
|
return self;
|
|
@@ -65,6 +65,23 @@ RUCY_DEF0(size)
|
|
|
65
65
|
}
|
|
66
66
|
RUCY_END
|
|
67
67
|
|
|
68
|
+
static
|
|
69
|
+
RUCY_DEF1(set_smooth, smooth)
|
|
70
|
+
{
|
|
71
|
+
CHECK;
|
|
72
|
+
THIS->set_smooth(to<bool>(smooth));
|
|
73
|
+
return smooth;
|
|
74
|
+
}
|
|
75
|
+
RUCY_END
|
|
76
|
+
|
|
77
|
+
static
|
|
78
|
+
RUCY_DEF0(smooth)
|
|
79
|
+
{
|
|
80
|
+
CHECK;
|
|
81
|
+
return value(THIS->smooth());
|
|
82
|
+
}
|
|
83
|
+
RUCY_END
|
|
84
|
+
|
|
68
85
|
static
|
|
69
86
|
RUCY_DEF1(width, str)
|
|
70
87
|
{
|
|
@@ -153,8 +170,10 @@ Init_rays_font ()
|
|
|
153
170
|
cFont.define_private_method("initialize", initialize);
|
|
154
171
|
cFont.define_private_method("initialize_copy", initialize_copy);
|
|
155
172
|
cFont.define_method("name", name);
|
|
156
|
-
cFont.define_method("size=",
|
|
157
|
-
cFont.define_method("size",
|
|
173
|
+
cFont.define_method("size=", set_size);
|
|
174
|
+
cFont.define_method("size", size);
|
|
175
|
+
cFont.define_method("smooth=", set_smooth);
|
|
176
|
+
cFont.define_method("smooth", smooth);
|
|
158
177
|
cFont.define_method("width", width);
|
|
159
178
|
cFont.define_method("height", height);
|
|
160
179
|
cFont.define_method("ascent", ascent);
|
|
@@ -185,12 +204,13 @@ namespace Rucy
|
|
|
185
204
|
if (argc == 0)
|
|
186
205
|
return Rays::get_default_font();
|
|
187
206
|
|
|
188
|
-
coord size
|
|
189
|
-
|
|
207
|
+
coord size = argc >= 2 ? to<coord>(argv[1]) : (coord) Rays::Font::DEFAULT_SIZE;
|
|
208
|
+
bool smooth = argc >= 3 ? to<bool>(argv[2]) : true;
|
|
209
|
+
|
|
190
210
|
if (argv->is_nil())
|
|
191
|
-
return Rays::Font(NULL, size);
|
|
211
|
+
return Rays::Font(NULL, size, smooth);
|
|
192
212
|
else if (argv->is_s() || argv->is_sym())
|
|
193
|
-
return Rays::Font(argv[0].c_str(), size);
|
|
213
|
+
return Rays::Font(argv[0].c_str(), size, smooth);
|
|
194
214
|
}
|
|
195
215
|
|
|
196
216
|
if (argc != 1)
|
data/ext/rays/image.cpp
CHANGED
|
@@ -162,7 +162,7 @@ Init_rays_image ()
|
|
|
162
162
|
cImage.define_private_method("get_bitmap", get_bitmap);
|
|
163
163
|
cImage.define_method("smooth=", set_smooth);
|
|
164
164
|
cImage.define_method("smooth", get_smooth);
|
|
165
|
-
cImage.define_module_function("load", load);
|
|
165
|
+
cImage.define_module_function("load!", load);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
|
data/ext/rays/native.cpp
CHANGED
data/ext/rays/painter.cpp
CHANGED
|
@@ -587,7 +587,7 @@ static
|
|
|
587
587
|
RUCY_DEFN(set_font)
|
|
588
588
|
{
|
|
589
589
|
CHECK;
|
|
590
|
-
check_arg_count(__FILE__, __LINE__, "Painter#set_font", argc, 0, 1, 2);
|
|
590
|
+
check_arg_count(__FILE__, __LINE__, "Painter#set_font", argc, 0, 1, 2, 3);
|
|
591
591
|
|
|
592
592
|
THIS->set_font(to<Rays::Font>(argc, argv));
|
|
593
593
|
return self;
|
data/include/rays/font.h
CHANGED
|
@@ -23,7 +23,7 @@ namespace Rays
|
|
|
23
23
|
|
|
24
24
|
Font ();
|
|
25
25
|
|
|
26
|
-
Font (const char* name, coord size = DEFAULT_SIZE);
|
|
26
|
+
Font (const char* name, coord size = DEFAULT_SIZE, bool smooth = true);
|
|
27
27
|
|
|
28
28
|
~Font ();
|
|
29
29
|
|
|
@@ -35,6 +35,10 @@ namespace Rays
|
|
|
35
35
|
|
|
36
36
|
coord size () const;
|
|
37
37
|
|
|
38
|
+
void set_smooth (bool smooth);
|
|
39
|
+
|
|
40
|
+
bool smooth () const;
|
|
41
|
+
|
|
38
42
|
coord get_width (const char* str) const;
|
|
39
43
|
|
|
40
44
|
coord get_height (
|
data/include/rays/painter.h
CHANGED
data/lib/rays/ext.rb
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'rays_ext'
|
data/lib/rays/image.rb
CHANGED
data/rays.gemspec
CHANGED
|
@@ -25,8 +25,8 @@ Gem::Specification.new do |s|
|
|
|
25
25
|
s.platform = Gem::Platform::RUBY
|
|
26
26
|
s.required_ruby_version = '>= 3.0.0'
|
|
27
27
|
|
|
28
|
-
s.add_dependency 'xot', '~> 0.3.
|
|
29
|
-
s.add_dependency 'rucy', '~> 0.3.
|
|
28
|
+
s.add_dependency 'xot', '~> 0.3.10'
|
|
29
|
+
s.add_dependency 'rucy', '~> 0.3.10'
|
|
30
30
|
|
|
31
31
|
s.files = `git ls-files`.split $/
|
|
32
32
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
data/src/bitmap.h
CHANGED
|
@@ -19,7 +19,8 @@ namespace Rays
|
|
|
19
19
|
Bitmap Bitmap_from (const Texture& texture);
|
|
20
20
|
|
|
21
21
|
void Bitmap_draw_string (
|
|
22
|
-
Bitmap* bitmap, const RawFont& font,
|
|
22
|
+
Bitmap* bitmap, const RawFont& font,
|
|
23
|
+
const char* str, coord x, coord y, bool smooth);
|
|
23
24
|
|
|
24
25
|
void Bitmap_set_modified (Bitmap* bitmap, bool modified = true);
|
|
25
26
|
|
data/src/font.cpp
CHANGED
|
@@ -14,6 +14,8 @@ namespace Rays
|
|
|
14
14
|
|
|
15
15
|
RawFont rawfont;
|
|
16
16
|
|
|
17
|
+
bool smooth = true;
|
|
18
|
+
|
|
17
19
|
mutable RawFont rawfont_for_pixel_density;
|
|
18
20
|
|
|
19
21
|
mutable float for_pixel_density = 1;
|
|
@@ -64,9 +66,10 @@ namespace Rays
|
|
|
64
66
|
{
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
Font::Font (const char* name, coord size)
|
|
69
|
+
Font::Font (const char* name, coord size, bool smooth)
|
|
68
70
|
{
|
|
69
71
|
self->rawfont = RawFont(name, size);
|
|
72
|
+
self->smooth = smooth;
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
Font::~Font ()
|
|
@@ -78,6 +81,7 @@ namespace Rays
|
|
|
78
81
|
{
|
|
79
82
|
Font f;
|
|
80
83
|
f.self->rawfont = RawFont(self->rawfont, self->rawfont.size());
|
|
84
|
+
f.self->smooth = self->smooth;
|
|
81
85
|
return f;
|
|
82
86
|
}
|
|
83
87
|
|
|
@@ -99,6 +103,18 @@ namespace Rays
|
|
|
99
103
|
return self->rawfont.size();
|
|
100
104
|
}
|
|
101
105
|
|
|
106
|
+
void
|
|
107
|
+
Font::set_smooth (bool smooth)
|
|
108
|
+
{
|
|
109
|
+
self->smooth = smooth;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
bool
|
|
113
|
+
Font::smooth () const
|
|
114
|
+
{
|
|
115
|
+
return self->smooth;
|
|
116
|
+
}
|
|
117
|
+
|
|
102
118
|
coord
|
|
103
119
|
Font::get_width (const char* str) const
|
|
104
120
|
{
|
data/src/ios/bitmap.mm
CHANGED
|
@@ -76,7 +76,7 @@ namespace Rays
|
|
|
76
76
|
clear();
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
CGContextRef get_context ()
|
|
79
|
+
CGContextRef get_context (bool smooth = true)
|
|
80
80
|
{
|
|
81
81
|
if (context) return context;
|
|
82
82
|
|
|
@@ -95,6 +95,17 @@ namespace Rays
|
|
|
95
95
|
context = CGBitmapContextCreate(
|
|
96
96
|
pixels, width, height, bpc, pitch, cgcs, make_bitmapinfo(color_space));
|
|
97
97
|
CGColorSpaceRelease(cgcs);
|
|
98
|
+
|
|
99
|
+
if (!smooth)
|
|
100
|
+
{
|
|
101
|
+
CGContextSetShouldAntialias( context, false);
|
|
102
|
+
CGContextSetShouldSmoothFonts( context, false);
|
|
103
|
+
CGContextSetInterpolationQuality( context, kCGInterpolationNone);
|
|
104
|
+
CGContextSetAllowsFontSmoothing( context, false);
|
|
105
|
+
CGContextSetShouldSubpixelPositionFonts(context, false);
|
|
106
|
+
CGContextSetShouldSubpixelQuantizeFonts(context, true);
|
|
107
|
+
}
|
|
108
|
+
|
|
98
109
|
return context;
|
|
99
110
|
}
|
|
100
111
|
|
|
@@ -201,7 +212,8 @@ namespace Rays
|
|
|
201
212
|
|
|
202
213
|
void
|
|
203
214
|
Bitmap_draw_string (
|
|
204
|
-
Bitmap* bitmap, const RawFont& font,
|
|
215
|
+
Bitmap* bitmap, const RawFont& font,
|
|
216
|
+
const char* str, coord x, coord y, bool smooth)
|
|
205
217
|
{
|
|
206
218
|
if (!bitmap)
|
|
207
219
|
argument_error(__FILE__, __LINE__);
|
|
@@ -214,7 +226,7 @@ namespace Rays
|
|
|
214
226
|
|
|
215
227
|
if (*str == '\0') return;
|
|
216
228
|
|
|
217
|
-
font.draw_string(bitmap->self->get_context(), bitmap->height(), str, x, y);
|
|
229
|
+
font.draw_string(bitmap->self->get_context(smooth), bitmap->height(), str, x, y);
|
|
218
230
|
Bitmap_set_modified(bitmap);
|
|
219
231
|
}
|
|
220
232
|
|
data/src/opengl.h
CHANGED
data/src/osx/bitmap.mm
CHANGED
|
@@ -75,7 +75,7 @@ namespace Rays
|
|
|
75
75
|
clear();
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
CGContextRef get_context ()
|
|
78
|
+
CGContextRef get_context (bool smooth = true)
|
|
79
79
|
{
|
|
80
80
|
if (context) return context;
|
|
81
81
|
|
|
@@ -94,6 +94,17 @@ namespace Rays
|
|
|
94
94
|
context = CGBitmapContextCreate(
|
|
95
95
|
pixels, width, height, bpc, pitch, cgcs, make_bitmapinfo(color_space));
|
|
96
96
|
CGColorSpaceRelease(cgcs);
|
|
97
|
+
|
|
98
|
+
if (!smooth)
|
|
99
|
+
{
|
|
100
|
+
CGContextSetShouldAntialias( context, false);
|
|
101
|
+
CGContextSetShouldSmoothFonts( context, false);
|
|
102
|
+
CGContextSetInterpolationQuality( context, kCGInterpolationNone);
|
|
103
|
+
CGContextSetAllowsFontSmoothing( context, false);
|
|
104
|
+
CGContextSetShouldSubpixelPositionFonts(context, false);
|
|
105
|
+
CGContextSetShouldSubpixelQuantizeFonts(context, true);
|
|
106
|
+
}
|
|
107
|
+
|
|
97
108
|
return context;
|
|
98
109
|
}
|
|
99
110
|
|
|
@@ -200,7 +211,8 @@ namespace Rays
|
|
|
200
211
|
|
|
201
212
|
void
|
|
202
213
|
Bitmap_draw_string (
|
|
203
|
-
Bitmap* bitmap, const RawFont& font,
|
|
214
|
+
Bitmap* bitmap, const RawFont& font,
|
|
215
|
+
const char* str, coord x, coord y, bool smooth)
|
|
204
216
|
{
|
|
205
217
|
if (!bitmap)
|
|
206
218
|
argument_error(__FILE__, __LINE__);
|
|
@@ -213,7 +225,7 @@ namespace Rays
|
|
|
213
225
|
|
|
214
226
|
if (*str == '\0') return;
|
|
215
227
|
|
|
216
|
-
font.draw_string(bitmap->self->get_context(), bitmap->height(), str, x, y);
|
|
228
|
+
font.draw_string(bitmap->self->get_context(smooth), bitmap->height(), str, x, y);
|
|
217
229
|
Bitmap_set_modified(bitmap);
|
|
218
230
|
}
|
|
219
231
|
|
data/src/painter.cpp
CHANGED
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
#include <algorithm>
|
|
10
10
|
#include <functional>
|
|
11
11
|
#include "rays/exception.h"
|
|
12
|
+
#include "rays/debug.h"
|
|
12
13
|
#include "rays/point.h"
|
|
13
14
|
#include "rays/bounds.h"
|
|
14
15
|
#include "rays/color.h"
|
|
15
|
-
#include "rays/debug.h"
|
|
16
16
|
#include "opengl.h"
|
|
17
17
|
#include "glm.h"
|
|
18
18
|
#include "matrix.h"
|
|
@@ -1275,7 +1275,8 @@ namespace Rays
|
|
|
1275
1275
|
|
|
1276
1276
|
assert(self->text_image.pixel_density() == density);
|
|
1277
1277
|
|
|
1278
|
-
Bitmap_draw_string(
|
|
1278
|
+
Bitmap_draw_string(
|
|
1279
|
+
&self->text_image.bitmap(), rawfont, line, 0, 0, font.smooth());
|
|
1279
1280
|
|
|
1280
1281
|
str_w /= density;
|
|
1281
1282
|
str_h /= density;
|
|
@@ -1625,19 +1626,20 @@ namespace Rays
|
|
|
1625
1626
|
}
|
|
1626
1627
|
|
|
1627
1628
|
static bool
|
|
1628
|
-
has_same_font (const Font& font, const char* name, coord size)
|
|
1629
|
+
has_same_font (const Font& font, const char* name, coord size, bool smooth)
|
|
1629
1630
|
{
|
|
1630
1631
|
return
|
|
1631
|
-
font.size()
|
|
1632
|
-
font.
|
|
1632
|
+
font.size() == size &&
|
|
1633
|
+
font.smooth() == smooth &&
|
|
1634
|
+
font.name() == (name ? name : get_default_font().name().c_str());
|
|
1633
1635
|
}
|
|
1634
1636
|
|
|
1635
1637
|
void
|
|
1636
|
-
Painter::set_font (const char* name, coord size)
|
|
1638
|
+
Painter::set_font (const char* name, coord size, bool smooth)
|
|
1637
1639
|
{
|
|
1638
|
-
if (has_same_font(self->state.font, name, size)) return;
|
|
1640
|
+
if (has_same_font(self->state.font, name, size, smooth)) return;
|
|
1639
1641
|
|
|
1640
|
-
set_font(Font(name, size));
|
|
1642
|
+
set_font(Font(name, size, smooth));
|
|
1641
1643
|
}
|
|
1642
1644
|
|
|
1643
1645
|
void
|