What is the use of html5 mask?
html5 The function of the mask is to specify the visible area of a display object. All display objects have the mask function; the rectangular mask means that the visible area of the display object is a square display area rather than an irregular display area; display Object masking means that the visible area of the display object is determined by another display object, which can achieve irregular masking.
The operating environment of this tutorial: Windows 10 system, HTML5 version, DELL G3 computer
html5 What is the use of masking?
Rectangular mask
Rectangular mask, that is, the visible area of the displayed object is a square display area rather than an irregular display area. Usage is: assign a rectangular object to themask property of the display object.
shp.mask = new egret.Rectangle(20,20,30,50);
IfIn the following example, tworect
changes,
rectneeds to be reassigned to
shp.mask.
Shape objects are drawn. One
Shape is used as a rectangular mask, and the other
Shape is used as refer to. The code is as follows:
class Test extends egret.DisplayObjectContainer{ public constructor() { super(); this.addEventListener(egret.Event.ADDED_TO_STAGE,this.onAddToStage,this); } private onAddToStage(event:egret.Event) { var shp:egret.Shape = new egret.Shape(); shp.graphics.beginFill( 0xff0000 ); shp.graphics.drawRect( 0,0,100,100); shp.graphics.endFill(); this.addChild( shp ); var shp2:egret.Shape = new egret.Shape(); shp2.graphics.beginFill( 0x00ff00 ); shp2.graphics.drawCircle( 0,0, 20); shp2.graphics.endFill(); this.addChild( shp2 ); shp2.x = 20; shp2.y = 20; }}
shp. The specific code is as follows:
var rect:egret.Rectangle = new egret.Rectangle(20,20,30,50); shp.mask = rect;
Display object mask
Display object mask, that is, the visible area of the display object is determined by another display object, which can achieve irregular masking. Usage is: Set themask attribute of the masked display object to the mask object:
//将maskSprite设置为mySprite的遮罩 mySprite.mask = maskSprite;
Shape instance containing a red square of 100 x 100 pixels and a
Sprite instance containing a blue circle with a radius of 25 pixels, which is set to Square mask. The square display area is the part covered by the circular opaque area.
//画一个红色的正方形 var square:egret.Shape = new egret.Shape(); square.graphics.beginFill(0xff0000); square.graphics.drawRect(0,0,100,100); square.graphics.endFill(); this.addChild(square);//画一个蓝色的圆形var circle:egret.Shape = new egret.Shape();circle.graphics.beginFill(0x0000ff);circle.graphics.drawCircle(25,25,25);circle.graphics.endFill();this.addChild(circle);square.mask = circle;
mask property to
null:
mySprite.mask = null;
You cannot use one mask object to mask another A mask object. Display the object as a mask, there is no need to repeatedly assignmask
like a rectangular mask, but
maskmust be an element in the display list.
Recommended study: "HTML5 Video Tutorial"
The above is the detailed content of What is the use of html5 mask?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
