rays 0.1.31 → 0.1.33

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: 958a334c5a26f773a1b99706103f104d1196d5e808721b89f8aa887641f65f00
4
- data.tar.gz: 4f63633edea9768657373a2b59323b11f2b3ab07632bf192a60ab83db42fd480
3
+ metadata.gz: 38c6d27f95affd2e2d8aa8126c4f5349eba44837eb4833a3ffa47de647edf1c5
4
+ data.tar.gz: d2aad318e705ba6e21dd3770b06d08d0eaacc63f65e148add39fd36866911348
5
5
  SHA512:
6
- metadata.gz: 749bf2ccb3d4b142e2ac4ef2531716f63632680cc44014b4e880abad0ed93ce6b9ce764bce040b53f10b4957927777ed009d9d2043e7d92b5d91bd939df975bf
7
- data.tar.gz: 150864fbee3311eec9c0c023cb1b6054af1cbadaabd5a5ffc6b867d72c5b628f4803dee02bbbd9e61e1f5df8e9785c0cb5d090e967b24f5e66405b53452a6ad1
6
+ metadata.gz: a8961d3744c161d2aed4d4277745c330acfd9d3295fda8723b9d88cb5778467f00a842e15425af33318e3ad5801e02da5691099ff87cb3701e7f7d599a685ae2
7
+ data.tar.gz: 2c627cb61a4bbe4a825ad648f7a512667e502b533b7809e4cad33ee43e98af3093d24c104e3bf9f81c5119687faa350e7ac57313e17f01d8c3c2e28e42096228
@@ -24,7 +24,7 @@ VALUE setup(VALUE self, VALUE device_name, VALUE min_width, VALUE min_height, VA
24
24
  RUCY_CHECK_OBJ(Rays::Camera, self);
25
25
 
26
26
  *THIS = Rays::Camera(
27
- device_name ? to<const char*>(device_name) : NULL,
27
+ device_name ? device_name.c_str() : NULL,
28
28
  to<int>(min_width), to<int>(min_height),
29
29
  to<bool>(resize), to<bool>(crop));
30
30
  return self;
@@ -60,6 +60,14 @@ VALUE initialize_copy(VALUE self, VALUE obj)
60
60
  return self;
61
61
  }
62
62
 
63
+ static
64
+ VALUE save(VALUE self, VALUE path)
65
+ {
66
+ CHECK;
67
+ THIS->save(path.c_str());
68
+ return self;
69
+ }
70
+
63
71
  static
64
72
  VALUE width(VALUE self)
65
73
  {
@@ -103,20 +111,9 @@ VALUE bitmap(VALUE self)
103
111
  }
104
112
 
105
113
  static
106
- VALUE save(VALUE self, VALUE path)
107
- {
108
- CHECK;
109
- Rays::save_image(*THIS, path.c_str());
110
- return self;
111
- }
112
-
113
-
114
- static
115
- VALUE load(VALUE self)
114
+ VALUE load(VALUE self, VALUE path)
116
115
  {
117
- check_arg_count(__FILE__, __LINE__, "Image.load", argc, 1);
118
-
119
- return value(Rays::load_image(argv[0].c_str()));
116
+ return value(Rays::load_image(path.c_str()));
120
117
  }
121
118
 
122
119
 
@@ -131,14 +128,14 @@ Init_rays_image ()
131
128
  rb_define_alloc_func(cImage, alloc);
132
129
  rb_define_private_method(cImage, "initialize", RUBY_METHOD_FUNC(initialize), -1);
133
130
  rb_define_private_method(cImage, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
131
+ rb_define_method(cImage, "save", RUBY_METHOD_FUNC(save), 1);
134
132
  rb_define_method(cImage, "width", RUBY_METHOD_FUNC(width), 0);
135
133
  rb_define_method(cImage, "height", RUBY_METHOD_FUNC(height), 0);
136
134
  rb_define_method(cImage, "color_space", RUBY_METHOD_FUNC(color_space), 0);
137
135
  rb_define_method(cImage, "pixel_density", RUBY_METHOD_FUNC(pixel_density), 0);
138
136
  rb_define_method(cImage, "painter", RUBY_METHOD_FUNC(painter), 0);
139
137
  rb_define_method(cImage, "bitmap", RUBY_METHOD_FUNC(bitmap), 0);
140
- rb_define_method(cImage, "save", RUBY_METHOD_FUNC(save), 1);
141
- rb_define_module_function(cImage, "load", RUBY_METHOD_FUNC(load), -1);
138
+ rb_define_module_function(cImage, "load", RUBY_METHOD_FUNC(load), 1);
142
139
  }
