sprite_animation 0.1.0 → 0.2.0
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/README.md +33 -13
- data/lib/sprite_animation/sprite_animation_helper.rb +9 -0
- data/lib/sprite_animation/sprite_animation_util.rb +1 -1
- data/lib/sprite_animation/version.rb +1 -1
- data/lib/sprite_animation.rb +3 -3
- metadata +2 -4
- data/app/assets/javascripts/sprite_animation_main.js +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f277c6078b5214f161cff653cfb61439e412abf
|
4
|
+
data.tar.gz: 1953ac9e2752bc00a2527bb149a78863b2c7b22b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f46c562b1dd10d737dd9dfc7ba951d18b8f05b0d861cc72656006cd1df18882c871d492c3f6136b98030ad8165cab59ab9f31401108459171654278cd9647b4
|
7
|
+
data.tar.gz: e90569d2ab773296e1849931bbf0698c39b866be97992c33ffdcd6ecd5e132842e17b6397424b6b45d77b82c6a36dabec365ad9a445afc716f40702e3133baa1
|
data/README.md
CHANGED
@@ -1,13 +1,22 @@
|
|
1
|
+
# NOT FUNCTIONAL
|
2
|
+
# WORKING ON IT
|
3
|
+
|
1
4
|
# SpriteAnimation
|
2
5
|
|
6
|
+
> Attention please.<br>
|
7
|
+
> I'm still working on documenting it.<br>
|
8
|
+
> There are still no tests whatsoever.<br>
|
9
|
+
> Any contribution would be extremely appreciated.<br>
|
10
|
+
|
11
|
+
|
3
12
|
This gem makes it easy creating animated images in your views given a sprite sheet. Just add it to your project and start animating sprite sheets.
|
4
13
|
SpriteAnimation gem encapsulates all the javascript, jquery and rails logic you need. It was made to be as simple as possible. Try it!
|
5
14
|
|
6
15
|
## Usage
|
7
16
|
|
8
|
-
SpriteAnimation gem extends your view helpers with one more method: `
|
17
|
+
SpriteAnimation gem extends your view helpers with one more method: `animate_sprite`.
|
9
18
|
|
10
|
-
`
|
19
|
+
`animate_sprite(image_src, frame_count, params = {})`
|
11
20
|
|
12
21
|
**image_src**
|
13
22
|
|
@@ -20,24 +29,35 @@ String with the number of frames that your sprite sheet has.
|
|
20
29
|
|
21
30
|
**params**
|
22
31
|
|
23
|
-
|
24
|
-
|
25
|
-
*scale*
|
32
|
+
An optional hash containing the following parameters:
|
26
33
|
|
27
|
-
Decimal value to resize your frame size. Defaults to 1.
|
34
|
+
* scale: Decimal value to resize your frame size. Defaults to 1.
|
35
|
+
* orientation: A symbol containing the orientation of your sprite sheet. <br>Can be: `:vertical` or `:horizontal`.
|
36
|
+
If it's not given, SpriteAnimation will try to guess it based on the height and width of your sprite sheet.
|
28
37
|
|
29
|
-
|
38
|
+
## Installation
|
39
|
+
Add this line to your application's Gemfile:
|
40
|
+
```ruby
|
41
|
+
gem 'sprite_animation'
|
42
|
+
```
|
43
|
+
|
44
|
+
Then run
|
45
|
+
```ruby
|
46
|
+
bundle install
|
47
|
+
```
|
30
48
|
|
31
|
-
|
32
|
-
|
49
|
+
After that, just add the require statement to your `application.js`
|
50
|
+
```ruby
|
51
|
+
//= require sprite_animation
|
52
|
+
```
|
33
53
|
|
34
54
|
## Examples
|
35
55
|
Using [slim-template](https://github.com/slim-template/slim)
|
36
56
|
```
|
37
|
-
=
|
38
|
-
=
|
39
|
-
=
|
40
|
-
=
|
57
|
+
= animate_sprite("sample-sheet.png", "10") # Looks for a sprite sheet located at app/assets/images/ with 10 frames.
|
58
|
+
= animate_sprite("sample-sheet.png", "10", scale: 0.5) # Same as above, but reducing the frame size to 50% of the original.
|
59
|
+
= animate_sprite("horizontal-sheet.png", "10", orientation: :horizontal) # Forces the orientation to be horizontal
|
60
|
+
= animate_sprite("http://www.remotesheet.com/sheet.jpg", "12") # Fetches the sprite sheet at the URL and animates it with 12 frames
|
41
61
|
```
|
42
62
|
|
43
63
|
## Dependencies
|
@@ -3,6 +3,15 @@ require_relative 'sprite_animation_util'
|
|
3
3
|
module SpriteAnimation
|
4
4
|
include SpriteAnimationUtil
|
5
5
|
|
6
|
+
# Returns an image_tag inside a div, an populates the image
|
7
|
+
# with data so it can be animated via javascript
|
8
|
+
# Params:
|
9
|
+
# +image_src+:: a sprite sheet source, just as you would pass to image_tag
|
10
|
+
# +frame_count+:: a string representing the number of frames for the sheet
|
11
|
+
# +params+:: a hash containing two optional parameters for the animation
|
12
|
+
##- +scale+:: a decimal number that will multiply the frame size. Default: 1
|
13
|
+
##- +orientation+:: a symbol representing the orientation of your sheet.
|
14
|
+
## Can be: :vertical or :horizontal. If not given, it will try to guess.
|
6
15
|
def animate_sprite(image_src, frame_count, params = {})
|
7
16
|
scale = params[:scale] || 1
|
8
17
|
|
data/lib/sprite_animation.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require "sprite_animation/version"
|
2
2
|
require "sprite_animation/sprite_animation_helper"
|
3
3
|
|
4
|
-
module SpriteAnimation
|
5
|
-
class Engine < Rails::Engine
|
4
|
+
module SpriteAnimation
|
5
|
+
class Engine < Rails::Engine #:nodoc:
|
6
6
|
end
|
7
7
|
|
8
|
-
class Railtie < Rails::Railtie
|
8
|
+
class Railtie < Rails::Railtie #:nodoc:
|
9
9
|
initializer "sprite_animation.initialize_sprite_animation_helper" do |app|
|
10
10
|
ActiveSupport.on_load(:action_view) do
|
11
11
|
include SpriteAnimation
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprite_animation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DanielsLuz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -95,7 +95,6 @@ files:
|
|
95
95
|
- README.md
|
96
96
|
- Rakefile
|
97
97
|
- app/assets/javascripts/sprite_animation.js
|
98
|
-
- app/assets/javascripts/sprite_animation_main.js
|
99
98
|
- bin/console
|
100
99
|
- bin/setup
|
101
100
|
- lib/sprite_animation.rb
|
@@ -129,4 +128,3 @@ signing_key:
|
|
129
128
|
specification_version: 4
|
130
129
|
summary: Simple gem for sprite sheet animation
|
131
130
|
test_files: []
|
132
|
-
has_rdoc:
|
@@ -1 +0,0 @@
|
|
1
|
-
//= require_tree .
|