aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/svg/element/mask/index.html
blob: 1bcca8da48c9d7f5deaee785e0f69b6ff68fadfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
---
title: <mask>
slug: Web/SVG/Element/mask
tags:
  - Element
  - SVG
  - SVG Container
translation_of: Web/SVG/Element/mask
---
<div>{{SVGRef}}</div>

<p>The <strong><code>&lt;mask&gt;</code></strong> element defines an alpha mask for compositing the current object into the background. A mask is used/referenced using the {{SVGAttr("mask")}} property.</p>

<div id="Example">
<div class="hidden">
<pre class="brush: css">html,body,svg { height:100% }</pre>
</div>

<pre class="brush: html">&lt;svg viewBox="-10 -10 120 120"&gt;
  &lt;mask id="myMask"&gt;
    &lt;!-- Everything under a white pixel will be visible --&gt;
    &lt;rect x="0" y="0" width="100" height="100" fill="white" /&gt;

    &lt;!-- Everything under a black pixel will be invisible --&gt;
    &lt;path d="M10,35 A20,20,0,0,1,50,35 A20,20,0,0,1,90,35 Q90,65,50,95 Q10,65,10,35 Z" fill="black" /&gt;
  &lt;/mask&gt;

  &lt;polygon points="-10,110 110,110 110,-10" fill="orange" /&gt;

  &lt;!-- with this mask applied, we "punch" a heart shape hole into the circle --&gt;
  &lt;circle cx="50" cy="50" r="50" mask="url(#myMask)" /&gt;
&lt;/svg&gt;</pre>

<p>{{EmbedLiveSample('Example', 100, 100)}}</p>
</div>

<h2 id="属性">属性</h2>

<dl>
 <dt id="attr-cx">{{SVGAttr("height")}}</dt>
 <dd>This attribute defines the height of the masking area.<br>
 <small><em>Value type</em>: <a href="/docs/Web/SVG/Content_type#Length"><strong>&lt;length&gt;</strong></a> ; <em>Default value</em>: <code>120%</code>; <em>Animatable</em>: <strong>yes</strong></small></dd>
 <dt>{{SVGAttr("maskContentUnits")}}</dt>
 <dd>This attribute defines the coordinate system for the contents of the <code>&lt;mask&gt;</code>.<br>
 <small><em>Value type</em><code>userSpaceOnUse</code>|<code>objectBoundingBox</code> ; <em>Default value</em>: <code>userSpaceOnUse</code>; <em>Animatable</em>: <strong>yes</strong></small></dd>
 <dt>{{SVGAttr("maskUnits")}}</dt>
 <dd>This attribute defines defines the coordinate system for attributes {{SVGAttr("x")}}, {{SVGAttr("y")}}, {{SVGAttr("width")}} and {{SVGAttr("height")}} on the <code>&lt;mask&gt;</code>.<br>
 <small><em>Value type</em><code>userSpaceOnUse</code>|<code>objectBoundingBox</code> ; <em>Default value</em>: <code>objectBoundingBox</code>; <em>Animatable</em>: <strong>yes</strong></small></dd>
 <dt id="attr-cx">{{SVGAttr("x")}}</dt>
 <dd>This attribute defines the x-axis coordinate of the top-left corner of the masking area.<br>
 <small><em>Value type</em>: <a href="/docs/Web/SVG/Content_type#Coordinate"><strong>&lt;coordinate&gt;</strong></a> ; <em>Default value</em>: <code>-10%</code>; <em>Animatable</em>: <strong>yes</strong></small></dd>
 <dt id="attr-cx">{{SVGAttr("y")}}</dt>
 <dd>This attribute defines the y-axis coordinate of the top-left corner of the masking area.<br>
 <small><em>Value type</em>: <a href="/docs/Web/SVG/Content_type#Coordinate"><strong>&lt;coordinate&gt;</strong></a> ; <em>Default value</em>: <code>-10%</code>; <em>Animatable</em>: <strong>yes</strong></small></dd>
 <dt id="attr-cx">{{SVGAttr("width")}}</dt>
 <dd>This attribute defines the width of the masking area.<br>
 <small><em>Value type</em>: <a href="/docs/Web/SVG/Content_type#Length"><strong>&lt;length&gt;</strong></a> ; <em>Default value</em>: <code>120%</code>; <em>Animatable</em>: <strong>yes</strong></small></dd>