143
140
 
144
141
 
@@ -0,0 +1,62 @@
1
+ name: Release Gem
2
+
3
+ on:
4
+ push:
5
+ tags: ['v[0-9]*']
6
+
7
+ jobs:
8
+ release:
9
+ runs-on: macos-latest
10
+
11
+ steps:
12
+ - name: ruby 3.2
13
+ uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: 3.2
16
+
17
+ - name: checkout
18
+ uses: actions/checkout@v2
19
+
20
+ - name: setup dependencies
21
+ run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
22
+
23
+ - name: install gems
24
+ run: gem install yard
25
+
26
+ - name: test
27
+ run: rake quiet test
28
+
29
+ - name: create gem
30
+ id: gem
31
+ run: |
32
+ rake gem
33
+ echo path=$(ruby -e 'print Dir.glob("*.gem").first') >> $GITHUB_OUTPUT
34
+
35
+ - name: create github release
36
+ id: release
37
+ uses: actions/create-release@v1
38
+ env:
39
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40
+ with:
41
+ tag_name: ${{ github.ref }}
42
+ release_name: ${{ github.ref }}
43
+
44
+ - name: upload to github release
45
+ uses: actions/upload-release-asset@v1
46
+ env:
47
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48
+ with:
49
+ upload_url: ${{ steps.release.outputs.upload_url }}
50
+ asset_path: ./${{ steps.gem.outputs.path }}
51
+ asset_name: ${{ steps.gem.outputs.path }}
52
+ asset_content_type: application/zip
53
+
54
+ - name: upload to rubygems
55
+ env:
56
+ GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
57
+ run: |
58
+ mkdir -p $HOME/.gem
59
+ touch $HOME/.gem/credentials
60
+ chmod 0600 $HOME/.gem/credentials
61
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
62
+ rake upload
@@ -22,11 +22,5 @@ jobs:
22
22
  - name: setup dependencies
23
23
  run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
24
24
 
25
- - name: lib
26
- run: rake lib
27
-
28
- - name: ext
29
- run: rake ext
30
-
31
25
  - name: test
32
26
  run: rake test
@@ -1,3 +1,5 @@
1
+ RENAMES = {reflex: 'reflexion'}
2
+
1
3
  def sh(cmd)
2
4
  puts cmd
3
5
  system cmd
@@ -5,8 +7,10 @@ end
5
7
 
6
8
  def setup_dependencies(build: true, only: nil)
7
9
  gemspec_path = `git ls-files`.lines(chomp: true).find {|l| l =~ /\.gemspec$/}
8
- gemspec = File.read gemspec_path
9
- name = File.basename gemspec_path, '.gemspec'
10
+ return unless gemspec_path
11
+
12
+ gemspec = File.read gemspec_path
13
+ name = File.basename gemspec_path, '.gemspec'
10
14
 
11
15
  exts = File.readlines('Rakefile')
12
16
  .map {|l| l[%r|^\s*require\W+(\w+)/extension\W+$|, 1]}
@@ -15,9 +19,13 @@ def setup_dependencies(build: true, only: nil)
15
19
  exts = exts & [only].flatten.map(&:to_s) if only
16
20
 
17
21
  exts.each do |ext|
