reflexion 0.1.8 → 0.1.9
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 +4 -4
- data/.doc/ext/reflex/application.cpp +5 -1
- data/.doc/ext/reflex/arc_shape.cpp +89 -0
- data/.doc/ext/reflex/body.cpp +91 -12
- data/.doc/ext/reflex/contact_event.cpp +90 -0
- data/.doc/ext/reflex/ellipse_shape.cpp +89 -0
- data/.doc/ext/reflex/image_view.cpp +0 -16
- data/.doc/ext/reflex/native.cpp +18 -6
- data/.doc/ext/reflex/rect_shape.cpp +83 -0
- data/.doc/ext/reflex/shape_view.cpp +153 -0
- data/.doc/ext/reflex/view.cpp +63 -26
- data/.doc/ext/reflex/window.cpp +5 -1
- data/VERSION +1 -1
- data/ext/reflex/application.cpp +6 -2
- data/ext/reflex/arc_shape.cpp +94 -0
- data/ext/reflex/body.cpp +101 -13
- data/ext/reflex/contact_event.cpp +95 -0
- data/ext/reflex/ellipse_shape.cpp +94 -0
- data/ext/reflex/image_view.cpp +0 -18
- data/ext/reflex/native.cpp +18 -6
- data/ext/reflex/rect_shape.cpp +86 -0
- data/ext/reflex/shape_view.cpp +161 -0
- data/ext/reflex/view.cpp +71 -30
- data/ext/reflex/window.cpp +5 -1
- data/include/reflex/body.h +42 -12
- data/include/reflex/event.h +27 -1
- data/include/reflex/fixture.h +6 -5
- data/include/reflex/image_view.h +5 -5
- data/include/reflex/ruby/application.h +27 -6
- data/include/reflex/ruby/event.h +11 -0
- data/include/reflex/ruby/shape_view.h +96 -0
- data/include/reflex/ruby/view.h +60 -5
- data/include/reflex/ruby/window.h +12 -3
- data/include/reflex/shape_view.h +146 -0
- data/include/reflex/view.h +17 -5
- data/lib/reflex/application.rb +9 -9
- data/lib/reflex/body.rb +2 -0
- data/lib/reflex/contact_event.rb +38 -0
- data/lib/reflex/image_view.rb +1 -1
- data/lib/reflex/shape_view.rb +25 -0
- data/lib/reflex/view.rb +19 -9
- data/lib/reflex/window.rb +11 -10
- data/lib/reflex.rb +15 -13
- data/lib/reflexion.rb +25 -18
- data/samples/osx/hello/hello/main.cpp +6 -0
- data/samples/physics.rb +22 -12
- data/samples/reflexion/breakout.rb +52 -0
- data/samples/reflexion/hello.rb +5 -7
- data/samples/reflexion/paint.rb +10 -11
- data/samples/reflexion/physics.rb +28 -0
- data/samples/reflexion/pulse.rb +10 -8
- data/samples/shapes.rb +2 -2
- data/src/body.cpp +241 -40
- data/src/event.cpp +32 -2
- data/src/shape_view.cpp +306 -0
- data/src/view.cpp +232 -66
- data/src/world.cpp +110 -30
- data/src/world.h +61 -14
- metadata +24 -7
- data/lib/reflex/arc_shape.rb +0 -20
- data/lib/reflex/ellipse_shape.rb +0 -20
- data/lib/reflex/line_shape.rb +0 -20
- data/lib/reflex/rect_shape.rb +0 -20
- data/lib/reflex/shape.rb +0 -34
data/src/world.cpp
CHANGED
@@ -7,6 +7,9 @@
|
|
7
7
|
#include <Box2D/Common/b2Draw.h>
|
8
8
|
#include "xot/util.h"
|
9
9
|
#include "reflex/body.h"
|
10
|
+
#include "reflex/view.h"
|
11
|
+
#include "reflex/event.h"
|
12
|
+
#include "reflex/exception.h"
|
10
13
|
|
11
14
|
|
12
15
|
namespace Reflex
|
@@ -18,10 +21,15 @@ namespace Reflex
|
|
18
21
|
|
19
22
|
public:
|
20
23
|
|
21
|
-
DebugDraw (float
|
22
|
-
:
|
24
|
+
DebugDraw (float ppm)
|
25
|
+
: ppm(ppm), painter(NULL)
|
23
26
|
{
|
24
|
-
SetFlags(
|
27
|
+
SetFlags(
|
28
|
+
e_shapeBit |
|
29
|
+
e_jointBit |
|
30
|
+
//e_aabbBit |
|
31
|
+
e_pairBit |
|
32
|
+
e_centerOfMassBit);
|
25
33
|
}
|
26
34
|
|
27
35
|
void begin (Painter* painter)
|
@@ -46,7 +54,7 @@ namespace Reflex
|
|
46
54
|
|
47
55
|
boost::scoped_array<Coord2> points(new Coord2[vertexCount]);
|
48
56
|
for (int i = 0; i < vertexCount; ++i)
|
49
|
-
points[i] = to_coord2(vertices[i],
|
57
|
+
points[i] = to_coord2(vertices[i], ppm);
|
50
58
|
|
51
59
|
painter->polygon(&points[0], vertexCount);
|
52
60
|
}
|
@@ -61,7 +69,7 @@ namespace Reflex
|
|
61
69
|
|
62
70
|
boost::scoped_array<Coord2> points(new Coord2[vertexCount]);
|
63
71
|
for (int i = 0; i < vertexCount; ++i)
|
64
|
-
points[i] = to_coord2(vertices[i],
|
72
|
+
points[i] = to_coord2(vertices[i], ppm);
|
65
73
|
|
66
74
|
painter->polygon(&points[0], vertexCount);
|
67
75
|
}
|
@@ -73,7 +81,7 @@ namespace Reflex
|
|
73
81
|
|
74
82
|
painter->no_fill();
|
75
83
|
painter->set_stroke(color.r, color.g, color.b, color.a * 0.5);
|
76
|
-
painter->ellipse(
|
84
|
+
painter->ellipse(to_point(center, ppm), to_coord(radius, ppm));
|
77
85
|
}
|
78
86
|
|
79
87
|
void DrawSolidCircle (
|
@@ -83,7 +91,7 @@ namespace Reflex
|
|
83
91
|
|
84
92
|
painter->set_fill(color.r, color.g, color.b, color.a * 0.5);
|
85
93
|
painter->no_stroke();
|
86
|
-
painter->ellipse(
|
94
|
+
painter->ellipse(to_point(center, ppm), to_coord(radius, ppm));
|
87
95
|
}
|
88
96
|
|
89
97
|
void DrawSegment (
|
@@ -93,7 +101,7 @@ namespace Reflex
|
|
93
101
|
|
94
102
|
painter->no_fill();
|
95
103
|
painter->set_stroke(color.r, color.g, color.b, color.a * 0.5);
|
96
|
-
painter->line(p1
|
104
|
+
painter->line(to_point(p1, ppm), to_point(p2, ppm));
|
97
105
|
}
|
98
106
|
|
99
107
|
void DrawTransform (const b2Transform& transform)
|
@@ -103,17 +111,19 @@ namespace Reflex
|
|
103
111
|
|
104
112
|
private:
|
105
113
|
|
106
|
-
float
|
114
|
+
float ppm;
|
107
115
|
|
108
116
|
Painter* painter;
|
109
117
|
|
110
118
|
};// DebugDraw
|
111
119
|
|
112
120
|
|
113
|
-
World::World (float
|
114
|
-
: world(b2Vec2(0, 0)),
|
121
|
+
World::World (View* owner, float pixels_per_meter)
|
122
|
+
: world(b2Vec2(0, 0)), ppm(pixels_per_meter), last_step(0), wall_(NULL),
|
123
|
+
debug_draw(NULL)
|
115
124
|
{
|
116
|
-
|
125
|
+
world.SetContactListener(this);
|
126
|
+
wall_ = create_body(owner);
|
117
127
|
}
|
118
128
|
|
119
129
|
World::~World ()
|
@@ -124,38 +134,58 @@ namespace Reflex
|
|
124
134
|
void
|
125
135
|
World::step (float dt)
|
126
136
|
{
|
127
|
-
|
137
|
+
static const double DT = 1. / 60.;
|
138
|
+
|
139
|
+
dt += last_step;
|
140
|
+
last_step = fmod(dt, DT);
|
141
|
+
|
142
|
+
int count = (int) (dt / DT);
|
143
|
+
for (int i = 0; i < count; ++i)
|
144
|
+
world.Step(DT, 8, 4);
|
128
145
|
}
|
129
146
|
|
130
147
|
Body*
|
131
|
-
World::create_body (const Point& position, float degree)
|
148
|
+
World::create_body (View* owner, const Point& position, float degree)
|
132
149
|
{
|
150
|
+
if (!owner)
|
151
|
+
argument_error(__FILE__, __LINE__);
|
152
|
+
|
153
|
+
if (world.IsLocked())
|
154
|
+
invalid_state_error(__FILE__, __LINE__);
|
155
|
+
|
133
156
|
b2BodyDef def;
|
134
|
-
def.position =
|
157
|
+
def.position = to_b2vec2(position, ppm);
|
135
158
|
def.angle = Xot::deg2rad(degree);
|
136
|
-
|
159
|
+
b2Body* body = world.CreateBody(&def);
|
160
|
+
body->SetUserData(owner);
|
161
|
+
return new Body(body, ppm);
|
137
162
|
}
|
138
163
|
|
139
164
|
void
|
140
165
|
World::destroy_body (Body* body)
|
141
166
|
{
|
142
|
-
|
167
|
+
if (!body)
|
168
|
+
argument_error(__FILE__, __LINE__);
|
169
|
+
|
170
|
+
b2Body* b = (b2Body*) body->handle;
|
171
|
+
if (!b || world.IsLocked())
|
172
|
+
invalid_state_error(__FILE__, __LINE__);
|
173
|
+
|
174
|
+
world.DestroyBody(b);
|
143
175
|
}
|
144
176
|
|
145
177
|
void
|
146
178
|
World::resize (coord width, coord height)
|
147
179
|
{
|
148
|
-
|
180
|
+
wall_->clear_fixtures();
|
149
181
|
|
150
|
-
coord w = width / scale;
|
151
|
-
coord h = height / scale;
|
152
182
|
const Point points[] = {
|
153
|
-
Point(0,
|
154
|
-
Point(0,
|
155
|
-
Point(
|
156
|
-
Point(
|
183
|
+
Point(0, 0),
|
184
|
+
Point(0, height),
|
185
|
+
Point(width, height),
|
186
|
+
Point(width, 0),
|
157
187
|
};
|
158
|
-
|
188
|
+
wall_->add_edge(points, 4, true);
|
159
189
|
}
|
160
190
|
|
161
191
|
void
|
@@ -168,25 +198,43 @@ namespace Reflex
|
|
168
198
|
debug_draw->end();
|
169
199
|
}
|
170
200
|
|
201
|
+
float
|
202
|
+
World::meter2pixel (float meter) const
|
203
|
+
{
|
204
|
+
return meter * ppm;
|
205
|
+
}
|
206
|
+
|
171
207
|
void
|
172
208
|
World::set_gravity (const Point& gravity)
|
173
209
|
{
|
174
|
-
world.SetGravity(
|
210
|
+
world.SetGravity(to_b2vec2(gravity, ppm));
|
175
211
|
}
|
176
212
|
|
177
213
|
Point
|
178
214
|
World::gravity () const
|
179
215
|
{
|
180
|
-
return to_point(world.GetGravity(),
|
216
|
+
return to_point(world.GetGravity(), ppm);
|
217
|
+
}
|
218
|
+
|
219
|
+
Body*
|
220
|
+
World::wall ()
|
221
|
+
{
|
222
|
+
return wall_;
|
223
|
+
}
|
224
|
+
|
225
|
+
const Body*
|
226
|
+
World::wall () const
|
227
|
+
{
|
228
|
+
return const_cast<World*>(this)->wall();
|
181
229
|
}
|
182
230
|
|
183
231
|
void
|
184
232
|
World::set_debug (bool state)
|
185
233
|
{
|
186
|
-
if (state ==
|
234
|
+
if (state == debugging()) return;
|
187
235
|
|
188
236
|
if (!debug_draw)
|
189
|
-
debug_draw = new DebugDraw(
|
237
|
+
debug_draw = new DebugDraw(ppm);
|
190
238
|
else
|
191
239
|
{
|
192
240
|
delete debug_draw;
|
@@ -197,10 +245,42 @@ namespace Reflex
|
|
197
245
|
}
|
198
246
|
|
199
247
|
bool
|
200
|
-
World::
|
248
|
+
World::debugging () const
|
201
249
|
{
|
202
250
|
return debug_draw;
|
203
251
|
}
|
204
252
|
|
253
|
+
void
|
254
|
+
World::BeginContact (b2Contact* contact)
|
255
|
+
{
|
256
|
+
View* v1 = (View*) contact->GetFixtureA()->GetBody()->GetUserData();
|
257
|
+
if (!v1) return;
|
258
|
+
|
259
|
+
View* v2 = (View*) contact->GetFixtureB()->GetBody()->GetUserData();
|
260
|
+
if (!v2) return;
|
261
|
+
|
262
|
+
ContactEvent e1(ContactEvent::BEGIN, v2);
|
263
|
+
v1->on_contact(&e1);
|
264
|
+
|
265
|
+
ContactEvent e2(ContactEvent::BEGIN, v1);
|
266
|
+
v2->on_contact(&e2);
|
267
|
+
}
|
268
|
+
|
269
|
+
void
|
270
|
+
World::EndContact (b2Contact* contact)
|
271
|
+
{
|
272
|
+
View* v1 = (View*) contact->GetFixtureA()->GetBody()->GetUserData();
|
273
|
+
if (!v1) return;
|
274
|
+
|
275
|
+
View* v2 = (View*) contact->GetFixtureB()->GetBody()->GetUserData();
|
276
|
+
if (!v2) return;
|
277
|
+
|
278
|
+
ContactEvent e1(ContactEvent::END, v2);
|
279
|
+
v1->on_contact(&e1);
|
280
|
+
|
281
|
+
ContactEvent e2(ContactEvent::END, v1);
|
282
|
+
v2->on_contact(&e2);
|
283
|
+
}
|
284
|
+
|
205
285
|
|
206
286
|
}// Reflex
|
data/src/world.h
CHANGED
@@ -6,6 +6,8 @@
|
|
6
6
|
|
7
7
|
#include <boost/noncopyable.hpp>
|
8
8
|
#include <Box2D/Dynamics/b2World.h>
|
9
|
+
#include <Box2D/Dynamics/b2WorldCallbacks.h>
|
10
|
+
#include <Box2D/Dynamics/Contacts/b2Contact.h>
|
9
11
|
#include <reflex/defs.h>
|
10
12
|
#include <reflex/point.h>
|
11
13
|
#include <reflex/painter.h>
|
@@ -15,23 +17,25 @@ namespace Reflex
|
|
15
17
|
{
|
16
18
|
|
17
19
|
|
20
|
+
class View;
|
21
|
+
|
18
22
|
class Body;
|
19
23
|
|
20
24
|
class DebugDraw;
|
21
25
|
|
22
26
|
|
23
|
-
class World : public boost::noncopyable
|
27
|
+
class World : public boost::noncopyable, private b2ContactListener
|
24
28
|
{
|
25
29
|
|
26
30
|
public:
|
27
31
|
|
28
|
-
World (float
|
32
|
+
World (View* owner, float pixels_per_meter = 100);
|
29
33
|
|
30
34
|
~World ();
|
31
35
|
|
32
36
|
void step (float dt);
|
33
37
|
|
34
|
-
Body* create_body (const Point& position = 0, float degree = 0);
|
38
|
+
Body* create_body (View* owner, const Point& position = 0, float degree = 0);
|
35
39
|
|
36
40
|
void destroy_body (Body* body);
|
37
41
|
|
@@ -39,21 +43,33 @@ namespace Reflex
|
|
39
43
|
|
40
44
|
void draw (Painter* painter);
|
41
45
|
|
46
|
+
float meter2pixel (float meter = 1) const;
|
47
|
+
|
42
48
|
void set_gravity (const Point& gravity);
|
43
49
|
|
44
50
|
Point gravity () const;
|
45
51
|
|
46
52
|
void set_debug (bool state = true);
|
47
53
|
|
48
|
-
bool
|
54
|
+
bool debugging () const;
|
55
|
+
|
56
|
+
Body* wall ();
|
57
|
+
|
58
|
+
const Body* wall () const;
|
59
|
+
|
60
|
+
protected:
|
61
|
+
|
62
|
+
void BeginContact (b2Contact* contact);
|
63
|
+
|
64
|
+
void EndContact (b2Contact* contact);
|
49
65
|
|
50
66
|
private:
|
51
67
|
|
52
68
|
b2World world;
|
53
69
|
|
54
|
-
float
|
70
|
+
float ppm, last_step;
|
55
71
|
|
56
|
-
Body*
|
72
|
+
Body* wall_;
|
57
73
|
|
58
74
|
DebugDraw* debug_draw;
|
59
75
|
|
@@ -61,32 +77,63 @@ namespace Reflex
|
|
61
77
|
|
62
78
|
|
63
79
|
template <typename T>
|
80
|
+
inline float32
|
81
|
+
to_b2coord (T t, float scale)
|
82
|
+
{
|
83
|
+
return t / scale;
|
84
|
+
}
|
85
|
+
|
86
|
+
template <typename T>
|
87
|
+
inline b2Vec2
|
88
|
+
to_b2vec2 (T x, T y, float scale)
|
89
|
+
{
|
90
|
+
return b2Vec2(
|
91
|
+
to_b2coord(x, scale),
|
92
|
+
to_b2coord(y, scale));
|
93
|
+
}
|
94
|
+
|
95
|
+
template <typename VEC>
|
64
96
|
inline b2Vec2
|
65
|
-
|
97
|
+
to_b2vec2 (const VEC& v, float scale)
|
98
|
+
{
|
99
|
+
return b2Vec2(
|
100
|
+
to_b2coord(v.x, scale),
|
101
|
+
to_b2coord(v.y, scale));
|
102
|
+
}
|
103
|
+
|
104
|
+
|
105
|
+
inline coord
|
106
|
+
to_coord (float32 t, float scale)
|
66
107
|
{
|
67
|
-
return
|
108
|
+
return t * scale;
|
68
109
|
}
|
69
110
|
|
70
111
|
inline Coord2
|
71
|
-
to_coord2 (const b2Vec2&
|
112
|
+
to_coord2 (const b2Vec2& v, float scale)
|
72
113
|
{
|
73
114
|
Coord2 c;
|
74
|
-
c.reset(
|
115
|
+
c.reset(
|
116
|
+
to_coord(v.x, scale),
|
117
|
+
to_coord(v.y, scale));
|
75
118
|
return c;
|
76
119
|
}
|
77
120
|
|
78
121
|
inline Coord3
|
79
|
-
to_coord3 (const b2Vec2&
|
122
|
+
to_coord3 (const b2Vec2& v, float scale)
|
80
123
|
{
|
81
124
|
Coord3 c;
|
82
|
-
c.reset(
|
125
|
+
c.reset(
|
126
|
+
to_coord(v.x, scale),
|
127
|
+
to_coord(v.y, scale));
|
83
128
|
return c;
|
84
129
|
}
|
85
130
|
|
86
131
|
inline Point
|
87
|
-
to_point (const b2Vec2&
|
132
|
+
to_point (const b2Vec2& v, float scale)
|
88
133
|
{
|
89
|
-
return Point(
|
134
|
+
return Point(
|
135
|
+
to_coord(v.x, scale),
|
136
|
+
to_coord(v.y, scale));
|
90
137
|
}
|
91
138
|
|
92
139
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reflexion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- snori
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -87,9 +87,12 @@ extensions:
|
|
87
87
|
- Rakefile
|
88
88
|
extra_rdoc_files:
|
89
89
|
- ".doc/ext/reflex/application.cpp"
|
90
|
+
- ".doc/ext/reflex/arc_shape.cpp"
|
90
91
|
- ".doc/ext/reflex/body.cpp"
|
91
92
|
- ".doc/ext/reflex/capture_event.cpp"
|
93
|
+
- ".doc/ext/reflex/contact_event.cpp"
|
92
94
|
- ".doc/ext/reflex/draw_event.cpp"
|
95
|
+
- ".doc/ext/reflex/ellipse_shape.cpp"
|
93
96
|
- ".doc/ext/reflex/event.cpp"
|
94
97
|
- ".doc/ext/reflex/fixture.cpp"
|
95
98
|
- ".doc/ext/reflex/focus_event.cpp"
|
@@ -98,9 +101,11 @@ extra_rdoc_files:
|
|
98
101
|
- ".doc/ext/reflex/key_event.cpp"
|
99
102
|
- ".doc/ext/reflex/native.cpp"
|
100
103
|
- ".doc/ext/reflex/pointer_event.cpp"
|
104
|
+
- ".doc/ext/reflex/rect_shape.cpp"
|
101
105
|
- ".doc/ext/reflex/reflex.cpp"
|
102
106
|
- ".doc/ext/reflex/scroll_event.cpp"
|
103
107
|
- ".doc/ext/reflex/selector.cpp"
|
108
|
+
- ".doc/ext/reflex/shape_view.cpp"
|
104
109
|
- ".doc/ext/reflex/style.cpp"
|
105
110
|
- ".doc/ext/reflex/style_length.cpp"
|
106
111
|
- ".doc/ext/reflex/style_length2.cpp"
|
@@ -114,10 +119,13 @@ files:
|
|
114
119
|
- Rakefile
|
115
120
|
- VERSION
|
116
121
|
- ext/reflex/application.cpp
|
122
|
+
- ext/reflex/arc_shape.cpp
|
117
123
|
- ext/reflex/body.cpp
|
118
124
|
- ext/reflex/capture_event.cpp
|
125
|
+
- ext/reflex/contact_event.cpp
|
119
126
|
- ext/reflex/defs.h
|
120
127
|
- ext/reflex/draw_event.cpp
|
128
|
+
- ext/reflex/ellipse_shape.cpp
|
121
129
|
- ext/reflex/event.cpp
|
122
130
|
- ext/reflex/extconf.rb
|
123
131
|
- ext/reflex/fixture.cpp
|
@@ -127,9 +135,11 @@ files:
|
|
127
135
|
- ext/reflex/key_event.cpp
|
128
136
|
- ext/reflex/native.cpp
|
129
137
|
- ext/reflex/pointer_event.cpp
|
138
|
+
- ext/reflex/rect_shape.cpp
|
130
139
|
- ext/reflex/reflex.cpp
|
131
140
|
- ext/reflex/scroll_event.cpp
|
132
141
|
- ext/reflex/selector.cpp
|
142
|
+
- ext/reflex/shape_view.cpp
|
133
143
|
- ext/reflex/style.cpp
|
134
144
|
- ext/reflex/style_length.cpp
|
135
145
|
- ext/reflex/style_length2.cpp
|
@@ -164,12 +174,14 @@ files:
|
|
164
174
|
- include/reflex/ruby/image_view.h
|
165
175
|
- include/reflex/ruby/reflex.h
|
166
176
|
- include/reflex/ruby/selector.h
|
177
|
+
- include/reflex/ruby/shape_view.h
|
167
178
|
- include/reflex/ruby/style.h
|
168
179
|
- include/reflex/ruby/style_length.h
|
169
180
|
- include/reflex/ruby/view.h
|
170
181
|
- include/reflex/ruby/window.h
|
171
182
|
- include/reflex/selector.h
|
172
183
|
- include/reflex/shader.h
|
184
|
+
- include/reflex/shape_view.h
|
173
185
|
- include/reflex/style.h
|
174
186
|
- include/reflex/style_length.h
|
175
187
|
- include/reflex/texture.h
|
@@ -177,7 +189,6 @@ files:
|
|
177
189
|
- include/reflex/window.h
|
178
190
|
- lib/reflex.rb
|
179
191
|
- lib/reflex/application.rb
|
180
|
-
- lib/reflex/arc_shape.rb
|
181
192
|
- lib/reflex/autoinit.rb
|
182
193
|
- lib/reflex/bitmap.rb
|
183
194
|
- lib/reflex/body.rb
|
@@ -186,8 +197,8 @@ files:
|
|
186
197
|
- lib/reflex/capture_event.rb
|
187
198
|
- lib/reflex/color.rb
|
188
199
|
- lib/reflex/color_space.rb
|
200
|
+
- lib/reflex/contact_event.rb
|
189
201
|
- lib/reflex/draw_event.rb
|
190
|
-
- lib/reflex/ellipse_shape.rb
|
191
202
|
- lib/reflex/ext.rb
|
192
203
|
- lib/reflex/fixture.rb
|
193
204
|
- lib/reflex/flags.rb
|
@@ -198,7 +209,6 @@ files:
|
|
198
209
|
- lib/reflex/image.rb
|
199
210
|
- lib/reflex/image_view.rb
|
200
211
|
- lib/reflex/key_event.rb
|
201
|
-
- lib/reflex/line_shape.rb
|
202
212
|
- lib/reflex/list_view.rb
|
203
213
|
- lib/reflex/model.rb
|
204
214
|
- lib/reflex/model_owner.rb
|
@@ -207,12 +217,11 @@ files:
|
|
207
217
|
- lib/reflex/painter.rb
|
208
218
|
- lib/reflex/point.rb
|
209
219
|
- lib/reflex/pointer_event.rb
|
210
|
-
- lib/reflex/rect_shape.rb
|
211
220
|
- lib/reflex/reflex.rb
|
212
221
|
- lib/reflex/scroll_event.rb
|
213
222
|
- lib/reflex/selector.rb
|
214
223
|
- lib/reflex/shader.rb
|
215
|
-
- lib/reflex/
|
224
|
+
- lib/reflex/shape_view.rb
|
216
225
|
- lib/reflex/style.rb
|
217
226
|
- lib/reflex/style_length.rb
|
218
227
|
- lib/reflex/style_length2.rb
|
@@ -252,8 +261,10 @@ files:
|
|
252
261
|
- samples/osx/hello/hello/hello-Prefix.pch
|
253
262
|
- samples/osx/hello/hello/main.cpp
|
254
263
|
- samples/physics.rb
|
264
|
+
- samples/reflexion/breakout.rb
|
255
265
|
- samples/reflexion/hello.rb
|
256
266
|
- samples/reflexion/paint.rb
|
267
|
+
- samples/reflexion/physics.rb
|
257
268
|
- samples/reflexion/pulse.rb
|
258
269
|
- samples/repl.rb
|
259
270
|
- samples/shader.rb
|
@@ -387,6 +398,7 @@ files:
|
|
387
398
|
- src/physics/Box2D/Rope/b2Rope.cpp
|
388
399
|
- src/physics/Box2D/Rope/b2Rope.h
|
389
400
|
- src/selector.cpp
|
401
|
+
- src/shape_view.cpp
|
390
402
|
- src/style.cpp
|
391
403
|
- src/style_length.cpp
|
392
404
|
- src/view.cpp
|
@@ -417,9 +429,12 @@ files:
|
|
417
429
|
- test/test_view.rb
|
418
430
|
- test/test_window.rb
|
419
431
|
- ".doc/ext/reflex/application.cpp"
|
432
|
+
- ".doc/ext/reflex/arc_shape.cpp"
|
420
433
|
- ".doc/ext/reflex/body.cpp"
|
421
434
|
- ".doc/ext/reflex/capture_event.cpp"
|
435
|
+
- ".doc/ext/reflex/contact_event.cpp"
|
422
436
|
- ".doc/ext/reflex/draw_event.cpp"
|
437
|
+
- ".doc/ext/reflex/ellipse_shape.cpp"
|
423
438
|
- ".doc/ext/reflex/event.cpp"
|
424
439
|
- ".doc/ext/reflex/fixture.cpp"
|
425
440
|
- ".doc/ext/reflex/focus_event.cpp"
|
@@ -428,9 +443,11 @@ files:
|
|
428
443
|
- ".doc/ext/reflex/key_event.cpp"
|
429
444
|
- ".doc/ext/reflex/native.cpp"
|
430
445
|
- ".doc/ext/reflex/pointer_event.cpp"
|
446
|
+
- ".doc/ext/reflex/rect_shape.cpp"
|
431
447
|
- ".doc/ext/reflex/reflex.cpp"
|
432
448
|
- ".doc/ext/reflex/scroll_event.cpp"
|
433
449
|
- ".doc/ext/reflex/selector.cpp"
|
450
|
+
- ".doc/ext/reflex/shape_view.cpp"
|
434
451
|
- ".doc/ext/reflex/style.cpp"
|
435
452
|
- ".doc/ext/reflex/style_length.cpp"
|
436
453
|
- ".doc/ext/reflex/style_length2.cpp"
|
data/lib/reflex/arc_shape.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
require 'reflex/shape'
|
5
|
-
|
6
|
-
|
7
|
-
module Reflex
|
8
|
-
|
9
|
-
|
10
|
-
class ArcShape < Shape
|
11
|
-
|
12
|
-
def on_draw (e)
|
13
|
-
p, b = e.painter, e.bounds
|
14
|
-
attach_color_and_border(p) {p.arc b}
|
15
|
-
end
|
16
|
-
|
17
|
-
end# ArcShape
|
18
|
-
|
19
|
-
|
20
|
-
end# Reflex
|
data/lib/reflex/ellipse_shape.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
require 'reflex/shape'
|
5
|
-
|
6
|
-
|
7
|
-
module Reflex
|
8
|
-
|
9
|
-
|
10
|
-
class EllipseShape < Shape
|
11
|
-
|
12
|
-
def on_draw (e)
|
13
|
-
p, b = e.painter, e.bounds
|
14
|
-
attach_color_and_border(p) {p.ellipse b}
|
15
|
-
end
|
16
|
-
|
17
|
-
end# EllipseShape
|
18
|
-
|
19
|
-
|
20
|
-
end# Reflex
|
data/lib/reflex/line_shape.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
require 'reflex/shape'
|
5
|
-
|
6
|
-
|
7
|
-
module Reflex
|
8
|
-
|
9
|
-
|
10
|
-
class LineShape < Shape
|
11
|
-
|
12
|
-
def on_draw (e)
|
13
|
-
p, b = e.painter, e.bounds
|
14
|
-
attach_color_and_border(p) {p.line b.lt, b.rb}
|
15
|
-
end
|
16
|
-
|
17
|
-
end# LineShape
|
18
|
-
|
19
|
-
|
20
|
-
end# Reflex
|
data/lib/reflex/rect_shape.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
require 'reflex/shape'
|
5
|
-
|
6
|
-
|
7
|
-
module Reflex
|
8
|
-
|
9
|
-
|
10
|
-
class RectShape < Shape
|
11
|
-
|
12
|
-
def on_draw (e)
|
13
|
-
p, b = e.painter, e.bounds
|
14
|
-
attach_color_and_border(p) {p.rect b}
|
15
|
-
end
|
16
|
-
|
17
|
-
end# RectShape
|
18
|
-
|
19
|
-
|
20
|
-
end# Reflex
|
data/lib/reflex/shape.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
require 'reflex/view'
|
5
|
-
|
6
|
-
|
7
|
-
module Reflex
|
8
|
-
|
9
|
-
|
10
|
-
class Shape < View
|
11
|
-
|
12
|
-
attr_accessor :color, :border
|
13
|
-
|
14
|
-
def initialize (*args, &block)
|
15
|
-
@color = :white
|
16
|
-
@border = :none
|
17
|
-
super
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def attach_color_and_border (painter, &block)
|
23
|
-
fill, stroke = painter.color @color, @border
|
24
|
-
if block
|
25
|
-
block.call
|
26
|
-
painter.color fill, stroke
|
27
|
-
end
|
28
|
-
return fill, stroke
|
29
|
-
end
|
30
|
-
|
31
|
-
end# Shape
|
32
|
-
|
33
|
-
|
34
|
-
end# Reflex
|