compass-stems 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.mkdn ADDED
@@ -0,0 +1,4 @@
1
+ compass-stems
2
+ =============
3
+
4
+ A compass extension that creates stem images for popups. Uses the chunky_png library.
@@ -0,0 +1,5 @@
1
+ require 'compass'
2
+ require File.join(File.dirname(__FILE__), 'compass-stems', 'compass-stems')
3
+ extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
4
+
5
+ Compass::Frameworks.register('compass-stems', :path => extension_path)
@@ -0,0 +1,19 @@
1
+ require "rubygems"
2
+ require "chunky_png"
3
+ require "base64"
4
+ require "compass-stems/compass-stems/stems.rb"
5
+
6
+ module Sass::Script::Functions
7
+
8
+ TRANSPARENT = ChunkyPNG::Color::TRANSPARENT
9
+
10
+ def return_image(png)
11
+ data = Base64.encode64(png.to_blob).gsub("\n", "")
12
+ Sass::Script::String.new("url('data:image/png;base64,#{data}')")
13
+ end
14
+
15
+ def get_color(color)
16
+ color = ChunkyPNG::Color.rgba(color.red, color.green, color.blue, (color.alpha*255).round)
17
+ end
18
+
19
+ end
@@ -0,0 +1,41 @@
1
+ module CompassStems
2
+ class Stems
3
+ module Sass::Script::Functions
4
+ def stem(color, width = 22, direction = top, border_color = color, border_inset_color, enable_gradient_background)
5
+ color = get_color(color)
6
+ border_color = get_color(border_color)
7
+
8
+ width = width.to_i if width.is_a? Sass::Script::Number
9
+ height = (width / 2).to_i
10
+
11
+ outer_stem = ChunkyPNG::Image.new(width, height-1, TRANSPARENT)
12
+ outer_stem.polygon([(width/2)-1,-1,(width/2),-1,0,height-1,width,height-1], border_color, color)
13
+
14
+ png = ChunkyPNG::Image.new(width, height, TRANSPARENT)
15
+ png = png.compose(outer_stem, 0, 0)
16
+
17
+ unless border_inset_color.is_a? Sass::Script::Bool
18
+ border_inset_color = get_color(border_inset_color)
19
+
20
+ inner_stem = ChunkyPNG::Image.new(width, height-1, TRANSPARENT)
21
+ inner_stem.polygon([(width/2)-1,-1,(width/2),-1,0,height-1,width,height-1], border_inset_color, color)
22
+ inner_stem = inner_stem.crop(0, 0, width, height-1)
23
+
24
+ png = png.compose(inner_stem, 0, 1)
25
+ end
26
+
27
+ case direction.to_s
28
+ when "left"
29
+ png = png.rotate_left
30
+ when "right"
31
+ png = png.rotate_right
32
+ when "bottom"
33
+ png = png.flip_horizontally
34
+ end
35
+
36
+ return_image(png)
37
+
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,19 @@
1
+ @mixin stem(
2
+ $color,
3
+ $width: 20,
4
+ $direction: top,
5
+ $border-color: $darken($color, 10%),
6
+ $border-inset-color: lighten($color, 10%),
7
+ $enable-gradient-background: false) {
8
+
9
+ $height: $width/2;
10
+ position: relative;
11
+ &:after {
12
+ background: stem($color, $width, $direction, $border-color, $border-inset-color, $enable-gradient-background);
13
+ position: absolute;
14
+ display: block;
15
+ z-index: 1;
16
+ height: $height;
17
+ top: -$height;
18
+ }
19
+ }
@@ -0,0 +1,2 @@
1
+ stylesheet '_stems.scss', :media => 'screen, projection'
2
+ description "an easy way to create image stems using chunky_png"
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: compass-stems
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - kelly korevec
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-08-05 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: compass
16
+ requirement: &2160698520 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.11.beta.5
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2160698520
25
+ - !ruby/object:Gem::Dependency
26
+ name: chunky_png
27
+ requirement: &2160697440 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 1.1.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2160697440
36
+ description: generate image stems for compass
37
+ email:
38
+ - kelly@dailymile.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - README.mkdn
44
+ - lib/compass-stems/compass-stems/stems.rb
45
+ - lib/compass-stems/compass-stems.rb
46
+ - lib/compass-stems.rb
47
+ - templates/project/_stems.scss
48
+ - templates/project/manifest.rb
49
+ homepage: http://www.dailymile.com
50
+ licenses: []
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubyforge_project: compass-stems
69
+ rubygems_version: 1.8.5
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: generate image stems for compass
73
+ test_files: []