compass-core 1.0.0.alpha.20 → 1.0.0.alpha.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/RELEASE_VERSION +1 -1
- data/VERSION +1 -1
- data/lib/compass/configuration/inheritance.rb +1 -1
- data/lib/compass/core/sass_extensions/functions/gradient_support.rb +147 -11
- data/stylesheets/compass/css3/_images.scss +1 -1
- data/stylesheets/compass/css3/_transition.scss +30 -13
- data/stylesheets/compass/utilities/color/_brightness.scss +10 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae333010970a851ce2a6e4afb2a3dadcd436039a
|
4
|
+
data.tar.gz: 0d100b0b67a12b9dd48e74c4de4ce4f4b98f1cc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 779b3f83ef661bff586fe40d5e19974f62b7b8a96a4b5038ca0ef59fef3ae1571d9292a14c001def22370dce0b19cd6a23305dfff79f82fd3bff60ad4026b2f2
|
7
|
+
data.tar.gz: d171aa6c8abf76fe03f530ffe31ef33a37bdddad66ab929798cf3c4bb9531d6ff136b518dcf6ec700871cbfa3e4d82133754e20845c997e126ff8f7c5d6bcb9b
|
data/RELEASE_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.alpha.
|
1
|
+
1.0.0.alpha.21
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.alpha.
|
1
|
+
1.0.0.alpha.20
|
@@ -2,6 +2,147 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
|
|
2
2
|
|
3
3
|
GRADIENT_ASPECTS = %w(webkit moz svg css2 o owg).freeze
|
4
4
|
|
5
|
+
class CSS3AngleToSVGConverter
|
6
|
+
include Math
|
7
|
+
|
8
|
+
def initialize(angle)
|
9
|
+
@original_angle = angle
|
10
|
+
@angle = handle_keywords(angle)
|
11
|
+
@angle = in_radians(@angle) % (2 * PI)
|
12
|
+
@quadrant = (@angle * 2 / PI).to_i
|
13
|
+
@angle = case @quadrant
|
14
|
+
when 0
|
15
|
+
@angle
|
16
|
+
when 1
|
17
|
+
PI - @angle
|
18
|
+
when 2
|
19
|
+
@angle - PI
|
20
|
+
when 3
|
21
|
+
2 * PI - @angle
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
TOP = 1
|
26
|
+
BOTTOM = 2
|
27
|
+
RIGHT = 4
|
28
|
+
LEFT = 8
|
29
|
+
|
30
|
+
DIR_KEYWORDS_TO_ANGLE = {
|
31
|
+
TOP => 0,
|
32
|
+
TOP | RIGHT => 45,
|
33
|
+
RIGHT => 90,
|
34
|
+
BOTTOM | RIGHT => 135,
|
35
|
+
BOTTOM => 180,
|
36
|
+
BOTTOM | LEFT => 225,
|
37
|
+
LEFT => 270,
|
38
|
+
TOP | LEFT => 315,
|
39
|
+
}
|
40
|
+
|
41
|
+
def handle_keywords(angle)
|
42
|
+
if angle.is_a?(Sass::Script::Value::List) || angle.is_a?(Sass::Script::Value::String)
|
43
|
+
direction = angle.to_sass
|
44
|
+
is_end_point = !!/\bto\b/i.match(direction)
|
45
|
+
dir = 0
|
46
|
+
dir |= TOP if /\btop\b/i.match(direction)
|
47
|
+
dir |= BOTTOM if /\bbottom\b/i.match(direction)
|
48
|
+
dir |= RIGHT if /\bright\b/i.match(direction)
|
49
|
+
dir |= LEFT if /\bleft\b/i.match(direction)
|
50
|
+
if (r = DIR_KEYWORDS_TO_ANGLE[dir])
|
51
|
+
r += 180 unless is_end_point
|
52
|
+
Sass::Script::Value::Number.new(r, %w(deg), [])
|
53
|
+
else
|
54
|
+
raise Sass::SyntaxError, "Unknown direction: #{angle.to_sass}"
|
55
|
+
end
|
56
|
+
else
|
57
|
+
angle
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def in_radians(angle)
|
62
|
+
case angle.unit_str
|
63
|
+
when "deg"
|
64
|
+
angle.value * PI / 180.0
|
65
|
+
when "grad"
|
66
|
+
angle.value * PI / 200.0
|
67
|
+
when "rad"
|
68
|
+
angle.value
|
69
|
+
when "turn"
|
70
|
+
angle.value * PI * 2
|
71
|
+
else
|
72
|
+
raise Sass::SyntaxError.new("#{angle.unit_str} is not an angle")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def sin2(a)
|
77
|
+
v = sin(a)
|
78
|
+
v * v
|
79
|
+
end
|
80
|
+
|
81
|
+
def x
|
82
|
+
@x ||= if @angle > 1.570621793869697
|
83
|
+
1.0 # avoid floating point rounding error at the asymptote
|
84
|
+
else
|
85
|
+
tan(@angle) + (1 - tan(@angle)) * sin2(@angle)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def y
|
90
|
+
@y ||= if @angle < 0.0001
|
91
|
+
1.0 # the limit of the expression as we approach 0 is 1.
|
92
|
+
else
|
93
|
+
x / tan(@angle)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def x1
|
98
|
+
result case @quadrant
|
99
|
+
when 0, 1
|
100
|
+
-x
|
101
|
+
when 2, 3
|
102
|
+
x
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def y1
|
107
|
+
result case @quadrant
|
108
|
+
when 0, 3
|
109
|
+
y
|
110
|
+
when 1, 2
|
111
|
+
-y
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def x2
|
116
|
+
result case @quadrant
|
117
|
+
when 0, 1
|
118
|
+
x
|
119
|
+
when 2, 3
|
120
|
+
-x
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def y2
|
125
|
+
result case @quadrant
|
126
|
+
when 0, 3
|
127
|
+
-y
|
128
|
+
when 1, 2
|
129
|
+
y
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def scale(p)
|
134
|
+
(p + 1) / 2.0
|
135
|
+
end
|
136
|
+
|
137
|
+
def round6(v)
|
138
|
+
(v * 1_000_000).round / 1_000_000.0
|
139
|
+
end
|
140
|
+
|
141
|
+
def result(v)
|
142
|
+
round6(scale(v))
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
5
146
|
class ColorStop < Sass::Script::Value::Base
|
6
147
|
include Sass::Script::Value::Helpers
|
7
148
|
attr_accessor :color, :stop
|
@@ -94,11 +235,11 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
|
|
94
235
|
|
95
236
|
module ClassMethods
|
96
237
|
def standardized_prefix(prefix)
|
97
|
-
class_eval %Q
|
238
|
+
class_eval %Q<
|
98
239
|
def to_#{prefix}(options = self.options)
|
99
240
|
identifier("-#{prefix}-\#{to_s_prefixed(options)}")
|
100
241
|
end
|
101
|
-
|
242
|
+
>
|
102
243
|
end
|
103
244
|
end
|
104
245
|
|
@@ -229,7 +370,7 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
|
|
229
370
|
|
230
371
|
def supports?(aspect)
|
231
372
|
# I don't know how to support degree-based gradients in old webkit gradients (owg) or svg so we just disable them.
|
232
|
-
if %w(owg
|
373
|
+
if %w(owg).include?(aspect) && position_or_angle.is_a?(Sass::Script::Value::Number) && position_or_angle.numerator_units.include?("deg")
|
233
374
|
false
|
234
375
|
elsif aspect == "svg" && color_stops.value.any?{|cs| cs.stop.is_a?(Sass::Script::Value::String) }
|
235
376
|
# calc expressions cannot be represented in svg
|
@@ -465,11 +606,10 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
|
|
465
606
|
end
|
466
607
|
|
467
608
|
def linear_svg_gradient(color_stops, start)
|
468
|
-
|
469
|
-
x2, y2 = *grad_point(opposite_position(start)).value
|
609
|
+
converter = CSS3AngleToSVGConverter.new(start)
|
470
610
|
stops = color_stops_in_percentages(color_stops)
|
471
611
|
|
472
|
-
svg = linear_svg(stops, x1, y1, x2, y2)
|
612
|
+
svg = linear_svg(stops, converter.x1, converter.y1, converter.x2, converter.y2)
|
473
613
|
inline_image_string(svg.gsub(/\s+/, ' '), 'image/svg+xml')
|
474
614
|
end
|
475
615
|
|
@@ -559,11 +699,7 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
|
|
559
699
|
end
|
560
700
|
|
561
701
|
def linear_svg(color_stops, x1, y1, x2, y2)
|
562
|
-
|
563
|
-
if angle?(position_or_angle)
|
564
|
-
transform = %Q{ gradientTransform = "rotate(#{position_or_angle.value})"}
|
565
|
-
end
|
566
|
-
gradient = %Q{<linearGradient id="grad" gradientUnits="userSpaceOnUse" x1="#{x1}" y1="#{y1}" x2="#{x2}" y2="#{y2}"#{transform}>#{color_stops_svg(color_stops)}</linearGradient>}
|
702
|
+
gradient = %Q{<linearGradient id="grad" gradientUnits="objectBoundingBox" x1="#{x1}" y1="#{y1}" x2="#{x2}" y2="#{y2}">#{color_stops_svg(color_stops)}</linearGradient>}
|
567
703
|
svg(gradient)
|
568
704
|
end
|
569
705
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
@import "compass/utilities/general/hacks";
|
3
3
|
|
4
4
|
$gradient-support-threshold: $graceful-usage-threshold !default;
|
5
|
-
$svg-gradient-shim-threshold:
|
5
|
+
$svg-gradient-shim-threshold: $graceful-usage-threshold !default;
|
6
6
|
$border-image-support-threshold: $graceful-usage-threshold !default;
|
7
7
|
|
8
8
|
// Compass assumes you will use the official gradient syntax,
|
@@ -56,6 +56,27 @@ $transitionable-prefixed-values: transform, transform-origin !default;
|
|
56
56
|
}
|
57
57
|
}
|
58
58
|
|
59
|
+
// Returns $transition-map which includes key and values that map to a transition declaration
|
60
|
+
@function transition-map($transition) {
|
61
|
+
$transition-map: ();
|
62
|
+
|
63
|
+
@each $item in $transition {
|
64
|
+
@if is-time($item) {
|
65
|
+
@if map-has-key($transition-map, duration) {
|
66
|
+
$transition-map: map-merge($transition-map, (delay: $item));
|
67
|
+
} @else {
|
68
|
+
$transition-map: map-merge($transition-map, (duration: $item));
|
69
|
+
}
|
70
|
+
} @else if map-has-key($transition-map, property) {
|
71
|
+
$transition-map: map-merge($transition-map, (timing-function: $item));
|
72
|
+
} @else {
|
73
|
+
$transition-map: map-merge($transition-map, (property: $item));
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
@return $transition-map;
|
78
|
+
}
|
79
|
+
|
59
80
|
// One or more properties to transition
|
60
81
|
//
|
61
82
|
// * for multiple, use a comma-delimited list
|
@@ -133,20 +154,16 @@ $transitionable-prefixed-values: transform, transform-origin !default;
|
|
133
154
|
// This block can be made considerably simpler at the point in time that
|
134
155
|
// we no longer need to deal with the differences in how delays are treated.
|
135
156
|
@each $transition in $transitions {
|
136
|
-
//
|
137
|
-
|
138
|
-
$property: nth($transition, 1);
|
139
|
-
$duration: if(length($transition) >= 2, nth($transition, 2), null);
|
140
|
-
$timing-function: if(length($transition) >= 3, nth($transition, 3), null);
|
141
|
-
$delay: if(length($transition) >= 4, nth($transition, 4), null);
|
142
|
-
$has-delays: $has-delays or $delay;
|
157
|
+
// Declare initial values for transition
|
158
|
+
$transition: transition-map($transition);
|
143
159
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
160
|
+
$property: map-get($transition, property);
|
161
|
+
$duration: map-get($transition, duration);
|
162
|
+
$timing-function: map-get($transition, timing-function);
|
163
|
+
$delay: map-get($transition, delay);
|
164
|
+
|
165
|
+
// Parse transition string to assign values into correct variables
|
166
|
+
$has-delays: $has-delays or $delay;
|
150
167
|
|
151
168
|
@if $current-prefix == -webkit {
|
152
169
|
// Keep a list of delays in case one is specified
|
@@ -5,8 +5,16 @@
|
|
5
5
|
// a color. Brightness is sometimes called luminance.
|
6
6
|
//
|
7
7
|
// Returns a number between 0% and 100%, where 100% is fully bright
|
8
|
-
// (white) and 0% is fully dark (black).
|
8
|
+
// (white) and 0% is fully dark (black) for color values.
|
9
|
+
//
|
10
|
+
// For numbers and percentages it returns the same value to be used
|
11
|
+
// in `@include filter(brightness(1.1))`.
|
9
12
|
@function brightness($color) {
|
10
|
-
@
|
13
|
+
@if type-of($color) == color {
|
14
|
+
@return ((red($color) * .299) + (green($color) * .587) + (blue($color) * .114)) / 255 * 100%;
|
15
|
+
}
|
16
|
+
@else {
|
17
|
+
@return unquote("brightness(#{$color})");
|
18
|
+
}
|
11
19
|
}
|
12
20
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compass-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.alpha.
|
4
|
+
version: 1.0.0.alpha.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Eppstein
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-
|
14
|
+
date: 2014-07-17 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: sass
|