Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
ac99e122
Commit
ac99e122
authored
Apr 05, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented the "invert" builtin.
parent
549f708f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
5 deletions
+68
-5
context.cpp
context.cpp
+4
-0
functions.cpp
functions.cpp
+57
-4
functions.hpp
functions.hpp
+3
-0
input.scss
spec/basic/22_colors_with_alpha/input.scss
+2
-0
output.css
spec/basic/22_colors_with_alpha/output.css
+2
-1
No files found.
context.cpp
View file @
ac99e122
...
@@ -30,6 +30,7 @@ namespace Sass {
...
@@ -30,6 +30,7 @@ namespace Sass {
void
Context
::
register_functions
()
void
Context
::
register_functions
()
{
{
using
namespace
Functions
;
using
namespace
Functions
;
// RGB Functions
register_function
(
rgb_descriptor
,
rgb
);
register_function
(
rgb_descriptor
,
rgb
);
register_function
(
rgba_4_descriptor
,
rgba_4
);
register_function
(
rgba_4_descriptor
,
rgba_4
);
register_function
(
rgba_2_descriptor
,
rgba_2
);
register_function
(
rgba_2_descriptor
,
rgba_2
);
...
@@ -38,6 +39,8 @@ namespace Sass {
...
@@ -38,6 +39,8 @@ namespace Sass {
register_function
(
blue_descriptor
,
blue
);
register_function
(
blue_descriptor
,
blue
);
register_function
(
mix_2_descriptor
,
mix_2
);
register_function
(
mix_2_descriptor
,
mix_2
);
register_function
(
mix_3_descriptor
,
mix_3
);
register_function
(
mix_3_descriptor
,
mix_3
);
// HSL Functions
register_function
(
invert_descriptor
,
invert
);
}
}
}
}
\ No newline at end of file
functions.cpp
View file @
ac99e122
...
@@ -7,6 +7,8 @@ namespace Sass {
...
@@ -7,6 +7,8 @@ namespace Sass {
// TO DO: functions need to check the types of their arguments
// TO DO: functions need to check the types of their arguments
// RGB Functions ///////////////////////////////////////////////////////
Function_Descriptor
rgb_descriptor
=
Function_Descriptor
rgb_descriptor
=
{
"rgb"
,
"$red"
,
"$green"
,
"$blue"
,
0
};
{
"rgb"
,
"$red"
,
"$green"
,
"$blue"
,
0
};
Node
rgb
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
)
{
Node
rgb
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
)
{
...
@@ -55,7 +57,7 @@ namespace Sass {
...
@@ -55,7 +57,7 @@ namespace Sass {
return
bindings
[
parameters
[
0
]][
2
];
return
bindings
[
parameters
[
0
]][
2
];
}
}
Node
mix_impl
(
Node
color1
,
Node
color2
,
double
weight
)
{
Node
mix_impl
(
Node
color1
,
Node
color2
,
double
weight
=
50
)
{
double
p
=
weight
/
100
;
double
p
=
weight
/
100
;
double
w
=
2
*
p
-
1
;
double
w
=
2
*
p
-
1
;
double
a
=
color1
[
3
].
content
.
numeric_value
-
color2
[
3
].
content
.
numeric_value
;
double
a
=
color1
[
3
].
content
.
numeric_value
-
color2
[
3
].
content
.
numeric_value
;
...
@@ -76,9 +78,7 @@ namespace Sass {
...
@@ -76,9 +78,7 @@ namespace Sass {
Function_Descriptor
mix_2_descriptor
=
Function_Descriptor
mix_2_descriptor
=
{
"mix"
,
"$color1"
,
"$color2"
,
0
};
{
"mix"
,
"$color1"
,
"$color2"
,
0
};
Node
mix_2
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
)
{
Node
mix_2
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
)
{
return
mix_impl
(
bindings
[
parameters
[
0
]],
return
mix_impl
(
bindings
[
parameters
[
0
]],
bindings
[
parameters
[
1
]]);
bindings
[
parameters
[
1
]],
50
);
}
}
Function_Descriptor
mix_3_descriptor
=
Function_Descriptor
mix_3_descriptor
=
...
@@ -88,5 +88,57 @@ namespace Sass {
...
@@ -88,5 +88,57 @@ namespace Sass {
bindings
[
parameters
[
1
]],
bindings
[
parameters
[
1
]],
bindings
[
parameters
[
2
]].
content
.
numeric_value
);
bindings
[
parameters
[
2
]].
content
.
numeric_value
);
}
}
// HSL Functions ///////////////////////////////////////////////////////
Function_Descriptor
invert_descriptor
=
{
"invert"
,
"$color"
,
0
};
Node
invert
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
)
{
Node
orig
(
bindings
[
parameters
[
0
]]);
return
Node
(
orig
.
line_number
,
255
-
orig
[
0
].
content
.
numeric_value
,
255
-
orig
[
1
].
content
.
numeric_value
,
255
-
orig
[
2
].
content
.
numeric_value
,
orig
[
3
].
content
.
numeric_value
);
}
}
}
}
}
\ No newline at end of file
functions.hpp
View file @
ac99e122
...
@@ -66,6 +66,9 @@ namespace Sass {
...
@@ -66,6 +66,9 @@ namespace Sass {
extern
Function_Descriptor
mix_3_descriptor
;
extern
Function_Descriptor
mix_3_descriptor
;
Node
mix_3
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
);
Node
mix_3
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
);
extern
Function_Descriptor
invert_descriptor
;
Node
invert
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
);
}
}
}
}
spec/basic/22_colors_with_alpha/input.scss
View file @
ac99e122
...
@@ -20,4 +20,6 @@ div {
...
@@ -20,4 +20,6 @@ div {
roo
:
mix
(
#f00
,
#00f
);
roo
:
mix
(
#f00
,
#00f
);
doo
:
mix
(
#f00
,
#00f
,
25%
);
doo
:
mix
(
#f00
,
#00f
,
25%
);
goo
:
mix
(
rgba
(
255
,
0
,
0
,
0
.5
)
,
#00f
);
goo
:
mix
(
rgba
(
255
,
0
,
0
,
0
.5
)
,
#00f
);
boo
:
invert
(
#123456
);
}
}
spec/basic/22_colors_with_alpha/output.css
View file @
ac99e122
...
@@ -12,4 +12,5 @@ div {
...
@@ -12,4 +12,5 @@ div {
poo
:
6
;
poo
:
6
;
roo
:
#7f007f
;
roo
:
#7f007f
;
doo
:
#3f00bf
;
doo
:
#3f00bf
;
goo
:
rgba
(
63
,
0
,
191
,
0.75
);
}
goo
:
rgba
(
63
,
0
,
191
,
0.75
);
boo
:
#edcba9
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment