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
097c2a4c
Commit
097c2a4c
authored
Sep 10, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converting the opacity functions to the new arg-checking interface.
parent
fcd6cd98
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
38 deletions
+20
-38
functions.cpp
functions.cpp
+20
-38
No files found.
functions.cpp
View file @
097c2a4c
...
@@ -457,61 +457,47 @@ namespace Sass {
...
@@ -457,61 +457,47 @@ namespace Sass {
extern
Signature
alpha_sig
=
"alpha($color)"
;
extern
Signature
alpha_sig
=
"alpha($color)"
;
Node
alpha
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
alpha
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
color
(
bindings
[
parameter_names
[
0
].
token
()]);
Node
color
(
arg
(
alpha_sig
,
path
,
line
,
parameter_names
,
bindings
,
0
,
Node
::
numeric_color
));
if
(
color
.
type
()
!=
Node
::
numeric_color
)
throw_eval_error
(
"argument to 'alpha' must be a color"
,
color
.
path
(),
color
.
line
());
return
new_Node
(
path
,
line
,
color
[
3
]);
return
color
[
3
];
}
}
extern
Signature
opacity_sig
=
"opacity($color)"
;
extern
Signature
opacity_sig
=
"opacity($color)"
;
Node
opacity
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
opacity
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
color
(
bindings
[
parameter_names
[
0
].
token
()]);
Node
color
(
arg
(
opacity_sig
,
path
,
line
,
parameter_names
,
bindings
,
0
,
Node
::
numeric_color
));
if
(
color
.
type
()
!=
Node
::
numeric_color
)
throw_eval_error
(
"argument to 'opacity' must be a color"
,
color
.
path
(),
color
.
line
());
return
new_Node
(
path
,
line
,
color
[
3
]);
return
color
[
3
];
}
}
extern
Signature
opacify_sig
=
"opacify($color, $amount)"
;
extern
Signature
opacify_sig
=
"opacify($color, $amount)"
;
Node
opacify
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
opacify
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
color
(
bindings
[
parameter_names
[
0
].
token
()]);
Node
color
(
arg
(
opacify_sig
,
path
,
line
,
parameter_names
,
bindings
,
0
,
Node
::
numeric_color
));
Node
delta
(
bindings
[
parameter_names
[
1
].
token
()]);
double
delta
=
arg
(
opacify_sig
,
path
,
line
,
parameter_names
,
bindings
,
1
,
0
,
1
).
numeric_value
();
if
(
color
.
type
()
!=
Node
::
numeric_color
)
throw_eval_error
(
"first argument to 'opacify' must be a color"
,
color
.
path
(),
color
.
line
());
delta
+=
color
[
3
].
numeric_value
();
if
(
!
delta
.
is_numeric
())
throw_eval_error
(
"second argument to 'opacify' must be numeric"
,
delta
.
path
(),
delta
.
line
());
if
(
delta
>
1
)
delta
=
1
;
double
dd
=
delta
.
numeric_value
();
if
(
dd
<
0
||
1
<
dd
)
throw_eval_error
(
"amount must be between 0 and 1 for 'opacify'"
,
delta
.
path
(),
delta
.
line
());
dd
+=
color
[
3
].
numeric_value
();
if
(
dd
>
1
)
dd
=
1
;
return
new_Node
(
path
,
line
,
return
new_Node
(
path
,
line
,
color
[
0
].
numeric_value
(),
color
[
0
].
numeric_value
(),
color
[
1
].
numeric_value
(),
color
[
1
].
numeric_value
(),
color
[
2
].
numeric_value
(),
color
[
2
].
numeric_value
(),
d
d
);
d
elta
);
}
}
extern
Signature
fade_in_sig
=
"fade-in($color, $amount)"
;
extern
Signature
fade_in_sig
=
"fade-in($color, $amount)"
;
Node
fade_in
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
fade_in
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
color
(
bindings
[
parameter_names
[
0
].
token
()]);
Node
color
(
arg
(
fade_in_sig
,
path
,
line
,
parameter_names
,
bindings
,
0
,
Node
::
numeric_color
));
Node
delta
(
bindings
[
parameter_names
[
1
].
token
()]);
double
delta
=
arg
(
fade_in_sig
,
path
,
line
,
parameter_names
,
bindings
,
1
,
0
,
1
).
numeric_value
();
if
(
color
.
type
()
!=
Node
::
numeric_color
)
throw_eval_error
(
"first argument to 'fade-in' must be a color"
,
color
.
path
(),
color
.
line
());
delta
+=
color
[
3
].
numeric_value
();
if
(
!
delta
.
is_numeric
())
throw_eval_error
(
"second argument to 'fade-in' must be numeric"
,
delta
.
path
(),
delta
.
line
());
if
(
delta
>
1
)
delta
=
1
;
double
dd
=
delta
.
numeric_value
();
if
(
dd
<
0
||
1
<
dd
)
throw_eval_error
(
"amount must be between 0 and 1 for 'fade-in'"
,
delta
.
path
(),
delta
.
line
());
dd
+=
color
[
3
].
numeric_value
();
if
(
dd
>
1
)
dd
=
1
;
return
new_Node
(
path
,
line
,
return
new_Node
(
path
,
line
,
color
[
0
].
numeric_value
(),
color
[
0
].
numeric_value
(),
color
[
1
].
numeric_value
(),
color
[
1
].
numeric_value
(),
color
[
2
].
numeric_value
(),
color
[
2
].
numeric_value
(),
d
d
);
d
elta
);
}
}
extern
Signature
transparentize_sig
=
"transparentize($color, $amount)"
;
extern
Signature
transparentize_sig
=
"transparentize($color, $amount)"
;
Node
transparentize
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
transparentize
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
color
(
bindings
[
parameter_names
[
0
].
token
()]);
Node
color
(
arg
(
transparentize_sig
,
path
,
line
,
parameter_names
,
bindings
,
0
,
Node
::
numeric_color
));
Node
delta
(
bindings
[
parameter_names
[
1
].
token
()]);
double
delta
=
arg
(
transparentize_sig
,
path
,
line
,
parameter_names
,
bindings
,
1
,
0
,
1
).
numeric_value
();
if
(
color
.
type
()
!=
Node
::
numeric_color
)
throw_eval_error
(
"first argument to 'transparentize' must be a color"
,
color
.
path
(),
color
.
line
());
double
alpha
=
color
[
3
].
numeric_value
()
-
delta
;
if
(
!
delta
.
is_numeric
())
throw_eval_error
(
"second argument to 'transparentize' must be numeric"
,
delta
.
path
(),
delta
.
line
());
double
dd
=
delta
.
numeric_value
();
if
(
dd
<
0
||
1
<
dd
)
throw_eval_error
(
"amount must be between 0 and 1 for 'transparentize'"
,
delta
.
path
(),
delta
.
line
());
double
alpha
=
color
[
3
].
numeric_value
()
-
dd
;
if
(
alpha
<
0
)
alpha
=
0
;
if
(
alpha
<
0
)
alpha
=
0
;
return
new_Node
(
path
,
line
,
return
new_Node
(
path
,
line
,
color
[
0
].
numeric_value
(),
color
[
0
].
numeric_value
(),
...
@@ -522,13 +508,9 @@ namespace Sass {
...
@@ -522,13 +508,9 @@ namespace Sass {
extern
Signature
fade_out_sig
=
"fade-out($color, $amount)"
;
extern
Signature
fade_out_sig
=
"fade-out($color, $amount)"
;
Node
fade_out
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
fade_out
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
color
(
bindings
[
parameter_names
[
0
].
token
()]);
Node
color
(
arg
(
fade_out_sig
,
path
,
line
,
parameter_names
,
bindings
,
0
,
Node
::
numeric_color
));
Node
delta
(
bindings
[
parameter_names
[
1
].
token
()]);
double
delta
=
arg
(
fade_out_sig
,
path
,
line
,
parameter_names
,
bindings
,
1
,
0
,
1
).
numeric_value
();
if
(
color
.
type
()
!=
Node
::
numeric_color
)
throw_eval_error
(
"first argument to 'fade-out' must be a color"
,
color
.
path
(),
color
.
line
());
double
alpha
=
color
[
3
].
numeric_value
()
-
delta
;
if
(
!
delta
.
is_numeric
())
throw_eval_error
(
"second argument to 'fade-out' must be numeric"
,
delta
.
path
(),
delta
.
line
());
double
dd
=
delta
.
numeric_value
();
if
(
dd
<
0
||
1
<
dd
)
throw_eval_error
(
"amount must be between 0 and 1 for 'fade-out'"
,
delta
.
path
(),
delta
.
line
());
double
alpha
=
color
[
3
].
numeric_value
()
-
dd
;
if
(
alpha
<
0
)
alpha
=
0
;
if
(
alpha
<
0
)
alpha
=
0
;
return
new_Node
(
path
,
line
,
return
new_Node
(
path
,
line
,
color
[
0
].
numeric_value
(),
color
[
0
].
numeric_value
(),
...
...
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