Skip to content

Commit 3b6d36a

Browse files
committed
ideas/radial-gradients: [Radial Gradient Wars]
1 parent b3ee7d1 commit 3b6d36a

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

ideas/radial-gradients.txt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,25 @@ If '%%[[center],]? circle%%', then the gradient's 100% color stop aligns with th
8383
* Percentages are relative to both dimensions, fixed distances measured against horizontal only. This is in the more complex syntax too.
8484
* <side-or-corner-or-center> and 'center' both have an effect on the gradient line length, but it is a very simple calculation (the centered gradients have half the gradient line length of the others; 'center' means you use the smaller dimension of either horizontal or vertical only).
8585

86+
== Things an author has to learn with syntax A, not in linear-gradient: ==
8687

87-
88+
* Differences with similar-looking background syntax:
89+
* radial-gradient uses a comma instead of a slash to disambiguate between position and size,
90+
* the size values are for a quarter of the image size, not the whole image size,
91+
* the explicit size doesn't give the image implicit dimensions,
92+
* the positioning lengths and keywords apply to the center of the gradient, instead of to the top left (and percentage offsets are even more different),
93+
* the positioning values move the whole gradient and then clip it to the image dimensions.
94+
* Two gradient lines (horizontal and vertical radii) instead of one (unless using 'circle' keyword). No getting around this in either syntax.
95+
* Percentages are relative to both dimensions, fixed distances measured against horizontal only. This is in simplified syntax too.
96+
* Even though the spec says “The gradient-ray is anchored at the center of the gradient and extends toward the right”, fixed distance color stops can just as easily be measured from center to left, since all the gradients are symetrical.
97+
* If you want to use an explicit size, you must include the <bg-position> part too (so that the comma will disambiguate).
98+
'closest-corner' and 'farthest-corner' are the same if there is no <bg-position> .
99+
moving the center via <bg-position> does not move it relative to the whole ellipse, it moves the entire ellipse. This means the gradient gets bigger if you have 'cover' or 'farthest-*', and smaller if you have 'contain' or 'closest-*'.
100+
* If you specify a <bg-position> and a <size> keyword, the positioning happens first. This means that the positioning affects the gradient length, then the sizing keyword changes it to something else. If these were done is the opposite order, then only the <size> would affect the gradient length (but it would be harder to get the image filled in useful and common ways).
101+
* Conversely, if you specify a <bg-position> and an explicit size, the size overrides the effect of positioning on gradient length.
102+
* When 'circle' is used, percentage stops refer to the shortest dimension when 'contain' or 'closest-*' is used, and to the longest dimension when 'cover' or 'farthest-*' is used.
103+
* 'closest-side' does not equal “shortest dimension” when there is a <bg-position> other than '50% 50%', because the closer you get to one side, the smaller the gradient line gets.
104+
* Every single argument of the function affects the gradient length, so just knowing the image dimensions and the color-stop percentage does not easily reveal the color-stop distance.
88105
===== Examples Shootout =====
89106

90107
^ Sample ^ Syntax A ^ Syntax B ^

0 commit comments

Comments
 (0)