</dl>

<h3 id="Global_attributes">Global attributes</h3>

<dl>
 <dt><a href="/docs/Web/SVG/Attribute/Core">Core Attributes</a></dt>
 <dd><small>Most notably: {{SVGAttr('id')}}</small></dd>
 <dt><a href="/docs/Web/SVG/Attribute/Styling">Styling Attributes</a></dt>
 <dd><small>{{SVGAttr('class')}}, {{SVGAttr('style')}}</small></dd>
 <dt><a href="/docs/Web/SVG/Attribute/Conditional_Processing">Conditional Processing Attributes</a></dt>
 <dd><small>Most notably: {{SVGAttr('requiredExtensions')}}, {{SVGAttr('systemLanguage')}}</small></dd>
 <dt><a href="/docs/Web/SVG/Attribute/Presentation">Presentation Attributes</a></dt>
 <dd><small>Most notably: {{SVGAttr('clip-path')}}, {{SVGAttr('clip-rule')}}, {{SVGAttr('color')}}, {{SVGAttr('display')}}, {{SVGAttr('fill')}}, {{SVGAttr('fill-opacity')}}, {{SVGAttr('fill-rule')}}, {{SVGAttr('filter')}}, {{SVGAttr('mask')}}, {{SVGAttr('opacity')}}, {{SVGAttr('shape-rendering')}}, {{SVGAttr('stroke')}}, {{SVGAttr('stroke-dasharray')}}, {{SVGAttr('stroke-dashoffset')}}, {{SVGAttr('stroke-linecap')}}, {{SVGAttr('stroke-linejoin')}}, {{SVGAttr('stroke-miterlimit')}}, {{SVGAttr('stroke-opacity')}}, {{SVGAttr('stroke-width')}}, {{SVGAttr("transform")}}, {{SVGAttr('vector-effect')}}, {{SVGAttr('visibility')}}</small></dd>
</dl>

<h2 id="Usage_notes">Usage notes</h2>

<p>{{svginfo}}</p>

<h2 id="仕様">仕様</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">仕様書</th>
   <th scope="col">ステータス</th>
   <th scope="col">コメント</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS Masks', '#MaskElement', '&lt;mask&gt;')}}</td>
   <td>{{Spec2('CSS Masks')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('SVG1.1', 'masking.html#Masking', '&lt;mask&gt;')}}</td>
   <td>{{Spec2('SVG1.1')}}</td>
   <td>初期定義</td>
  </tr>
 </tbody>
</table>

<h2 id="ブラウザの互換性">ブラウザの互換性</h2>

<div class="hidden">このページの互換性テーブルは構造化データから生成されます。データに貢献したい場合は <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックしてプルリクエストを送ってください。</div>

<p>{{Compat("svg.elements.mask")}}</p>

<h2 id="あわせて参照">あわせて参照</h2>

<ul>
 <li>Other clipping and masking SVG elements: {{SVGElement("clipPath")}}</li>
 <li>Clipping and masking CSS properties: {{cssxref("mask")}}, {{cssxref("mask-image")}},{{cssxref("mask-mode")}}, {{cssxref("mask-repeat")}}, {{cssxref("mask-position")}}, {{cssxref("mask-clip")}}, {{cssxref("mask-origin")}}, {{cssxref("mask-composite")}}, {{cssxref("mask-size")}}, {{cssxref("pointer-events")}}</li>
</ul>