rays 0.1.2 → 0.1.3
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 +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/src/cocoa/bitmap.mm
CHANGED
@@ -14,6 +14,9 @@ namespace Rays
|
|
14
14
|
static CGBitmapInfo
|
15
15
|
make_bitmapinfo (const ColorSpace& cs)
|
16
16
|
{
|
17
|
+
// Q: What color spaces does CGBitmapContextCreate support?
|
18
|
+
// http://developer.apple.com/library/mac/#qa/qa1037/_index.html
|
19
|
+
|
17
20
|
CGBitmapInfo info = 0;
|
18
21
|
|
19
22
|
if (cs.is_alpha_first())
|
data/src/colorspace.cpp
CHANGED
@@ -48,7 +48,7 @@ namespace Rays
|
|
48
48
|
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // RGB(A), BGR(A)
|
49
49
|
32, 32, 32, 32, 32, 32, // RGB(A), BGR(A) float
|
50
50
|
};
|
51
|
-
if (type_ < 0 || COLORSPACE_LAST <= type_) return BPPS[
|
51
|
+
if (type_ < 0 || COLORSPACE_LAST <= type_) return BPPS[COLORSPACE_UNKNOWN];
|
52
52
|
return BPPS[type_];
|
53
53
|
}
|
54
54
|
|
@@ -70,7 +70,7 @@ namespace Rays
|
|
70
70
|
96, 128, 128, // RGB(A) float
|
71
71
|
96, 128, 128, // BGR(A) float
|
72
72
|
};
|
73
|
-
if (type_ < 0 || COLORSPACE_LAST <= type_) return BPPS[
|
73
|
+
if (type_ < 0 || COLORSPACE_LAST <= type_) return BPPS[COLORSPACE_UNKNOWN];
|
74
74
|
return BPPS[type_];
|
75
75
|
}
|
76
76
|
|
data/src/exception.cpp
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
#include "rays/exception.h"
|
2
|
+
|
3
|
+
|
4
|
+
#define VA_STRING(format, result) \
|
5
|
+
String result; \
|
6
|
+
do \
|
7
|
+
{ \
|
8
|
+
if (format) \
|
9
|
+
{ \
|
10
|
+
va_list args; \
|
11
|
+
va_start(args, format); \
|
12
|
+
result = Xot::stringf(format, args); \
|
13
|
+
va_end(args); \
|
14
|
+
} \
|
15
|
+
} \
|
16
|
+
while (false)
|
17
|
+
|
18
|
+
|
19
|
+
namespace Rays
|
20
|
+
{
|
21
|
+
|
22
|
+
|
23
|
+
RaysException::RaysException (const char* format, ...)
|
24
|
+
: Super("")
|
25
|
+
{
|
26
|
+
VA_STRING(format, s);
|
27
|
+
text = s;
|
28
|
+
}
|
29
|
+
|
30
|
+
RaysException::~RaysException () throw()
|
31
|
+
{
|
32
|
+
}
|
33
|
+
|
34
|
+
const char*
|
35
|
+
RaysException::what () const throw()
|
36
|
+
{
|
37
|
+
return text.c_str();
|
38
|
+
}
|
39
|
+
|
40
|
+
|
41
|
+
void
|
42
|
+
error (const char* format, ...)
|
43
|
+
{
|
44
|
+
VA_STRING(format, s);
|
45
|
+
throw RaysException(s.c_str());
|
46
|
+
}
|
47
|
+
|
48
|
+
|
49
|
+
}// Rays
|
data/src/painter.cpp
CHANGED
@@ -52,12 +52,12 @@ namespace Rays
|
|
52
52
|
|
53
53
|
coord right () const
|
54
54
|
{
|
55
|
-
return x + width
|
55
|
+
return x + width;
|
56
56
|
}
|
57
57
|
|
58
58
|
coord bottom () const
|
59
59
|
{
|
60
|
-
return y + height
|
60
|
+
return y + height;
|
61
61
|
}
|
62
62
|
|
63
63
|
void set (coord x, coord y, coord width, coord height)
|
@@ -237,7 +237,7 @@ namespace Rays
|
|
237
237
|
no_clip();
|
238
238
|
clear();
|
239
239
|
|
240
|
-
return
|
240
|
+
return push_matrix();
|
241
241
|
}
|
242
242
|
|
243
243
|
bool
|
@@ -245,7 +245,7 @@ namespace Rays
|
|
245
245
|
{
|
246
246
|
if (!self->painting) return false;
|
247
247
|
|
248
|
-
|
248
|
+
pop_matrix();
|
249
249
|
|
250
250
|
self->painting = false;
|
251
251
|
|
@@ -256,14 +256,14 @@ namespace Rays
|
|
256
256
|
}
|
257
257
|
|
258
258
|
bool
|
259
|
-
Painter::
|
259
|
+
Painter::push_matrix ()
|
260
260
|
{
|
261
261
|
glPushMatrix();
|
262
262
|
return true;
|
263
263
|
}
|
264
264
|
|
265
265
|
bool
|
266
|
-
Painter::
|
266
|
+
Painter::pop_matrix ()
|
267
267
|
{
|
268
268
|
glPopMatrix();
|
269
269
|
return true;
|
data/src/texture.cpp
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#include "rays/texture.h"
|
2
2
|
|
3
3
|
|
4
|
-
#include <boost/scoped_array.hpp>
|
5
4
|
#include <rays/bitmap.h>
|
6
5
|
|
7
6
|
|
@@ -195,11 +194,14 @@ namespace Rays
|
|
195
194
|
if (src_offset >= (src_Bpp / src_Bpc))
|
196
195
|
return false;
|
197
196
|
|
198
|
-
|
197
|
+
int width = std::min(src.width(), dest->width());
|
198
|
+
int height = std::min(src.height(), dest->height());
|
199
|
+
|
200
|
+
for (int y = 0; y < height; ++y)
|
199
201
|
{
|
200
202
|
const uchar* s = src. at<uchar>(0, y) + src_offset * src_Bpc;
|
201
203
|
uchar* d = dest->at<uchar>(0, y);
|
202
|
-
copy_pixels(src_Bpp,
|
204
|
+
copy_pixels(src_Bpp, width, d, dest_Bpp, s, src_Bpp);
|
203
205
|
}
|
204
206
|
|
205
207
|
return true;
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rays
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- snori
|
@@ -10,10 +10,10 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-09-19 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: xot
|
17
17
|
prerelease: false
|
18
18
|
requirement: &id001 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
type: :runtime
|
25
25
|
version_requirements: *id001
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
|
-
name:
|
27
|
+
name: rucy
|
28
28
|
prerelease: false
|
29
29
|
requirement: &id002 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: "0"
|
35
|
-
type: :
|
35
|
+
type: :runtime
|
36
36
|
version_requirements: *id002
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: rake
|
39
39
|
prerelease: false
|
40
40
|
requirement: &id003 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
@@ -45,6 +45,17 @@ dependencies:
|
|
45
45
|
version: "0"
|
46
46
|
type: :development
|
47
47
|
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: gemcutter
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id004
|
48
59
|
description: This library helps you to develop graphics application with OpenGL.
|
49
60
|
email: snori@xord.org
|
50
61
|
executables: []
|
@@ -53,19 +64,21 @@ extensions:
|
|
53
64
|
- Rakefile
|
54
65
|
extra_rdoc_files:
|
55
66
|
- README
|
67
|
+
- .doc/ext/rays/bitmap.cpp
|
68
|
+
- .doc/ext/rays/font.cpp
|
69
|
+
- .doc/ext/rays/image.cpp
|
70
|
+
- .doc/ext/rays/native.cpp
|
71
|
+
- .doc/ext/rays/painter.cpp
|
72
|
+
- .doc/ext/rays/rays.cpp
|
73
|
+
- .doc/ext/rays/texture.cpp
|
56
74
|
files:
|
57
|
-
- ChangeLog
|
58
75
|
- README
|
76
|
+
- ChangeLog
|
59
77
|
- Rakefile
|
60
|
-
- support.rb
|
61
78
|
- rays.gemspec
|
62
79
|
- VERSION
|
63
|
-
- task/ext.rake
|
64
|
-
- task/gem.rake
|
65
|
-
- task/git.rake
|
66
|
-
- task/lib.rake
|
67
80
|
- ext/rays/extconf.rb
|
68
|
-
- ext/rays/
|
81
|
+
- ext/rays/defs.h
|
69
82
|
- ext/rays/bitmap.cpp
|
70
83
|
- ext/rays/font.cpp
|
71
84
|
- ext/rays/image.cpp
|
@@ -76,6 +89,7 @@ files:
|
|
76
89
|
- include/rays/bitmap.h
|
77
90
|
- include/rays/colorspace.h
|
78
91
|
- include/rays/defs.h
|
92
|
+
- include/rays/exception.h
|
79
93
|
- include/rays/font.h
|
80
94
|
- include/rays/helpers.h
|
81
95
|
- include/rays/image.h
|
@@ -102,6 +116,7 @@ files:
|
|
102
116
|
- src/cocoa/helpers.h
|
103
117
|
- src/win32/gdi.h
|
104
118
|
- src/colorspace.cpp
|
119
|
+
- src/exception.cpp
|
105
120
|
- src/helpers.cpp
|
106
121
|
- src/image.cpp
|
107
122
|
- src/painter.cpp
|
@@ -119,6 +134,13 @@ files:
|
|
119
134
|
- test/test_painter.rb
|
120
135
|
- test/test_rays.rb
|
121
136
|
- test/test_texture.rb
|
137
|
+
- .doc/ext/rays/bitmap.cpp
|
138
|
+
- .doc/ext/rays/font.cpp
|
139
|
+
- .doc/ext/rays/image.cpp
|
140
|
+
- .doc/ext/rays/native.cpp
|
141
|
+
- .doc/ext/rays/painter.cpp
|
142
|
+
- .doc/ext/rays/rays.cpp
|
143
|
+
- .doc/ext/rays/texture.cpp
|
122
144
|
homepage: http://github.com/xord/rays
|
123
145
|
licenses: []
|
124
146
|
|
data/support.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
require 'erb'
|
5
|
-
require 'pp'
|
6
|
-
|
7
|
-
|
8
|
-
def glob (*patterns)
|
9
|
-
paths = []
|
10
|
-
patterns.each do |pattern|
|
11
|
-
paths.concat Dir.glob(pattern)
|
12
|
-
end
|
13
|
-
paths
|
14
|
-
end
|
15
|
-
|
16
|
-
def erb (str)
|
17
|
-
ERB.new(str, nil, "%").result binding
|
18
|
-
end
|
19
|
-
|
20
|
-
def compile (path, out)
|
21
|
-
open(path) do |input|
|
22
|
-
open(out, "w") do |output|
|
23
|
-
output.write erb(input.read)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
#rescue
|
27
|
-
end
|
28
|
-
|
29
|
-
def convertions (paths, convs)
|
30
|
-
raise "empty conversion." if convs.empty?
|
31
|
-
paths = paths.map do |path|
|
32
|
-
convpath = path
|
33
|
-
convs.each do |from, to|
|
34
|
-
convpath = convpath.sub(/#{from.gsub('.', '\.')}$/, to)
|
35
|
-
end
|
36
|
-
[path, convpath]
|
37
|
-
end
|
38
|
-
Hash[*paths.flatten]
|
39
|
-
end
|
40
|
-
|
41
|
-
alias sh_original sh
|
42
|
-
|
43
|
-
def sh (*args)
|
44
|
-
sh_original *args
|
45
|
-
#rescue
|
46
|
-
end
|
47
|
-
|
48
|
-
def win32? ()
|
49
|
-
RUBY_PLATFORM =~ /mswin|ming|cygwin/
|
50
|
-
end
|
51
|
-
|
52
|
-
def cocoa? ()
|
53
|
-
RUBY_PLATFORM =~ /darwin/
|
54
|
-
end
|
data/task/ext.rake
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# -*- mode: ruby; coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
require 'rucy/module'
|
5
|
-
|
6
|
-
|
7
|
-
namespace :ext do
|
8
|
-
|
9
|
-
dir = "#{EXTDIR}/#{NAME}"
|
10
|
-
name = "#{NAME}/native"
|
11
|
-
outname = "#{name}.#{EXTEXT}"
|
12
|
-
out = File.join EXTDIR, outname
|
13
|
-
|
14
|
-
extconf = File.join dir, "extconf.rb"
|
15
|
-
makefile = File.join dir, "Makefile"
|
16
|
-
depend = File.join dir, "depend"
|
17
|
-
|
18
|
-
cpps = Dir.glob("#{dir}/**/*.cpp")
|
19
|
-
|
20
|
-
task :build => makefile do
|
21
|
-
sh %( cd #{dir} && #{MAKE} )
|
22
|
-
end
|
23
|
-
|
24
|
-
task :clean do
|
25
|
-
sh %( cd #{dir} && #{MAKE} clean ) if File.exist? makefile
|
26
|
-
sh %( rm -f #{makefile} #{depend} )
|
27
|
-
end
|
28
|
-
|
29
|
-
file makefile => [extconf, depend] do
|
30
|
-
sh %( cd #{dir} && #{RUBY} #{File.basename extconf} )
|
31
|
-
end
|
32
|
-
|
33
|
-
file depend => ["lib:build"] + cpps do
|
34
|
-
incdirs = INCDIRS + Rucy.include_dirs
|
35
|
-
incdirs = incdirs.map{|s| " -I#{s}"}.join
|
36
|
-
srcs = cpps.map{|cpp| File.basename cpp}.join ' '
|
37
|
-
dep = File.basename depend
|
38
|
-
sh %( cd #{dir} && #{CC} -M #{CFLAGS} #{incdirs} #{srcs} > #{dep} )
|
39
|
-
end
|
40
|
-
|
41
|
-
end# :ext
|
data/task/gem.rake
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# -*- mode: ruby; coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
namespace :gem do
|
5
|
-
|
6
|
-
name = NAME
|
7
|
-
|
8
|
-
gemspec = "#{name}.gemspec"
|
9
|
-
gem = "#{name}-#{MODULE.version}.gem"
|
10
|
-
|
11
|
-
task :build => gem
|
12
|
-
|
13
|
-
task :install => gem do
|
14
|
-
sh %( #{GEM} install #{gem} )
|
15
|
-
end
|
16
|
-
|
17
|
-
task :uninstall do
|
18
|
-
sh %( #{GEM} uninstall #{name} )
|
19
|
-
end
|
20
|
-
|
21
|
-
task :clean do
|
22
|
-
sh %( rm -f #{gem} )
|
23
|
-
end
|
24
|
-
|
25
|
-
task :upload => gem do
|
26
|
-
sh %( #{GEM} push #{gem} )
|
27
|
-
end
|
28
|
-
|
29
|
-
file gem => "lib:build" do
|
30
|
-
sh %( #{GEM} build #{gemspec} )
|
31
|
-
end
|
32
|
-
|
33
|
-
end# :gem
|
data/task/git.rake
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# -*- mode: ruby; coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
namespace :git do
|
5
|
-
|
6
|
-
task :status do
|
7
|
-
sh %( #{GIT} status )
|
8
|
-
end
|
9
|
-
|
10
|
-
task :diff do
|
11
|
-
sh %( #{GIT} diff | cat )
|
12
|
-
end
|
13
|
-
|
14
|
-
task :push do
|
15
|
-
sh %( #{GIT} push )
|
16
|
-
end
|
17
|
-
|
18
|
-
task :pull do
|
19
|
-
sh %( #{GIT} pull )
|
20
|
-
end
|
21
|
-
|
22
|
-
end# :git
|
data/task/lib.rake
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
# -*- mode: ruby; coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
require 'rake/loaders/makefile'
|
5
|
-
|
6
|
-
|
7
|
-
namespace :lib do
|
8
|
-
|
9
|
-
name = NAME
|
10
|
-
outname = "lib#{name}.a"
|
11
|
-
out = File.join LIBDIR, outname
|
12
|
-
|
13
|
-
headers = glob("include/**/*.h")
|
14
|
-
srcs = glob("src/**/*.cpp")
|
15
|
-
srcs += glob("src/**/*.mm") if cocoa?
|
16
|
-
srcs = srcs.reject {|s| s =~ %r(/win32/)} unless win32?
|
17
|
-
srcs = srcs.reject {|s| s =~ %r(/cocoa/)} unless cocoa?
|
18
|
-
|
19
|
-
depend = 'depend.mf'
|
20
|
-
objs = convertions srcs, {".cpp" => ".o", ".mm" => ".o"}
|
21
|
-
tmps = objs.values + [depend]
|
22
|
-
|
23
|
-
cflags = CFLAGS.dup
|
24
|
-
cflags << INCDIRS.map{|s| " -I#{s}"}.join
|
25
|
-
|
26
|
-
task :build => out
|
27
|
-
|
28
|
-
task :compile => objs.values
|
29
|
-
|
30
|
-
task :clean do
|
31
|
-
sh %( rm -rf #{tmps.join " "} #{out} )
|
32
|
-
end
|
33
|
-
|
34
|
-
file out => objs.values do
|
35
|
-
sh %( #{AR} #{ARFLAGS} #{out} #{objs.values.join " "} )
|
36
|
-
end
|
37
|
-
|
38
|
-
file depend do
|
39
|
-
sh %( #{CC} -M #{cflags} #{srcs.join ' '} > #{depend} )
|
40
|
-
input = open(depend) {|f| f.read}
|
41
|
-
open(depend, 'w') do |output|
|
42
|
-
output << input.gsub(/\w+\.o/, SRCDIR + '/\0')
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
import depend if File.exist? depend
|
47
|
-
|
48
|
-
objs.each do |(src, obj)|
|
49
|
-
file obj => [depend, src] do
|
50
|
-
sh %( #{CC} -c #{cflags} -o #{obj} #{src} )
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
end# :lib
|