mirror of
https://github.com/sharkdp/bat.git
synced 2025-02-26 14:41:53 +01:00
Add Stylus syntax test file
This commit is contained in:
parent
6e5a2a5c51
commit
768189859a
90
tests/syntax-tests/highlighted/Stylus/gradients.styl
Normal file
90
tests/syntax-tests/highlighted/Stylus/gradients.styl
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
[38;2;249;38;114m@import[0m[38;2;248;248;242m [0m[38;2;230;219;116m'config'[0m
|
||||||
|
|
||||||
|
[38;2;117;113;94m/*[0m
|
||||||
|
[38;2;117;113;94m * Implicit color stop position.[0m
|
||||||
|
[38;2;117;113;94m [0m[38;2;117;113;94m*/[0m
|
||||||
|
|
||||||
|
[38;2;166;226;46mpos-in-stops[0m[38;2;248;248;242m([0m[38;2;255;255;255mi[0m[38;2;248;248;242m, [0m[38;2;255;255;255mstops[0m[38;2;248;248;242m)[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;255;255;255mlen[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;166;226;46mlength[0m[38;2;248;248;242m([0m[38;2;255;255;255mstops[0m[38;2;248;248;242m)[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;255;255;255mlen[0m[38;2;248;248;242m [0m[38;2;249;38;114m-[0m[38;2;248;248;242m [0m[38;2;190;132;255m1[0m[38;2;248;248;242m [0m[38;2;249;38;114m==[0m[38;2;248;248;242m [0m[38;2;255;255;255mi[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;166;226;46m100%[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;249;38;114melse[0m[38;2;248;248;242m [0m[38;2;255;255;255mif[0m[38;2;248;248;242m [0m[38;2;255;255;255mi[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;166;226;46munit[0m[38;2;248;248;242m([0m[38;2;255;255;255mi[0m[38;2;248;248;242m [0m[38;2;249;38;114m/[0m[38;2;248;248;242m [0m[38;2;255;255;255mlen[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;190;132;255m100[0m[38;2;248;248;242m, [0m[38;2;230;219;116m'%'[0m[38;2;248;248;242m)[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;249;38;114melse[0m
|
||||||
|
[38;2;248;248;242m [0m[3;38;2;166;226;46m0[0m
|
||||||
|
|
||||||
|
[38;2;117;113;94m/*[0m
|
||||||
|
[38;2;117;113;94m * Normalize color stops:[0m
|
||||||
|
[38;2;117;113;94m *[0m
|
||||||
|
[38;2;117;113;94m * - (color pos) -> (pos color)[0m
|
||||||
|
[38;2;117;113;94m * - (color) -> (implied-pos color)[0m
|
||||||
|
[38;2;117;113;94m *[0m
|
||||||
|
[38;2;117;113;94m [0m[38;2;117;113;94m*/[0m
|
||||||
|
|
||||||
|
[38;2;166;226;46mnormalize-stops[0m[38;2;248;248;242m([0m[38;2;255;255;255mstops[0m[38;2;248;248;242m)[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;255;255;255mstops[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;166;226;46mclone[0m[38;2;248;248;242m([0m[38;2;255;255;255mstops[0m[38;2;248;248;242m)[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;249;38;114mfor[0m[38;2;248;248;242m [0m[38;2;255;255;255mstop[0m[38;2;248;248;242m, [0m[38;2;255;255;255mi[0m[38;2;249;38;114m in[0m[38;2;248;248;242m [0m[38;2;255;255;255mstops[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;166;226;46mlength[0m[38;2;248;248;242m([0m[38;2;255;255;255mstop[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m==[0m[38;2;248;248;242m [0m[38;2;190;132;255m1[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;255;255;255mcolor[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mstop[0m[38;2;248;248;242m[[0m[38;2;255;255;255m0[0m[38;2;248;248;242m][0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;255;255;255mstop[0m[38;2;248;248;242m[[0m[38;2;255;255;255m0[0m[38;2;248;248;242m][0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;166;226;46mpos-in-stops[0m[38;2;248;248;242m([0m[38;2;255;255;255mi[0m[38;2;248;248;242m, [0m[38;2;255;255;255mstops[0m[38;2;248;248;242m)[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;255;255;255mstop[0m[38;2;248;248;242m[[0m[38;2;255;255;255m1[0m[38;2;248;248;242m][0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mcolor[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;249;38;114melse[0m[38;2;248;248;242m [0m[38;2;255;255;255mif[0m[38;2;248;248;242m [0m[38;2;166;226;46mtypeof[0m[38;2;248;248;242m([0m[38;2;255;255;255mstop[0m[38;2;248;248;242m[[0m[38;2;255;255;255m1[0m[38;2;248;248;242m][0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m==[0m[38;2;248;248;242m [0m[38;2;230;219;116m'unit'[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;255;255;255mpos[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mstop[0m[38;2;248;248;242m[[0m[38;2;255;255;255m1[0m[38;2;248;248;242m][0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;255;255;255mstop[0m[38;2;248;248;242m[[0m[38;2;255;255;255m1[0m[38;2;248;248;242m][0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mstop[0m[38;2;248;248;242m[[0m[38;2;255;255;255m0[0m[38;2;248;248;242m][0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;255;255;255mstop[0m[38;2;248;248;242m[[0m[38;2;255;255;255m0[0m[38;2;248;248;242m][0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mpos[0m
|
||||||
|
[38;2;248;248;242m [0m[3;38;2;166;226;46ms[0m[3;38;2;166;226;46mt[0m[3;38;2;166;226;46mo[0m[3;38;2;166;226;46mp[0m[3;38;2;166;226;46ms[0m
|
||||||
|
|
||||||
|
[38;2;117;113;94m/*[0m
|
||||||
|
[38;2;117;113;94m * Join color stops with the given translation function.[0m
|
||||||
|
[38;2;117;113;94m [0m[38;2;117;113;94m*/[0m
|
||||||
|
|
||||||
|
[38;2;166;226;46mjoin-stops[0m[38;2;248;248;242m([0m[38;2;255;255;255mstops[0m[38;2;248;248;242m, [0m[38;2;255;255;255mtranslate[0m[38;2;248;248;242m)[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;255;255;255mstr[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m''[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;255;255;255mlen[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;166;226;46mlength[0m[38;2;248;248;242m([0m[38;2;255;255;255mstops[0m[38;2;248;248;242m)[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;249;38;114mfor[0m[38;2;248;248;242m [0m[38;2;255;255;255mstop[0m[38;2;248;248;242m, [0m[38;2;255;255;255mi[0m[38;2;249;38;114m in[0m[38;2;248;248;242m [0m[38;2;255;255;255mstops[0m
|
||||||
|
[38;2;248;248;242m [0m[3;38;2;166;226;46ms[0m[3;38;2;166;226;46mt[0m[3;38;2;166;226;46mr[0m[38;2;248;248;242m [0m[38;2;249;38;114m+[0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m', '[0m[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;255;255;255mi[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;255;255;255mpos[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mstop[0m[38;2;248;248;242m[[0m[38;2;255;255;255m0[0m[38;2;248;248;242m][0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;255;255;255mcolor[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mstop[0m[38;2;248;248;242m[[0m[38;2;255;255;255m1[0m[38;2;248;248;242m][0m
|
||||||
|
[38;2;248;248;242m [0m[3;38;2;166;226;46ms[0m[3;38;2;166;226;46mt[0m[3;38;2;166;226;46mr[0m[38;2;248;248;242m [0m[38;2;249;38;114m+[0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;166;226;46mtranslate[0m[38;2;248;248;242m([0m[38;2;255;255;255mcolor[0m[38;2;248;248;242m, [0m[38;2;255;255;255mpos[0m[38;2;248;248;242m)[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;166;226;46munquote[0m[38;2;248;248;242m([0m[38;2;255;255;255mstr[0m[38;2;248;248;242m)[0m
|
||||||
|
|
||||||
|
[38;2;117;113;94m/*[0m
|
||||||
|
[38;2;117;113;94m * Standard color stop.[0m
|
||||||
|
[38;2;117;113;94m [0m[38;2;117;113;94m*/[0m
|
||||||
|
|
||||||
|
[38;2;166;226;46mstd-stop[0m[38;2;248;248;242m([0m[38;2;255;255;255mcolor[0m[38;2;248;248;242m, [0m[38;2;255;255;255mpos[0m[38;2;248;248;242m)[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;230;219;116m'%s %s'[0m[38;2;248;248;242m [0m[38;2;249;38;114m%[0m[38;2;248;248;242m (color pos)[0m
|
||||||
|
|
||||||
|
[38;2;117;113;94m/*[0m
|
||||||
|
[38;2;117;113;94m * Create a linear gradient with the given start position[0m
|
||||||
|
[38;2;117;113;94m * and variable number of color stops.[0m
|
||||||
|
[38;2;117;113;94m *[0m
|
||||||
|
[38;2;117;113;94m * Examples:[0m
|
||||||
|
[38;2;117;113;94m *[0m
|
||||||
|
[38;2;117;113;94m * background: linear-gradient(top, red, green, blue)[0m
|
||||||
|
[38;2;117;113;94m * background: linear-gradient(bottom, red, green 50%, blue)[0m
|
||||||
|
[38;2;117;113;94m * background: linear-gradient(bottom, red, 50% green, blue)[0m
|
||||||
|
[38;2;117;113;94m * background: linear-gradient(bottom, red, 50% green, 90% white, blue)[0m
|
||||||
|
[38;2;117;113;94m *[0m
|
||||||
|
[38;2;117;113;94m [0m[38;2;117;113;94m*/[0m
|
||||||
|
|
||||||
|
[38;2;166;226;46mlinear-gradient[0m[38;2;248;248;242m([0m[38;2;255;255;255mstart[0m[38;2;248;248;242m, [0m[38;2;255;255;255mstops[0m[38;2;248;248;242m.[0m[38;2;248;248;242m.[0m[38;2;248;248;242m.[0m[38;2;248;248;242m)[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;166;226;46merror[0m[38;2;248;248;242m([0m[38;2;230;219;116m'color stops required'[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114munless[0m[38;2;248;248;242m [0m[38;2;166;226;46mlength[0m[38;2;248;248;242m([0m[38;2;255;255;255mstops[0m[38;2;248;248;242m)[0m
|
||||||
|
|
||||||
|
[38;2;248;248;242m [0m[38;2;166;226;46munquote[0m[38;2;248;248;242m([0m[38;2;230;219;116m'linear-gradient('[0m[38;2;248;248;242m [0m[38;2;249;38;114m+[0m[38;2;248;248;242m [0m[38;2;166;226;46mjoin[0m[38;2;248;248;242m([0m[38;2;230;219;116m', '[0m[38;2;248;248;242m,[0m[38;2;255;255;255marguments[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m+[0m[38;2;248;248;242m [0m[38;2;230;219;116m')'[0m[38;2;248;248;242m)[0m
|
||||||
|
|
||||||
|
[38;2;117;113;94m/*[0m
|
||||||
|
[38;2;117;113;94m * Create a linear gradient image with the given start position[0m
|
||||||
|
[38;2;117;113;94m * and variable number of color stops.[0m
|
||||||
|
[38;2;117;113;94m [0m[38;2;117;113;94m*/[0m
|
||||||
|
|
||||||
|
[38;2;166;226;46mlinear-gradient-image[0m[38;2;248;248;242m([0m[38;2;255;255;255mstart[0m[38;2;248;248;242m, [0m[38;2;255;255;255mstops[0m[38;2;248;248;242m.[0m[38;2;248;248;242m.[0m[38;2;248;248;242m.[0m[38;2;248;248;242m)[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;166;226;46merror[0m[38;2;248;248;242m([0m[38;2;230;219;116m'node-canvas is required for linear-gradient-image()'[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114munless[0m[38;2;248;248;242m [0m[38;2;255;255;255mhas-canvas[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;255;255;255mstops[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mstops[0m[38;2;248;248;242m[[0m[38;2;255;255;255m0[0m[38;2;248;248;242m][0m[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;166;226;46mlength[0m[38;2;248;248;242m([0m[38;2;255;255;255mstops[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m==[0m[38;2;248;248;242m [0m[38;2;190;132;255m1[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;166;226;46merror[0m[38;2;248;248;242m([0m[38;2;230;219;116m'gradient image size required'[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114munless[0m[38;2;248;248;242m [0m[38;2;255;255;255mstart[0m[38;2;248;248;242m[[0m[38;2;255;255;255m0[0m[38;2;248;248;242m][0m[38;2;249;38;114m is a[0m[38;2;248;248;242m [0m[38;2;230;219;116m'unit'[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;255;255;255msize[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mstart[0m[38;2;248;248;242m[[0m[38;2;255;255;255m0[0m[38;2;248;248;242m][0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;255;255;255mstart[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mstart[0m[38;2;248;248;242m[[0m[38;2;255;255;255m1[0m[38;2;248;248;242m][0m[38;2;248;248;242m [0m[38;2;255;255;255mor[0m[38;2;248;248;242m [0m[38;2;230;219;116m'top'[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;255;255;255mgrad[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;166;226;46mcreate-gradient-image[0m[38;2;248;248;242m([0m[38;2;255;255;255msize[0m[38;2;248;248;242m, [0m[38;2;255;255;255mstart[0m[38;2;248;248;242m)[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;255;255;255mstops[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;166;226;46mnormalize-stops[0m[38;2;248;248;242m([0m[38;2;255;255;255mstops[0m[38;2;248;248;242m)[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;166;226;46madd-color-stop[0m[38;2;248;248;242m([0m[38;2;255;255;255mgrad[0m[38;2;248;248;242m, [0m[38;2;255;255;255mstop[0m[38;2;248;248;242m[[0m[38;2;255;255;255m0[0m[38;2;248;248;242m][0m[38;2;248;248;242m, [0m[38;2;255;255;255mstop[0m[38;2;248;248;242m[[0m[38;2;255;255;255m1[0m[38;2;248;248;242m][0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114mfor[0m[38;2;248;248;242m [0m[38;2;255;255;255mstop[0m[38;2;249;38;114m in[0m[38;2;248;248;242m [0m[38;2;255;255;255mstops[0m
|
||||||
|
[38;2;248;248;242m [0m[38;2;230;219;116m'url(%s)'[0m[38;2;248;248;242m [0m[38;2;249;38;114m%[0m[38;2;248;248;242m [0m[38;2;166;226;46mgradient-data-uri[0m[38;2;248;248;242m([0m[38;2;255;255;255mgrad[0m[38;2;248;248;242m)[0m
|
24
tests/syntax-tests/source/Stylus/LICENSE.md
Normal file
24
tests/syntax-tests/source/Stylus/LICENSE.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
The `gradients.styl` file has been added from https://github.com/stylus/nib under the following license:
|
||||||
|
|
||||||
|
```text
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
```
|
90
tests/syntax-tests/source/Stylus/gradients.styl
Normal file
90
tests/syntax-tests/source/Stylus/gradients.styl
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
@import 'config'
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Implicit color stop position.
|
||||||
|
*/
|
||||||
|
|
||||||
|
pos-in-stops(i, stops)
|
||||||
|
len = length(stops)
|
||||||
|
if len - 1 == i
|
||||||
|
100%
|
||||||
|
else if i
|
||||||
|
unit(i / len * 100, '%')
|
||||||
|
else
|
||||||
|
0
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Normalize color stops:
|
||||||
|
*
|
||||||
|
* - (color pos) -> (pos color)
|
||||||
|
* - (color) -> (implied-pos color)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
normalize-stops(stops)
|
||||||
|
stops = clone(stops)
|
||||||
|
for stop, i in stops
|
||||||
|
if length(stop) == 1
|
||||||
|
color = stop[0]
|
||||||
|
stop[0] = pos-in-stops(i, stops)
|
||||||
|
stop[1] = color
|
||||||
|
else if typeof(stop[1]) == 'unit'
|
||||||
|
pos = stop[1]
|
||||||
|
stop[1] = stop[0]
|
||||||
|
stop[0] = pos
|
||||||
|
stops
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Join color stops with the given translation function.
|
||||||
|
*/
|
||||||
|
|
||||||
|
join-stops(stops, translate)
|
||||||
|
str = ''
|
||||||
|
len = length(stops)
|
||||||
|
for stop, i in stops
|
||||||
|
str += ', ' if i
|
||||||
|
pos = stop[0]
|
||||||
|
color = stop[1]
|
||||||
|
str += translate(color, pos)
|
||||||
|
unquote(str)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Standard color stop.
|
||||||
|
*/
|
||||||
|
|
||||||
|
std-stop(color, pos)
|
||||||
|
'%s %s' % (color pos)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a linear gradient with the given start position
|
||||||
|
* and variable number of color stops.
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
*
|
||||||
|
* background: linear-gradient(top, red, green, blue)
|
||||||
|
* background: linear-gradient(bottom, red, green 50%, blue)
|
||||||
|
* background: linear-gradient(bottom, red, 50% green, blue)
|
||||||
|
* background: linear-gradient(bottom, red, 50% green, 90% white, blue)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
linear-gradient(start, stops...)
|
||||||
|
error('color stops required') unless length(stops)
|
||||||
|
|
||||||
|
unquote('linear-gradient(' + join(', ',arguments) + ')')
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a linear gradient image with the given start position
|
||||||
|
* and variable number of color stops.
|
||||||
|
*/
|
||||||
|
|
||||||
|
linear-gradient-image(start, stops...)
|
||||||
|
error('node-canvas is required for linear-gradient-image()') unless has-canvas
|
||||||
|
stops = stops[0] if length(stops) == 1
|
||||||
|
error('gradient image size required') unless start[0] is a 'unit'
|
||||||
|
size = start[0]
|
||||||
|
start = start[1] or 'top'
|
||||||
|
grad = create-gradient-image(size, start)
|
||||||
|
stops = normalize-stops(stops)
|
||||||
|
add-color-stop(grad, stop[0], stop[1]) for stop in stops
|
||||||
|
'url(%s)' % gradient-data-uri(grad)
|
Loading…
Reference in New Issue
Block a user