opal-pixi 0.0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +11 -11
- data/README.md +45 -0
- data/demo/Gemfile +0 -1
- data/demo/Gemfile.lock +11 -11
- data/demo/app/main.rb +29 -9
- data/demo/index.html +2 -2
- data/demo/pixi.js +27488 -0
- data/demo/pixi.js.map +1 -0
- data/demo/pixi.min.js +11 -0
- data/demo/pixi.min.js.map +1 -0
- data/demo/{main.js → pixi_main.js} +0 -0
- data/lib/opal/pixi/container.rb +12 -0
- data/lib/opal/pixi/graphics.rb +28 -0
- data/lib/opal/pixi/point.rb +61 -7
- data/lib/opal/pixi/sprite.rb +22 -21
- data/lib/opal/pixi/text.rb +22 -0
- data/lib/opal/pixi/texture.rb +4 -5
- data/lib/opal/pixi/version.rb +1 -1
- data/lib/opal/pixi/web_gl_renderer.rb +12 -13
- data/lib/opal/pixi.rb +4 -1
- data/opal-pixi.gemspec +3 -3
- metadata +15 -9
- data/lib/opal/pixi/stage.rb +0 -16
File without changes
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module PIXI
|
2
|
+
class Graphics #< `PIXI.Graphics`
|
3
|
+
include Native
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
super(`new PIXI.Graphics()`)
|
7
|
+
end
|
8
|
+
|
9
|
+
alias_native :height
|
10
|
+
alias_native :isMask
|
11
|
+
alias_native :lineColor
|
12
|
+
alias_native :lineWidth
|
13
|
+
|
14
|
+
alias_native :worldVisible
|
15
|
+
alias_native :clear
|
16
|
+
alias_native :beginFill
|
17
|
+
alias_native :lineStyle
|
18
|
+
|
19
|
+
alias_native :moveTo
|
20
|
+
alias_native :quadraticCurveTo
|
21
|
+
alias_native :drawRect
|
22
|
+
alias_native :bezierCurveTo
|
23
|
+
alias_native :lineTo
|
24
|
+
|
25
|
+
alias_native :add_child, :addChild
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
data/lib/opal/pixi/point.rb
CHANGED
@@ -1,12 +1,66 @@
|
|
1
|
-
|
2
1
|
module PIXI
|
3
2
|
class Point
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
include Native
|
4
|
+
|
5
|
+
def self.new(x_or_native , y)
|
6
|
+
if native?(x_or_native)
|
7
|
+
super(x_or_native)
|
8
|
+
else
|
9
|
+
super(`new PIXI.Point(x_or_native, y)`)
|
10
|
+
end
|
10
11
|
end
|
12
|
+
|
13
|
+
alias_native :set
|
14
|
+
alias_native :x
|
15
|
+
alias_native :y
|
16
|
+
|
17
|
+
alias_native :x=
|
18
|
+
alias_native :y=
|
19
|
+
|
20
|
+
# just add another point to this one
|
21
|
+
# return self for chaining
|
22
|
+
def add point
|
23
|
+
self.x += point.x
|
24
|
+
self.y += point.y
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
# add a point (the first arg), but "bounce" off the wall, second arg
|
29
|
+
# second arg is a pint that defines a rectangle with 0,0
|
30
|
+
# if the adding makes the point go beyond the rectangle it bounces off the wall back in
|
31
|
+
def add_and_bounce distance , wall
|
32
|
+
self.add(distance).bounce(wall)
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
# check if the point is outside the rectangle spanned by the wall arg (a point)
|
37
|
+
def bounce wall
|
38
|
+
self.x = - self.x if self.x < 0
|
39
|
+
self.x = wall.x - (self.x - wall.x) if self.x > wall.x
|
40
|
+
self.y = -self.y if self.y < 0
|
41
|
+
self.y = wall.y - (self.y - wall.y) if self.y > wall.y
|
42
|
+
end
|
43
|
+
|
44
|
+
# scale the point down by the given factor.
|
45
|
+
# off course for factors smaller than 1 that means it gets bigger
|
46
|
+
# try to avoid 0 division by applying a minimum of 0.0001
|
47
|
+
def scale_by num
|
48
|
+
min = 0.001
|
49
|
+
num = min if num < min and num > -min
|
50
|
+
self.x = self.x / num
|
51
|
+
self.y = self.y / num
|
52
|
+
self
|
53
|
+
end
|
54
|
+
|
55
|
+
# return new point with same x coordiante but the given y
|
56
|
+
def at_y new_y
|
57
|
+
PIXI::Point.new(self.x ,new_y)
|
58
|
+
end
|
59
|
+
|
60
|
+
# return new point with same y coordiante but the given x
|
61
|
+
def at_x new_x
|
62
|
+
PIXI::Point.new(new_x , self.y)
|
63
|
+
end
|
64
|
+
|
11
65
|
end
|
12
66
|
end
|
data/lib/opal/pixi/sprite.rb
CHANGED
@@ -1,26 +1,27 @@
|
|
1
|
+
require 'opal/pixi/point'
|
2
|
+
require 'pp'
|
3
|
+
|
1
4
|
module PIXI
|
2
5
|
class Sprite
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
Point.new `#{self}.anchor.x`,`#{self}.anchor.y`
|
12
|
-
end
|
13
|
-
def rotation
|
14
|
-
`self.rotation`
|
15
|
-
end
|
16
|
-
def rotation=(r)
|
17
|
-
`self.rotation = r`
|
18
|
-
end
|
19
|
-
def anchor=(a)
|
20
|
-
`self.anchor = a`
|
21
|
-
end
|
22
|
-
def position=(p)
|
23
|
-
`self.position = p`
|
6
|
+
include Native
|
7
|
+
|
8
|
+
def initialize(native_or_texture)
|
9
|
+
if native?(native_or_texture)
|
10
|
+
super
|
11
|
+
else
|
12
|
+
super `new PIXI.Sprite(#{native_or_texture.to_n})`
|
13
|
+
end
|
24
14
|
end
|
15
|
+
|
16
|
+
|
17
|
+
alias_native :anchor, :anchor, as: Point
|
18
|
+
alias_native :rotation
|
19
|
+
alias_native :interactive=
|
20
|
+
alias_native :position, :position, as: Point
|
21
|
+
alias_native :on
|
22
|
+
alias_native :anchor=
|
23
|
+
alias_native :position=
|
24
|
+
alias_native :rotation=
|
25
|
+
|
25
26
|
end
|
26
27
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module PIXI
|
2
|
+
class Text
|
3
|
+
include Native
|
4
|
+
|
5
|
+
# options according to http://pixijs.github.io/docs/PIXI.Text.html
|
6
|
+
def initialize(x_or_native, y)
|
7
|
+
if native?(x_or_native)
|
8
|
+
super(x_or_native)
|
9
|
+
else
|
10
|
+
super(`new PIXI.Text(x_or_native,y)`)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
alias_native :width
|
15
|
+
alias_native :position, :position, as: Point
|
16
|
+
|
17
|
+
alias_native :position=
|
18
|
+
alias_native :text=
|
19
|
+
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/lib/opal/pixi/texture.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
module PIXI
|
2
2
|
class Texture
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
}
|
3
|
+
|
4
|
+
include Native
|
5
|
+
|
7
6
|
def self.from_image(name)
|
8
|
-
`
|
7
|
+
new(`PIXI.Texture.fromImage(name)`)
|
9
8
|
end
|
10
9
|
end
|
11
10
|
end
|
data/lib/opal/pixi/version.rb
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
module PIXI
|
2
|
-
class WebGLRenderer
|
3
|
-
|
4
|
-
#{self}._proto = window.PIXI.WebGLRenderer.prototype, def = #{self}._proto;
|
5
|
-
window.PIXI.WebGLRenderer.prototype._klass = #{self};
|
6
|
-
}
|
7
|
-
def self.new(width, height)
|
8
|
-
`new window.PIXI.WebGLRenderer(width, height)`
|
9
|
-
end
|
2
|
+
class WebGLRenderer #< `PIXI.WebGLRenderer`
|
3
|
+
include Native
|
10
4
|
|
11
|
-
def
|
12
|
-
|
5
|
+
def initialize(w_or_native, height, options)
|
6
|
+
if native?(w_or_native)
|
7
|
+
super(w_or_native)
|
8
|
+
else
|
9
|
+
super(`new PIXI.WebGLRenderer(w_or_native, height , #{ options.to_n })`)
|
10
|
+
end
|
13
11
|
end
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
alias_native :render
|
14
|
+
alias_native :view
|
15
|
+
alias_native :width
|
16
|
+
|
18
17
|
end
|
19
18
|
end
|
data/lib/opal/pixi.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
if RUBY_ENGINE == 'opal'
|
2
|
-
require '
|
2
|
+
require 'native'
|
3
|
+
require 'opal/pixi/container'
|
4
|
+
require 'opal/pixi/graphics'
|
3
5
|
require 'opal/pixi/web_gl_renderer'
|
4
6
|
require 'opal/pixi/sprite'
|
7
|
+
require 'opal/pixi/text'
|
5
8
|
require 'opal/pixi/point'
|
6
9
|
require 'opal/pixi/texture'
|
7
10
|
else
|
data/opal-pixi.gemspec
CHANGED
@@ -7,14 +7,14 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.authors = [ 'George D. Plymale II', 'Gabriel Rios' ]
|
8
8
|
s.email = [ 'gabrielfalcaorios@gmail.com']
|
9
9
|
s.homepage = 'http://github.com/orbitalimpact/opal-pixi'
|
10
|
-
s.summary =
|
11
|
-
s.description =
|
10
|
+
s.summary = 'Pixi wrapper for opal'
|
11
|
+
s.description = 'Pixi wrapper for opal'
|
12
12
|
|
13
13
|
s.files = `git ls-files`.split("\n")
|
14
14
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
16
|
s.require_paths = ['lib']
|
17
17
|
|
18
|
-
s.add_runtime_dependency 'opal', '~> 0.
|
18
|
+
s.add_runtime_dependency 'opal', '~> 0.7.0'
|
19
19
|
s.add_development_dependency 'rake'
|
20
20
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-pixi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George D. Plymale II
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-07-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: opal
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.
|
20
|
+
version: 0.7.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.
|
27
|
+
version: 0.7.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
|
-
description:
|
42
|
+
description: Pixi wrapper for opal
|
43
43
|
email:
|
44
44
|
- gabrielfalcaorios@gmail.com
|
45
45
|
executables: []
|
@@ -56,13 +56,19 @@ files:
|
|
56
56
|
- demo/bunny.png
|
57
57
|
- demo/config.ru
|
58
58
|
- demo/index.html
|
59
|
-
- demo/
|
59
|
+
- demo/pixi.js
|
60
|
+
- demo/pixi.js.map
|
61
|
+
- demo/pixi.min.js
|
62
|
+
- demo/pixi.min.js.map
|
63
|
+
- demo/pixi_main.js
|
60
64
|
- demo/style.css
|
61
65
|
- lib/opal-pixi.rb
|
62
66
|
- lib/opal/pixi.rb
|
67
|
+
- lib/opal/pixi/container.rb
|
68
|
+
- lib/opal/pixi/graphics.rb
|
63
69
|
- lib/opal/pixi/point.rb
|
64
70
|
- lib/opal/pixi/sprite.rb
|
65
|
-
- lib/opal/pixi/
|
71
|
+
- lib/opal/pixi/text.rb
|
66
72
|
- lib/opal/pixi/texture.rb
|
67
73
|
- lib/opal/pixi/version.rb
|
68
74
|
- lib/opal/pixi/web_gl_renderer.rb
|
@@ -86,8 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
92
|
version: '0'
|
87
93
|
requirements: []
|
88
94
|
rubyforge_project:
|
89
|
-
rubygems_version: 2.
|
95
|
+
rubygems_version: 2.4.5
|
90
96
|
signing_key:
|
91
97
|
specification_version: 4
|
92
|
-
summary:
|
98
|
+
summary: Pixi wrapper for opal
|
93
99
|
test_files: []
|
data/lib/opal/pixi/stage.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module PIXI
|
2
|
-
class Stage
|
3
|
-
%x{
|
4
|
-
#{self}._proto = window.PIXI.Stage.prototype, def = #{self}._proto;
|
5
|
-
window.PIXI.Stage.prototype._klass = #{self};
|
6
|
-
}
|
7
|
-
|
8
|
-
def self.new(color)
|
9
|
-
`new window.PIXI.Stage(color)`
|
10
|
-
end
|
11
|
-
|
12
|
-
def add_child(child)
|
13
|
-
`#{self}.addChild(child)`
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|