opal-pixi 0.2.1 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/README.md +22 -30
- data/Rakefile +45 -0
- data/lib/opal/pixi.rb +1 -8
- data/lib/opal/pixi/base.rb +14 -0
- data/lib/opal/pixi/container.rb +32 -4
- data/lib/opal/pixi/core/display/container.rb +38 -0
- data/lib/opal/pixi/core/display/display_object.rb +44 -0
- data/lib/opal/pixi/core/files.rb +18 -0
- data/lib/opal/pixi/core/graphics/graphics.rb +42 -0
- data/lib/opal/pixi/core/graphics/graphics_data.rb +19 -0
- data/lib/opal/pixi/core/graphics/webgl/graphics_renderer.rb +0 -0
- data/lib/opal/pixi/core/graphics/webgl/web_gl_graphics_data.rb +11 -0
- data/lib/opal/pixi/core/math/matrix.rb +40 -0
- data/lib/opal/pixi/core/math/point.rb +24 -0
- data/lib/opal/pixi/core/math/shapes/circle.rb +26 -0
- data/lib/opal/pixi/core/math/shapes/ellipse.rb +28 -0
- data/lib/opal/pixi/core/math/shapes/polygon.rb +23 -0
- data/lib/opal/pixi/core/math/shapes/rectangle.rb +27 -0
- data/lib/opal/pixi/core/math/shapes/rounded_rectangle.rb +29 -0
- data/lib/opal/pixi/core/renderers/canvas/canvas_renderer.rb +19 -0
- data/lib/opal/pixi/core/renderers/system_renderer.rb +9 -0
- data/lib/opal/pixi/core/renderers/webgl/filters/abstract_filter.rb +16 -0
- data/lib/opal/pixi/core/renderers/webgl/webgl_renderer.rb +20 -0
- data/lib/opal/pixi/core/sprites/sprite.rb +47 -0
- data/lib/opal/pixi/core/text/text.rb +28 -0
- data/lib/opal/pixi/core/textures/render_texture.rb +17 -0
- data/lib/opal/pixi/core/textures/texture.rb +18 -0
- data/lib/opal/pixi/display_object.rb +41 -0
- data/lib/opal/pixi/extras/movie_clip.rb +16 -0
- data/lib/opal/pixi/extras/tiling_sprite.rb +18 -0
- data/lib/opal/pixi/interaction/interactive_target.rb +16 -0
- data/lib/opal/pixi/mesh/mesh.rb +9 -0
- data/lib/opal/pixi/mesh/rope.rb +14 -0
- data/lib/opal/pixi/point.rb +10 -6
- data/lib/opal/pixi/setup.rb +13 -0
- data/lib/opal/pixi/sprite.rb +37 -11
- data/lib/opal/pixi/texture.rb +7 -1
- data/lib/opal/pixi/version.rb +1 -1
- data/lib/opal/pixi/web_gl_renderer.rb +18 -7
- data/opal-pixi.gemspec +11 -9
- data/spec/spec_helper.rb +2 -0
- metadata +70 -18
- data/demo/Gemfile +0 -3
- data/demo/app/main.rb +0 -49
- data/demo/bunny.png +0 -0
- data/demo/config.ru +0 -11
- data/demo/index.html +0 -19
- data/demo/pixi.js +0 -27488
- data/demo/pixi.js.map +0 -1
- data/demo/pixi.min.js +0 -11
- data/demo/pixi.min.js.map +0 -1
- data/demo/pixi_main.js +0 -36
- data/demo/style.css +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a99f57549d2d962eae3275ed573faa53a93d7350
|
4
|
+
data.tar.gz: 99bebe3f31dc09fbfcf7f2a34aab53930738f442
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5657530b7bd0aa53ca5c8c96b3a148377ee9712ac4073e9f9f3ffe662b667e5537b4833b7dc9539559e7cd57d4e373da911cbda2b77fc39e873223e34e1ef40c
|
7
|
+
data.tar.gz: d4ae86ccf458287e1e130e60b4d228a340fed9fa7529e9d59087fcfbe15910f5a9ff20ec272f150af99aeaae18f2cba99b50924b0230cc040bbc0dd1b54b3a3b
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,45 +1,37 @@
|
|
1
1
|
## Ruby wrapper for the Pixi.js graphical library
|
2
2
|
|
3
|
-
|
3
|
+
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/orbitalimpact/opal-pixi?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
4
|
|
5
|
-
|
6
|
-
- "it's fast. Really fast"
|
5
|
+
The goal of this project is to completely wrap the Pixi API in Opal, to allow developers to write HTML5 and WebGL rendering from Ruby.
|
7
6
|
|
8
|
-
|
9
|
-
It's low-ish level, but very useful and **fast** .
|
7
|
+
If you have not heard of Pixi, check out these links:
|
10
8
|
|
11
|
-
|
12
|
-
|
9
|
+
* Pixi: https://github.com/GoodBoyDigital/pixi.js/
|
10
|
+
* Pixi Examples: https://github.com/pixijs/examples
|
13
11
|
|
12
|
+
Also, to get examples of opal-pixi in action, check out the [opal-pixi-examples repository](https://github.com/ktec/opal-pixi-examples).
|
14
13
|
|
15
|
-
|
14
|
+
## Cloning this repository
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
### Usage
|
22
|
-
|
23
|
-
Check out the [demo code](https://github.com/orbitalimpact/opal-pixi/blob/master/demo/app/main.rb)
|
24
|
-
and read the [pixi resources](https://github.com/GoodBoyDigital/pixi.js/wiki/Resources)
|
16
|
+
```
|
17
|
+
$ git clone https://github.com/orbitalimpact/opal-pixi
|
18
|
+
```
|
25
19
|
|
26
|
-
|
27
|
-
You can add things to display to a container,
|
28
|
-
like Sprites (with texture) and all sorts of objects and collections thereof.
|
20
|
+
## Getting involved
|
29
21
|
|
30
|
-
|
22
|
+
To contribute to this project, follow the steps below.
|
31
23
|
|
32
|
-
|
33
|
-
|
24
|
+
1. Fork the repo ( https://github.com/orbitalimpact/opal-pixi/fork )
|
25
|
+
2. Create your feature branch (`git checkout -b new-branch`)
|
26
|
+
3. Commit your changes (`git commit -am 'description of commit'`)
|
27
|
+
4. Push to the branch (`git push origin new-branch`)
|
28
|
+
5. Create a Pull Request
|
34
29
|
|
35
|
-
|
30
|
+
## Licenses
|
36
31
|
|
37
|
-
|
32
|
+
Phaser and all examples are released under the MIT License: http://opensource.org/licenses/MIT
|
38
33
|
|
39
|
-
|
40
|
-
cd demo
|
41
|
-
bundle
|
42
|
-
bundle exec rackup
|
43
|
-
```
|
34
|
+
opal-pixi is released under the Berkeley Software Distribution (BSD) 3-Clause License: http://opensource.org/licenses/BSD-3-Clause
|
44
35
|
|
45
|
-
|
36
|
+
Copyright (c) 2015, Orbital Impact
|
37
|
+
All rights reserved.
|
data/Rakefile
CHANGED
@@ -1,3 +1,48 @@
|
|
1
1
|
require 'bundler'
|
2
2
|
Bundler.require
|
3
3
|
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
require 'opal/rspec/rake_task'
|
6
|
+
Opal::RSpec::RakeTask.new(:default) do |s|
|
7
|
+
s.index_path = 'spec/html/index.html.erb'
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Build build/opal-pixi.js"
|
11
|
+
task :dist do
|
12
|
+
require 'fileutils'
|
13
|
+
FileUtils.mkdir_p 'build'
|
14
|
+
|
15
|
+
src = Opal::Builder.build('opal-pixi')
|
16
|
+
#min = uglify src
|
17
|
+
#gzp = gzip min
|
18
|
+
|
19
|
+
File.open('build/opal-pixi.js', 'w+') do |out|
|
20
|
+
out << src
|
21
|
+
end
|
22
|
+
|
23
|
+
#puts "development: #{src.size}, minified: #{min.size}, gzipped: #{gzp.size}"
|
24
|
+
end
|
25
|
+
|
26
|
+
# Used for uglifying source to minify
|
27
|
+
def uglify(str)
|
28
|
+
IO.popen('uglifyjs', 'r+') do |i|
|
29
|
+
i.puts str
|
30
|
+
i.close_write
|
31
|
+
return i.read
|
32
|
+
end
|
33
|
+
rescue Errno::ENOENT
|
34
|
+
$stderr.puts '"uglifyjs" command not found (install with: "npm install -g uglify-js")'
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
|
38
|
+
# Gzip code to check file size
|
39
|
+
def gzip(str)
|
40
|
+
IO.popen('gzip -f', 'r+') do |i|
|
41
|
+
i.puts str
|
42
|
+
i.close_write
|
43
|
+
return i.read
|
44
|
+
end
|
45
|
+
rescue Errno::ENOENT
|
46
|
+
$stderr.puts '"gzip" command not found, it is required to produce the .gz version'
|
47
|
+
nil
|
48
|
+
end
|
data/lib/opal/pixi.rb
CHANGED
@@ -1,12 +1,5 @@
|
|
1
1
|
if RUBY_ENGINE == 'opal'
|
2
|
-
require '
|
3
|
-
require 'opal/pixi/container'
|
4
|
-
require 'opal/pixi/graphics'
|
5
|
-
require 'opal/pixi/web_gl_renderer'
|
6
|
-
require 'opal/pixi/sprite'
|
7
|
-
require 'opal/pixi/text'
|
8
|
-
require 'opal/pixi/point'
|
9
|
-
require 'opal/pixi/texture'
|
2
|
+
require 'opal/pixi/setup'
|
10
3
|
else
|
11
4
|
require 'opal'
|
12
5
|
require 'opal/pixi/version'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module PIXI
|
2
|
+
module Base
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
base.class_eval do
|
6
|
+
name = "window.#{self.name.split('::').join('.')}"
|
7
|
+
code = "self._proto = #{name}.prototype, def = self._proto; #{name}.prototype._klass = self"
|
8
|
+
# %x{ alert(code) }
|
9
|
+
%x{ eval(code) }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
data/lib/opal/pixi/container.rb
CHANGED
@@ -1,12 +1,40 @@
|
|
1
|
+
require 'native'
|
2
|
+
require './base'
|
3
|
+
require './display_object'
|
4
|
+
|
1
5
|
module PIXI
|
2
|
-
class Container
|
6
|
+
class Container < PIXI::DisplayObject
|
3
7
|
include Native
|
4
8
|
|
5
|
-
|
6
|
-
|
9
|
+
%x{
|
10
|
+
self._proto = window.PIXI.Container.prototype, def = self._proto;
|
11
|
+
window.PIXI.Container.prototype._klass = self;
|
12
|
+
}
|
13
|
+
|
14
|
+
def self.new(color)
|
15
|
+
`new window.PIXI.Container(color)`
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_child(child)
|
19
|
+
`self.addChild(child)`
|
20
|
+
end
|
21
|
+
|
22
|
+
def x
|
23
|
+
`self.position.x`
|
24
|
+
end
|
25
|
+
|
26
|
+
def x=(x)
|
27
|
+
`self.position.x = x`
|
28
|
+
end
|
29
|
+
|
30
|
+
def y
|
31
|
+
`self.position.y`
|
32
|
+
end
|
33
|
+
|
34
|
+
def y=(y)
|
35
|
+
`self.position.y = y`
|
7
36
|
end
|
8
37
|
|
9
|
-
alias_native :add_child, :addChild
|
10
38
|
|
11
39
|
end
|
12
40
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'opal/pixi/core/display/display_object'
|
2
|
+
require 'opal/pixi/interaction/interactive_target'
|
3
|
+
|
4
|
+
module PIXI
|
5
|
+
class Container
|
6
|
+
include Native
|
7
|
+
include PIXI::DisplayObject
|
8
|
+
include PIXI::InteractiveTarget
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super(`new PIXI.Container()`)
|
12
|
+
end
|
13
|
+
|
14
|
+
alias_native :children
|
15
|
+
|
16
|
+
alias_native :width
|
17
|
+
alias_native :width=
|
18
|
+
alias_native :height
|
19
|
+
alias_native :height=
|
20
|
+
|
21
|
+
alias_native :add_child, :addChild
|
22
|
+
alias_native :add_child_at, :addChildAt
|
23
|
+
alias_native :swap_children, :swapChildren
|
24
|
+
alias_native :get_child_index, :getChildIndex
|
25
|
+
alias_native :set_child_index, :setChildIndex
|
26
|
+
alias_native :get_child_at, :getChildAt
|
27
|
+
alias_native :remove_child, :removeChild
|
28
|
+
alias_native :remove_child_at, :removeChildAt
|
29
|
+
alias_native :remove_children, :removeChildren
|
30
|
+
alias_native :generate_texture, :generateTexture # renderer, resolution, scaleMode
|
31
|
+
alias_native :get_bounds, :getBounds
|
32
|
+
alias_native :get_local_bounds, :getLocalBounds
|
33
|
+
alias_native :render_webGL, :renderWebGL # WebGLRenderer
|
34
|
+
alias_native :render_canvas, :renderCanvas # CanvasRenderer
|
35
|
+
alias_native :destroy # destroyChildren=false
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'opal/pixi/core/math/point'
|
2
|
+
|
3
|
+
module PIXI
|
4
|
+
module DisplayObject
|
5
|
+
include Native
|
6
|
+
|
7
|
+
alias_native :x
|
8
|
+
alias_native :x=
|
9
|
+
alias_native :y
|
10
|
+
alias_native :y=
|
11
|
+
|
12
|
+
alias_native :position, :position, as: Point
|
13
|
+
alias_native :position=
|
14
|
+
alias_native :scale, :scale, as: Point
|
15
|
+
alias_native :scale=
|
16
|
+
alias_native :pivot, :pivot, as: Point
|
17
|
+
alias_native :pivot=
|
18
|
+
alias_native :rotation
|
19
|
+
alias_native :rotation=
|
20
|
+
alias_native :alpha
|
21
|
+
alias_native :alpha=
|
22
|
+
alias_native :visible
|
23
|
+
alias_native :visible=
|
24
|
+
alias_native :renderable
|
25
|
+
alias_native :renderable=
|
26
|
+
|
27
|
+
alias_native :parent
|
28
|
+
alias_native :world_alpha, :worldAlpha
|
29
|
+
alias_native :world_transform, :worldTransform
|
30
|
+
|
31
|
+
alias_native :filter_area, :filterArea
|
32
|
+
alias_native :filter_area=
|
33
|
+
|
34
|
+
alias_native :world_visible, :worldVisible
|
35
|
+
alias_native :mask
|
36
|
+
alias_native :mask=
|
37
|
+
|
38
|
+
alias_native :filters
|
39
|
+
alias_native :filters=
|
40
|
+
|
41
|
+
alias_native :destroy
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# These requires must be loaded in order of dependency:
|
2
|
+
# TODO: look into why `puts File.dirname(__FILE__)` is not working for Opal
|
3
|
+
|
4
|
+
require 'opal/pixi/core/display/container'
|
5
|
+
require 'opal/pixi/core/display/display_object'
|
6
|
+
require 'opal/pixi/core/renderers/webgl/filters/abstract_filter'
|
7
|
+
require 'opal/pixi/core/renderers/webgl/webgl_renderer'
|
8
|
+
#require 'opal/pixi/core/renderers/system_renderer'
|
9
|
+
require 'opal/pixi/core/graphics/graphics'
|
10
|
+
# require 'opal/pixi/core/math'
|
11
|
+
# require 'opal/pixi/core/particles'
|
12
|
+
# require 'opal/pixi/core/renderers'
|
13
|
+
require 'opal/pixi/core/sprites/sprite'
|
14
|
+
require 'opal/pixi/core/text/text'
|
15
|
+
require 'opal/pixi/core/textures/texture'
|
16
|
+
require 'opal/pixi/core/textures/render_texture'
|
17
|
+
# require 'opal/pixi/core/ticker'
|
18
|
+
# require 'opal/pixi/core/utils'
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'opal/pixi/core/display/display_object'
|
2
|
+
|
3
|
+
module PIXI
|
4
|
+
class Graphics < Container
|
5
|
+
include Native
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super(`new PIXI.Graphics()`)
|
9
|
+
end
|
10
|
+
|
11
|
+
alias_native :fill_alpha, :fillAlpha
|
12
|
+
alias_native :line_width, :lineWidth
|
13
|
+
alias_native :line_color, :lineColor
|
14
|
+
alias_native :tint
|
15
|
+
alias_native :blend_mode, :blendMode
|
16
|
+
alias_native :is_mask, :isMask
|
17
|
+
alias_native :bounds_padding, :boundsPadding
|
18
|
+
alias_native :clone
|
19
|
+
alias_native :line_style, :lineStyle
|
20
|
+
alias_native :move_to, :moveTo
|
21
|
+
alias_native :line_to, :lineTo
|
22
|
+
alias_native :quadratic_curve_to, :quadraticCurveTo
|
23
|
+
alias_native :bezier_curve_to, :bezierCurveTo
|
24
|
+
alias_native :arc_to, :arcTo
|
25
|
+
alias_native :arc
|
26
|
+
alias_native :begin_fill, :beginFill
|
27
|
+
alias_native :end_fill, :endFill
|
28
|
+
alias_native :draw_rect, :drawRect
|
29
|
+
alias_native :draw_rounded_rect, :drawRoundedRect
|
30
|
+
alias_native :draw_circle, :drawCircle
|
31
|
+
alias_native :draw_ellipse, :drawEllipse
|
32
|
+
alias_native :draw_polygon, :drawPolygon
|
33
|
+
alias_native :clear
|
34
|
+
alias_native :generate_texture, :generateTexture
|
35
|
+
alias_native :get_bounds, :getBounds
|
36
|
+
alias_native :contains_point, :containsPoint
|
37
|
+
alias_native :update_local_bounds, :updateLocalBounds
|
38
|
+
alias_native :draw_shape, :drawShape
|
39
|
+
alias_native :destroy
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module PIXI
|
2
|
+
class GraphicsData
|
3
|
+
include Native
|
4
|
+
|
5
|
+
def initialize(lineWidth, lineColor, lineAlpha, fillColor, fillAlpha, fill, shape)
|
6
|
+
super(`new PIXI.GraphicsData(lineWidth, lineColor, lineAlpha, fillColor, fillAlpha, fill, shape)`)
|
7
|
+
end
|
8
|
+
|
9
|
+
alias_native :line_width, :lineWidth
|
10
|
+
alias_native :line_color, :lineColor
|
11
|
+
alias_native :line_alpha, :lineAlpha
|
12
|
+
alias_native :fill_color, :fillColor
|
13
|
+
alias_native :fill_alpha, :fillAlpha
|
14
|
+
alias_native :fill
|
15
|
+
alias_native :shape
|
16
|
+
alias_native :type
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
File without changes
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module PIXI
|
2
|
+
class Matrix
|
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.Matrix(x_or_native, y)`)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
alias_native :a
|
14
|
+
alias_native :a=
|
15
|
+
alias_native :b
|
16
|
+
alias_native :b=
|
17
|
+
alias_native :c
|
18
|
+
alias_native :c=
|
19
|
+
alias_native :d
|
20
|
+
alias_native :d=
|
21
|
+
alias_native :tx
|
22
|
+
alias_native :tx=
|
23
|
+
alias_native :ty
|
24
|
+
alias_native :ty=
|
25
|
+
|
26
|
+
alias_native :from_array, :fromArray
|
27
|
+
alias_native :to_array, :toArray
|
28
|
+
alias_native :apply
|
29
|
+
alias_native :apply_inverse, :applyInverse
|
30
|
+
alias_native :translate
|
31
|
+
alias_native :scale
|
32
|
+
alias_native :rotate
|
33
|
+
alias_native :append
|
34
|
+
alias_native :prepend
|
35
|
+
alias_native :invert
|
36
|
+
alias_native :identity
|
37
|
+
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module PIXI
|
2
|
+
class Point
|
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
|
11
|
+
end
|
12
|
+
|
13
|
+
alias_native :x
|
14
|
+
alias_native :x=
|
15
|
+
alias_native :y
|
16
|
+
alias_native :y=
|
17
|
+
|
18
|
+
alias_native :clone
|
19
|
+
alias_native :copy
|
20
|
+
alias_native :equals
|
21
|
+
alias_native :set
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|