In SVG, you can specify that any other graphics object or 'g' element can be used as an alpha mask for compositing the current object into the background.
在SVG中,你可以指定任一图形对象或"g"节点,作为ALPHA MASK,混合当前对象进入背景.
A mask is defined with a 'mask' element. A mask is used/referenced using the 'mask' property.
mask 是通过"mask"节点来定义的, 通过"mask"属性来引用mask.
'mask' can contain any graphical elements or container elements such as a 'g'.
"mask" 节点可包含任何图形节点或类似"g"的容器节点.
It is an error if the 'mask' property references a non-existent object or if the referenced object is not a 'mask' element (see Error Processing).The effect is as if the child elements of the 'mask' are rendered into an offscreen image which has been initialized to transparent black.
"mask"属性不能引用不存在的对象或非"mask" 节点类型的对象.此时的效果相当于被"mask"的子节点,被绘制到一个初始化为黑色透明的offscreen 的图像中.
Any graphical object which uses/references the given 'mask' element will be painted onto the background through the mask, thus completely or partially masking out parts of the graphical object.
引用"mask"属性的对象,绘制时,mask进入背景.因此,完全或部分MASK了部分图形对象
For any graphics object that is used as a mask, the mask value at any point is computed from the color channel values and alpha channel value as follows.
按照下面的方法,计算MASK图形对象的任一点上的COLOR 通道和ALPHA 通道,作为MASK 值.
A linear luminance value is computed from the color channel values
计算颜色通道上线性亮度值.
This can be done, for example, by first converting the original image color values (potentially in the sRGB color space) to the linear RGB color space (see Rendering properties).
这一步可能已经完成,例如在第一次转换过程中,颜色空间转成线性的RGB颜色空间.
Then, using non-premultiplied linear RGB color values, apply the luminance-to-alpha coefficients (as defined in the 'feColorMatrix' filter primitive) to convert the linear RGB color values to linear luminance values
接着,应用系数,转线性RGB值(non-premultiplied)为线性亮度值.
If the graphics object also includes an alpha channel, then the computed linear luminance value is multiplied by the corresponding alpha value to produce the mask value.
如果MASK图形包含ALAPHA 通道,线性亮度值需要乘上ALAHA.
For a four-channel RGBA graphics object that is used as a mask, both the color channels and the alpha channel of the mask contribute to the masking operation.
对于一个4-CHANNEL 的RGBA 的MASK图形,用来MASK,颜色通道和alpha通道,都对MASK的操作产生了作用.
The alpha mask that is used to composite the current object into the background represents the product of the luminance of the color channels (see previous paragraph) and the alpha channel from the mask.
代表了mask 的亮度彩色通道(见前一段)和alpha通道的乘积的alpha mask,混合当前对象进入背景。
For a three-channel RGB graphics object that is used as a mask (e.g., when referencing a 3-channel image file), the effect is as if the object were converted into a 4-channel RGBA image with the alpha channel uniformly set to 1.
对于一个三通道RGB的图形对象,用来MASK (例如,引用了三通道图像文件) ,其效果是,该对象将被转换成一个4通道RGBA图像,Alpha通道设置为1.
For a single-channel image that is used as a mask (e.g., when referencing a 1-channel grayscale image file), the effect is as if the object were converted into a 4-channel RGBA image, where the single channel from the referenced object is used to compute the three color channels and the alpha channel is uniformly set to 1
对于单一通道图像,用来MASK(例如,引用了单一通道图像文件),其效果是,该对象将被转换成一个4通道RGBA的图像,那里的单一通道的来代替三色通道计算,Alpha通道设置为1.
Note that when referencing a grayscale image file, the transfer curve relating the encoded grayscale values to linear light values must be taken into account when computing the color channels.
请注意,当引用灰阶图像文件,关于编码灰阶值的线性光值的转换曲线,必须考虑到计算时的颜色通道.
The effect of a mask is identical to what would have happened if there were no mask but instead the alpha channel of the given object were multiplied with the mask's resulting alpha values (i.e., the product of the mask's luminance from its color channels multiplied by the mask's alpha channel).
mask的效果等同于,用只包含单一的ALPHA通道的图像,混合当前对象进入背景.