sprite_animation 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea44cd766b7d903541704b202bc2f2d5c97beb7c
4
- data.tar.gz: d35e6fed5b7fdc76bec6edf7a18743855d877e5c
3
+ metadata.gz: 8f277c6078b5214f161cff653cfb61439e412abf
4
+ data.tar.gz: 1953ac9e2752bc00a2527bb149a78863b2c7b22b
5
5
  SHA512:
6
- metadata.gz: 5547272430b723fa94a328a99c4dfb755938d7fec43b29961b85ccfb62b86a9eb3441ac5d169faa57a42aac06b517e319bad79487e101682657b844eaee4d057
7
- data.tar.gz: 3974c38865836b011d25f43e2714ac2c21b1cdf98031f336c0ab64b8ced2df95b7c59ebdac2e989c707bf9e0ef52734dbe0dbdeb6afac8cfa82ed5b87ce010fc
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: `animated_image`.
17
+ SpriteAnimation gem extends your view helpers with one more method: `animate_sprite`.
9
18
 
10
- `animated_image(image_src, frame_count, params = {})`
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
- A hash containing the following optional parameters:
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
- *orientation*
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
- A symbol containing the orientation of your sprite sheet. Can be: `:vertical` or `:horizontal`.
32
- If it's not given, SpriteAnimation will try to guess it based on the height and width of your sprite sheet.
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
- = animated_image("sample-sheet.png", "10") # Looks for a sprite sheet located at app/assets/images/ with 10 frames.
38
- = animated_image("sample-sheet.png", "10", scale: 0.5) # Same as above, but reducing the frame size to 50% of the original.
39
- = animated_image("horizontal-sheet.png", "10", orientation: :horizontal) # Forces the orientation to be horizontal
40
- = animated_image("http://www.remotesheet.com/sheet.jpg", "12") # Fetches the sprite sheet at the URL and animates it with 12 frames
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
 
@@ -1,7 +1,7 @@
1
1
  require 'fastimage'
2
2
  require 'uri'
3
3
 
4
- module SpriteAnimationUtil
4
+ module SpriteAnimationUtil #:nodoc: all
5
5
  class ImageSize
6
6
  def self.size(image_src)
7
7
  FastImage.size(parse_image_path(image_src), :raise_on_failure => true)
@@ -1,3 +1,3 @@
1
1
  module SpriteAnimation
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -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.1.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-13 00:00:00.000000000 Z
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 .