opal-pixi 0.2.1 → 0.3.4

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 (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/README.md +22 -30
  4. data/Rakefile +45 -0
  5. data/lib/opal/pixi.rb +1 -8
  6. data/lib/opal/pixi/base.rb +14 -0
  7. data/lib/opal/pixi/container.rb +32 -4
  8. data/lib/opal/pixi/core/display/container.rb +38 -0
  9. data/lib/opal/pixi/core/display/display_object.rb +44 -0
  10. data/lib/opal/pixi/core/files.rb +18 -0
  11. data/lib/opal/pixi/core/graphics/graphics.rb +42 -0
  12. data/lib/opal/pixi/core/graphics/graphics_data.rb +19 -0
  13. data/lib/opal/pixi/core/graphics/webgl/graphics_renderer.rb +0 -0
  14. data/lib/opal/pixi/core/graphics/webgl/web_gl_graphics_data.rb +11 -0
  15. data/lib/opal/pixi/core/math/matrix.rb +40 -0
  16. data/lib/opal/pixi/core/math/point.rb +24 -0
  17. data/lib/opal/pixi/core/math/shapes/circle.rb +26 -0
  18. data/lib/opal/pixi/core/math/shapes/ellipse.rb +28 -0
  19. data/lib/opal/pixi/core/math/shapes/polygon.rb +23 -0
  20. data/lib/opal/pixi/core/math/shapes/rectangle.rb +27 -0
  21. data/lib/opal/pixi/core/math/shapes/rounded_rectangle.rb +29 -0
  22. data/lib/opal/pixi/core/renderers/canvas/canvas_renderer.rb +19 -0
  23. data/lib/opal/pixi/core/renderers/system_renderer.rb +9 -0
  24. data/lib/opal/pixi/core/renderers/webgl/filters/abstract_filter.rb +16 -0
  25. data/lib/opal/pixi/core/renderers/webgl/webgl_renderer.rb +20 -0
  26. data/lib/opal/pixi/core/sprites/sprite.rb +47 -0
  27. data/lib/opal/pixi/core/text/text.rb +28 -0
  28. data/lib/opal/pixi/core/textures/render_texture.rb +17 -0
  29. data/lib/opal/pixi/core/textures/texture.rb +18 -0
  30. data/lib/opal/pixi/display_object.rb +41 -0
  31. data/lib/opal/pixi/extras/movie_clip.rb +16 -0
  32. data/lib/opal/pixi/extras/tiling_sprite.rb +18 -0
  33. data/lib/opal/pixi/interaction/interactive_target.rb +16 -0
  34. data/lib/opal/pixi/mesh/mesh.rb +9 -0
  35. data/lib/opal/pixi/mesh/rope.rb +14 -0
  36. data/lib/opal/pixi/point.rb +10 -6
  37. data/lib/opal/pixi/setup.rb +13 -0
  38. data/lib/opal/pixi/sprite.rb +37 -11
  39. data/lib/opal/pixi/texture.rb +7 -1
  40. data/lib/opal/pixi/version.rb +1 -1
  41. data/lib/opal/pixi/web_gl_renderer.rb +18 -7
  42. data/opal-pixi.gemspec +11 -9
  43. data/spec/spec_helper.rb +2 -0
  44. metadata +70 -18
  45. data/demo/Gemfile +0 -3
  46. data/demo/app/main.rb +0 -49
  47. data/demo/bunny.png +0 -0
  48. data/demo/config.ru +0 -11
  49. data/demo/index.html +0 -19
  50. data/demo/pixi.js +0 -27488
  51. data/demo/pixi.js.map +0 -1
  52. data/demo/pixi.min.js +0 -11
  53. data/demo/pixi.min.js.map +0 -1
  54. data/demo/pixi_main.js +0 -36
  55. data/demo/style.css +0 -5
@@ -0,0 +1,26 @@
1
+ module PIXI
2
+ class Circle
3
+ include Native
4
+
5
+ def self.new(x_or_native, y, radius)
6
+ if native?(x_or_native)
7
+ super(x_or_native)
8
+ else
9
+ super(`new PIXI.Circle(x_or_native, y, radius)`)
10
+ end
11
+ end
12
+
13
+ alias_native :x
14
+ alias_native :x=
15
+ alias_native :y
16
+ alias_native :y=
17
+ alias_native :radius
18
+ alias_native :radius=
19
+ alias_native :type
20
+
21
+ alias_native :clone
22
+ alias_native :contains
23
+ alias_native :get_bounds, :getBounds
24
+
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ module PIXI
2
+ class Ellipse
3
+ include Native
4
+
5
+ def self.new(x_or_native, y, width, height)
6
+ if native?(x_or_native)
7
+ super(x_or_native)
8
+ else
9
+ super(`new PIXI.Ellipse(x_or_native, y, width, height)`)
10
+ end
11
+ end
12
+
13
+ alias_native :x
14
+ alias_native :x=
15
+ alias_native :y
16
+ alias_native :y=
17
+ alias_native :width
18
+ alias_native :width=
19
+ alias_native :height
20
+ alias_native :height=
21
+ alias_native :type
22
+
23
+ alias_native :clone
24
+ alias_native :contains
25
+ alias_native :get_bounds, :getBounds
26
+
27
+ end
28
+ end
@@ -0,0 +1,23 @@
1
+ module PIXI
2
+ class Polygon
3
+ include Native
4
+
5
+ def self.new(points_or_native)
6
+ if native?(points_or_native)
7
+ super(points_or_native)
8
+ else
9
+ super(`new PIXI.Polygon(points_or_native)`)
10
+ end
11
+ end
12
+
13
+ alias_native :points
14
+ alias_native :points=
15
+ alias_native :closed
16
+ alias_native :closed=
17
+ alias_native :type
18
+
19
+ alias_native :clone
20
+ alias_native :contains
21
+
22
+ end
23
+ end
@@ -0,0 +1,27 @@
1
+ module PIXI
2
+ class Rectange
3
+ include Native
4
+
5
+ def self.new(x_or_native, y, width, height)
6
+ if native?(x_or_native)
7
+ super(x_or_native)
8
+ else
9
+ super(`new PIXI.Rectangle(x_or_native, y, width, height)`)
10
+ end
11
+ end
12
+
13
+ alias_native :x
14
+ alias_native :x=
15
+ alias_native :y
16
+ alias_native :y=
17
+ alias_native :width
18
+ alias_native :width=
19
+ alias_native :height
20
+ alias_native :height=
21
+ alias_native :type
22
+
23
+ alias_native :clone
24
+ alias_native :contains
25
+
26
+ end
27
+ end
@@ -0,0 +1,29 @@
1
+ module PIXI
2
+ class RoundedRectangle < Rectange
3
+ include Native
4
+
5
+ def self.new(x_or_native, y, width, height, radius)
6
+ if native?(x_or_native)
7
+ super(x_or_native)
8
+ else
9
+ super(`new PIXI.Rectangle(x_or_native, y, width, height, radius)`)
10
+ end
11
+ end
12
+
13
+ alias_native :x
14
+ alias_native :x=
15
+ alias_native :y
16
+ alias_native :y=
17
+ alias_native :width
18
+ alias_native :width=
19
+ alias_native :height
20
+ alias_native :height=
21
+ alias_native :radius
22
+ alias_native :radius=
23
+ alias_native :type
24
+
25
+ alias_native :clone
26
+ alias_native :contains
27
+
28
+ end
29
+ end
@@ -0,0 +1,19 @@
1
+ module PIXI
2
+ class CanvasRenderer
3
+ include Native
4
+
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.CanvasRenderer(w_or_native, height, #{ options.to_n })`)
10
+ end
11
+ end
12
+
13
+ alias_native :render
14
+ alias_native :view
15
+ alias_native :width
16
+ alias_native :height
17
+
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ module PIXI
2
+ class SystemRenderer
3
+ include Native
4
+
5
+ alias_native :width
6
+ alias_native :height
7
+
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ module PIXI
2
+ class AbstractFilter
3
+ include Native
4
+
5
+ def initialize(vertexSrc, fragmentSrc, uniforms={})
6
+ super(`new PIXI.AbstractFilter(vertexSrc, fragmentSrc, #{uniforms.to_n})`)
7
+ end
8
+
9
+ alias_native :padding
10
+ alias_native :uniforms
11
+ alias_native :get_shader, :getShader
12
+ alias_native :apply_filter, :applyFilter
13
+ alias_native :sync_uniform, :syncUniform
14
+
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ module PIXI
2
+ class WebGLRenderer
3
+ include Native
4
+
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
11
+ end
12
+
13
+ alias_native :render
14
+ alias_native :destroy
15
+ alias_native :view
16
+ alias_native :width
17
+ alias_native :height
18
+
19
+ end
20
+ end
@@ -0,0 +1,47 @@
1
+ require 'opal/pixi/core/display/container'
2
+ require 'opal/pixi/core/math/point'
3
+ require 'opal/pixi/core/textures/texture'
4
+ require 'opal/pixi/interaction/interactive_target'
5
+
6
+ module PIXI
7
+ class Sprite #< Container
8
+ include Native
9
+ include PIXI::DisplayObject
10
+ include PIXI::InteractiveTarget
11
+
12
+ def self.from_image(imageId, crossorigin=false, scaleMode='')
13
+ new(`PIXI.Sprite.fromImage(imageId, crossorigin, scaleMode)`)
14
+ end
15
+
16
+ def self.from_frame(frameId)
17
+ new(`PIXI.Sprite.fromFrame(frameId)`)
18
+ end
19
+
20
+ def initialize(native_or_texture)
21
+ if native?(native_or_texture)
22
+ super
23
+ else
24
+ super(`new PIXI.Sprite(#{native_or_texture.to_n})`)
25
+ end
26
+ end
27
+
28
+ alias_native :anchor, :anchor, as: Point
29
+ alias_native :anchor=
30
+ alias_native :tint
31
+ alias_native :tint=
32
+ alias_native :blend_mode, :blendMode
33
+ alias_native :blend_mode=
34
+ alias_native :shader
35
+ alias_native :shader=
36
+ alias_native :cached_tint, :cachedTint
37
+ alias_native :cached_tint=
38
+ alias_native :texture, :texture, as: Texture
39
+ alias_native :texture=
40
+
41
+ alias_native :width
42
+ alias_native :width=
43
+ alias_native :height
44
+ alias_native :height=
45
+
46
+ end
47
+ end
@@ -0,0 +1,28 @@
1
+ require 'opal/pixi/core/sprites/sprite'
2
+
3
+ module PIXI
4
+ class Text < PIXI::Sprite
5
+ include Native
6
+
7
+ def initialize(text_or_native, style={}, resolution=1)
8
+ if native?(text_or_native)
9
+ super(text_or_native)
10
+ else
11
+ super(`new PIXI.Text(text_or_native, #{style.to_n}, resolution)`)
12
+ end
13
+ end
14
+
15
+ alias_native :canvas
16
+ alias_native :context
17
+ alias_native :resolution
18
+ alias_native :text
19
+ alias_native :text=
20
+ alias_native :style
21
+ alias_native :style=
22
+
23
+ alias_native :render_webGL, :renderWebGL
24
+ alias_native :getBounds, :getBounds
25
+ alias_native :destroy
26
+
27
+ end
28
+ end
@@ -0,0 +1,17 @@
1
+ module PIXI
2
+ class RenderTexture
3
+ include Native
4
+
5
+ def initialize(native_or_renderer, width=100, height=100, scaleMode=`CONST.SCALE_MODES.DEFAULT`, resolution=1)
6
+ if native?(native_or_renderer)
7
+ super
8
+ else
9
+ super(`new PIXI.RenderTexture(#{native_or_renderer.to_n}, width, height, scaleMode, resolution)`)
10
+ end
11
+ end
12
+
13
+
14
+ alias_native :render
15
+
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ module PIXI
2
+ class Texture
3
+ include Native
4
+
5
+ def self.from_image(name)
6
+ new(`PIXI.Texture.fromImage(name)`)
7
+ end
8
+
9
+ def self.from_frame(name)
10
+ new(`PIXI.Texture.fromFrame(name)`)
11
+ end
12
+
13
+ def self.from_video(name)
14
+ new(`PIXI.Texture.fromVideo(name)`)
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,41 @@
1
+ require './base'
2
+
3
+ module PIXI
4
+ class DisplayObject
5
+ #include PIXI::Base
6
+ # class_name = self.name.split('::').last || ''
7
+ # code = "self._proto = window.PIXI.#{class_name}.prototype, def = self._proto; window.PIXI.#{class_name}.prototype._klass = self"
8
+ # # %x{ alert(code) }
9
+ # %x{ eval(code) }
10
+
11
+ %x{
12
+ self._proto = window.PIXI.DisplayObject.prototype, def = self._proto;
13
+ window.PIXI.DisplayObject.prototype._klass = self;
14
+ }
15
+
16
+ def position
17
+ `self.position`
18
+ end
19
+
20
+ def position=(point)
21
+ `self.position = point`
22
+ end
23
+
24
+ def rotation
25
+ `self.rotation`
26
+ end
27
+
28
+ def rotation=(r)
29
+ `self.rotation = r`
30
+ end
31
+
32
+ def anchor=(a)
33
+ `self.anchor = a`
34
+ end
35
+
36
+ def anchor
37
+ Point.new `self.anchor.x`,`self.anchor.y`
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,16 @@
1
+ require 'opal/pixi/core/sprites/sprite'
2
+
3
+ module PIXI::Extras
4
+ class MovieClip < PIXI::Sprite
5
+ include Native
6
+
7
+ def initialize(textures)
8
+ super(`new PIXI.extras.MovieClip(#{textures.to_n})`)
9
+ end
10
+
11
+ alias_native :animation_speed, :animationSpeed
12
+ alias_native :animation_speed=, :animationSpeed=
13
+ alias_native :play
14
+
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ require 'opal/pixi/core/sprites/sprite'
2
+ require 'opal/pixi/core/math/point'
3
+
4
+ module PIXI::Extras
5
+ class TilingSprite < PIXI::Sprite
6
+ include Native
7
+
8
+ def initialize(texture, width, height)
9
+ super(`new PIXI.extras.TilingSprite(#{texture.to_n},#{width},#{height})`)
10
+ end
11
+
12
+ alias_native :tile_scale, :tileScale, as: Point
13
+ alias_native :tile_scale=, :tileScale=
14
+ alias_native :tile_position, :tilePosition, as: Point
15
+ alias_native :tile_position=, :tilePosition=
16
+
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ require 'opal/pixi/core/math/point'
2
+
3
+ module PIXI
4
+ module InteractiveTarget
5
+ include Native
6
+
7
+ alias_native :interactive
8
+ alias_native :interactive=
9
+ alias_native :interactive_children, :interactiveChildren
10
+ alias_native :interactive_children=, :interactiveChildren=
11
+ alias_native :default_cursor, :defaultCursor
12
+ alias_native :default_cursor=, :defaultCursor=
13
+
14
+ alias_native :on
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ require 'opal/pixi/core/display/container'
2
+ require 'opal/pixi/core/math/point'
3
+
4
+ module PIXI::Mesh
5
+ class Mesh < PIXI::Container
6
+ include Native
7
+
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ require 'opal/pixi/core/math/point'
2
+
3
+ module PIXI::Mesh
4
+ class Rope < PIXI::Mesh::Mesh
5
+ include Native
6
+
7
+ def initialize(texture, points)
8
+ super(`new PIXI.mesh.Rope(#{texture.to_n}, #{points.to_n})`)
9
+ end
10
+
11
+ alias_native :position
12
+
13
+ end
14
+ end