You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The compositing model follows the SVG compositing model [[!SVG11]]: First the element is styled under absence of filter effects, masking, clipping and opacity. Then the element and its descendants are drawn on a temporary canvas. In a last step the following effects are applied to the element in order: filter effects [[FILTER-EFFECTS]], clipping, masking and opacity.
78
78
79
+
This specification allows compositing multiple mask layers with the Porter Duff compositing operators defined in CSS Compositing and Blending [[!COMPOSITING-1]].
80
+
79
81
The terms <i>object bounding box</i> and <i>stroke bounding box</i> follow the definitions in SVG 2 [[!SVG2]].
A value of ''none'' counts as an image layer but does not mask the element.
372
+
A value of ''none'' counts as a transparent black image layer.
371
373
</dd>
372
374
</dl>
373
375
374
376
A computed value of other than ''none'' results in the creation of a <aspec="css21">stacking context</a> [[!CSS21]] the same way that CSS 'opacity' [[CSS3COLOR]] does for values other than ''1''.
375
377
376
-
A mask reference that is an empty image (zero width or zero height), that fails to download, is not a reference to an <aelement>mask</a> element, is non-existent, or that cannot be displayed (e.g. because it is not in a supported image format) is ignored. It still counts as an image layer but does not mask the element.
378
+
A mask reference that is an empty image (zero width or zero height), that fails to download, is not a reference to an <aelement>mask</a> element, is non-existent, or that cannot be displayed (e.g. because it is not in a supported image format) still counts as an image layer of transparent black.
377
379
378
380
See the section <ahref="#MaskValues">“Mask processing”</a> for how to process a mask image.
379
381
382
+
Note: A value of ''none'' in a list of <<mask-reference>>s may influence the masking operation depending on the used compositing operator specified by 'mask-composite'.
383
+
384
+
Note: A <<mask-source>> counts as mask layer and can be combined in a repeatable <<mask-reference>> list with <<image>> or further <<mask-source>> list items.
385
+
380
386
Note: An element can also be masked with 'mask-box-source'. See 'mask-box-source' for the interaction of that property with 'mask-image'.
div { mask-image: url(resources.svg#mask2) }</code></pre>
388
394
</div>
389
395
396
+
See the section <ahref="#layering">“Layering multiple mask images”</a> for how 'mask-image' interacts with other comma-separated mask properties to form each mask image layer.
397
+
390
398
<h3id="the-mask-type">Mask Image Interpretation: the 'mask-type' property</h3>
391
399
392
400
<preclass='propdef'>
393
401
Name: mask-type
394
-
Value: <<source-type>>
402
+
Value: <<source-type>>#
395
403
Initial: auto
396
404
Applies to: All elements. In SVG, it applies to <a>container elements</a> excluding the <a>'defs'</a> element and all <a>graphics elements</a>
See the section <ahref="#layering">“Layering multiple mask images”</a> for how 'mask-type' interacts with other comma-separated mask properties to form each mask image layer.
457
+
448
458
<h3id="the-mask-repeat">Tiling Mask Images: The 'mask-repeat' property</h3>
449
459
450
460
<preclass='propdef'>
451
461
Name: mask-repeat
452
-
Value: <<repeat-style>>
462
+
Value: <<repeat-style>>#
453
463
Initial: no-repeat
454
464
Applies to: All elements. In SVG, it applies to <a>container elements</a> excluding the <a>'defs'</a> element and all <a>graphics elements</a>
See the section <ahref="#layering">“Layering multiple mask images”</a> for how 'mask-repeat' interacts with other comma-separated mask properties to form each mask image layer.
494
+
483
495
<h3id="the-mask-position">Positioning Mask Images: the 'mask-position' property</h3>
484
496
485
497
<preclass='propdef'>
486
498
Name: mask-position
487
-
Value: <<position>>
499
+
Value: <<position>>#
488
500
Initial: center
489
501
Applies to: All elements. In SVG, it applies to <a>container elements</a> excluding the <a>'defs'</a> element and all <a>graphics elements</a>
490
502
Inherited: no
491
503
Percentages: refer to size of <i>mask painting area</i><em>minus</em> size of mask image; see text 'background-position' [[!CSS3BG]]
492
504
Computed value: Consisting of: two keywords representing the origin and two offsets from that origin, each given as an absolute length (if given a <<length>>), otherwise as a percentage.
493
505
Media: visual
494
-
Animatable: as <ahref="http://dev.w3.org/csswg/css3-transitions/#animtype-simple-list">simple list</a> of <ahref="http://dev.w3.org/csswg/css3-transitions/#animtype-lpcalc">length, percentage, or calc
506
+
Animatable: as <ahref="http://www.w3.org/TR/css3-transitions/#animtype-repeatable-list">repeatable list</a> of <ahref="http://www.w3.org/TR/css3-transitions/#animtype-simple-list">simple list</a> of <ahref="http://www.w3.org/TR/css3-transitions/#animtype-lpcalc">length, percentage, or calc
495
507
</pre>
496
508
497
509
See the 'background-position' property [[!CSS3BG]] for the definitions of the property values.
<pre><codeclass=css>mask-position: right 3em bottom 10px</code></pre>
514
526
</div>
515
527
528
+
See the section <ahref="#layering">“Layering multiple mask images”</a> for how 'mask-position' interacts with other comma-separated mask properties to form each mask image layer.
529
+
516
530
<h3id="the-mask-clip">Masking Area: the 'mask-clip' property</h3>
517
531
518
532
<preclass='propdef'>
519
533
Name: mask-clip
520
-
Value: <<geometry-box>> | no-clip
534
+
Value: [ <<geometry-box>> | no-clip ]#
521
535
Initial: border-box
522
536
Applies to: All elements. In SVG, it applies to <a>container elements</a> excluding the <a>'defs'</a> element and all <a>graphics elements</a>
523
537
Inherited: no
@@ -576,11 +590,13 @@ <h3 id="the-mask-clip">Masking Area: the 'mask-clip' property</h3>
576
590
577
591
For elements with associated CSS layout box, the values <avaluefor=mask-clip>fill-box</a>, <avaluefor=mask-clip>stroke-box</a> and <avaluefor=mask-clip>view-box</a> compute to the initial value of 'mask-clip'.
578
592
593
+
See the section <ahref="#layering">“Layering multiple mask images”</a> for how 'mask-clip' interacts with other comma-separated mask properties to form each mask image layer.
594
+
579
595
<h3id="the-mask-origin">Positioning Area: the 'mask-origin' property</h3>
580
596
581
597
<preclass='propdef'>
582
598
Name: mask-origin
583
-
Value: <<geometry-box>>
599
+
Value: <<geometry-box>>#
584
600
Initial: border-box
585
601
Applies to: All elements. In SVG, it applies to <a>container elements</a> excluding the <a>'defs'</a> element and all <a>graphics elements</a>
586
602
Inherited: no
@@ -635,29 +651,83 @@ <h3 id="the-mask-origin">Positioning Area: the 'mask-origin' property</h3>
635
651
636
652
Note: If 'mask-clip' is <avaluefor=mask-origin>padding-box</a>, 'mask-origin' is <avaluefor=mask-origin>border-box</a>, 'mask-position' is ''top left'' (the initial value), and the element has a non-zero border, then the top and left of the mask image will be clipped.
637
653
654
+
See the section <ahref="#layering">“Layering multiple mask images”</a> for how 'mask-origin' interacts with other comma-separated mask properties to form each mask image layer.
655
+
638
656
<h3id="the-mask-size">Sizing Mask Images: the 'mask-size' property</h3>
639
657
640
658
<preclass='propdef'>
641
659
Name: mask-size
642
-
Value: <<bg-size>>
660
+
Value: <<bg-size>>#
643
661
Initial: border-box
644
662
Applies to: All elements. In SVG, it applies to <a>container elements</a> excluding the <a>'defs'</a> element and all <a>graphics elements</a>
645
663
Inherited: no
646
664
Percentages: n/a
647
665
Computed value: as specified, but with lengths made absolute
648
666
Media: visual
649
-
Animatable: as <ahref="http://dev.w3.org/csswg/css3-transitions/#animtype-simple-list">simple list</a> of <ahref="http://dev.w3.org/csswg/css3-transitions/#animtype-lpcalc">length, percentage, or calc</a> (<spanclass="note">This means keyword values are not animatable.</span>)
667
+
Animatable: as <ahref="http://www.w3.org/TR/css3-transitions/#animtype-repeatable-list">repeatable list</a> of <ahref="http://www.w3.org/TR/css3-transitions/#animtype-simple-list">simple list</a> of <ahref="http://www.w3.org/TR/css3-transitions/#animtype-lpcalc">length, percentage, or calc</a> (<spanclass="note">This means keyword values are not animatable.</span>)
650
668
</pre>
651
669
652
670
Specifies the size of the mask images.
653
671
654
672
See 'background-size' property [[!CSS3BG]] for the definitions of the property values.
655
673
674
+
See the section <ahref="#layering">“Layering multiple mask images”</a> for how 'mask-size' interacts with other comma-separated mask properties to form each mask image layer.
675
+
676
+
<h3id="the-mask-composite">Compositing mask layers: the 'mask-composite' property</h3>
677
+
678
+
<preclass='propdef'>
679
+
Name: mask-composite
680
+
Value: <<composite-mode>>#
681
+
Initial: source-over
682
+
Applies to: All elements. In SVG, it applies to <a>container elements</a> without the <a>'defs'</a> element and all <a>graphics elements</a>
683
+
Inherited: no
684
+
Percentages: n/a
685
+
Computed value: as specified
686
+
Media: visual
687
+
Animatable: no
688
+
</pre>
689
+
690
+
Defines a Porter Duff compositing operator for each mask layer [[!COMPOSITING-1]].
691
+
692
+
A specified compositing operator defines the compositing operation for the current mask layer with the immediate mask layer below it. If there is no further mask layer, the compositing operator must be ignored. Mask layers must not composite with the element's content or the content behind the element, instead they must act as if they are rendered into an isolated group.
693
+
694
+
<divclass=example>
695
+
An example of the initial compositing operator <em>source-over</em>. Both mask layers will be drawn on top of each other. The result will be used to mask the content of the element.
696
+
697
+
<pre><codeclass=css>
698
+
mask-image: circle.svg, rect.svg;
699
+
mask-composite: source-over;
700
+
</code></pre>
701
+
<imgsrc="images/mask-source-over.svg" width="665" height="260" alt="Example of source-over compositing of mask layers">
702
+
</div>
703
+
704
+
<divclass=example>
705
+
An example of the compositing operator <em>destination-in</em>. The top layer “masks” the mask layer below. Just areas where both, <code>circle.svg</code> and <code>rect.svg</code> are visible will be used as mask.
706
+
707
+
<pre><codeclass=css>
708
+
mask-image: circle.svg, rect.svg;
709
+
mask-composite: destination-in;
710
+
</code></pre>
711
+
<imgsrc="images/mask-destination-in.svg" width="665" height="260" alt="Example of destination-in compositing of mask layers">
712
+
</div>
713
+
714
+
<divclass=example>
715
+
An example of the compositing operator <em>xor</em>. The resulting mask will be the visible areas of <code>circle.svg</code> and <code>rect.svg</code> where both do NOT overlap.
716
+
717
+
<pre><codeclass=css>
718
+
mask-image: circle.svg, rect.svg;
719
+
mask-composite: xor;
720
+
</code></pre>
721
+
<imgsrc="images/mask-xor.svg" width="665" height="260" alt="Example of xor compositing of mask layers">
722
+
</div>
723
+
724
+
See the section <ahref="#layering">“Layering multiple mask images”</a> for how 'mask-composite' interacts with other comma-separated mask properties to form each mask image layer.
725
+
656
726
<h3id="the-mask">Mask Shorthand: the 'mask' property</h3>
657
727
658
728
<preclass='propdef'>
659
729
Name: mask
660
-
Value: <<mask-layer>>
730
+
Value: <<mask-layer>>#
661
731
Initial: see individual properties
662
732
Applies to: All elements. In SVG, it applies to <a>container elements</a> excluding the <a>'defs'</a> element and all <a>graphics elements</a>
663
733
Inherited: no
@@ -668,7 +738,7 @@ <h3 id="the-mask">Mask Shorthand: the 'mask' property</h3>
If one <<geometry-box>> value is present then it sets both 'mask-origin' and 'mask-clip' to that value. If two <<geometry-box>> values are present, then the first sets 'mask-origin' and the second 'mask-clip'.
Note: Masks with repeating mask image tiles may have an offset to each other. The space between the mask images is treated as a transparent black mask.
The mask of a box can have multiple layers. The number of layers is determined by the number of comma-separated values for the 'mask-image' property. A value of ''none'' in a list of values with other <<mask-reference>>s still creates a layer.
794
+
795
+
See <ahref="http://www.w3.org/TR/css3-background/#layering">Layering Multiple Background Images</a> [[!CSS3BG]].
796
+
797
+
All mask images are transformed to alpha masks (if necessary see <ahref="#MaskValue">Mask processing</a>) and combined by compositing taking the compositing operators specified by 'mask-composite' into account.
798
+
721
799
<h2id="box-masks">Box Masks</h2>
722
800
723
801
With 'mask-box' an image can be split into nine pieces: four corners, four edges and the middle piece as demonstrated in the figure below.
0 commit comments