Skip to content

Commit 08d0b92

Browse files
committed
[css-images-4] Added rotation angle to conic-gradient(), added several examples
1 parent fd07f07 commit 08d0b92

7 files changed

Lines changed: 91 additions & 11 deletions

File tree

css-images-4/Overview.bs

Lines changed: 91 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -572,14 +572,16 @@ Gradients</h2>
572572
<h3 id='conic-gradients'>
573573
Conic Gradients: the ''conic-gradient()'' notation</h3>
574574

575+
576+
575577
A conic gradient starts by specifying the center of a circle,
576578
similar to radial gradients,
577579
except that conic gradient color-stops are placed <em>around</em> the circumference of the circle,
578580
rather than on a line emerging from the center,
579581
causing the color to smoothly transition as you spin around the center,
580582
rather than as you progress outward from the center.
581583

582-
A conic gradient is specified by indicating the center of the gradient,
584+
A conic gradient is specified by indicating a rotation angle, the center of the gradient,
583585
and then specifying a list of color-stops.
584586
Unlike linear and radial gradients,
585587
whose color-stops are placed by specifying a <<length>>,
@@ -590,6 +592,16 @@ Conic Gradients: the ''conic-gradient()'' notation</h3>
590592
Note: These gradients are called "conic" or "conical"
591593
because, if the color stops are chosen to be significantly lighter on one side than the other,
592594
it produces a pattern that looks like a cone observed from above.
595+
They are also known as "angle" gradients in some contexts,
596+
since they are produced by varying the rotation angle of a ray.
597+
598+
<div class=example>
599+
<div style="overflow: hidden">
600+
<img style="float: right; margin-left: 1em;" src='images/conic-diagram.png' alt="[An image showing a box with a background shading gradually clockwise from white to black, starting from the top. A gradient circle is shown, and the colors at 0 and 216 degrees respectively.]">
601+
602+
This example visually illustrates how conic-gradient(at 25% 30%, white, black 60%) would be drawn. Note that since color stop positions always resolve to angles, the only effect of the center center is a 2D translation of the gradient, i.e. it does not affect how the gradient is drawn.
603+
</div>
604+
</div>
593605

594606
<h4 id='conic-gradient-syntax' class='no-toc'>
595607
''conic-gradient()'' Syntax</h4>
@@ -598,16 +610,28 @@ Conic Gradients: the ''conic-gradient()'' notation</h3>
598610

599611
<pre class='prod'>
600612
<dfn>conic-gradient()</dfn> = conic-gradient(
601-
[ at <<position>> , ]?
613+
[ from <<angle>> ]? [ at <<position>> ]?,
602614
<<angular-color-stop-list>>
603615
)
604616
</pre>
605617

606-
The <<position>> argument is defined in [!CSS3VAL],
607-
and is resolved using the center-point as the object area
608-
and the gradient box as the positioning area.
609-
If this argument is omitted,
610-
it defaults to 'at center'.
618+
The arguments are defined as follows:
619+
620+
<dl dfn-type=value dfn-for="conic-gradient(), repeating-conic-gradient()">
621+
<dt><dfn><<angle>></dfn>
622+
<dd>
623+
The entire gradient is rotated by this angle.
624+
If omitted, defaults to ''<angle>|0deg''.
625+
626+
<dt><dfn><<position>></dfn>
627+
<dd>
628+
Determines the <dfn dfn>gradient center</dfn> of the gradient.
629+
The <<position>> value type (which is also used for 'background-position')
630+
is defined in [[!CSS3VAL]],
631+
and is resolved using the center-point as the object area
632+
and the <a>gradient box</a> as the positioning area.
633+
If this argument is omitted, it defaults to ''<position>/center''.
634+
</dl>
611635

612636
<p class='issue'>
613637
Anything else that might be useful? Defining the shape of the gradient as elliptical, perhaps?
@@ -640,12 +664,68 @@ Placing Color Stops</h4>
640664
<h4 id='conic-gradient-examples' class='no-toc'>
641665
Conic Gradient Examples</h4>
642666

643-
<p class='issue'>
644-
Produce examples.
645-
Better yet, strike this section, and intermix some examples into the sections above.
646-
Do this for the other two types of gradients as well.
667+
All of the following ''conic-gradient()'' examples are presumed to be applied to a box that is 300px wide and 200px tall, unless otherwise specified.
668+
669+
<div class=example>
670+
Below are various ways of specifying the same basic conic gradient:
671+
672+
<pre>
673+
background: conic-gradient(#f06, gold);
674+
background: conic-gradient(at 50% 50%, #f06, gold);
675+
background: conic-gradient(from 0deg, #f06, gold);
676+
background: conic-gradient(from 0deg at center, #f06, gold);
677+
background: conic-gradient(#f06 0%, gold 100%);
678+
background: conic-gradient(#f06 0deg, gold 1turn);
679+
</pre>
680+
681+
<img src="images/conic1.png" alt="" >
682+
</div>
683+
684+
<div class=example>
685+
Below are two different ways of specifying the same rotated conic gradient, one with a rotation angle and one without:
686+
687+
<pre>
688+
background: conic-gradient(from 45deg, white, black, white);
689+
background: conic-gradient(hsl(0,0%,87.5%), white 45deg, black 225deg, hsl(0,0%,87.5%));
690+
</pre>
691+
692+
<img src="images/conic2.png" alt="" >
647693

694+
Note that offsetting every color stop by the rotation angle instead would not work and produces an entirely different gradient:
695+
696+
<pre>
697+
background: conic-gradient(white 45deg, black 225deg, white 405deg);
698+
</pre>
648699

700+
<img src="images/conic3.png" alt="" >
701+
</div>
702+
703+
<div class=example>
704+
A conic gradient used to draw a hue wheel:
705+
706+
<pre>
707+
background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
708+
border-radius: 50%;
709+
width: 200px; height: 200px;
710+
</pre>
711+
712+
<img src="images/conic4.png" alt="" >
713+
</div>
714+
715+
<div class=example>
716+
A conic gradient used to draw a simple pie chart.
717+
The 0 color stop positions will be fixed up to be equal to the position of the color stop before them.
718+
This will produce infinitesimal (invisible) transitions between the color stops with different colors,
719+
effectively producing solid color segments.
720+
721+
<pre>
722+
background: conic-gradient(yellowgreen 40%, gold 0 75%, #f06 0);
723+
border-radius: 50%;
724+
width: 200px; height: 200px;
725+
</pre>
726+
727+
<img src="images/conic5.png" alt="" >
728+
</div>
649729

650730
<!--
651731
████████ ████████ ████████ ████████ ███ ████████ ████ ██ ██ ██████
86.4 KB
Loading

css-images-4/images/conic1.png

20 KB
Loading

css-images-4/images/conic2.png

17.3 KB
Loading

css-images-4/images/conic3.png

16.3 KB
Loading

css-images-4/images/conic4.png

15.8 KB
Loading

css-images-4/images/conic5.png

5.16 KB
Loading

0 commit comments

Comments
 (0)