18
- ver = gemspec[/add_runtime_dependency.*'#{ext}'.*'\s*~>\s*([\d\.]+)\s*'/, 1]
19
- url = "https://github.com/xord/#{ext}.git"
20
- sh %( git clone --depth 1 --branch v#{ver} #{url} ../#{ext} )
22
+ gem = RENAMES[ext.to_sym].then {|s| s || ext}
23
+ clone = "git clone --depth 1 https://github.com/xord/#{ext}.git ../#{ext}"
24
+ ver = gemspec[/add_runtime_dependency.*['"]#{gem}['"].*['"]\s*~>\s*([\d\.]+)\s*['"]/, 1]
25
+
26
+ # 'rake subtree:push' pushes all subrepos, so cloning by new tag
27
+ # often fails before tagging each new tag
28
+ sh %( #{clone} --branch v#{ver} || #{clone} )
21
29
  sh %( cd ../#{ext} && rake ext )
22
30
  end
23
31
  end
data/ChangeLog.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # rays ChangeLog
2
2
 
3
3
 
4
+ ## [v0.1.33] - 2023-04-22
5
+
6
+ - Update external libraries
7
+ - save_image(image, path) -> Image::save(path)
8
+
9
+
10
+ ## [v0.1.32] - 2023-03-01
11
+
12
+ - fix bugs
13
+
14
+
4
15
  ## [v0.1.31] - 2023-02-27
5
16
 
6
17
  - add ChangeLog.md file
data/Rakefile CHANGED
@@ -13,29 +13,30 @@ require 'rays/extension'
13
13
 
14
14
 
15
15
  EXTENSIONS = [Xot, Rucy, Rays]
16
- TESTS_ALONE = ['test/test_rays.rb']
16
+ TESTS_ALONE = ['test/test_rays_init.rb']
17
17
 
18
18
  use_external_library 'https://github.com/g-truc/glm',
19
- tag: '0.9.8.5',
20
- srcdir: 'NOSRC'
19
+ tag: '0.9.9.8',
20
+ srcdirs: 'NOSRC'
21
21
 
22
22
  use_external_library 'https://github.com/skyrpex/clipper',
23
- tag: '6.4.2',
24
- incdir: 'cpp',
25
- srcdir: 'cpp',
23
+ tag: '6.4.2',
24
+ incdirs: 'cpp',
25
+ srcdirs: 'cpp',
26
26
  excludes: 'clipper/cpp/cpp_'
27
27
 
28
28
  use_external_library 'https://github.com/greenm01/poly2tri',
29
- incdir: 'poly2tri',
30
- srcdir: 'poly2tri'
29
+ commit: '88de49021b6d9bef6faa1bc94ceb3fbd85c3c204',
30
+ incdirs: 'poly2tri',
31
+ srcdirs: 'poly2tri'
31
32
 
32
- use_external_library 'https://github.com/andrewwillmott/splines-lib.git',
33
+ use_external_library 'https://github.com/andrewwillmott/splines-lib',
34
+ commit: '11e7240d57b0d22871aec3308186a5fcf915ba77',
33
35
  excludes: 'Test\.cpp'
34
36
 
37
+ default_tasks :ext
35
38
  build_native_library
36
39
  build_ruby_extension
37
40
  test_ruby_extension
38
41
  generate_documents
39
42
  build_ruby_gem
40
-
41
- task :default => :ext
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.31
1
+ 0.1.33
data/ext/rays/camera.cpp CHANGED
@@ -25,7 +25,7 @@ RUCY_DEF5(setup, device_name, min_width, min_height, resize, crop)
25
25
  RUCY_CHECK_OBJ(Rays::Camera, self);
26
26
 
27
27
  *THIS = Rays::Camera(
28
- device_name ? to<const char*>(device_name) : NULL,
28
+ device_name ? device_name.c_str() : NULL,
29
29
  to<int>(min_width), to<int>(min_height),
30
30
  to<bool>(resize), to<bool>(crop));
31
31
  return self;
data/ext/rays/extconf.rb CHANGED
@@ -15,7 +15,6 @@ require 'rays/extension'
15
15
  Xot::ExtConf.new Xot, Rucy, Rays do
16
16
  setup do
17
17
  headers << 'ruby.h'
18
- local_libs << 'rucy'
19
18
  libs.unshift 'gdi21', 'opengl32' if win32?
20
19
  frameworks << 'AppKit' << 'OpenGL' << 'AVFoundation' if osx?
21
20
  $LDFLAGS << ' -Wl,--out-implib=native.dll.a' if cygwin?
data/ext/rays/image.cpp CHANGED
@@ -63,6 +63,15 @@ RUCY_DEF1(initialize_copy, obj)
63
63
  }
64
64
  RUCY_END
65
65
 
66
+ static
67
+ RUCY_DEF1(save, path)
68
+ {
69
+ CHECK;
70
+ THIS->save(path.c_str());
71
+ return self;
72
+ }
73
+ RUCY_END
74
+
66
75
  static
67
76
  RUCY_DEF0(width)
68
77
  {
@@ -112,21 +121,9 @@ RUCY_DEF0(bitmap)
112
121
  RUCY_END
113
122
 
114
123
  static
115
- RUCY_DEF1(save, path)
116
- {
117
- CHECK;
118
- Rays::save_image(*THIS, path.c_str());
119
- return self;
120
- }
121
- RUCY_END
122
-
123
-
124
- static
125
- RUCY_DEFN(load)
124
+ RUCY_DEF1(load, path)
126
125
  {
127
- check_arg_count(__FILE__, __LINE__, "Image.load", argc, 1);
128
-
129
- return value(Rays::load_image(argv[0].c_str()));
126
+ return value(Rays::load_image(path.c_str()));
130
127
  }
131
128
  RUCY_END
132
129
 
@@ -142,13 +139,13 @@ Init_rays_image ()
142
139
  cImage.define_alloc_func(alloc);
143
140
  cImage.define_private_method("initialize", initialize);
144
141
  cImage.define_private_method("initialize_copy", initialize_copy);
142
+ cImage.define_method("save", save);
145
143
  cImage.define_method("width", width);
146
144
  cImage.define_method("height", height);
147
145
  cImage.define_method("color_space", color_space);
148
146
  cImage.define_method("pixel_density", pixel_density);
149
147
  cImage.define_method("painter", painter);
150
148
  cImage.define_method("bitmap", bitmap);
151
- cImage.define_method("save", save);
152
149
  cImage.define_module_function("load", load);
153
150
  }
154
151
 
data/include/rays/image.h CHANGED
@@ -35,6 +35,8 @@ namespace Rays
35
35
 
36
36
  Image dup () const;
37
37
 
38
+ void save (const char* path);
39
+
38
40
  coord width () const;
39
41
 
40
42
  coord height () const;
@@ -60,8 +62,6 @@ namespace Rays
60
62
  };// Image
61
63
 
62
64
 
63
- void save_image (const Image& image, const char* path);
64
-
65
65
  Image load_image (const char* path);
66
66
 
67
67
 
@@ -9,6 +9,9 @@
9
9
  #include <rays/bitmap.h>
10
10
 
11
11
 
12
+ RUCY_DECLARE_VALUE_FROM_TO(Rays::Bitmap)
13
+
14
+
12
15
  namespace Rays
13
16
  {
14
17
 
@@ -20,9 +23,6 @@ namespace Rays
20
23
  }// Rays
21
24
 
22
25
 
23
- RUCY_DECLARE_VALUE_FROM_TO(Rays::Bitmap)
24
-
25
-
26
26
  namespace Rucy
27
27
  {
28
28
 
@@ -10,6 +10,9 @@
10
10
  #include <rays/ruby/point.h>
11
11
 
12
12
 
13
+ RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Bounds)
14
+
15
+
13
16
  namespace Rays
14
17
  {
15
18
 
@@ -21,9 +24,6 @@ namespace Rays
21
24
  }// Rays
22
25
 
23
26
 
24
- RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Bounds)
25
-
26
-
27
27
  namespace Rucy
28
28
  {
29
29
 
@@ -9,6 +9,9 @@
9
9
  #include <rays/camera.h>
10
10
 
11
11
 
12
+ RUCY_DECLARE_VALUE_FROM_TO(Rays::Camera)
13
+
14
+
12
15
  namespace Rays
13
16
  {
14
17
 
@@ -20,9 +23,6 @@ namespace Rays
20
23
  }// Rays
21
24
 
22
25
 
23
- RUCY_DECLARE_VALUE_FROM_TO(Rays::Camera)
24
-
25
-
26
26
  namespace Rucy
27
27
  {
28
28
 
@@ -9,6 +9,9 @@
9
9
  #include <rays/color.h>
10
10
 
11
11
 
12
+ RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Color)
13
+
14
+
12
15
  namespace Rays
13
16
  {
14
17
 
@@ -20,9 +23,6 @@ namespace Rays
20
23
  }// Rays
21
24
 
22
25
 
23
- RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Color)
24
-
25
-
26
26
  namespace Rucy
27
27
  {
28
28
 
@@ -9,6 +9,9 @@
9
9
  #include <rays/color_space.h>
10
10
 
11
11
 
12
+ RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::ColorSpace)
13
+
14
+
12
15
  namespace Rays
13
16
  {
14
17
 
@@ -20,9 +23,6 @@ namespace Rays
20
23
  }// Rays
21
24
 
22
25
 
23
- RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::ColorSpace)
24
-
25
-
26
26
  namespace Rucy
27
27
  {
28
28
 
@@ -9,6 +9,9 @@
9
9
  #include <rays/font.h>
10
10
 
11
11
 
12
+ RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Font)
13
+
14
+
12
15
  namespace Rays
13
16
  {
14
17
 
@@ -20,9 +23,6 @@ namespace Rays
20
23
  }// Rays
21
24
 
22
25
 
23
- RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Font)
24
-
25
-
26
26
  namespace Rucy
