Skip to content

Commit cf24fe2

Browse files
committed
clip masks
1 parent f6b9cf4 commit cf24fe2

File tree

5 files changed

+149
-0
lines changed

5 files changed

+149
-0
lines changed

src/clips/mask/circleMask.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import {Graphics} from "pixi.js";
2+
3+
4+
export interface CircleMaskProps {
5+
radius?: number,
6+
}
7+
8+
export class CircleMask extends Graphics {
9+
10+
public radius = 30
11+
public constructor(props: CircleMaskProps){
12+
super()
13+
14+
Object.assign(this, props);
15+
16+
this.circle(this.position.x + this.radius, this.position.y + this.radius, this.radius)
17+
this.fill({color: '#FFF'})
18+
}
19+
}

src/clips/mask/ellipseMask.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {Graphics} from "pixi.js";
2+
3+
4+
export interface ellipseMaskProps {
5+
radius: {
6+
x?: number,
7+
y?: number,
8+
}
9+
}
10+
11+
export class ellipseMask extends Graphics {
12+
13+
public radius = {
14+
x: 30,
15+
y: 30
16+
}
17+
18+
public constructor(props: ellipseMaskProps){
19+
super()
20+
21+
Object.assign(this, props);
22+
23+
this.ellipse(this.position.x + (this.radius.x /2), this.position.y + (this.radius.y /2), this.radius.x /2, this.radius.y /2 )
24+
this.fill({color: '#FFF'})
25+
}
26+
}

src/clips/mask/rectangleMask.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import {Graphics} from "pixi.js";
2+
import { int } from "../../types";
3+
4+
5+
export interface rectangleMaskProps {
6+
_width?: number,
7+
_height?: number,
8+
}
9+
10+
export class rectangleMask extends Graphics {
11+
12+
public constructor(props: rectangleMaskProps) {
13+
super()
14+
15+
Object.assign(this, props);
16+
17+
this.rect(this.position.x, this.position.y, this._width, this._height)
18+
this.fill({color: '#FFF'})
19+
}
20+
21+
private _width = 100;
22+
private _height = 100;
23+
24+
set width(val: int){
25+
this._width = val
26+
}
27+
28+
get width(){
29+
return this._width;
30+
}
31+
32+
set height(val: int){
33+
this._height = val
34+
}
35+
36+
get height(){
37+
return this._height;
38+
}
39+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import {Graphics} from "pixi.js";
2+
import { int } from "../../types";
3+
4+
5+
export interface roundRectangleMaskProps {
6+
_width?: number,
7+
_height?: number,
8+
radius?: number,
9+
}
10+
11+
export class roundRectangleMask extends Graphics {
12+
13+
public radius = 50
14+
15+
public constructor(props: roundRectangleMaskProps) {
16+
super()
17+
18+
Object.assign(this, props);
19+
20+
this.roundRect(this.position.x, this.position.y, this._width, this._height, this.radius)
21+
this.fill({color: '#FFF'})
22+
}
23+
24+
private _width = 100;
25+
private _height = 100;
26+
27+
set width(val: int){
28+
this._width = val
29+
}
30+
31+
get width(){
32+
return this._width;
33+
}
34+
35+
set height(val: int){
36+
this._height = val
37+
}
38+
39+
get height(){
40+
return this._height;
41+
}
42+
}

src/clips/mask/starMask.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {Graphics} from "pixi.js";
2+
3+
4+
export interface StarMaskProps {
5+
points?: number,
6+
radius?: number,
7+
InnerRadius?: number,
8+
}
9+
10+
export class StarMask extends Graphics {
11+
12+
public points = 5
13+
public radius = 30
14+
public InnerRadius = 0
15+
public constructor(props: StarMaskProps){
16+
super()
17+
18+
Object.assign(this, props);
19+
20+
this.star(this.position.x + this.radius, this.position.y + this.radius, this.points, this.radius, this.InnerRadius, this.rotation)
21+
this.fill({color: '#FFF'})
22+
}
23+
}

0 commit comments

Comments
 (0)