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
a3627ca3
Commit
a3627ca3
authored
Sep 06, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented the hue, saturation, and lightness built-ins.
parent
04f81a75
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
13 deletions
+56
-13
context.cpp
context.cpp
+3
-0
functions.cpp
functions.cpp
+44
-13
functions.hpp
functions.hpp
+9
-0
No files found.
context.cpp
View file @
a3627ca3
...
@@ -111,6 +111,9 @@ namespace Sass {
...
@@ -111,6 +111,9 @@ namespace Sass {
// HSL Functions
// HSL Functions
register_function
(
hsla_sig
,
hsla
);
register_function
(
hsla_sig
,
hsla
);
register_function
(
hsl_sig
,
hsl
);
register_function
(
hsl_sig
,
hsl
);
register_function
(
hue_sig
,
hue
);
register_function
(
saturation_sig
,
saturation
);
register_function
(
lightness_sig
,
lightness
);
register_function
(
adjust_hue_sig
,
adjust_hue
);
register_function
(
adjust_hue_sig
,
adjust_hue
);
register_function
(
adjust_color_sig
,
adjust_color
);
register_function
(
adjust_color_sig
,
adjust_color
);
register_function
(
change_color_sig
,
change_color
);
register_function
(
change_color_sig
,
change_color
);
...
...
functions.cpp
View file @
a3627ca3
...
@@ -44,6 +44,19 @@ namespace Sass {
...
@@ -44,6 +44,19 @@ namespace Sass {
namespace
Functions
{
namespace
Functions
{
extern
const
char
true_str
[]
=
"true"
;
extern
const
char
false_str
[]
=
"false"
;
extern
const
char
empty_str
[]
=
""
;
extern
const
char
percent_str
[]
=
"%"
;
extern
const
char
deg_str
[]
=
"deg"
;
extern
const
char
number_name
[]
=
"number"
;
extern
const
char
string_name
[]
=
"string"
;
extern
const
char
bool_name
[]
=
"bool"
;
extern
const
char
color_name
[]
=
"color"
;
extern
const
char
list_name
[]
=
"list"
;
static
void
throw_eval_error
(
string
message
,
string
path
,
size_t
line
)
static
void
throw_eval_error
(
string
message
,
string
path
,
size_t
line
)
{
{
if
(
!
path
.
empty
()
&&
Prelexer
::
string_constant
(
path
.
c_str
()))
if
(
!
path
.
empty
()
&&
Prelexer
::
string_constant
(
path
.
c_str
()))
...
@@ -238,6 +251,36 @@ namespace Sass {
...
@@ -238,6 +251,36 @@ namespace Sass {
return
color
;
return
color
;
}
}
extern
Signature
hue_sig
=
"hue($color)"
;
Node
hue
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
)
{
Node
rgb_color
(
bindings
[
parameter_names
[
0
].
token
()]);
Node
hsl_color
(
rgb_to_hsl
(
rgb_color
[
0
].
numeric_value
(),
rgb_color
[
1
].
numeric_value
(),
rgb_color
[
2
].
numeric_value
(),
new_Node
));
return
new_Node
(
""
,
0
,
hsl_color
[
0
].
numeric_value
(),
Token
::
make
(
deg_str
));
}
extern
Signature
saturation_sig
=
"saturation($color)"
;
Node
saturation
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
)
{
Node
rgb_color
(
bindings
[
parameter_names
[
0
].
token
()]);
Node
hsl_color
(
rgb_to_hsl
(
rgb_color
[
0
].
numeric_value
(),
rgb_color
[
1
].
numeric_value
(),
rgb_color
[
2
].
numeric_value
(),
new_Node
));
return
new_Node
(
""
,
0
,
hsl_color
[
1
].
numeric_value
(),
Token
::
make
(
percent_str
));
}
extern
Signature
lightness_sig
=
"lightness($color)"
;
Node
lightness
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
)
{
Node
rgb_color
(
bindings
[
parameter_names
[
0
].
token
()]);
Node
hsl_color
(
rgb_to_hsl
(
rgb_color
[
0
].
numeric_value
(),
rgb_color
[
1
].
numeric_value
(),
rgb_color
[
2
].
numeric_value
(),
new_Node
));
return
new_Node
(
""
,
0
,
hsl_color
[
2
].
numeric_value
(),
Token
::
make
(
percent_str
));
}
extern
Signature
adjust_hue_sig
=
"adjust-hue($color, $degrees)"
;
extern
Signature
adjust_hue_sig
=
"adjust-hue($color, $degrees)"
;
Node
adjust_hue
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
)
{
Node
adjust_hue
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
)
{
Node
rgb_col
(
bindings
[
parameter_names
[
0
].
token
()]);
Node
rgb_col
(
bindings
[
parameter_names
[
0
].
token
()]);
...
@@ -714,12 +757,6 @@ namespace Sass {
...
@@ -714,12 +757,6 @@ namespace Sass {
// Introspection Functions /////////////////////////////////////////////
// Introspection Functions /////////////////////////////////////////////
extern
const
char
number_name
[]
=
"number"
;
extern
const
char
string_name
[]
=
"string"
;
extern
const
char
bool_name
[]
=
"bool"
;
extern
const
char
color_name
[]
=
"color"
;
extern
const
char
list_name
[]
=
"list"
;
extern
Signature
type_of_sig
=
"type-of($value)"
;
extern
Signature
type_of_sig
=
"type-of($value)"
;
Node
type_of
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
)
{
Node
type_of
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
)
{
Node
val
(
bindings
[
parameter_names
[
0
].
token
()]);
Node
val
(
bindings
[
parameter_names
[
0
].
token
()]);
...
@@ -754,10 +791,7 @@ namespace Sass {
...
@@ -754,10 +791,7 @@ namespace Sass {
type
.
is_unquoted
()
=
true
;
type
.
is_unquoted
()
=
true
;
return
type
;
return
type
;
}
}
extern
const
char
empty_str
[]
=
""
;
extern
const
char
percent_str
[]
=
"%"
;
extern
Signature
unit_sig
=
"unit($number)"
;
extern
Signature
unit_sig
=
"unit($number)"
;
Node
unit
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
)
{
Node
unit
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
)
{
Node
val
(
bindings
[
parameter_names
[
0
].
token
()]);
Node
val
(
bindings
[
parameter_names
[
0
].
token
()]);
...
@@ -780,9 +814,6 @@ namespace Sass {
...
@@ -780,9 +814,6 @@ namespace Sass {
return
Node
();
return
Node
();
}
}
extern
const
char
true_str
[]
=
"true"
;
extern
const
char
false_str
[]
=
"false"
;
extern
Signature
unitless_sig
=
"unitless($number)"
;
extern
Signature
unitless_sig
=
"unitless($number)"
;
Node
unitless
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
)
{
Node
unitless
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
)
{
Node
val
(
bindings
[
parameter_names
[
0
].
token
()]);
Node
val
(
bindings
[
parameter_names
[
0
].
token
()]);
...
...
functions.hpp
View file @
a3627ca3
...
@@ -92,6 +92,15 @@ namespace Sass {
...
@@ -92,6 +92,15 @@ namespace Sass {
extern
Signature
hsl_sig
;
extern
Signature
hsl_sig
;
Node
hsl
(
const
Node
,
Environment
&
,
Node_Factory
&
);
Node
hsl
(
const
Node
,
Environment
&
,
Node_Factory
&
);
extern
Signature
hue_sig
;
Node
hue
(
const
Node
,
Environment
&
,
Node_Factory
&
);
extern
Signature
saturation_sig
;
Node
saturation
(
const
Node
,
Environment
&
,
Node_Factory
&
);
extern
Signature
lightness_sig
;
Node
lightness
(
const
Node
,
Environment
&
,
Node_Factory
&
);
extern
Signature
adjust_hue_sig
;
extern
Signature
adjust_hue_sig
;
Node
adjust_hue
(
const
Node
,
Environment
&
,
Node_Factory
&
);
Node
adjust_hue
(
const
Node
,
Environment
&
,
Node_Factory
&
);
...
...
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