27
27
  {
28
28
 
@@ -9,6 +9,9 @@
9
9
  #include <rays/image.h>
10
10
 
11
11
 
12
+ RUCY_DECLARE_VALUE_FROM_TO(Rays::Image)
13
+
14
+
12
15
  namespace Rays
13
16
  {
14
17
 
@@ -20,9 +23,6 @@ namespace Rays
20
23
  }// Rays
21
24
 
22
25
 
23
- RUCY_DECLARE_VALUE_FROM_TO(Rays::Image)
24
-
25
-
26
26
  namespace Rucy
27
27
  {
28
28
 
@@ -9,6 +9,9 @@
9
9
  #include <rays/matrix.h>
10
10
 
11
11
 
12
+ RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Matrix)
13
+
14
+
12
15
  namespace Rays
13
16
  {
14
17
 
@@ -20,9 +23,6 @@ namespace Rays
20
23
  }// Rays
21
24
 
22
25
 
23
- RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Matrix)
24
-
25
-
26
26
  namespace Rucy
27
27
  {
28
28
 
@@ -9,6 +9,9 @@
9
9
  #include <rays/painter.h>
10
10
 
11
11
 
12
+ RUCY_DECLARE_VALUE_FROM_TO(Rays::Painter)
13
+
14
+
12
15
  namespace Rays
13
16
  {
14
17
 
@@ -20,9 +23,6 @@ namespace Rays
20
23
  }// Rays
21
24
 
22
25
 
23
- RUCY_DECLARE_VALUE_FROM_TO(Rays::Painter)
24
-
25
-
26
26
  namespace Rucy
27
27
  {
28
28
 
@@ -9,6 +9,9 @@
9
9
  #include <rays/point.h>
10
10
 
11
11
 
12
+ RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Point)
13
+
14
+
12
15
  namespace Rays
13
16
  {
14
17
 
@@ -20,9 +23,6 @@ namespace Rays
20
23
  }// Rays
21
24
 
22
25
 
23
- RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Point)
24
-
25
-
26
26
  namespace Rucy
