rays 0.1.1

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.
Files changed (66) hide show
  1. data/ChangeLog +8 -0
  2. data/README +4 -0
  3. data/Rakefile +72 -0
  4. data/VERSION +1 -0
  5. data/ext/rays/bitmap.cpp +322 -0
  6. data/ext/rays/extconf.rb +61 -0
  7. data/ext/rays/font.cpp +125 -0
  8. data/ext/rays/image.cpp +166 -0
  9. data/ext/rays/native.cpp +24 -0
  10. data/ext/rays/painter.cpp +573 -0
  11. data/ext/rays/rays.cpp +61 -0
  12. data/ext/rays/rays.h +39 -0
  13. data/ext/rays/texture.cpp +130 -0
  14. data/include/rays.h +20 -0
  15. data/include/rays/bitmap.h +80 -0
  16. data/include/rays/colorspace.h +101 -0
  17. data/include/rays/defs.h +33 -0
  18. data/include/rays/font.h +49 -0
  19. data/include/rays/helpers.h +37 -0
  20. data/include/rays/image.h +68 -0
  21. data/include/rays/opengl.h +15 -0
  22. data/include/rays/painter.h +179 -0
  23. data/include/rays/rays.h +19 -0
  24. data/include/rays/ruby.h +15 -0
  25. data/include/rays/ruby/bitmap.h +39 -0
  26. data/include/rays/ruby/font.h +39 -0
  27. data/include/rays/ruby/image.h +39 -0
  28. data/include/rays/ruby/painter.h +39 -0
  29. data/include/rays/ruby/rays.h +21 -0
  30. data/include/rays/ruby/texture.h +39 -0
  31. data/include/rays/texture.h +56 -0
  32. data/include/rays/transform.h +35 -0
  33. data/lib/rays.rb +9 -0
  34. data/lib/rays/autoinit.rb +10 -0
  35. data/lib/rays/bitmap.rb +25 -0
  36. data/lib/rays/image.rb +15 -0
  37. data/lib/rays/module.rb +30 -0
  38. data/lib/rays/painter.rb +99 -0
  39. data/lib/rays/texture.rb +15 -0
  40. data/rays.gemspec +54 -0
  41. data/src/cocoa/bitmap.mm +286 -0
  42. data/src/cocoa/font.mm +193 -0
  43. data/src/cocoa/helpers.h +26 -0
  44. data/src/cocoa/helpers.mm +25 -0
  45. data/src/cocoa/rays.mm +40 -0
  46. data/src/colorspace.cpp +183 -0
  47. data/src/helpers.cpp +22 -0
  48. data/src/image.cpp +133 -0
  49. data/src/painter.cpp +769 -0
  50. data/src/texture.cpp +360 -0
  51. data/src/transform.cpp +88 -0
  52. data/src/win32/bitmap.cpp +212 -0
  53. data/src/win32/font.cpp +99 -0
  54. data/src/win32/gdi.cpp +771 -0
  55. data/src/win32/gdi.h +226 -0
  56. data/src/win32/rays.cpp +36 -0
  57. data/support.rb +58 -0
  58. data/task/ext.rake +41 -0
  59. data/task/gem.rake +33 -0
  60. data/task/git.rake +22 -0
  61. data/task/lib.rake +54 -0
  62. data/test/helpers.rb +15 -0
  63. data/test/test_painter.rb +11 -0
  64. data/test/test_rays.rb +19 -0
  65. data/test/test_texture.rb +11 -0
  66. metadata +153 -0
