rays 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.doc/ext/rays/bitmap.cpp +318 -0
- data/.doc/ext/rays/font.cpp +124 -0
- data/.doc/ext/rays/image.cpp +163 -0
- data/.doc/ext/rays/native.cpp +28 -0
- data/.doc/ext/rays/painter.cpp +554 -0
- data/.doc/ext/rays/rays.cpp +52 -0
- data/.doc/ext/rays/texture.cpp +128 -0
- data/Rakefile +10 -34
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +20 -16
- data/ext/rays/{rays.h → defs.h} +4 -13
- data/ext/rays/extconf.rb +28 -18
- data/ext/rays/font.cpp +15 -10
- data/ext/rays/image.cpp +19 -14
- data/ext/rays/native.cpp +5 -1
- data/ext/rays/painter.cpp +44 -39
- data/ext/rays/rays.cpp +8 -15
- data/ext/rays/texture.cpp +17 -12
- data/include/rays.h +2 -1
- data/include/rays/colorspace.h +1 -1
- data/include/rays/defs.h +4 -11
- data/include/rays/exception.h +41 -0
- data/include/rays/painter.h +3 -3
- data/lib/rays/module.rb +9 -1
- data/rays.gemspec +18 -8
- data/src/cocoa/bitmap.mm +3 -0
- data/src/colorspace.cpp +2 -2
- data/src/exception.cpp +49 -0
- data/src/painter.cpp +6 -6
- data/src/texture.cpp +5 -3
- metadata +35 -13
- data/support.rb +0 -54
- data/task/ext.rake +0 -41
- data/task/gem.rake +0 -33
- data/task/git.rake +0 -22
- data/task/lib.rake +0 -54
data/ext/rays/image.cpp
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
#include <rucy.h>
|
5
|
-
#include
|
6
|
-
#include
|
7
|
-
#include "
|
5
|
+
#include <rays/ruby/bitmap.h>
|
6
|
+
#include <rays/ruby/texture.h>
|
7
|
+
#include "defs.h"
|
8
8
|
|
9
9
|
|
10
10
|
using namespace Rucy;
|
@@ -16,11 +16,12 @@ namespace Rays
|
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
+
static Class cImage;
|
20
|
+
|
19
21
|
Class
|
20
22
|
image_class ()
|
21
23
|
{
|
22
|
-
|
23
|
-
return c;
|
24
|
+
return cImage;
|
24
25
|
}
|
25
26
|
|
26
27
|
|
@@ -154,13 +155,17 @@ RUBY_END
|
|
154
155
|
void
|
155
156
|
Init_image ()
|
156
157
|
{
|
157
|
-
Rays
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
158
|
+
Module m = define_module("Rays");
|
159
|
+
|
160
|
+
Class c = m.define_class("Image");
|
161
|
+
Rays::cImage = c;
|
162
|
+
|
163
|
+
c.define_alloc_func(alloc);
|
164
|
+
c.define_method("initialize", initialize);
|
165
|
+
c.define_method("width", width);
|
166
|
+
c.define_method("height", height);
|
167
|
+
c.define_method("color_space", color_space);
|
168
|
+
c.define_method("bitmap", bitmap);
|
169
|
+
c.define_method("texture", texture);
|
170
|
+
c.define_function("load", load);
|
166
171
|
}
|
data/ext/rays/native.cpp
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
#include <rucy.h>
|
2
|
+
#include "defs.h"
|
3
|
+
|
4
|
+
|
5
|
+
using namespace Rucy;
|
2
6
|
|
3
7
|
|
4
8
|
void Init_rays ();
|
@@ -13,7 +17,7 @@ extern "C" void
|
|
13
17
|
Init_native ()
|
14
18
|
{
|
15
19
|
if (!Rucy::init())
|
16
|
-
|
20
|
+
raise(rb_eLoadError, "Rucy::init() failed.");
|
17
21
|
|
18
22
|
Init_rays();
|
19
23
|
Init_bitmap();
|
data/ext/rays/painter.cpp
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
#include <rucy.h>
|
5
|
-
#include
|
6
|
-
#include
|
7
|
-
#include "
|
5
|
+
#include <rays/ruby/image.h>
|
6
|
+
#include <rays/ruby/font.h>
|
7
|
+
#include "defs.h"
|
8
8
|
|
9
9
|
|
10
10
|
using namespace Rucy;
|
@@ -16,11 +16,12 @@ namespace Rays
|
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
+
static Class cPainter;
|
20
|
+
|
19
21
|
Class
|
20
22
|
painter_class ()
|
21
23
|
{
|
22
|
-
|
23
|
-
return c;
|
24
|
+
return cPainter;
|
24
25
|
}
|
25
26
|
|
26
27
|
|
@@ -95,24 +96,24 @@ RUBY_DEF0(end)
|
|
95
96
|
RUBY_END
|
96
97
|
|
97
98
|
static
|
98
|
-
RUBY_DEF0(
|
99
|
+
RUBY_DEF0(push_matrix)
|
99
100
|
{
|
100
101
|
CHECK;
|
101
102
|
|
102
|
-
if (!this->
|
103
|
-
error("Painter#
|
103
|
+
if (!this->push_matrix())
|
104
|
+
error("Painter#push_matrix() failed.");
|
104
105
|
|
105
106
|
return self;
|
106
107
|
}
|
107
108
|
RUBY_END
|
108
109
|
|
109
110
|
static
|
110
|
-
RUBY_DEF0(
|
111
|
+
RUBY_DEF0(pop_matrix)
|
111
112
|
{
|
112
113
|
CHECK;
|
113
114
|
|
114
|
-
if (!this->
|
115
|
-
error("Painter#
|
115
|
+
if (!this->pop_matrix())
|
116
|
+
error("Painter#pop_matrix() failed.");
|
116
117
|
|
117
118
|
return self;
|
118
119
|
}
|
@@ -542,32 +543,36 @@ RUBY_END
|
|
542
543
|
void
|
543
544
|
Init_painter ()
|
544
545
|
{
|
545
|
-
Rays
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
546
|
+
Module m = define_module("Rays");
|
547
|
+
|
548
|
+
Class c = m.define_class("Painter");
|
549
|
+
Rays::cPainter = c;
|
550
|
+
|
551
|
+
c.define_alloc_func(alloc);
|
552
|
+
|
553
|
+
c.define_method("canvas", canvas);
|
554
|
+
c.define_method("begin", begin);
|
555
|
+
c.define_method("end", end);
|
556
|
+
c.define_method("push_matrix", push_matrix);
|
557
|
+
c.define_method("pop_matrix", pop_matrix);
|
558
|
+
|
559
|
+
c.define_private_method("draw_line", line);
|
560
|
+
c.define_private_method("draw_rect", rect);
|
561
|
+
c.define_private_method("draw_ellipse", ellipse);
|
562
|
+
c.define_private_method("draw_arc", arc);
|
563
|
+
c.define_private_method("draw_image", image);
|
564
|
+
c.define_private_method("draw_text", text);
|
565
|
+
|
566
|
+
c.define_method("get_fill", get_fill);
|
567
|
+
c.define_method("set_fill", set_fill);
|
568
|
+
c.define_method("no_fill", no_fill);
|
569
|
+
c.define_method("get_stroke", get_stroke);
|
570
|
+
c.define_method("set_stroke", set_stroke);
|
571
|
+
c.define_method("no_stroke", no_stroke);
|
572
|
+
c.define_method("get_clear", get_clear);
|
573
|
+
c.define_method("set_clear", set_clear);
|
574
|
+
c.define_method("no_clear", no_clear);
|
575
|
+
c.define_method("get_clip", get_clip);
|
576
|
+
c.define_method("set_clip", set_clip);
|
577
|
+
c.define_method("no_clip", no_clip);
|
573
578
|
}
|
data/ext/rays/rays.cpp
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#include <rucy.h>
|
2
2
|
#include <rays/rays.h>
|
3
|
-
#include "
|
3
|
+
#include "defs.h"
|
4
4
|
|
5
5
|
|
6
6
|
using namespace Rucy;
|
@@ -10,19 +10,12 @@ namespace Rays
|
|
10
10
|
{
|
11
11
|
|
12
12
|
|
13
|
+
static Module mRays;
|
14
|
+
|
13
15
|
Module
|
14
16
|
rays_module ()
|
15
17
|
{
|
16
|
-
|
17
|
-
return m;
|
18
|
-
}
|
19
|
-
|
20
|
-
Class
|
21
|
-
rays_error_class ()
|
22
|
-
{
|
23
|
-
static Class c =
|
24
|
-
rays_module().define_class("RaysError", native_error_class());
|
25
|
-
return c;
|
18
|
+
return mRays;
|
26
19
|
}
|
27
20
|
|
28
21
|
|
@@ -53,9 +46,9 @@ RUBY_END
|
|
53
46
|
void
|
54
47
|
Init_rays ()
|
55
48
|
{
|
56
|
-
Rays
|
49
|
+
Module m = define_module("Rays");
|
50
|
+
Rays::mRays = m;
|
57
51
|
|
58
|
-
|
59
|
-
|
60
|
-
.define_singleton_method("fin!", fin);
|
52
|
+
m.define_singleton_method("init!", init);
|
53
|
+
m.define_singleton_method("fin!", fin);
|
61
54
|
}
|
data/ext/rays/texture.cpp
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
#include <rucy.h>
|
5
|
-
#include
|
6
|
-
#include "
|
5
|
+
#include <rays/ruby/bitmap.h>
|
6
|
+
#include "defs.h"
|
7
7
|
|
8
8
|
|
9
9
|
using namespace Rucy;
|
@@ -15,11 +15,12 @@ namespace Rays
|
|
15
15
|
{
|
16
16
|
|
17
17
|
|
18
|
+
static Class cTexture;
|
19
|
+
|
18
20
|
Class
|
19
21
|
texture_class ()
|
20
22
|
{
|
21
|
-
|
22
|
-
return c;
|
23
|
+
return cTexture;
|
23
24
|
}
|
24
25
|
|
25
26
|
|
@@ -119,12 +120,16 @@ RUBY_END
|
|
119
120
|
void
|
120
121
|
Init_texture ()
|
121
122
|
{
|
122
|
-
Rays
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
123
|
+
Module m = define_module("Rays");
|
124
|
+
|
125
|
+
Class c = m.define_class("Texture");
|
126
|
+
Rays::cTexture = c;
|
127
|
+
|
128
|
+
c.define_alloc_func(alloc);
|
129
|
+
c.define_method("initialize", initialize);
|
130
|
+
c.define_method("width", width);
|
131
|
+
c.define_method("height", height);
|
132
|
+
c.define_method("s_max", s_max);
|
133
|
+
c.define_method("t_max", t_max);
|
134
|
+
c.define_method("bitmap", bitmap);
|
130
135
|
}
|
data/include/rays.h
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
|
7
7
|
#include <rays/defs.h>
|
8
8
|
#include <rays/rays.h>
|
9
|
+
#include <rays/exception.h>
|
9
10
|
#include <rays/colorspace.h>
|
10
11
|
#include <rays/bitmap.h>
|
11
12
|
#include <rays/texture.h>
|
@@ -13,8 +14,8 @@
|
|
13
14
|
#include <rays/font.h>
|
14
15
|
#include <rays/transform.h>
|
15
16
|
#include <rays/painter.h>
|
16
|
-
#include <rays/helpers.h>
|
17
17
|
#include <rays/opengl.h>
|
18
|
+
#include <rays/helpers.h>
|
18
19
|
|
19
20
|
|
20
21
|
#endif//EOH
|
data/include/rays/colorspace.h
CHANGED
data/include/rays/defs.h
CHANGED
@@ -4,28 +4,21 @@
|
|
4
4
|
#define __RAYS_DEFS_H__
|
5
5
|
|
6
6
|
|
7
|
-
#include <
|
7
|
+
#include <xot/defs.h>
|
8
|
+
#include <xot/string.h>
|
8
9
|
|
9
10
|
|
10
11
|
namespace Rays
|
11
12
|
{
|
12
13
|
|
13
14
|
|
14
|
-
|
15
|
+
using namespace Xot::Types;
|
15
16
|
|
16
|
-
|
17
|
+
using Xot::String;
|
17
18
|
|
18
|
-
typedef unsigned int uint;
|
19
|
-
|
20
|
-
typedef unsigned long ulong;
|
21
19
|
|
22
20
|
typedef float coord;
|
23
21
|
|
24
|
-
typedef std::string String;
|
25
|
-
|
26
|
-
|
27
|
-
enum {UNKNOWN = 0};
|
28
|
-
|
29
22
|
|
30
23
|
}// Rays
|
31
24
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_EXCEPTION_H__
|
4
|
+
#define __RAYS_EXCEPTION_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <stdexcept>
|
8
|
+
#include <rays/defs.h>
|
9
|
+
|
10
|
+
|
11
|
+
namespace Rays
|
12
|
+
{
|
13
|
+
|
14
|
+
|
15
|
+
class RaysException : public std::runtime_error
|
16
|
+
{
|
17
|
+
|
18
|
+
typedef std::runtime_error Super;
|
19
|
+
|
20
|
+
public:
|
21
|
+
|
22
|
+
RaysException (const char* format = NULL, ...);
|
23
|
+
|
24
|
+
~RaysException () throw();
|
25
|
+
|
26
|
+
const char* what () const throw();
|
27
|
+
|
28
|
+
private:
|
29
|
+
|
30
|
+
String text;
|
31
|
+
|
32
|
+
};// RaysException
|
33
|
+
|
34
|
+
|
35
|
+
void error (const char* format = NULL, ...);
|
36
|
+
|
37
|
+
|
38
|
+
}// Rays
|
39
|
+
|
40
|
+
|
41
|
+
#endif//EOH
|
data/include/rays/painter.h
CHANGED
@@ -17,7 +17,7 @@ namespace Rays
|
|
17
17
|
enum ShapeType
|
18
18
|
{
|
19
19
|
|
20
|
-
SHAPE_UNKNOWN = UNKNOWN,
|
20
|
+
SHAPE_UNKNOWN = Xot::UNKNOWN,
|
21
21
|
|
22
22
|
POINTS = GL_POINTS,
|
23
23
|
|
@@ -62,9 +62,9 @@ namespace Rays
|
|
62
62
|
|
63
63
|
bool end ();
|
64
64
|
|
65
|
-
bool
|
65
|
+
bool push_matrix ();
|
66
66
|
|
67
|
-
bool
|
67
|
+
bool pop_matrix ();
|
68
68
|
|
69
69
|
//
|
70
70
|
// high level drawing methods
|
data/lib/rays/module.rb
CHANGED
@@ -15,7 +15,15 @@ module Rays
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def library_dirs ()
|
18
|
-
[File.join
|
18
|
+
%w[lib ext].map {|dir| File.join root_dir, dir}
|
19
|
+
end
|
20
|
+
|
21
|
+
def task_dir ()
|
22
|
+
File.join root_dir, 'task'
|
23
|
+
end
|
24
|
+
|
25
|
+
def load_tasks ()
|
26
|
+
Dir["#{task_dir}/**/*.rake"].each {|path| load path}
|
19
27
|
end
|
20
28
|
|
21
29
|
def version ()
|
data/rays.gemspec
CHANGED
@@ -7,12 +7,15 @@ require 'rake'
|
|
7
7
|
require 'rays/module'
|
8
8
|
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
MODULE = Rays
|
11
|
+
NAME = MODULE.name.downcase
|
12
|
+
|
13
|
+
|
14
|
+
FILES = FileList[*%W[
|
12
15
|
README
|
16
|
+
ChangeLog
|
13
17
|
Rakefile
|
14
|
-
|
15
|
-
rays.gemspec
|
18
|
+
#{NAME}.gemspec
|
16
19
|
VERSION
|
17
20
|
task/**/*.rake
|
18
21
|
ext/**/*.rb
|
@@ -26,20 +29,27 @@ FILES = FileList[*%w[
|
|
26
29
|
test/**/*.rb
|
27
30
|
]]
|
28
31
|
|
32
|
+
RDOCS = FileList[*%W[
|
33
|
+
README
|
34
|
+
.doc/ext/**/*.cpp
|
35
|
+
]]
|
36
|
+
|
37
|
+
|
29
38
|
Gem::Specification.new do |s|
|
30
|
-
s.name =
|
39
|
+
s.name = NAME
|
31
40
|
s.summary = 'A Drawing Engine using OpenGL.'
|
32
41
|
s.description = 'This library helps you to develop graphics application with OpenGL.'
|
33
|
-
s.version =
|
42
|
+
s.version = MODULE.version
|
34
43
|
|
35
44
|
s.authors = %w[snori]
|
36
45
|
s.email = 'snori@xord.org'
|
37
|
-
s.homepage =
|
46
|
+
s.homepage = "http://github.com/xord/#{NAME}"
|
38
47
|
|
39
48
|
s.platform = Gem::Platform::RUBY
|
40
49
|
s.required_ruby_version = '>=1.9.0'
|
41
50
|
s.require_paths << 'ext'
|
42
51
|
|
52
|
+
s.add_runtime_dependency 'xot'
|
43
53
|
s.add_runtime_dependency 'rucy'
|
44
54
|
s.add_development_dependency 'rake'
|
45
55
|
s.add_development_dependency 'gemcutter'
|
@@ -48,7 +58,7 @@ Gem::Specification.new do |s|
|
|
48
58
|
s.test_files = FileList['test/**/test_*.rb'].to_a
|
49
59
|
|
50
60
|
s.has_rdoc = true
|
51
|
-
s.extra_rdoc_files =
|
61
|
+
s.extra_rdoc_files = RDOCS.to_a
|
52
62
|
|
53
63
|
s.extensions << 'Rakefile'
|
54
64
|
end
|