27
27
  {
28
28
 
@@ -9,6 +9,11 @@
9
9
  #include <rays/polygon.h>
10
10
 
11
11
 
12
+ RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Polygon)
13
+
14
+ RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Polygon::Line)
15
+
16
+
12
17
  namespace Rays
13
18
  {
14
19
 
@@ -23,11 +28,6 @@ namespace Rays
23
28
  }// Rays
24
29
 
25
30
 
26
- RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Polygon)
27
-
28
- RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Polygon::Line)
29
-
30
-
31
31
  namespace Rucy
32
32
  {
33
33
 
@@ -9,6 +9,9 @@
9
9
  #include <rays/polyline.h>
10
10
 
11
11
 
12
+ RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Polyline)
13
+
14
+
12
15
  namespace Rays
13
16
  {
14
17
 
@@ -20,9 +23,6 @@ namespace Rays
20
23
  }// Rays
21
24
 
22
25
 
23
- RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Polyline)
24
-
25
-
26
26
  namespace Rucy
27
27
  {
28
28
 
@@ -9,6 +9,13 @@
9
9
  #include <rays/rays.h>
10
10
 
11
11
 
12
+ RUCY_DECLARE_CONVERT_TO(Rays::CapType)
13
+
14
+ RUCY_DECLARE_CONVERT_TO(Rays::JoinType)
15
+
16
+ RUCY_DECLARE_CONVERT_TO(Rays::BlendMode)
17
+
18
+
12
19
  namespace Rays
13
20
  {
14
21
 
@@ -20,11 +27,4 @@ namespace Rays
20
27
  }// Rays
21
28
 
22
29
 
23
- RUCY_DECLARE_CONVERT_TO(Rays::CapType)
24
-
25
- RUCY_DECLARE_CONVERT_TO(Rays::JoinType)
26
-
27
- RUCY_DECLARE_CONVERT_TO(Rays::BlendMode)
28
-
29
-
30
30
  #endif//EOH
@@ -9,6 +9,9 @@
9
9
  #include <rays/shader.h>
10
10
 
11
11
 
12
+ RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Shader)
13
+
14
+
12
15
  namespace Rays
13
16
  {
14
17
 
@@ -20,9 +23,6 @@ namespace Rays
20
23
  }// Rays
21
24
 
22
25
 
23
- RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Shader)
24
-
25
-
26
26
  namespace Rucy
