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/include/rays/point.h
CHANGED
@@ -4,105 +4,98 @@
|
|
4
4
|
#define __RAYS_POINT_H__
|
5
5
|
|
6
6
|
|
7
|
-
#include <rays/
|
7
|
+
#include <rays/coord.h>
|
8
8
|
|
9
9
|
|
10
10
|
namespace Rays
|
11
11
|
{
|
12
12
|
|
13
13
|
|
14
|
-
struct
|
14
|
+
struct Point : public Coord3
|
15
15
|
{
|
16
16
|
|
17
|
-
|
18
|
-
{
|
19
|
-
struct {coord x, y;};
|
20
|
-
coord array[2];
|
21
|
-
};
|
17
|
+
typedef Point This;
|
22
18
|
|
23
|
-
|
19
|
+
typedef Coord3 Super;
|
24
20
|
|
25
|
-
|
21
|
+
Point (coord value = 0);
|
26
22
|
|
27
|
-
|
23
|
+
Point (coord x, coord y, coord z = 0);
|
28
24
|
|
29
|
-
|
25
|
+
This dup () const;
|
30
26
|
|
31
|
-
|
27
|
+
This& reset (coord value = 0);
|
32
28
|
|
29
|
+
This& reset (coord x, coord y, coord z = 0);
|
33
30
|
|
34
|
-
|
35
|
-
{
|
31
|
+
This& move_to (coord x, coord y, coord z = 0);
|
36
32
|
|
37
|
-
|
38
|
-
{
|
39
|
-
struct {coord x, y, z;};
|
40
|
-
coord array[3];
|
41
|
-
};
|
33
|
+
This& move_to (const This& point);
|
42
34
|
|
43
|
-
|
35
|
+
This& move_by (coord x, coord y, coord z = 0);
|
44
36
|
|
45
|
-
|
37
|
+
This& move_by (const This& point);
|
46
38
|
|
47
|
-
|
39
|
+
void rotate (float degree);
|
48
40
|
|
49
|
-
|
41
|
+
coord length () const;
|
50
42
|
|
51
|
-
|
43
|
+
This normal () const;
|
52
44
|
|
45
|
+
void normalize ();
|
53
46
|
|
54
|
-
|
55
|
-
{
|
47
|
+
This operator - () const;
|
56
48
|
|
57
|
-
|
49
|
+
This& operator += (coord rhs);
|
58
50
|
|
59
|
-
|
51
|
+
This& operator += (const This& rhs);
|
60
52
|
|
61
|
-
|
53
|
+
This& operator -= (coord rhs);
|
62
54
|
|
63
|
-
|
55
|
+
This& operator -= (const This& rhs);
|
64
56
|
|
65
|
-
|
57
|
+
This& operator *= (coord rhs);
|
66
58
|
|
67
|
-
|
59
|
+
This& operator *= (const This& rhs);
|
68
60
|
|
69
|
-
|
61
|
+
This& operator /= (coord rhs);
|
70
62
|
|
71
|
-
|
63
|
+
This& operator /= (const This& rhs);
|
72
64
|
|
73
|
-
|
65
|
+
friend bool operator == (const This& lhs, const This& rhs);
|
74
66
|
|
75
|
-
|
67
|
+
friend bool operator != (const This& lhs, const This& rhs);
|
76
68
|
|
77
|
-
|
69
|
+
friend This operator + (coord lhs, const This& rhs);
|
78
70
|
|
79
|
-
|
71
|
+
friend This operator + (const This& lhs, coord rhs);
|
80
72
|
|
81
|
-
|
73
|
+
friend This operator + (const This& lhs, const This& rhs);
|
82
74
|
|
83
|
-
|
75
|
+
friend This operator - (coord lhs, const This& rhs);
|
84
76
|
|
85
|
-
|
77
|
+
friend This operator - (const This& lhs, coord rhs);
|
86
78
|
|
87
|
-
|
79
|
+
friend This operator - (const This& lhs, const This& rhs);
|
88
80
|
|
89
|
-
|
81
|
+
friend This operator * (coord lhs, const This& rhs);
|
90
82
|
|
91
|
-
friend
|
83
|
+
friend This operator * (const This& lhs, coord rhs);
|
92
84
|
|
93
|
-
friend
|
85
|
+
friend This operator * (const This& lhs, const This& rhs);
|
94
86
|
|
95
|
-
friend
|
87
|
+
friend This operator / (coord lhs, const This& rhs);
|
96
88
|
|
97
|
-
friend
|
89
|
+
friend This operator / (const This& lhs, coord rhs);
|
98
90
|
|
99
|
-
friend
|
91
|
+
friend This operator / (const This& lhs, const This& rhs);
|
100
92
|
|
101
|
-
|
93
|
+
};// Point
|
102
94
|
|
103
|
-
friend Point operator / (const Point& lhs, coord rhs);
|
104
95
|
|
105
|
-
|
96
|
+
coord dot (const Point& p1, const Point& p2);
|
97
|
+
|
98
|
+
Point cross (const Point& p1, const Point& p2);
|
106
99
|
|
107
100
|
|
108
101
|
}// Rays
|
@@ -0,0 +1,164 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_POLYGON_H__
|
4
|
+
#define __RAYS_POLYGON_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <vector>
|
8
|
+
#include <xot/pimpl.h>
|
9
|
+
#include <rays/bounds.h>
|
10
|
+
#include <rays/polyline.h>
|
11
|
+
|
12
|
+
|
13
|
+
namespace Rays
|
14
|
+
{
|
15
|
+
|
16
|
+
|
17
|
+
class Polygon
|
18
|
+
{
|
19
|
+
|
20
|
+
public:
|
21
|
+
|
22
|
+
struct Line : public Polyline
|
23
|
+
{
|
24
|
+
|
25
|
+
typedef Polyline Super;
|
26
|
+
|
27
|
+
public:
|
28
|
+
|
29
|
+
Line ();
|
30
|
+
|
31
|
+
Line (
|
32
|
+
const Point* points, size_t size,
|
33
|
+
bool loop = true,
|
34
|
+
bool hole = false);
|
35
|
+
|
36
|
+
Line (const Polyline& polyline, bool hole = false);
|
37
|
+
|
38
|
+
bool hole () const;
|
39
|
+
|
40
|
+
operator bool () const;
|
41
|
+
|
42
|
+
bool operator ! () const;
|
43
|
+
|
44
|
+
private:
|
45
|
+
|
46
|
+
bool hole_;
|
47
|
+
|
48
|
+
};// Line
|
49
|
+
|
50
|
+
typedef std::vector<Line> LineList;
|
51
|
+
|
52
|
+
typedef LineList::const_iterator const_iterator;
|
53
|
+
|
54
|
+
Polygon ();
|
55
|
+
|
56
|
+
Polygon (const Point* points, size_t size, bool loop = true);
|
57
|
+
|
58
|
+
Polygon (const Polyline& polyline);
|
59
|
+
|
60
|
+
Polygon (const Line* lines, size_t size);
|
61
|
+
|
62
|
+
~Polygon ();
|
63
|
+
|
64
|
+
bool expand (Polygon* result, coord width) const;
|
65
|
+
|
66
|
+
Bounds bounds () const;
|
67
|
+
|
68
|
+
size_t size () const;
|
69
|
+
|
70
|
+
bool empty (bool deep = false) const;
|
71
|
+
|
72
|
+
const_iterator begin () const;
|
73
|
+
|
74
|
+
const_iterator end () const;
|
75
|
+
|
76
|
+
const Line& operator [] (size_t index) const;
|
77
|
+
|
78
|
+
operator bool () const;
|
79
|
+
|
80
|
+
bool operator ! () const;
|
81
|
+
|
82
|
+
friend Polygon operator + (const Polygon& lhs, const Polygon& rhs);
|
83
|
+
|
84
|
+
friend Polygon operator - (const Polygon& lhs, const Polygon& rhs);
|
85
|
+
|
86
|
+
friend Polygon operator & (const Polygon& lhs, const Polygon& rhs);
|
87
|
+
|
88
|
+
friend Polygon operator | (const Polygon& lhs, const Polygon& rhs);
|
89
|
+
|
90
|
+
friend Polygon operator ^ (const Polygon& lhs, const Polygon& rhs);
|
91
|
+
|
92
|
+
struct Data;
|
93
|
+
|
94
|
+
Xot::PSharedImpl<Data> self;
|
95
|
+
|
96
|
+
typedef std::vector<Point> TrianglePointList;
|
97
|
+
|
98
|
+
Polygon (Data* data);
|
99
|
+
|
100
|
+
protected:
|
101
|
+
|
102
|
+
bool triangulate (TrianglePointList* triangles) const;
|
103
|
+
|
104
|
+
};// Polygon
|
105
|
+
|
106
|
+
|
107
|
+
Polygon create_line (coord x1, coord y1, coord x2, coord y2);
|
108
|
+
|
109
|
+
Polygon create_line (const Point& p1, const Point& p2);
|
110
|
+
|
111
|
+
Polygon create_line (const Point* points, size_t size, bool loop = false);
|
112
|
+
|
113
|
+
Polygon create_line (const Polyline& polyline);
|
114
|
+
|
115
|
+
|
116
|
+
Polygon create_rect (
|
117
|
+
coord x, coord y, coord width, coord height,
|
118
|
+
coord round = 0,
|
119
|
+
uint nsegment = 0);
|
120
|
+
|
121
|
+
Polygon create_rect (
|
122
|
+
coord x, coord y, coord width, coord height,
|
123
|
+
coord round_left_top, coord round_right_top,
|
124
|
+
coord round_left_bottom, coord round_right_bottom,
|
125
|
+
uint nsegment = 0);
|
126
|
+
|
127
|
+
Polygon create_rect (
|
128
|
+
const Bounds& bounds,
|
129
|
+
coord round = 0,
|
130
|
+
uint nsegment = 0);
|
131
|
+
|
132
|
+
Polygon create_rect (
|
133
|
+
const Bounds& bounds,
|
134
|
+
coord round_left_top, coord round_right_top,
|
135
|
+
coord round_left_bottom, coord round_right_bottom,
|
136
|
+
uint nsegment = 0);
|
137
|
+
|
138
|
+
|
139
|
+
Polygon create_ellipse (
|
140
|
+
coord x, coord y, coord width, coord height = 0,
|
141
|
+
const Point& hole_size = 0,
|
142
|
+
float angle_from = 0,
|
143
|
+
float angle_to = 360,
|
144
|
+
uint nsegment = 0);
|
145
|
+
|
146
|
+
Polygon create_ellipse (
|
147
|
+
const Bounds& bounds,
|
148
|
+
const Point& hole_size = 0,
|
149
|
+
float angle_from = 0,
|
150
|
+
float angle_to = 360,
|
151
|
+
uint nsegment = 0);
|
152
|
+
|
153
|
+
Polygon create_ellipse (
|
154
|
+
const Point& center, const Point& radius,
|
155
|
+
const Point& hole_radius = 0,
|
156
|
+
float angle_from = 0,
|
157
|
+
float angle_to = 360,
|
158
|
+
uint nsegment = 0);
|
159
|
+
|
160
|
+
|
161
|
+
}// Rays
|
162
|
+
|
163
|
+
|
164
|
+
#endif//EOH
|
@@ -0,0 +1,65 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_POLYLINE_H__
|
4
|
+
#define __RAYS_POLYLINE_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <vector>
|
8
|
+
#include <xot/pimpl.h>
|
9
|
+
#include <rays/point.h>
|
10
|
+
#include <rays/bounds.h>
|
11
|
+
|
12
|
+
|
13
|
+
namespace Rays
|
14
|
+
{
|
15
|
+
|
16
|
+
|
17
|
+
class Polygon;
|
18
|
+
|
19
|
+
|
20
|
+
class Polyline
|
21
|
+
{
|
22
|
+
|
23
|
+
public:
|
24
|
+
|
25
|
+
typedef std::vector<Point> PointList;
|
26
|
+
|
27
|
+
typedef PointList::const_iterator const_iterator;
|
28
|
+
|
29
|
+
Polyline ();
|
30
|
+
|
31
|
+
Polyline (const Point* points, size_t size, bool loop = false);
|
32
|
+
|
33
|
+
~Polyline ();
|
34
|
+
|
35
|
+
bool expand (Polygon* result, coord width) const;
|
36
|
+
|
37
|
+
Bounds bounds () const;
|
38
|
+
|
39
|
+
bool loop () const;
|
40
|
+
|
41
|
+
size_t size () const;
|
42
|
+
|
43
|
+
bool empty () const;
|
44
|
+
|
45
|
+
const_iterator begin () const;
|
46
|
+
|
47
|
+
const_iterator end () const;
|
48
|
+
|
49
|
+
const Point& operator [] (size_t index) const;
|
50
|
+
|
51
|
+
operator bool () const;
|
52
|
+
|
53
|
+
bool operator ! () const;
|
54
|
+
|
55
|
+
struct Data;
|
56
|
+
|
57
|
+
Xot::PSharedImpl<Data> self;
|
58
|
+
|
59
|
+
};// Polyline
|
60
|
+
|
61
|
+
|
62
|
+
}// Rays
|
63
|
+
|
64
|
+
|
65
|
+
#endif//EOH
|
data/include/rays/rays.h
CHANGED
data/include/rays/ruby.h
CHANGED
@@ -5,14 +5,20 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
#include <rays/ruby/rays.h>
|
8
|
+
|
8
9
|
#include <rays/ruby/point.h>
|
9
10
|
#include <rays/ruby/bounds.h>
|
10
11
|
#include <rays/ruby/color.h>
|
12
|
+
#include <rays/ruby/color_space.h>
|
13
|
+
#include <rays/ruby/matrix.h>
|
14
|
+
|
15
|
+
#include <rays/ruby/polyline.h>
|
16
|
+
#include <rays/ruby/polygon.h>
|
11
17
|
#include <rays/ruby/bitmap.h>
|
12
|
-
#include <rays/ruby/texture.h>
|
13
18
|
#include <rays/ruby/image.h>
|
14
19
|
#include <rays/ruby/font.h>
|
15
20
|
#include <rays/ruby/shader.h>
|
21
|
+
|
16
22
|
#include <rays/ruby/painter.h>
|
17
23
|
|
18
24
|
|
data/include/rays/ruby/bounds.h
CHANGED
data/include/rays/ruby/color.h
CHANGED