rays 0.1.3 → 0.1.4
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.
- data/.doc/ext/rays/bitmap.cpp +76 -53
- data/.doc/ext/rays/font.cpp +31 -27
- data/.doc/ext/rays/image.cpp +44 -37
- data/.doc/ext/rays/native.cpp +6 -0
- data/.doc/ext/rays/painter.cpp +276 -160
- data/.doc/ext/rays/rays.cpp +8 -9
- data/.doc/ext/rays/texture.cpp +50 -28
- data/.gitignore +14 -0
- data/Rakefile +5 -30
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +77 -53
- data/ext/rays/bounds.cpp +426 -0
- data/ext/rays/color.cpp +199 -0
- data/ext/rays/defs.h +1 -18
- data/ext/rays/extconf.rb +10 -8
- data/ext/rays/font.cpp +31 -27
- data/ext/rays/image.cpp +44 -37
- data/ext/rays/matrix.cpp +154 -0
- data/ext/rays/native.cpp +6 -0
- data/ext/rays/painter.cpp +288 -163
- data/ext/rays/point.cpp +175 -0
- data/ext/rays/rays.cpp +8 -9
- data/ext/rays/texture.cpp +52 -28
- data/include/rays.h +1 -2
- data/include/rays/bitmap.h +5 -3
- data/include/rays/bounds.h +94 -0
- data/include/rays/color.h +53 -0
- data/include/rays/colorspace.h +2 -2
- data/include/rays/exception.h +1 -1
- data/include/rays/font.h +7 -3
- data/include/rays/image.h +6 -2
- data/include/rays/matrix.h +63 -0
- data/include/rays/opengl.h +1 -1
- data/include/rays/painter.h +138 -39
- data/include/rays/point.h +39 -0
- data/include/rays/ruby.h +3 -0
- data/include/rays/ruby/bitmap.h +5 -3
- data/include/rays/ruby/bounds.h +41 -0
- data/include/rays/ruby/color.h +41 -0
- data/include/rays/ruby/font.h +5 -3
- data/include/rays/ruby/image.h +5 -3
- data/include/rays/ruby/matrix.h +41 -0
- data/include/rays/ruby/painter.h +5 -3
- data/include/rays/ruby/point.h +41 -0
- data/include/rays/ruby/texture.h +5 -3
- data/include/rays/texture.h +6 -2
- data/lib/rays.rb +3 -0
- data/lib/rays/autoinit.rb +1 -1
- data/lib/rays/bitmap.rb +15 -1
- data/lib/rays/bounds.rb +138 -0
- data/lib/rays/color.rb +52 -0
- data/lib/rays/ext.rb +4 -0
- data/lib/rays/image.rb +1 -1
- data/lib/rays/module.rb +9 -2
- data/lib/rays/painter.rb +40 -41
- data/lib/rays/point.rb +82 -0
- data/lib/rays/texture.rb +1 -1
- data/rays.gemspec +16 -37
- data/src/bounds.cpp +234 -0
- data/src/cocoa/bitmap.mm +4 -4
- data/src/cocoa/font.mm +35 -30
- data/src/cocoa/rays.mm +2 -0
- data/src/color.cpp +77 -0
- data/src/colorspace.cpp +3 -3
- data/src/exception.cpp +3 -18
- data/src/image.cpp +9 -2
- data/src/matrix.cpp +103 -0
- data/src/painter.cpp +475 -224
- data/src/point.cpp +52 -0
- data/src/texture.cpp +14 -2
- data/src/win32/bitmap.cpp +2 -2
- data/src/win32/gdi.cpp +22 -13
- data/src/win32/gdi.h +7 -7
- data/test/helpers.rb +1 -5
- data/test/test_bitmap.rb +9 -0
- data/test/test_bounds.rb +246 -0
- data/test/test_color.rb +88 -0
- data/test/test_font.rb +28 -0
- data/test/test_image.rb +9 -0
- data/test/test_painter.rb +1 -3
- data/test/test_point.rb +121 -0
- data/test/test_rays.rb +2 -3
- data/test/test_texture.rb +1 -3
- metadata +146 -75
- data/include/rays/helpers.h +0 -37
- data/include/rays/transform.h +0 -35
- data/src/helpers.cpp +0 -22
- data/src/transform.cpp +0 -88
@@ -0,0 +1,39 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_POINT_H__
|
4
|
+
#define __RAYS_POINT_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <rays/defs.h>
|
8
|
+
|
9
|
+
|
10
|
+
namespace Rays
|
11
|
+
{
|
12
|
+
|
13
|
+
|
14
|
+
struct Point
|
15
|
+
{
|
16
|
+
|
17
|
+
coord x, y, z;
|
18
|
+
|
19
|
+
Point (coord value = 0);
|
20
|
+
|
21
|
+
Point (coord x, coord y, coord z = 0);
|
22
|
+
|
23
|
+
Point dup () const;
|
24
|
+
|
25
|
+
Point& set (coord value = 0);
|
26
|
+
|
27
|
+
Point& set (coord x, coord y, coord z = 0);
|
28
|
+
|
29
|
+
coord* array ();
|
30
|
+
|
31
|
+
const coord* array () const;
|
32
|
+
|
33
|
+
};// Point
|
34
|
+
|
35
|
+
|
36
|
+
}// Rays
|
37
|
+
|
38
|
+
|
39
|
+
#endif//EOH
|
data/include/rays/ruby.h
CHANGED
data/include/rays/ruby/bitmap.h
CHANGED
@@ -24,12 +24,14 @@ namespace Rucy
|
|
24
24
|
{
|
25
25
|
|
26
26
|
|
27
|
-
Value value (const Rays::Bitmap&
|
27
|
+
Value value (const Rays::Bitmap& obj);
|
28
|
+
|
29
|
+
Value value (const Rays::Bitmap* obj);
|
28
30
|
|
29
31
|
template <> inline Rays::Bitmap*
|
30
|
-
value_to<Rays::Bitmap*> (Value
|
32
|
+
value_to<Rays::Bitmap*> (Value val, bool)
|
31
33
|
{
|
32
|
-
return
|
34
|
+
return get_type_ptr<Rays::Bitmap>(val, Rays::bitmap_class());
|
33
35
|
}
|
34
36
|
|
35
37
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_RUBY_BOUNDS_H__
|
4
|
+
#define __RAYS_RUBY_BOUNDS_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <rucy/rucy.h>
|
8
|
+
#include <rucy/class.h>
|
9
|
+
#include <rays/bounds.h>
|
10
|
+
|
11
|
+
|
12
|
+
namespace Rays
|
13
|
+
{
|
14
|
+
|
15
|
+
|
16
|
+
Rucy::Class bounds_class ();
|
17
|
+
// class Rays::Bounds
|
18
|
+
|
19
|
+
|
20
|
+
}// Rays
|
21
|
+
|
22
|
+
|
23
|
+
namespace Rucy
|
24
|
+
{
|
25
|
+
|
26
|
+
|
27
|
+
Value value (const Rays::Bounds& obj);
|
28
|
+
|
29
|
+
Value value (const Rays::Bounds* obj);
|
30
|
+
|
31
|
+
template <> inline Rays::Bounds*
|
32
|
+
value_to<Rays::Bounds*> (Value val, bool)
|
33
|
+
{
|
34
|
+
return get_type_ptr<Rays::Bounds>(val, Rays::bounds_class());
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
}// Rucy
|
39
|
+
|
40
|
+
|
41
|
+
#endif//EOH
|
@@ -0,0 +1,41 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_RUBY_COLOR_H__
|
4
|
+
#define __RAYS_RUBY_COLOR_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <rucy/rucy.h>
|
8
|
+
#include <rucy/class.h>
|
9
|
+
#include <rays/color.h>
|
10
|
+
|
11
|
+
|
12
|
+
namespace Rays
|
13
|
+
{
|
14
|
+
|
15
|
+
|
16
|
+
Rucy::Class color_class ();
|
17
|
+
// class Rays::Color
|
18
|
+
|
19
|
+
|
20
|
+
}// Rays
|
21
|
+
|
22
|
+
|
23
|
+
namespace Rucy
|
24
|
+
{
|
25
|
+
|
26
|
+
|
27
|
+
Value value (const Rays::Color& obj);
|
28
|
+
|
29
|
+
Value value (const Rays::Color* obj);
|
30
|
+
|
31
|
+
template <> inline Rays::Color*
|
32
|
+
value_to<Rays::Color*> (Value val, bool)
|
33
|
+
{
|
34
|
+
return get_type_ptr<Rays::Color>(val, Rays::color_class());
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
}// Rucy
|
39
|
+
|
40
|
+
|
41
|
+
#endif//EOH
|
data/include/rays/ruby/font.h
CHANGED
@@ -24,12 +24,14 @@ namespace Rucy
|
|
24
24
|
{
|
25
25
|
|
26
26
|
|
27
|
-
Value value (const Rays::Font&
|
27
|
+
Value value (const Rays::Font& obj);
|
28
|
+
|
29
|
+
Value value (const Rays::Font* obj);
|
28
30
|
|
29
31
|
template <> inline Rays::Font*
|
30
|
-
value_to<Rays::Font*> (Value
|
32
|
+
value_to<Rays::Font*> (Value val, bool)
|
31
33
|
{
|
32
|
-
return
|
34
|
+
return get_type_ptr<Rays::Font>(val, Rays::font_class());
|
33
35
|
}
|
34
36
|
|
35
37
|
|
data/include/rays/ruby/image.h
CHANGED
@@ -24,12 +24,14 @@ namespace Rucy
|
|
24
24
|
{
|
25
25
|
|
26
26
|
|
27
|
-
Value value (const Rays::Image&
|
27
|
+
Value value (const Rays::Image& obj);
|
28
|
+
|
29
|
+
Value value (const Rays::Image* obj);
|
28
30
|
|
29
31
|
template <> inline Rays::Image*
|
30
|
-
value_to<Rays::Image*> (Value
|
32
|
+
value_to<Rays::Image*> (Value val, bool)
|
31
33
|
{
|
32
|
-
return
|
34
|
+
return get_type_ptr<Rays::Image>(val, Rays::image_class());
|
33
35
|
}
|
34
36
|
|
35
37
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_RUBY_MATRIX_H__
|
4
|
+
#define __RAYS_RUBY_MATRIX_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <rucy/rucy.h>
|
8
|
+
#include <rucy/class.h>
|
9
|
+
#include <rays/matrix.h>
|
10
|
+
|
11
|
+
|
12
|
+
namespace Rays
|
13
|
+
{
|
14
|
+
|
15
|
+
|
16
|
+
Rucy::Class matrix_class ();
|
17
|
+
// class Rays::Matrix
|
18
|
+
|
19
|
+
|
20
|
+
}// Rays
|
21
|
+
|
22
|
+
|
23
|
+
namespace Rucy
|
24
|
+
{
|
25
|
+
|
26
|
+
|
27
|
+
Value value (const Rays::Matrix& obj);
|
28
|
+
|
29
|
+
Value value (const Rays::Matrix* obj);
|
30
|
+
|
31
|
+
template <> inline Rays::Matrix*
|
32
|
+
value_to<Rays::Matrix*> (Value val, bool)
|
33
|
+
{
|
34
|
+
return get_type_ptr<Rays::Matrix>(val, Rays::matrix_class());
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
}// Rucy
|
39
|
+
|
40
|
+
|
41
|
+
#endif//EOH
|
data/include/rays/ruby/painter.h
CHANGED
@@ -24,12 +24,14 @@ namespace Rucy
|
|
24
24
|
{
|
25
25
|
|
26
26
|
|
27
|
-
Value value (const Rays::Painter&
|
27
|
+
Value value (const Rays::Painter& obj);
|
28
|
+
|
29
|
+
Value value (const Rays::Painter* obj);
|
28
30
|
|
29
31
|
template <> inline Rays::Painter*
|
30
|
-
value_to<Rays::Painter*> (Value
|
32
|
+
value_to<Rays::Painter*> (Value val, bool)
|
31
33
|
{
|
32
|
-
return
|
34
|
+
return get_type_ptr<Rays::Painter>(val, Rays::painter_class());
|
33
35
|
}
|
34
36
|
|
35
37
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_RUBY_POINT_H__
|
4
|
+
#define __RAYS_RUBY_POINT_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <rucy/rucy.h>
|
8
|
+
#include <rucy/class.h>
|
9
|
+
#include <rays/point.h>
|
10
|
+
|
11
|
+
|
12
|
+
namespace Rays
|
13
|
+
{
|
14
|
+
|
15
|
+
|
16
|
+
Rucy::Class point_class ();
|
17
|
+
// class Rays::Point
|
18
|
+
|
19
|
+
|
20
|
+
}// Rays
|
21
|
+
|
22
|
+
|
23
|
+
namespace Rucy
|
24
|
+
{
|
25
|
+
|
26
|
+
|
27
|
+
Value value (const Rays::Point& obj);
|
28
|
+
|
29
|
+
Value value (const Rays::Point* obj);
|
30
|
+
|
31
|
+
template <> inline Rays::Point*
|
32
|
+
value_to<Rays::Point*> (Value val, bool)
|
33
|
+
{
|
34
|
+
return get_type_ptr<Rays::Point>(val, Rays::point_class());
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
}// Rucy
|
39
|
+
|
40
|
+
|
41
|
+
#endif//EOH
|
data/include/rays/ruby/texture.h
CHANGED
@@ -24,12 +24,14 @@ namespace Rucy
|
|
24
24
|
{
|
25
25
|
|
26
26
|
|
27
|
-
Value value (const Rays::Texture&
|
27
|
+
Value value (const Rays::Texture& obj);
|
28
|
+
|
29
|
+
Value value (const Rays::Texture* obj);
|
28
30
|
|
29
31
|
template <> inline Rays::Texture*
|
30
|
-
value_to<Rays::Texture*> (Value
|
32
|
+
value_to<Rays::Texture*> (Value val, bool)
|
31
33
|
{
|
32
|
-
return
|
34
|
+
return get_type_ptr<Rays::Texture>(val, Rays::texture_class());
|
33
35
|
}
|
34
36
|
|
35
37
|
|
data/include/rays/texture.h
CHANGED
@@ -4,9 +4,9 @@
|
|
4
4
|
#define __RAYS_TEXTURE_H__
|
5
5
|
|
6
6
|
|
7
|
+
#include <xot/pimpl.h>
|
7
8
|
#include <rays/defs.h>
|
8
9
|
#include <rays/opengl.h>
|
9
|
-
#include <rays/helpers.h>
|
10
10
|
|
11
11
|
|
12
12
|
namespace Rays
|
@@ -33,6 +33,10 @@ namespace Rays
|
|
33
33
|
|
34
34
|
int height () const;
|
35
35
|
|
36
|
+
float s (float x) const;
|
37
|
+
|
38
|
+
float t (float y) const;
|
39
|
+
|
36
40
|
float s_max () const;
|
37
41
|
|
38
42
|
float t_max () const;
|
@@ -45,7 +49,7 @@ namespace Rays
|
|
45
49
|
|
46
50
|
struct Data;
|
47
51
|
|
48
|
-
|
52
|
+
Xot::PImpl<Data, true> self;
|
49
53
|
|
50
54
|
};// Texture
|
51
55
|
|
data/lib/rays.rb
CHANGED
data/lib/rays/autoinit.rb
CHANGED
data/lib/rays/bitmap.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
|
4
|
-
require 'rays/
|
4
|
+
require 'rays/ext'
|
5
5
|
|
6
6
|
|
7
7
|
module Rays
|
@@ -11,6 +11,16 @@ module Rays
|
|
11
11
|
|
12
12
|
include Enumerable
|
13
13
|
|
14
|
+
def initialize (width, height, colorspace = RGBA)
|
15
|
+
colorspace = case colorspace
|
16
|
+
when :GRAY then GRAY
|
17
|
+
when :RGB then RGB
|
18
|
+
when :RGBA then RGBA
|
19
|
+
else colorspace
|
20
|
+
end
|
21
|
+
setup width, height, colorspace
|
22
|
+
end
|
23
|
+
|
14
24
|
def each ()
|
15
25
|
height.times do |y|
|
16
26
|
width.times do |x|
|
@@ -19,6 +29,10 @@ module Rays
|
|
19
29
|
end
|
20
30
|
end
|
21
31
|
|
32
|
+
def size ()
|
33
|
+
[width, height]
|
34
|
+
end
|
35
|
+
|
22
36
|
end# Bitmap
|
23
37
|
|
24
38
|
|
data/lib/rays/bounds.rb
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require 'rays/ext'
|
5
|
+
require 'rays/point'
|
6
|
+
|
7
|
+
|
8
|
+
module Rays
|
9
|
+
|
10
|
+
|
11
|
+
class Bounds
|
12
|
+
|
13
|
+
include Comparable
|
14
|
+
|
15
|
+
alias w width
|
16
|
+
alias w= width=
|
17
|
+
|
18
|
+
alias h height
|
19
|
+
alias h= height=
|
20
|
+
|
21
|
+
alias d depth
|
22
|
+
alias d= depth=
|
23
|
+
|
24
|
+
alias pos position
|
25
|
+
alias pos= position=
|
26
|
+
|
27
|
+
def move_to! (*args)
|
28
|
+
case args.size
|
29
|
+
when 1 then self.x = self.y = args[0]
|
30
|
+
when 2 then self.x, self.y = args
|
31
|
+
when 3 then self.x, self.y, self.z = args
|
32
|
+
else raise ArgumentError
|
33
|
+
end
|
34
|
+
self
|
35
|
+
end
|
36
|
+
|
37
|
+
def move_to (*args)
|
38
|
+
dup.move_to! *args
|
39
|
+
end
|
40
|
+
|
41
|
+
def move_by! (*args)
|
42
|
+
case args.size
|
43
|
+
when 1 then self.x += args[0]; self.y += args[0]
|
44
|
+
when 2 then self.x += args[0]; self.y += args[1]
|
45
|
+
when 3 then self.x += args[0]; self.y += args[1]; self.z += args[2]
|
46
|
+
else raise ArgumentError
|
47
|
+
end
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
51
|
+
def move_by (*args)
|
52
|
+
dup.move_by! *args
|
53
|
+
end
|
54
|
+
|
55
|
+
def resize_to! (*args)
|
56
|
+
case args.size
|
57
|
+
when 1 then self.w = self.h = args[0]
|
58
|
+
when 2 then self.w, self.h = args
|
59
|
+
when 3 then self.w, self.h, self.d = args
|
60
|
+
else raise ArgumentError
|
61
|
+
end
|
62
|
+
self
|
63
|
+
end
|
64
|
+
|
65
|
+
def resize_to (*args)
|
66
|
+
dup.resize_to! *args
|
67
|
+
end
|
68
|
+
|
69
|
+
def resize_by! (*args)
|
70
|
+
case args.size
|
71
|
+
when 1 then self.w += args[0]; self.h += args[0]
|
72
|
+
when 2 then self.w += args[0]; self.h += args[1]
|
73
|
+
when 3 then self.w += args[0]; self.h += args[1]; self.d += args[2]
|
74
|
+
else raise ArgumentError
|
75
|
+
end
|
76
|
+
self
|
77
|
+
end
|
78
|
+
|
79
|
+
def resize_by (*args)
|
80
|
+
dup.resize_by! *args
|
81
|
+
end
|
82
|
+
|
83
|
+
def inset_by! (*args)
|
84
|
+
move_by! *args
|
85
|
+
resize_by! *args.map {|n| -n * 2}
|
86
|
+
self
|
87
|
+
end
|
88
|
+
|
89
|
+
def inset_by (*args)
|
90
|
+
dup.inset_by! *args
|
91
|
+
end
|
92
|
+
|
93
|
+
def center ()
|
94
|
+
Point.new (x + w / 2).round, (y + h / 2).round
|
95
|
+
end
|
96
|
+
|
97
|
+
def to_a (dimension = 2)
|
98
|
+
case dimension
|
99
|
+
when 1 then [x, w]
|
100
|
+
when 2 then [x, y, w, h]
|
101
|
+
when 3 then [x, y, z, w, h, d]
|
102
|
+
else raise ArgumentError
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def [] (index)
|
107
|
+
case index
|
108
|
+
when 0 then Point.new(left, top, back)
|
109
|
+
when 1 then Point.new(right, bottom, front)
|
110
|
+
else raise IndexError
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def []= (index, point)
|
115
|
+
case index
|
116
|
+
when 0 then self.left, self.top, self.back = point.to_a(3)
|
117
|
+
when 1 then self.right, self.bottom, self.front = point.to_a(3)
|
118
|
+
else raise IndexError
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def <=> (o)
|
123
|
+
ret = x <=> o.x; return ret if ret != 0
|
124
|
+
ret = y <=> o.y; return ret if ret != 0
|
125
|
+
ret = z <=> o.z; return ret if ret != 0
|
126
|
+
ret = w <=> o.w; return ret if ret != 0
|
127
|
+
ret = h <=> o.h; return ret if ret != 0
|
128
|
+
d <=> o.d
|
129
|
+
end
|
130
|
+
|
131
|
+
def inspect ()
|
132
|
+
"#<Rays::Bounds x=#{x}, y=#{y}, z=#{z}, width=#{w}, height=#{h}, depth=#{d}>"
|
133
|
+
end
|
134
|
+
|
135
|
+
end# Bounds
|
136
|
+
|
137
|
+
|
138
|
+
end# Rays
|