27
27
  {
28
28
 
data/rays.gemspec CHANGED
@@ -28,8 +28,8 @@ Gem::Specification.new do |s|
28
28
  s.platform = Gem::Platform::RUBY
29
29
  s.required_ruby_version = '>= 2.7.0'
30
30
 
31
- s.add_runtime_dependency 'xot', '~> 0.1.31'
32
- s.add_runtime_dependency 'rucy', '~> 0.1.31'
31
+ s.add_runtime_dependency 'xot', '~> 0.1.33'
32
+ s.add_runtime_dependency 'rucy', '~> 0.1.33'
33
33
 
34
34
  s.add_development_dependency 'rake'
35
35
  s.add_development_dependency 'test-unit'
data/src/image.cpp CHANGED
@@ -138,15 +138,6 @@ namespace Rays
138
138
  return Image_get_texture(const_cast<Image&>(image));
139
139
  }
140
140
 
141
- void
142
- save_image (const Image& image, const char* path)
143
- {
144
- if (!image)
145
- argument_error(__FILE__, __LINE__);
146
-
147
- return Bitmap_save(image.bitmap(), path);
148
- }
149
-
150
141
  Image
151
142
  load_image (const char* path)
152
143
  {
@@ -197,6 +188,15 @@ namespace Rays
197
188
  return Image(bitmap().dup(), pixel_density());
198
189
  }
199
190
 
191
+ void
192
+ Image::save (const char* path)
193
+ {
194
+ if (!*this)
195
+ invalid_state_error(__FILE__, __LINE__);
196
+
197
+ Bitmap_save(bitmap(), path);
198
+ }
199
+
200
200
  coord
201
201
  Image::width () const
202
202
  {
data/src/painter.cpp CHANGED
@@ -1092,7 +1092,7 @@ namespace Rays
1092
1092
  coord x, coord y, coord str_width, coord str_height)
