rays 0.1.12 → 0.1.13
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 +5 -5
- data/.doc/ext/rays/bitmap.cpp +22 -76
- data/.doc/ext/rays/bounds.cpp +95 -125
- data/.doc/ext/rays/color.cpp +224 -45
- data/.doc/ext/rays/color_space.cpp +137 -45
- data/.doc/ext/rays/defs.cpp +183 -0
- data/.doc/ext/rays/font.cpp +39 -21
- data/.doc/ext/rays/image.cpp +26 -37
- data/.doc/ext/rays/matrix.cpp +186 -29
- data/.doc/ext/rays/native.cpp +12 -6
- data/.doc/ext/rays/noise.cpp +53 -0
- data/.doc/ext/rays/painter.cpp +120 -308
- data/.doc/ext/rays/point.cpp +82 -77
- data/.doc/ext/rays/polygon.cpp +287 -0
- data/.doc/ext/rays/polygon_line.cpp +96 -0
- data/.doc/ext/rays/polyline.cpp +161 -0
- data/.doc/ext/rays/rays.cpp +0 -13
- data/.doc/ext/rays/shader.cpp +83 -9
- data/README.md +1 -1
- data/Rakefile +21 -9
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +22 -80
- data/ext/rays/bounds.cpp +100 -128
- data/ext/rays/color.cpp +232 -51
- data/ext/rays/color_space.cpp +140 -46
- data/ext/rays/defs.cpp +183 -0
- data/ext/rays/defs.h +26 -2
- data/ext/rays/extconf.rb +1 -2
- data/ext/rays/font.cpp +39 -22
- data/ext/rays/image.cpp +27 -39
- data/ext/rays/matrix.cpp +198 -30
- data/ext/rays/native.cpp +12 -6
- data/ext/rays/noise.cpp +55 -0
- data/ext/rays/painter.cpp +129 -315
- data/ext/rays/point.cpp +89 -81
- data/ext/rays/polygon.cpp +301 -0
- data/ext/rays/polygon_line.cpp +99 -0
- data/ext/rays/polyline.cpp +170 -0
- data/ext/rays/rays.cpp +0 -14
- data/ext/rays/shader.cpp +84 -9
- data/include/rays.h +10 -2
- data/include/rays/bitmap.h +14 -26
- data/include/rays/bounds.h +21 -4
- data/include/rays/color.h +25 -14
- data/include/rays/color_space.h +11 -8
- data/include/rays/coord.h +114 -0
- data/include/rays/debug.h +22 -0
- data/include/rays/defs.h +3 -0
- data/include/rays/font.h +4 -4
- data/include/rays/image.h +11 -17
- data/include/rays/matrix.h +50 -24
- data/include/rays/noise.h +42 -0
- data/include/rays/opengl.h +2 -50
- data/include/rays/painter.h +57 -99
- data/include/rays/point.h +44 -51
- data/include/rays/polygon.h +164 -0
- data/include/rays/polyline.h +65 -0
- data/include/rays/rays.h +3 -0
- data/include/rays/ruby.h +7 -1
- data/include/rays/ruby/bounds.h +1 -1
- data/include/rays/ruby/color.h +1 -1
- data/include/rays/ruby/color_space.h +1 -1
- data/include/rays/ruby/font.h +1 -1
- data/include/rays/ruby/matrix.h +1 -1
- data/include/rays/ruby/point.h +1 -1
- data/include/rays/ruby/polygon.h +52 -0
- data/include/rays/ruby/polyline.h +41 -0
- data/include/rays/ruby/shader.h +1 -1
- data/include/rays/shader.h +36 -8
- data/lib/rays.rb +6 -1
- data/lib/rays/bitmap.rb +0 -15
- data/lib/rays/bounds.rb +17 -23
- data/lib/rays/color.rb +20 -47
- data/lib/rays/color_space.rb +13 -13
- data/lib/rays/image.rb +2 -6
- data/lib/rays/matrix.rb +28 -0
- data/lib/rays/module.rb +4 -19
- data/lib/rays/painter.rb +60 -97
- data/lib/rays/point.rb +13 -21
- data/lib/rays/polygon.rb +50 -0
- data/lib/rays/polygon_line.rb +36 -0
- data/lib/rays/polyline.rb +32 -0
- data/lib/rays/shader.rb +20 -1
- data/rays.gemspec +5 -7
- data/src/bitmap.h +36 -0
- data/src/bounds.cpp +74 -11
- data/src/color.cpp +58 -23
- data/src/color_space.cpp +50 -32
- data/src/color_space.h +22 -0
- data/src/coord.cpp +170 -0
- data/src/coord.h +35 -0
- data/src/font.cpp +118 -0
- data/src/font.h +64 -0
- data/src/frame_buffer.cpp +37 -71
- data/src/frame_buffer.h +4 -4
- data/src/image.cpp +171 -97
- data/src/image.h +25 -0
- data/src/ios/bitmap.mm +107 -105
- data/src/ios/font.mm +48 -60
- data/src/ios/helper.h +2 -2
- data/src/ios/opengl.mm +19 -4
- data/src/ios/rays.mm +3 -0
- data/src/matrix.cpp +111 -26
- data/src/matrix.h +30 -0
- data/src/noise.cpp +74 -0
- data/src/opengl.cpp +9 -27
- data/src/opengl.h +37 -0
- data/src/osx/bitmap.mm +111 -106
- data/src/osx/font.mm +48 -61
- data/src/osx/helper.h +2 -2
- data/src/osx/opengl.mm +19 -83
- data/src/osx/rays.mm +3 -0
- data/src/painter.cpp +780 -696
- data/src/painter.h +24 -0
- data/src/point.cpp +140 -119
- data/src/polygon.cpp +1100 -0
- data/src/polygon.h +32 -0
- data/src/polyline.cpp +158 -0
- data/src/polyline.h +67 -0
- data/src/render_buffer.cpp +11 -4
- data/src/render_buffer.h +2 -2
- data/src/shader.cpp +163 -106
- data/src/shader.h +38 -0
- data/src/shader_program.cpp +533 -0
- data/src/{program.h → shader_program.h} +28 -16
- data/src/shader_source.cpp +140 -0
- data/src/shader_source.h +52 -0
- data/src/texture.cpp +136 -160
- data/src/texture.h +65 -0
- data/src/win32/bitmap.cpp +62 -52
- data/src/win32/font.cpp +11 -13
- data/src/win32/font.h +24 -0
- data/src/win32/gdi.h +6 -6
- data/test/helper.rb +0 -3
- data/test/test_bitmap.rb +31 -7
- data/test/test_bounds.rb +36 -0
- data/test/test_color.rb +59 -19
- data/test/test_color_space.rb +95 -0
- data/test/test_image.rb +24 -20
- data/test/test_matrix.rb +106 -0
- data/test/test_painter.rb +92 -46
- data/test/test_painter_shape.rb +57 -0
- data/test/test_point.rb +21 -0
- data/test/test_polygon.rb +234 -0
- data/test/test_polygon_line.rb +167 -0
- data/test/test_polyline.rb +145 -0
- data/test/test_shader.rb +9 -9
- metadata +88 -67
- data/.doc/ext/rays/texture.cpp +0 -138
- data/ext/rays/texture.cpp +0 -149
- data/include/rays/ruby/texture.h +0 -41
- data/include/rays/texture.h +0 -71
- data/lib/rays/texture.rb +0 -24
- data/src/program.cpp +0 -648
- data/test/test_texture.rb +0 -27
data/src/texture.h
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_SRC_TEXTURE_H__
|
4
|
+
#define __RAYS_SRC_TEXTURE_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <xot/pimpl.h>
|
8
|
+
#include <rays/defs.h>
|
9
|
+
#include <rays/color_space.h>
|
10
|
+
#include "opengl.h"
|
11
|
+
|
12
|
+
|
13
|
+
namespace Rays
|
14
|
+
{
|
15
|
+
|
16
|
+
|
17
|
+
class Bitmap;
|
18
|
+
|
19
|
+
|
20
|
+
class Texture
|
21
|
+
{
|
22
|
+
|
23
|
+
public:
|
24
|
+
|
25
|
+
Texture ();
|
26
|
+
|
27
|
+
Texture (int width, int height, const ColorSpace& cs = RGBA);
|
28
|
+
|
29
|
+
Texture (const Bitmap& bitmap);
|
30
|
+
|
31
|
+
~Texture ();
|
32
|
+
|
33
|
+
int width () const;
|
34
|
+
|
35
|
+
int reserved_width () const;
|
36
|
+
|
37
|
+
int height () const;
|
38
|
+
|
39
|
+
int reserved_height () const;
|
40
|
+
|
41
|
+
const ColorSpace& color_space () const;
|
42
|
+
|
43
|
+
Context context () const;
|
44
|
+
|
45
|
+
GLuint id () const;
|
46
|
+
|
47
|
+
void set_modified (bool modified = true);
|
48
|
+
|
49
|
+
bool modified () const;
|
50
|
+
|
51
|
+
operator bool () const;
|
52
|
+
|
53
|
+
bool operator ! () const;
|
54
|
+
|
55
|
+
struct Data;
|
56
|
+
|
57
|
+
Xot::PSharedImpl<Data> self;
|
58
|
+
|
59
|
+
};// Texture
|
60
|
+
|
61
|
+
|
62
|
+
}// Rays
|
63
|
+
|
64
|
+
|
65
|
+
#endif//EOH
|
data/src/win32/bitmap.cpp
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
#include "
|
1
|
+
#include "../bitmap.h"
|
2
2
|
|
3
3
|
|
4
|
+
#include "font.h"
|
4
5
|
#include "gdi.h"
|
5
6
|
|
6
7
|
|
@@ -19,10 +20,10 @@ namespace Rays
|
|
19
20
|
|
20
21
|
Win32::MemoryDC memdc;
|
21
22
|
|
22
|
-
bool
|
23
|
+
bool modified;
|
23
24
|
|
24
25
|
Data ()
|
25
|
-
: pixels(NULL),
|
26
|
+
: pixels(NULL), modified(true)
|
26
27
|
{
|
27
28
|
}
|
28
29
|
|
@@ -56,7 +57,7 @@ namespace Rays
|
|
56
57
|
}
|
57
58
|
|
58
59
|
static bool
|
59
|
-
|
60
|
+
setup_bitmap (Bitmap* bmp, int w, int h, const ColorSpace& cs, HDC hdc = NULL)
|
60
61
|
{
|
61
62
|
if (w <= 0 || h <= 0 || !cs || !bmp || *bmp)
|
62
63
|
return false;
|
@@ -94,6 +95,59 @@ namespace Rays
|
|
94
95
|
return init_bitmap_pixels(bmp);
|
95
96
|
}
|
96
97
|
|
98
|
+
static void
|
99
|
+
setup_bitmap (Bitmap* this_, const Texture& tex)
|
100
|
+
{
|
101
|
+
not_implement_error(__FILE__, __LINE__);
|
102
|
+
}
|
103
|
+
|
104
|
+
Bitmap
|
105
|
+
Bitmap_from (const Texture& texture)
|
106
|
+
{
|
107
|
+
Bitmap bmp;
|
108
|
+
setup_bitmap(&bmp, texture);
|
109
|
+
return bmp;
|
110
|
+
}
|
111
|
+
|
112
|
+
void
|
113
|
+
Bitmap_draw_string (
|
114
|
+
Bitmap* bitmap, const RawFont& font, const char* str, coord x, coord y)
|
115
|
+
{
|
116
|
+
if (!bitmap || !*bitmap || !font || !str)
|
117
|
+
argument_error(__FILE__, __LINE__);
|
118
|
+
|
119
|
+
if (*str == '\0') return;
|
120
|
+
|
121
|
+
font.draw_string(bitmap->self->memdc.handle(), bitmap->height(), str, x, y);
|
122
|
+
Bitmap_set_modified(bitmap);
|
123
|
+
}
|
124
|
+
|
125
|
+
void
|
126
|
+
Bitmap_set_modified (Bitmap* bitmap, bool modified)
|
127
|
+
{
|
128
|
+
assert(bitmap);
|
129
|
+
|
130
|
+
bitmap->self->modified = modified;
|
131
|
+
}
|
132
|
+
|
133
|
+
bool
|
134
|
+
Bitmap_get_modified (const Bitmap& bitmap)
|
135
|
+
{
|
136
|
+
return bitmap.self->modified;
|
137
|
+
}
|
138
|
+
|
139
|
+
bool
|
140
|
+
Bitmap_save (const Bitmap& bitmap, const char* path)
|
141
|
+
{
|
142
|
+
return false;
|
143
|
+
}
|
144
|
+
|
145
|
+
bool
|
146
|
+
Bitmap_load (Bitmap* bitmap, const char* path)
|
147
|
+
{
|
148
|
+
return false;
|
149
|
+
}
|
150
|
+
|
97
151
|
|
98
152
|
Bitmap::Bitmap ()
|
99
153
|
{
|
@@ -101,7 +155,7 @@ namespace Rays
|
|
101
155
|
|
102
156
|
Bitmap::Bitmap (int width, int height, const ColorSpace& cs)
|
103
157
|
{
|
104
|
-
|
158
|
+
setup_bitmap(this, width, height, cs);
|
105
159
|
}
|
106
160
|
|
107
161
|
Bitmap::~Bitmap ()
|
@@ -138,28 +192,16 @@ namespace Rays
|
|
138
192
|
return pitch() * height();
|
139
193
|
}
|
140
194
|
|
141
|
-
bool
|
142
|
-
Bitmap::dirty () const
|
143
|
-
{
|
144
|
-
return self->dirty;
|
145
|
-
}
|
146
|
-
|
147
|
-
void
|
148
|
-
Bitmap::set_dirty (bool b)
|
149
|
-
{
|
150
|
-
self->dirty = b;
|
151
|
-
}
|
152
|
-
|
153
195
|
void*
|
154
|
-
Bitmap::
|
196
|
+
Bitmap::pixels ()
|
155
197
|
{
|
156
198
|
return self->pixels;
|
157
199
|
}
|
158
200
|
|
159
201
|
const void*
|
160
|
-
Bitmap::
|
202
|
+
Bitmap::pixels () const
|
161
203
|
{
|
162
|
-
return const_cast<This*>(this)->
|
204
|
+
return const_cast<This*>(this)->pixels();
|
163
205
|
}
|
164
206
|
|
165
207
|
Bitmap::operator bool () const
|
@@ -177,36 +219,4 @@ namespace Rays
|
|
177
219
|
}
|
178
220
|
|
179
221
|
|
180
|
-
bool
|
181
|
-
load_bitmap (Bitmap* bitmap, const char* path)
|
182
|
-
{
|
183
|
-
return false;
|
184
|
-
}
|
185
|
-
|
186
|
-
bool
|
187
|
-
save_bitmap (const Bitmap& bitmap, const char* path)
|
188
|
-
{
|
189
|
-
return false;
|
190
|
-
}
|
191
|
-
|
192
|
-
|
193
|
-
bool draw_string (
|
194
|
-
HDC, coord, const char*, coord, coord, const Font&);
|
195
|
-
|
196
|
-
bool
|
197
|
-
draw_string (
|
198
|
-
Bitmap* bmp, const char* str, coord x, coord y, const Font& font)
|
199
|
-
{
|
200
|
-
if (!bmp || !*bmp || !str || !font) return false;
|
201
|
-
|
202
|
-
if (*str == '\0') return true;
|
203
|
-
|
204
|
-
if (!draw_string(bmp->self->memdc.handle(), bmp->height(), str, x, y, font))
|
205
|
-
return false;
|
206
|
-
|
207
|
-
bmp->set_dirty();
|
208
|
-
return true;
|
209
|
-
}
|
210
|
-
|
211
|
-
|
212
222
|
}// Rays
|
data/src/win32/font.cpp
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
#include "
|
2
|
-
|
3
|
-
|
4
|
-
#include "gdi.h"
|
1
|
+
#include "font.h"
|
5
2
|
|
6
3
|
|
7
4
|
namespace Rays
|
@@ -67,23 +64,23 @@ namespace Rays
|
|
67
64
|
}
|
68
65
|
|
69
66
|
|
70
|
-
|
71
|
-
|
72
|
-
HDC hdc, coord context_height,
|
73
|
-
const char* str, coord x, coord y
|
67
|
+
void
|
68
|
+
Font_draw_string (
|
69
|
+
const Font& font, HDC hdc, coord context_height,
|
70
|
+
const char* str, coord x, coord y)
|
74
71
|
{
|
75
72
|
using namespace Win32;
|
76
73
|
|
77
|
-
if (!
|
74
|
+
if (!font || !hdc || !str)
|
75
|
+
argument_error(__FILE__, __LINE__);
|
78
76
|
|
79
|
-
if (*str == '\0') return
|
77
|
+
if (*str == '\0') return;
|
80
78
|
|
81
79
|
coord width = 0, height = 0;
|
82
80
|
if (!font.get_extent(&width, &height, str))
|
83
|
-
|
81
|
+
rays_error(__FILE__, __LINE__, "getting font extent failed.");
|
84
82
|
|
85
83
|
DC dc = hdc;
|
86
|
-
|
87
84
|
RECT rect = {x, y, x + (int) width, y + (int) height};
|
88
85
|
FillRect(dc.handle(), &rect, Brush(0, 0, 0).handle());
|
89
86
|
|
@@ -92,7 +89,8 @@ namespace Rays
|
|
92
89
|
BOOL ret = TextOutA(dc.handle(), x, y, str, strlen(str));
|
93
90
|
dc.set_font(old);
|
94
91
|
|
95
|
-
|
92
|
+
if (ret == FALSE)
|
93
|
+
rays_error(__FILE__, __LINE__, "drawing text failed.");
|
96
94
|
}
|
97
95
|
|
98
96
|
|
data/src/win32/font.h
ADDED
@@ -0,0 +1,24 @@
|
|
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
|
data/src/win32/gdi.h
CHANGED
@@ -38,7 +38,7 @@ namespace Rays
|
|
38
38
|
|
39
39
|
struct Data;
|
40
40
|
|
41
|
-
Xot::
|
41
|
+
Xot::PSharedImpl<Data> self;
|
42
42
|
|
43
43
|
};// Pen
|
44
44
|
|
@@ -64,7 +64,7 @@ namespace Rays
|
|
64
64
|
|
65
65
|
struct Data;
|
66
66
|
|
67
|
-
Xot::
|
67
|
+
Xot::PSharedImpl<Data> self;
|
68
68
|
|
69
69
|
};// Brush
|
70
70
|
|
@@ -95,7 +95,7 @@ namespace Rays
|
|
95
95
|
|
96
96
|
struct Data;
|
97
97
|
|
98
|
-
Xot::
|
98
|
+
Xot::PSharedImpl<Data> self;
|
99
99
|
|
100
100
|
};// Font
|
101
101
|
|
@@ -123,7 +123,7 @@ namespace Rays
|
|
123
123
|
|
124
124
|
struct Data;
|
125
125
|
|
126
|
-
Xot::
|
126
|
+
Xot::PSharedImpl<Data> self;
|
127
127
|
|
128
128
|
};// Bitmap
|
129
129
|
|
@@ -181,7 +181,7 @@ namespace Rays
|
|
181
181
|
|
182
182
|
struct Data;
|
183
183
|
|
184
|
-
Xot::
|
184
|
+
Xot::PSharedImpl<Data> self;
|
185
185
|
|
186
186
|
};// DC
|
187
187
|
|
@@ -209,7 +209,7 @@ namespace Rays
|
|
209
209
|
|
210
210
|
struct Data;
|
211
211
|
|
212
|
-
Xot::
|
212
|
+
Xot::PSharedImpl<Data> self;
|
213
213
|
|
214
214
|
};// MemoryDC
|
215
215
|
|
data/test/helper.rb
CHANGED
data/test/test_bitmap.rb
CHANGED
@@ -9,19 +9,43 @@ class TestBitmap < Test::Unit::TestCase
|
|
9
9
|
W = 32
|
10
10
|
H = 16
|
11
11
|
|
12
|
-
def
|
12
|
+
def bitmap (w = W, h = H)
|
13
13
|
Rays::Bitmap.new w, h
|
14
14
|
end
|
15
15
|
|
16
|
+
def color (*args)
|
17
|
+
Rays::Color.new *args
|
18
|
+
end
|
19
|
+
|
16
20
|
def test_initialize ()
|
17
|
-
assert_equal W,
|
18
|
-
assert_equal H,
|
21
|
+
assert_equal W, bitmap.width
|
22
|
+
assert_equal H, bitmap.height
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_dup ()
|
26
|
+
o = bitmap
|
27
|
+
assert_equal color(0, 0, 0, 0), o[0, 0]
|
28
|
+
o[0, 0] = color(1, 0, 0, 0)
|
29
|
+
assert_equal color(1, 0, 0, 0), o[0, 0]
|
30
|
+
x = o.dup
|
31
|
+
assert_equal color(1, 0, 0, 0), x[0, 0]
|
32
|
+
x[0, 0] = color(0, 1, 0, 0)
|
33
|
+
assert_equal color(0, 1, 0, 0), x[0, 0]
|
34
|
+
assert_equal color(1, 0, 0, 0), o[0, 0]
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_at ()
|
38
|
+
o = bitmap
|
39
|
+
assert_equal color(0, 0, 0, 0), o[0, 0]
|
40
|
+
o[0, 0] = 1
|
41
|
+
assert_equal color(1, 1, 1, 1), o[0, 0]
|
19
42
|
end
|
20
43
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
|
44
|
+
def test_to_a ()
|
45
|
+
colors = %w[#f00 #0f0 #00f #ff0].map {|s| color s}
|
46
|
+
bmp = bitmap 2, 2
|
47
|
+
bmp[0, 0], bmp[1, 0], bmp[0, 1], bmp[1, 1] = colors
|
48
|
+
assert_equal colors, bmp.to_a
|
25
49
|
end
|
26
50
|
|
27
51
|
end# TestBitmap
|
data/test/test_bounds.rb
CHANGED
@@ -25,6 +25,18 @@ class TestBounds < Test::Unit::TestCase
|
|
25
25
|
assert_raise(ArgumentError) {bounds(1, 2, 3, 4, 5, 6, 7)}
|
26
26
|
end
|
27
27
|
|
28
|
+
def test_dup ()
|
29
|
+
o = bounds
|
30
|
+
assert_equal bounds(0, 0, 0, 0, 0, 0), o
|
31
|
+
o.x = 1
|
32
|
+
assert_equal bounds(1, 0, 0, 0, 0, 0), o
|
33
|
+
x = o.dup
|
34
|
+
assert_equal bounds(1, 0, 0, 0, 0, 0), x
|
35
|
+
x.x = 2
|
36
|
+
assert_equal bounds(2, 0, 0, 0, 0, 0), x
|
37
|
+
assert_equal bounds(1, 0, 0, 0, 0, 0), o
|
38
|
+
end
|
39
|
+
|
28
40
|
def test_intersect? ()
|
29
41
|
assert bounds(10, 20, 30, 100, 100, 100).intersect?(bounds 50, 60, 70, 100, 100, 100)
|
30
42
|
assert_not bounds(10, 20, 30, 10, 10, 10).intersect?(bounds 50, 60, 70, 100, 100, 100)
|
@@ -35,6 +47,16 @@ class TestBounds < Test::Unit::TestCase
|
|
35
47
|
assert_not bounds(10, 20, 30, 10, 10, 10).include?(point 50, 60)
|
36
48
|
end
|
37
49
|
|
50
|
+
def test_valid? ()
|
51
|
+
assert bounds(0, 0, 0, 0, 0, 0).valid?
|
52
|
+
assert bounds(0, 0, 0, 1, 0, 0).valid?
|
53
|
+
assert bounds(0, 0, 0, 0, 1, 0).valid?
|
54
|
+
assert bounds(0, 0, 0, 0, 0, 1).valid?
|
55
|
+
assert_not bounds(0, 0, 0, -1, 0, 0).valid?
|
56
|
+
assert_not bounds(0, 0, 0, 0, -1, 0).valid?
|
57
|
+
assert_not bounds(0, 0, 0, 0, 0, -1).valid?
|
58
|
+
end
|
59
|
+
|
38
60
|
def test_get_xyzwhd ()
|
39
61
|
o = bounds 1, 2, 3, 4, 5, 6
|
40
62
|
assert_equal 1, o.x
|
@@ -285,8 +307,22 @@ class TestBounds < Test::Unit::TestCase
|
|
285
307
|
def test_operators ()
|
286
308
|
assert_equal bounds(50, 60, 70, 60, 60, 60), bounds(10, 20, 30, 100, 100, 100) & bounds(50, 60, 70, 100, 100, 100)
|
287
309
|
assert_equal bounds(10, 20, 30, 140, 140, 140), bounds(10, 20, 30, 100, 100, 100) | bounds(50, 60, 70, 100, 100, 100)
|
310
|
+
assert_equal bounds(10, 20, 30, 20, 20, 20), bounds(20, 30, 40, 10, 10, 10) | point(10, 20, 30)
|
311
|
+
assert_equal bounds(10, 20, 30, 30, 30, 30), bounds(10, 20, 30, 10, 10, 10) | point(40, 50, 60)
|
288
312
|
|
289
313
|
assert_equal point(0), (bounds(10, 20, 30, 10, 10, 10) & bounds(50, 60, 70, 10, 10, 10)).size
|
290
314
|
end
|
291
315
|
|
316
|
+
def test_invalid ()
|
317
|
+
o = Rays::Bounds.invalid
|
318
|
+
assert_not o.valid?
|
319
|
+
|
320
|
+
o |= point(1, 2)
|
321
|
+
assert o.valid?
|
322
|
+
assert_equal bounds(1, 2, 0, 0), o
|
323
|
+
|
324
|
+
o |= point(10, 20)
|
325
|
+
assert_equal bounds(1, 2, 9, 18), o
|
326
|
+
end
|
327
|
+
|
292
328
|
end# TestBounds
|