@@ -0,0 +1,39 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_RUBY_IMAGE_H__
4
+ #define __RAYS_RUBY_IMAGE_H__
5
+
6
+
7
+ #include <rucy/rucy.h>
8
+ #include <rucy/class.h>
9
+ #include <rays/image.h>
10
+
11
+
12
+ namespace Rays
13
+ {
14
+
15
+
16
+ Rucy::Class image_class ();
17
+ // class Rays::Image
18
+
19
+
20
+ }// Rays
21
+
22
+
23
+ namespace Rucy
24
+ {
25
+
26
+
27
+ Value value (const Rays::Image& image);
28
+
29
+ template <> inline Rays::Image*
30
+ value_to<Rays::Image*> (Value obj, bool convert)
31
+ {
32
+ return get_type<Rays::Image>(obj, Rays::image_class());
33
+ }
34
+
35
+
36
+ }// Rucy
37
+
38
+
39
+ #endif//EOH
@@ -0,0 +1,39 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_RUBY_PAINTER_H__
4
+ #define __RAYS_RUBY_PAINTER_H__
5
+
6
+
7
+ #include <rucy/rucy.h>
8
+ #include <rucy/class.h>
9
+ #include <rays/painter.h>
10
+
11
+
12
+ namespace Rays
13
+ {
14
+
15
+
16
+ Rucy::Class painter_class ();
17
+ // class Rays::Painter
18
+
19
+
20
+ }// Rays
21
+
22
+
23
+ namespace Rucy
24
+ {
25
+
26
+
27
+ Value value (const Rays::Painter& painter);
28
+
29
+ template <> inline Rays::Painter*
30
+ value_to<Rays::Painter*> (Value obj, bool convert)
31
+ {
32
+ return get_type<Rays::Painter>(obj, Rays::painter_class());
33
+ }
34
+
35
+
36
+ }// Rucy
37
+
38
+
39
+ #endif//EOH
@@ -0,0 +1,21 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_RUBY_RAYS_H__
4
+ #define __RAYS_RUBY_RAYS_H__
5
+
6
+
7
+ #include <rucy/module.h>
8
+
9
+
10
+ namespace Rays
11
+ {
12
+
13
+
14
+ Rucy::Module rays_module ();
15
+ // module Rays
16
+
17
+
18
+ }// Rays
19
+
20
+
21
+ #endif//EOH
@@ -0,0 +1,39 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_RUBY_TEXTURE_H__
4
+ #define __RAYS_RUBY_TEXTURE_H__
5
+
6
+
7
+ #include <rucy/rucy.h>
8
+ #include <rucy/class.h>
9
+ #include <rays/texture.h>
10
+
11
+
12
+ namespace Rays
13
+ {
14
+
15
+
16
+ Rucy::Class texture_class ();
17
+ // class Rays::Texture
18
+
19
+
20
+ }// Rays
21
+
22
+
23
+ namespace Rucy
24
+ {
25
+
26
+
27
+ Value value (const Rays::Texture& texture);
28
+
29
+ template <> inline Rays::Texture*
30
+ value_to<Rays::Texture*> (Value obj, bool convert)
31
+ {
32
+ return get_type<Rays::Texture>(obj, Rays::texture_class());
33
+ }
34
+
35
+
36
+ }// Rucy
37
+
38
+
39
+ #endif//EOH
@@ -0,0 +1,56 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_TEXTURE_H__
4
+ #define __RAYS_TEXTURE_H__
5
+
6
+
7
+ #include <rays/defs.h>
8
+ #include <rays/opengl.h>
9
+ #include <rays/helpers.h>
10
+
11
+
12
+ namespace Rays
13
+ {
14
+
15
+
16
+ class Bitmap;
17
+
18
+
19
+ class Texture
20
+ {
21
+
22
+ public:
23
+
24
+ Texture ();
25
+
26
+ Texture (const Bitmap& bitmap, bool alphaonly = false);
27
+
28
+ ~Texture ();
29
+
30
+ GLuint id () const;
31
+
32
+ int width () const;
33
+
34
+ int height () const;
35
+
36
+ float s_max () const;
37
+
38
+ float t_max () const;
39
+
40
+ const Bitmap& bitmap () const;
41
+
42
+ operator bool () const;
43
+
44
+ bool operator ! () const;
45
+
46
+ struct Data;
47
+
48
+ Impl<Data> self;
49
+
50
+ };// Texture
51
+
52
+
53
+ }// Rays
54
+
55
+
56
+ #endif//EOH
@@ -0,0 +1,35 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_TRANSFORM_H__
4
+ #define __RAYS_TRANSFORM_H__
5
+
6
+
7
+ #include <rays/defs.h>
8
+
9
+
10
+ namespace Rays
11
+ {
12
+
13
+
14
+ bool translate (coord x, coord y, coord z = 0);
15
+
16
+ bool scale (coord x, coord y, coord z = 1);
17
+
18
+ bool rotate (coord angle, coord x = 0, coord y = 0, coord z = 1);
19
+
20
+
21
+ bool set_matrix (coord value = 1);
22
+
23
+ bool set_matrix (coord* elements, size_t size);
24
+
25
+ bool get_matrix (coord* elements, size_t size);
26
+
27
+ bool push_matrix ();
28
+
29
+ bool pop_matrix ();
30
+
31
+
32
+ }// Rays
33
+
34
+
35
+ #endif//EOH
data/lib/rays.rb ADDED
@@ -0,0 +1,9 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ require 'rays/autoinit'
5
+ require 'rays/module'
6
+ require 'rays/bitmap'
7
+ require 'rays/texture'
8
+ require 'rays/image'
9
+ require 'rays/painter'
@@ -0,0 +1,10 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ require 'rays/native'
5
+
6
+
7
+ unless $RAYS_NOAUTOINIT
8
+ Rays.init!
9
+ at_exit {Rays.fin!}
10
+ end
@@ -0,0 +1,25 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ require 'rays/native'
5
+
6
+
7
+ module Rays
8
+
9
+
10
+ class Bitmap
11
+
12
+ include Enumerable
13
+
14
+ def each ()
15
+ height.times do |y|
16
+ width.times do |x|
17
+ yield x, y, at(x, y)
18
+ end
19
+ end
20
+ end
21
+
22
+ end# Bitmap
23
+
24
+
25
+ end# Rays
data/lib/rays/image.rb ADDED
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ require 'rays/native'
5
+
6
+
7
+ module Rays
8
+
9
+
10
+ class Image
11
+
12
+ end# Image
13
+
14
+
15
+ end# Rays
@@ -0,0 +1,30 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ module Rays
5
+
6
+
7
+ extend module ClassMethods
8
+
9
+ def root_dir ()
10
+ File.expand_path(File.join File.dirname(__FILE__), '..', '..')
11
+ end
12
+
13
+ def include_dirs ()
14
+ [File.join(root_dir, 'include')]
15
+ end
16
+
17
+ def library_dirs ()
18
+ [File.join(root_dir, 'lib')]
19
+ end
20
+
21
+ def version ()
22
+ open(File.join root_dir, 'VERSION') {|f| f.readline.chomp}
23
+ end
24
+
25
+ self
26
+
27
+ end# ClassMethods
28
+
29
+
30
+ end# Rays
@@ -0,0 +1,99 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ require 'rays/native'
5
+
6
+
7
+ module Rays
8
+
9
+
10
+ class Painter
11
+
12
+ attr_accessor :font
13
+
14
+ def initialize ()
15
+ @font = Rays::Font.new
16
+ end
17
+
18
+ def line (*args)
19
+ args = args[0] if !args.empty? && args[0] === Array
20
+ draw_rect *args
21
+ end
22
+
23
+ def rect (*args)
24
+ args = args[0] if !args.empty? && args[0] === Array
25
+ draw_rect *args
26
+ end
27
+
28
+ def ellipse (*args)
29
+ args = args[0] if !args.empty? && args[0] === Array
30
+ draw_ellipse *args
31
+ end
32
+
33
+ def arc (*args)
34
+ args = args[0] if !args.empty? && args[0] === Array
35
+ draw_arc *args
36
+ end
37
+
38
+ alias image draw_image
39
+
40
+ def text (*args)
41
+ case args.size
42
+ when 1 then args << 0 << 0 << @font
43
+ when 2 then args << 0 << @font
44
+ when 3 then args << @font
45
+ end
46
+ draw_text *args
47
+ end
48
+
49
+ def clear (*args)
50
+ send :clear=, *args unless args.empty?
51
+ get_clear
52
+ end
53
+
54
+ def clear= (*args)
55
+ send_set :set_clear, :no_clear, args
56
+ end
57
+
58
+ def fill (*args)
59
+ send :fill=, *args unless args.empty?
60
+ get_fill
61
+ end
62
+
63
+ def fill= (*args)
64
+ send_set :set_fill, :no_fill, args
65
+ end
66
+
67
+ def stroke (*args)
68
+ send :stroke=, *args unless args.empty?
69
+ get_stroke
70
+ end
71
+
72
+ def stroke= (*args)
73
+ send_set :set_stroke, :no_stroke, args
74
+ end
75
+
76
+ def clip (*args)
77
+ send :clip=, *args unless args.empty?
78
+ get_clip
79
+ end
80
+
81
+ def clip= (*args)
82
+ send_set :set_clip, :no_clip, args
83
+ end
84
+
85
+ private
86
+
87
+ def send_set (set, no, args)
88
+ args = args[0] if args[0].kind_of?(Array)
89
+ if args.size == 1 && [nil, :no, :none].include?(args[0])
90
+ send no
91
+ else
92
+ send set, *args
93
+ end
94
+ end
95
+
96
+ end# Painter
97
+
98
+
99
+ end# Rays
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ require 'rays/native'
5
+
6
+
7
+ module Rays
8
+
9
+
10
+ class Texture
11
+
12
+ end# Texture
13
+
14
+
15
+ end# Rays