1093
1093
  {
1094
1094
  #if 0
1095
- save_image(painter->self->text_image, "/tmp/font.png");
1095
+ painter->self->text_image.save("/tmp/font.png");
1096
1096
 
1097
1097
  painter->push_state();
1098
1098
  {
data/src/win32/bitmap.cpp CHANGED
@@ -98,7 +98,7 @@ namespace Rays
98
98
  static void
99
99
  setup_bitmap (Bitmap* this_, const Texture& tex)
100
100
  {
101
- not_implement_error(__FILE__, __LINE__);
101
+ not_implemented_error(__FILE__, __LINE__);
102
102
  }
103
103
 
104
104
  Bitmap
data/test/helper.rb CHANGED
@@ -5,13 +5,22 @@
5
5
  .map {|s| File.expand_path "../#{s}/lib", __dir__}
6
6
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
7
7
 
8
- require 'test/unit'
9
8
  require 'xot/test'
10
9
  require 'rays'
11
10
 
11
+ require 'test/unit'
12
+
12
13
  include Xot::Test
13
14
 
14
15
 
15
16
  unless defined?($RAYS_NOAUTOINIT) && $RAYS_NOAUTOINIT
16
17
  def Rays.fin!() end
17
18
  end
19
+
20
+
21
+ def assert_equal_color(c1, c2, delta = 0.000001)
22
+ assert_in_delta c1.r, c2.r, delta
23
+ assert_in_delta c1.g, c2.g, delta
24
+ assert_in_delta c1.b, c2.b, delta
25
+ assert_in_delta c1.a, c2.a, delta
26
+ end
data/test/test_color.rb CHANGED
@@ -19,25 +19,25 @@ class TestColor < Test::Unit::TestCase
19
19
  end
20
20
 
21
21
  def test_initialize()
22
- assert_equal color(0, 0, 0, 1), color()
23
- assert_equal color(1, 1, 1, 1), color(1)
24
- assert_equal color(1, 1, 1, 2), color(1, 2)
25
- assert_equal color(1, 2, 3, 1), color(1, 2, 3)
26
- assert_equal color(1, 2, 3, 4), color(1, 2, 3, 4)
27
- assert_equal color8(1, 2, 3, 4), color('#01020304')
22
+ assert_equal_color color(0, 0, 0, 1), color()
23
+ assert_equal_color color(1, 1, 1, 1), color(1)
24
+ assert_equal_color color(1, 1, 1, 2), color(1, 2)
25
+ assert_equal_color color(1, 2, 3, 1), color(1, 2, 3)
26
+ assert_equal_color color(1, 2, 3, 4), color(1, 2, 3, 4)
27
+ assert_equal_color color8(1, 2, 3, 4), color('#01020304')
28
28
  assert_raise(ArgumentError) {color(1, 2, 3, 4, 5)}
29
29
  end
30
30
 
31
31
  def test_initialize_with_string()
32
- assert_equal color(0, 0, 0, 1), color('#000')
33
- assert_equal color(0, 0, 0, 1), color('#000000')
34
- assert_equal color(0, 0, 0, 0), color('#0000')
35
- assert_equal color(0, 0, 0, 0), color('#00000000')
36
- assert_equal color8(0x01, 0x23, 0x45, 0x67), color('#01234567')
37
- assert_equal color8(0x89, 0xab, 0xcd, 0xef), color('#89abcdef')
38
- assert_equal color8(0x0, 0x2, 0x4, 0x6, 15), color('#0246')
39
- assert_equal color8(0x9, 0xb, 0xd, 0xf, 15), color('#9bdf')
40
- assert_equal color(0, 0, 0, 1), color(' #000 ')
32
+ assert_equal_color color(0, 0, 0, 1), color('#000')
33
+ assert_equal_color color(0, 0, 0, 1), color('#000000')
34
+ assert_equal_color color(0, 0, 0, 0), color('#0000')
35
+ assert_equal_color color(0, 0, 0, 0), color('#00000000')
36
+ assert_equal_color color8(0x01, 0x23, 0x45, 0x67), color('#01234567')
37
+ assert_equal_color color8(0x89, 0xab, 0xcd, 0xef), color('#89abcdef')
38
+ assert_equal_color color8(0x0, 0x2, 0x4, 0x6, 15), color('#0246')
39
+ assert_equal_color color8(0x9, 0xb, 0xd, 0xf, 15), color('#9bdf')
40
+ assert_equal_color color(0, 0, 0, 1), color(' #000 ')
41
41
  assert_raise(ArgumentError) {color '#'}
42
42
  assert_raise(ArgumentError) {color '000'}
43
43
  assert_raise(ArgumentError) {color '#0'}
@@ -48,14 +48,14 @@ class TestColor < Test::Unit::TestCase
48
48
 
49
49
  def test_dup()
50
50
  o = color
51
- assert_equal color(0, 0, 0), o
51
+ assert_equal_color color(0, 0, 0), o
52
52
  o.red = 1
53
- assert_equal color(1, 0, 0), o
53
+ assert_equal_color color(1, 0, 0), o
54
54
  x = o.dup
55
- assert_equal color(1, 0, 0), x
55
+ assert_equal_color color(1, 0, 0), x
56
56
  x.red = 2
57
- assert_equal color(2, 0, 0), x
58
- assert_equal color(1, 0, 0), o
57
+ assert_equal_color color(2, 0, 0), x
58
+ assert_equal_color color(1, 0, 0), o
59
59
  end
60
60
 
61
61
  def test_get_rgb()
@@ -125,31 +125,31 @@ class TestColor < Test::Unit::TestCase
125
125
  end
126
126
 
127
127
  def test_hsv_hue()
128
- assert_equal color(0.5, 0, 1), hsv(-0.25, 1, 1)
129
- assert_equal color(1, 0, 0), hsv( 0, 1, 1)
130
- assert_equal color(0.5, 1, 0), hsv( 0.25, 1, 1)
131
- assert_equal color(0, 1, 1), hsv( 0.5, 1, 1)
132
- assert_equal color(0.5, 0, 1), hsv( 0.75, 1, 1)
133
- assert_equal color(1, 0, 0), hsv( 1, 1, 1)
134
- assert_equal color(0.5, 1, 0), hsv( 1.25, 1, 1)
128
+ assert_equal_color color(0.5, 0, 1), hsv(-0.25, 1, 1)
129
+ assert_equal_color color(1, 0, 0), hsv( 0, 1, 1)
130
+ assert_equal_color color(0.5, 1, 0), hsv( 0.25, 1, 1)
131
+ assert_equal_color color(0, 1, 1), hsv( 0.5, 1, 1)
132
+ assert_equal_color color(0.5, 0, 1), hsv( 0.75, 1, 1)
133
+ assert_equal_color color(1, 0, 0), hsv( 1, 1, 1)
134
+ assert_equal_color color(0.5, 1, 0), hsv( 1.25, 1, 1)
135
135
  end
136
136
 
137
137
  def test_hsv_saturation()
138
- assert_equal color(1, 1, 1), hsv(1, 0, 1)
139
- assert_equal color(1, 0.5, 0.5), hsv(1, 0.5, 1)
140
- assert_equal color(1, 0, 0), hsv(1, 1, 1)
138
+ assert_equal_color color(1, 1, 1), hsv(1, 0, 1)
139
+ assert_equal_color color(1, 0.5, 0.5), hsv(1, 0.5, 1)
140
+ assert_equal_color color(1, 0, 0), hsv(1, 1, 1)
141
141
  end
142
142
 
143
143
  def test_hsv_value()
144
- assert_equal color(0, 0, 0), hsv(1, 1, 0)
145
- assert_equal color(0.5, 0, 0), hsv(1, 1, 0.5)
146
- assert_equal color(1, 0, 0), hsv(1, 1, 1)
144
+ assert_equal_color color(0, 0, 0), hsv(1, 1, 0)
145
+ assert_equal_color color(0.5, 0, 0), hsv(1, 1, 0.5)
146
+ assert_equal_color color(1, 0, 0), hsv(1, 1, 1)
147
147
  end
148
148
 
149
149
  def test_hsv_alpha()
150
- assert_equal color(1, 0, 0, 0), hsv(1, 1, 1, 0)
151
- assert_equal color(1, 0, 0, 0.5), hsv(1, 1, 1, 0.5)
152
- assert_equal color(1, 0, 0, 1), hsv(1, 1, 1, 1)
150
+ assert_equal_color color(1, 0, 0, 0), hsv(1, 1, 1, 0)
151
+ assert_equal_color color(1, 0, 0, 0.5), hsv(1, 1, 1, 0.5)
152
+ assert_equal_color color(1, 0, 0, 1), hsv(1, 1, 1, 1)
153
153
  end
154
154
 
155
155
  end# TestColor
@@ -6,7 +6,7 @@ $RAYS_NOAUTOINIT = true
6
6
  require_relative 'helper'
7
7
 
8
8
 
9
- class TestRays < Test::Unit::TestCase
9
+ class TestRaysInit < Test::Unit::TestCase
10
10
 
11
11
  def test_init!()
12
12
  assert_raise(Rays::RaysError) {Rays.fin!}
@@ -15,4 +15,4 @@ class TestRays < Test::Unit::TestCase
15
15
  assert Rays.fin!
16
16
  end
17
17
 
18
- end# TestRays
18
+ end# TestRaysInit
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.31
4
+ version: 0.1.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-26 00:00:00.000000000 Z
11
+ date: 2023-04-21 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.31
19
+ version: 0.1.33
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.31
26
+ version: 0.1.33
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.31
33
+ version: 0.1.33
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.31
40
+ version: 0.1.33
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -111,7 +111,7 @@ files:
111
111
  - ".doc/ext/rays/polyline.cpp"
112
112
  - ".doc/ext/rays/rays.cpp"
113
113
  - ".doc/ext/rays/shader.cpp"
114
- - ".github/workflows/release.yml"
114
+ - ".github/workflows/release-gem.yml"
115
115
  - ".github/workflows/tag.yml"
116
116
  - ".github/workflows/test.yml"
117
117
  - ".github/workflows/utils.rb"
@@ -270,7 +270,7 @@ files:
270
270
  - test/test_polygon.rb
271
271
  - test/test_polygon_line.rb
272
272
  - test/test_polyline.rb
273
- - test/test_rays.rb
273
+ - test/test_rays_init.rb
274
274
  - test/test_shader.rb
275
275
  homepage: https://github.com/xord/rays
276
276
  licenses: []
@@ -290,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
290
  - !ruby/object:Gem::Version
291
291
  version: '0'
292
292
  requirements: []
293
- rubygems_version: 3.4.6
293
+ rubygems_version: 3.4.10
294
294
  signing_key:
295
295
  specification_version: 4
296
296
  summary: A Drawing Engine using OpenGL.
@@ -309,5 +309,5 @@ test_files:
309
309
  - test/test_polygon.rb
310
310
  - test/test_polygon_line.rb
311
311
  - test/test_polyline.rb
312
- - test/test_rays.rb
312
+ - test/test_rays_init.rb
313
313
  - test/test_shader.rb
@@ -1,34 +0,0 @@
1
- name: Release
2
-
3
- on:
4
- push:
5
- tags: ['v[0-9]*']
6
-
7
- jobs:
8
- release:
9
- runs-on: macos-latest
10
-
11
- steps:
12
- - name: ruby 3.2
13
- uses: ruby/setup-ruby@v1
14
- with:
15
- ruby-version: 3.2
16
-
17
- - name: checkout
18
- uses: actions/checkout@v2
19
-
20
- - name: setup dependencies
21
- run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
22
-
23
- - name: test
24
- run: rake test
25
-
26
- - name: upload to rubygems
27
- env:
28
- GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
29
- run: |
30
- mkdir -p $HOME/.gem
31
- touch $HOME/.gem/credentials
32
- chmod 0600 $HOME/.gem/credentials
33
- printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
34
- rake upload