@@ -564,14 +564,15 @@ Image Fallbacks and Annotations: the ''image()'' notation {#image-notation}
564
564
565
565
566
566
567
-
576
577
577
578
Combining images: the ''cross-fade()'' notation {#cross-fade-function}
@@ -647,37 +648,35 @@ Combining images: the ''cross-fade()'' notation {#cross-fade-function}
647
648
648
649
To determine the [=natural dimensions=] of a cross-fade() :
649
650
650
- 1. Let |images| be an empty list.
651
+ 1. [=Normalize mix percentages=] from the function's arguments,
652
+ and let |args| and |leftover| be the result.
653
+
654
+ 2. If |leftover| is 100%,
655
+ return no [=natural dimensions=] .
651
656
652
- 2. For each |argument| of the ''cross-fade()'' function with an <> value:
653
- 1. Let |item| be a [=tuple=] consisting of a width, a height, and a percentage.
654
- 2. Run the [=object size negotiation=] algorithm for the <> ,
657
+ 3. Let |images| be an empty list.
658
+
659
+ 4. For each <> |argument| of the function's arguments:
660
+ 1. If |argument| is not an <> ,
661
+ or is an <> with no natural dimensions,
662
+ [=iteration/continue=] .
663
+ 2. Let |item| be a [=tuple=] consisting of a width, a height, and a percentage.
664
+ 3. Run the [=object size negotiation=] algorithm for the <> ,
655
665
as appropriate for the context in which the ''cross-fade()'' appears,
656
666
and set |item|’s width and height
657
667
to the width and height of the resulting [=concrete object size=] .
658
- 3 . Set |item|’s percentage to the |argument|’s percentage.
668
+ 4 . Set |item|’s percentage to the |argument|’s percentage.
659
669
660
- 3 . If |images| is empty,
670
+ 5 . If |images| is empty,
661
671
return no [=natural dimensions=] .
662
672
663
- 4. Let |percentage sum| be the sum of all the percentages of the [=list/items=] in |images|.
664
-
665
- 5. [=list/For each=] |item| in |images|,
666
- divide |item|’s percentage by |percentage sum|,
667
- and set |item|’s percentage to the result.
673
+ 6. Return a [=natural width=] and [=natural height=]
674
+ that are weighted averages of the width and height
675
+ of each item in |images|,
676
+ according to their corresponding percentages.
668
677
669
- Assert: The percentages in |images| now sum to ''100%'' .
670
-
671
- 6. Let |final width| and |final height| be ''0px'' .
672
-
673
- 7. [=list/For each=] |item| in |images|,
674
- multiply |item|’s width by |item|’s percentage
675
- and add the result to |final width|,
676
- and multiply |item|’s height by |item|’s percentage
677
- and add the result to |final height|.
678
-
679
- 8. Return a [=natural width=] of |final width|
680
- and a [=natural height=] of |final height|.
678
+ Note: The percentages might sum to a value less than 100%,
679
+ so a naive weighted-averaging process might need to normalize them first.
681
680
682
681
683
682
### ''cross-fade()'' Painting ### {#cross-fade-painting}
@@ -686,10 +685,12 @@ Combining images: the ''cross-fade()'' notation {#cross-fade-function}
686
685
is a weighted average of the input arguments to the function,
687
686
calculated as follows:
688
687
689
-
690
688
691
689
To determine the appearance of a cross-fade() :
692
690
691
+ 1. [=Normalize mix percentages=] from the function's arguments,
692
+ and let |args| and |leftover| be the result.
693
+
693
694
1. Let |images| be an empty list.
694
695
695
696
2. Let |size| be a [=tuple=] of width and height,
@@ -707,19 +708,11 @@ Combining images: the ''cross-fade()'' notation {#cross-fade-function}
707
708
with |size|’s dimensions.
708
709
3. Set |item|’s percentage to the |argument|’s percentage.
709
710
710
- 4. Let |percentage sum| be the sum of all the percentages of the [=list/items=] in |images|.
711
-
712
- 5. If |percentage sum| is less than ''100%'' ,
711
+ 5. If |leftover| is greater than ''0%'' ,
713
712
append a [=tuple=] to |images|
714
713
consisting of a solid-color transparent-black image
715
714
with |size|’s dimensions,
716
- and a percentage equal to ''100%'' minus |percentage sum|.
717
-
718
- Otherwise,
719
- if |percentage sum| is greater than ''100%'' ,
720
- then [=list/for each=] |item| in |images|,
721
- divide |item|’s percentage by |percentage sum|,
722
- and set |item|’s percentage to the result.
715
+ and a percentage equal to |leftover|.
723
716
724
717
6. Let |final image| be an image
725
718
with |size|’s dimensions,
0 commit comments