rays 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +8 -0
- data/README +4 -0
- data/Rakefile +72 -0
- data/VERSION +1 -0
- data/ext/rays/bitmap.cpp +322 -0
- data/ext/rays/extconf.rb +61 -0
- data/ext/rays/font.cpp +125 -0
- data/ext/rays/image.cpp +166 -0
- data/ext/rays/native.cpp +24 -0
- data/ext/rays/painter.cpp +573 -0
- data/ext/rays/rays.cpp +61 -0
- data/ext/rays/rays.h +39 -0
- data/ext/rays/texture.cpp +130 -0
- data/include/rays.h +20 -0
- data/include/rays/bitmap.h +80 -0
- data/include/rays/colorspace.h +101 -0
- data/include/rays/defs.h +33 -0
- data/include/rays/font.h +49 -0
- data/include/rays/helpers.h +37 -0
- data/include/rays/image.h +68 -0
- data/include/rays/opengl.h +15 -0
- data/include/rays/painter.h +179 -0
- data/include/rays/rays.h +19 -0
- data/include/rays/ruby.h +15 -0
- data/include/rays/ruby/bitmap.h +39 -0
- data/include/rays/ruby/font.h +39 -0
- data/include/rays/ruby/image.h +39 -0
- data/include/rays/ruby/painter.h +39 -0
- data/include/rays/ruby/rays.h +21 -0
- data/include/rays/ruby/texture.h +39 -0
- data/include/rays/texture.h +56 -0
- data/include/rays/transform.h +35 -0
- data/lib/rays.rb +9 -0
- data/lib/rays/autoinit.rb +10 -0
- data/lib/rays/bitmap.rb +25 -0
- data/lib/rays/image.rb +15 -0
- data/lib/rays/module.rb +30 -0
- data/lib/rays/painter.rb +99 -0
- data/lib/rays/texture.rb +15 -0
- data/rays.gemspec +54 -0
- data/src/cocoa/bitmap.mm +286 -0
- data/src/cocoa/font.mm +193 -0
- data/src/cocoa/helpers.h +26 -0
- data/src/cocoa/helpers.mm +25 -0
- data/src/cocoa/rays.mm +40 -0
- data/src/colorspace.cpp +183 -0
- data/src/helpers.cpp +22 -0
- data/src/image.cpp +133 -0
- data/src/painter.cpp +769 -0
- data/src/texture.cpp +360 -0
- data/src/transform.cpp +88 -0
- data/src/win32/bitmap.cpp +212 -0
- data/src/win32/font.cpp +99 -0
- data/src/win32/gdi.cpp +771 -0
- data/src/win32/gdi.h +226 -0
- data/src/win32/rays.cpp +36 -0
- data/support.rb +58 -0
- data/task/ext.rake +41 -0
- data/task/gem.rake +33 -0
- data/task/git.rake +22 -0
- data/task/lib.rake +54 -0
- data/test/helpers.rb +15 -0
- data/test/test_painter.rb +11 -0
- data/test/test_rays.rb +19 -0
- data/test/test_texture.rb +11 -0
- metadata +153 -0
data/include/rays/font.h
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_FONT_H__
|
4
|
+
#define __RAYS_FONT_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <rays/defs.h>
|
8
|
+
#include <rays/helpers.h>
|
9
|
+
|
10
|
+
|
11
|
+
namespace Rays
|
12
|
+
{
|
13
|
+
|
14
|
+
|
15
|
+
class Font
|
16
|
+
{
|
17
|
+
|
18
|
+
public:
|
19
|
+
|
20
|
+
Font ();
|
21
|
+
|
22
|
+
Font (const char* name, coord size = 0);
|
23
|
+
|
24
|
+
~Font ();
|
25
|
+
|
26
|
+
String name () const;
|
27
|
+
|
28
|
+
coord size () const;
|
29
|
+
|
30
|
+
bool get_extent (coord* width, coord* height, const char* str) const;
|
31
|
+
|
32
|
+
operator bool () const;
|
33
|
+
|
34
|
+
bool operator ! () const;
|
35
|
+
|
36
|
+
struct Data;
|
37
|
+
|
38
|
+
Impl<Data> self;
|
39
|
+
|
40
|
+
};// Font
|
41
|
+
|
42
|
+
|
43
|
+
const Font& default_font ();
|
44
|
+
|
45
|
+
|
46
|
+
}// Rays
|
47
|
+
|
48
|
+
|
49
|
+
#endif//EOH
|
@@ -0,0 +1,37 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_HELPERS_H__
|
4
|
+
#define __RAYS_HELPERS_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <boost/shared_ptr.hpp>
|
8
|
+
|
9
|
+
|
10
|
+
namespace Rays
|
11
|
+
{
|
12
|
+
|
13
|
+
|
14
|
+
template <typename T>
|
15
|
+
class Impl : public boost::shared_ptr<T>
|
16
|
+
{
|
17
|
+
|
18
|
+
typedef boost::shared_ptr<T> Super;
|
19
|
+
|
20
|
+
public:
|
21
|
+
|
22
|
+
Impl () : Super(new T) {}
|
23
|
+
|
24
|
+
Impl (T* p) : Super(p) {}
|
25
|
+
|
26
|
+
};// Impl
|
27
|
+
|
28
|
+
|
29
|
+
int bit2byte (int bits);
|
30
|
+
|
31
|
+
int byte2bit (int bytes);
|
32
|
+
|
33
|
+
|
34
|
+
}// Rays
|
35
|
+
|
36
|
+
|
37
|
+
#endif//EOH
|
@@ -0,0 +1,68 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_IMAGE_H__
|
4
|
+
#define __RAYS_IMAGE_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <rays/colorspace.h>
|
8
|
+
#include <rays/helpers.h>
|
9
|
+
|
10
|
+
|
11
|
+
namespace Rays
|
12
|
+
{
|
13
|
+
|
14
|
+
|
15
|
+
class Bitmap;
|
16
|
+
|
17
|
+
class Texture;
|
18
|
+
|
19
|
+
|
20
|
+
class Image
|
21
|
+
{
|
22
|
+
|
23
|
+
public:
|
24
|
+
|
25
|
+
Image ();
|
26
|
+
|
27
|
+
Image (
|
28
|
+
int width, int height, const ColorSpace& cs = RGBA,
|
29
|
+
bool alphatexture = false);
|
30
|
+
|
31
|
+
Image (const Bitmap& bitmap, bool alphatexture = false);
|
32
|
+
|
33
|
+
~Image ();
|
34
|
+
|
35
|
+
int width () const;
|
36
|
+
|
37
|
+
int height () const;
|
38
|
+
|
39
|
+
const ColorSpace& color_space () const;
|
40
|
+
|
41
|
+
bool alpha_texture () const;
|
42
|
+
|
43
|
+
Bitmap& bitmap ();
|
44
|
+
|
45
|
+
const Bitmap& bitmap () const;
|
46
|
+
|
47
|
+
Texture& texture ();
|
48
|
+
|
49
|
+
const Texture& texture () const;
|
50
|
+
|
51
|
+
operator bool () const;
|
52
|
+
|
53
|
+
bool operator ! () const;
|
54
|
+
|
55
|
+
struct Data;
|
56
|
+
|
57
|
+
Impl<Data> self;
|
58
|
+
|
59
|
+
};// Image
|
60
|
+
|
61
|
+
|
62
|
+
bool load_image (Image* image, const char* path, bool alphatexture = false);
|
63
|
+
|
64
|
+
|
65
|
+
}// Rays
|
66
|
+
|
67
|
+
|
68
|
+
#endif//EOH
|
@@ -0,0 +1,179 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_PAINTER_H__
|
4
|
+
#define __RAYS_PAINTER_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <rays/defs.h>
|
8
|
+
#include <rays/opengl.h>
|
9
|
+
#include <rays/font.h>
|
10
|
+
#include <rays/helpers.h>
|
11
|
+
|
12
|
+
|
13
|
+
namespace Rays
|
14
|
+
{
|
15
|
+
|
16
|
+
|
17
|
+
enum ShapeType
|
18
|
+
{
|
19
|
+
|
20
|
+
SHAPE_UNKNOWN = UNKNOWN,
|
21
|
+
|
22
|
+
POINTS = GL_POINTS,
|
23
|
+
|
24
|
+
LINES = GL_LINES,
|
25
|
+
|
26
|
+
LINE_STRIP = GL_LINE_STRIP,
|
27
|
+
|
28
|
+
LINE_LOOP = GL_LINE_LOOP,
|
29
|
+
|
30
|
+
TRIANGLES = GL_TRIANGLES,
|
31
|
+
|
32
|
+
TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
|
33
|
+
|
34
|
+
TRIANGLE_FAN = GL_TRIANGLE_FAN,
|
35
|
+
|
36
|
+
QUADS = GL_QUADS,
|
37
|
+
|
38
|
+
QUAD_STRIP = GL_QUAD_STRIP,
|
39
|
+
|
40
|
+
POLYGON = GL_POLYGON,
|
41
|
+
|
42
|
+
};// ShapeType
|
43
|
+
|
44
|
+
|
45
|
+
class Texture;
|
46
|
+
|
47
|
+
class Image;
|
48
|
+
|
49
|
+
|
50
|
+
class Painter
|
51
|
+
{
|
52
|
+
|
53
|
+
public:
|
54
|
+
|
55
|
+
Painter ();
|
56
|
+
|
57
|
+
~Painter ();
|
58
|
+
|
59
|
+
bool canvas (coord x, coord y, coord width, coord height);
|
60
|
+
|
61
|
+
bool begin ();
|
62
|
+
|
63
|
+
bool end ();
|
64
|
+
|
65
|
+
bool push ();
|
66
|
+
|
67
|
+
bool pop ();
|
68
|
+
|
69
|
+
//
|
70
|
+
// high level drawing methods
|
71
|
+
//
|
72
|
+
bool line (coord x1, coord y1, coord x2, coord y2);
|
73
|
+
|
74
|
+
bool rect (coord x, coord y, coord width, coord height);
|
75
|
+
|
76
|
+
bool ellipse (
|
77
|
+
coord x, coord y, coord width, coord height = 0, coord radius_min = 0,
|
78
|
+
uint nsegment = 0);
|
79
|
+
|
80
|
+
bool arc (
|
81
|
+
coord x, coord y, coord width, coord height = 0,
|
82
|
+
float angle_from = 0, float angle_to = 360, coord radius_min = 0,
|
83
|
+
uint nsegment = 0);
|
84
|
+
|
85
|
+
bool image (
|
86
|
+
const Image& image, coord x = 0, coord y = 0);
|
87
|
+
|
88
|
+
bool image (
|
89
|
+
const Image& image, coord x, coord y, coord width, coord height);
|
90
|
+
|
91
|
+
bool image (
|
92
|
+
const Image& image,
|
93
|
+
coord src_x, coord src_y, coord src_width, coord src_height,
|
94
|
+
coord dest_x, coord dest_y);
|
95
|
+
|
96
|
+
bool image (
|
97
|
+
const Image& image,
|
98
|
+
coord src_x, coord src_y, coord src_width, coord src_height,
|
99
|
+
coord dest_x, coord dest_y, coord dest_width, coord dest_height);
|
100
|
+
|
101
|
+
bool text (
|
102
|
+
const char* str, coord x = 0, coord y = 0,
|
103
|
+
const Font& font = default_font());
|
104
|
+
|
105
|
+
bool text (
|
106
|
+
const char* str, coord x, coord y, coord width, coord height,
|
107
|
+
const Font& font = default_font());
|
108
|
+
|
109
|
+
bool clear ();
|
110
|
+
|
111
|
+
bool get_clear (
|
112
|
+
float* red, float* green = NULL, float* blue = NULL,
|
113
|
+
float* alpha = NULL);
|
114
|
+
|
115
|
+
bool set_clear (
|
116
|
+
float red, float green, float blue, float alpha = 1);
|
117
|
+
|
118
|
+
bool no_clear ();
|
119
|
+
|
120
|
+
bool get_fill (
|
121
|
+
float* red, float* green = NULL, float* blue = NULL,
|
122
|
+
float* alpha = NULL);
|
123
|
+
|
124
|
+
bool set_fill (float red, float green, float blue, float alpha = 1);
|
125
|
+
|
126
|
+
bool no_fill ();
|
127
|
+
|
128
|
+
bool get_stroke (
|
129
|
+
float* red, float* green = NULL, float* blue = NULL,
|
130
|
+
float* alpha = NULL);
|
131
|
+
|
132
|
+
bool set_stroke (float red, float green, float blue, float alpha = 1);
|
133
|
+
|
134
|
+
bool no_stroke ();
|
135
|
+
|
136
|
+
bool get_clip (
|
137
|
+
coord* x, coord* y = NULL,
|
138
|
+
coord* width = NULL, coord* height = NULL);
|
139
|
+
|
140
|
+
bool set_clip (coord x, coord y, coord width, coord height);
|
141
|
+
|
142
|
+
bool no_clip ();
|
143
|
+
|
144
|
+
//
|
145
|
+
// low level drawing methods
|
146
|
+
//
|
147
|
+
bool begin_shape (ShapeType type);
|
148
|
+
|
149
|
+
bool end_shape ();
|
150
|
+
|
151
|
+
bool color (float red, float green, float blue, float alpha = 1);
|
152
|
+
|
153
|
+
bool texture (const Texture& tex);
|
154
|
+
|
155
|
+
bool no_texture ();
|
156
|
+
|
157
|
+
bool vertex (coord x, coord y);
|
158
|
+
|
159
|
+
bool vertex (coord x, coord y, coord z);
|
160
|
+
|
161
|
+
bool vertex (coord x, coord y, coord texture_s, coord texture_t);
|
162
|
+
|
163
|
+
bool vertex (coord x, coord y, coord z, coord texture_s, coord texture_t);
|
164
|
+
|
165
|
+
operator bool () const;
|
166
|
+
|
167
|
+
bool operator ! () const;
|
168
|
+
|
169
|
+
struct Data;
|
170
|
+
|
171
|
+
Impl<Data> self;
|
172
|
+
|
173
|
+
};// Painter
|
174
|
+
|
175
|
+
|
176
|
+
}// Rays
|
177
|
+
|
178
|
+
|
179
|
+
#endif//EOH
|
data/include/rays/rays.h
ADDED
data/include/rays/ruby.h
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_RUBY_H__
|
4
|
+
#define __RAYS_RUBY_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <rays/ruby/rays.h>
|
8
|
+
#include <rays/ruby/bitmap.h>
|
9
|
+
#include <rays/ruby/texture.h>
|
10
|
+
#include <rays/ruby/image.h>
|
11
|
+
#include <rays/ruby/font.h>
|
12
|
+
#include <rays/ruby/painter.h>
|
13
|
+
|
14
|
+
|
15
|
+
#endif//EOH
|
@@ -0,0 +1,39 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_RUBY_BITMAP_H__
|
4
|
+
#define __RAYS_RUBY_BITMAP_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <rucy/rucy.h>
|
8
|
+
#include <rucy/class.h>
|
9
|
+
#include <rays/bitmap.h>
|
10
|
+
|
11
|
+
|
12
|
+
namespace Rays
|
13
|
+
{
|
14
|
+
|
15
|
+
|
16
|
+
Rucy::Class bitmap_class ();
|
17
|
+
// class Rays::Bitmap
|
18
|
+
|
19
|
+
|
20
|
+
}// Rays
|
21
|
+
|
22
|
+
|
23
|
+
namespace Rucy
|
24
|
+
{
|
25
|
+
|
26
|
+
|
27
|
+
Value value (const Rays::Bitmap& bitmap);
|
28
|
+
|
29
|
+
template <> inline Rays::Bitmap*
|
30
|
+
value_to<Rays::Bitmap*> (Value obj, bool convert)
|
31
|
+
{
|
32
|
+
return get_type<Rays::Bitmap>(obj, Rays::bitmap_class());
|
33
|
+
}
|
34
|
+
|
35
|
+
|
36
|
+
}// Rucy
|
37
|
+
|
38
|
+
|
39
|
+
#endif//EOH
|
@@ -0,0 +1,39 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_RUBY_FONT_H__
|
4
|
+
#define __RAYS_RUBY_FONT_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <rucy/rucy.h>
|
8
|
+
#include <rucy/class.h>
|
9
|
+
#include <rays/font.h>
|
10
|
+
|
11
|
+
|
12
|
+
namespace Rays
|
13
|
+
{
|
14
|
+
|
15
|
+
|
16
|
+
Rucy::Class font_class ();
|
17
|
+
// class Rays::Font
|
18
|
+
|
19
|
+
|
20
|
+
}// Rays
|
21
|
+
|
22
|
+
|
23
|
+
namespace Rucy
|
24
|
+
{
|
25
|
+
|
26
|
+
|
27
|
+
Value value (const Rays::Font& font);
|
28
|
+
|
29
|
+
template <> inline Rays::Font*
|
30
|
+
value_to<Rays::Font*> (Value obj, bool convert)
|
31
|
+
{
|
32
|
+
return get_type<Rays::Font>(obj, Rays::font_class());
|
33
|
+
}
|
34
|
+
|
35
|
+
|
36
|
+
}// Rucy
|
37
|
+
|
38
|
+
|
39
|
+
#endif//EOH
|