Commit 81c8fc27 authored by rockyl's avatar rockyl

代码格式化

parent a3ab12b1
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<!-- <meta name="viewport" content="width=device-width,minimum-scale=1.0,user-scalable=no"> -->
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: white;
}
</style>
</head>
<body>
<script type="text/javascript" src="../build/render.min.js"></script>
<div id="cusEngine" style="line-height:0;font-size:0"></div>
<script src="game-stage.js"></script>
</body>
</html>
\ No newline at end of file
/**
* Created by rockyl on 2019-11-06.
*/
let stage = new render.Stage(
"cusEngine",
750,
1334,
60,
render.StageScaleMode.FIXED_WIDTH,
render.RENDERER_TYPE.WEBGL
);
//启动循环
render.Stage.flushAll();
let node = new render.Node();
node.width = 400;
console.log(node.width);
/*let gameStage = new render.GameStage(stage);
stage.addChild(gameStage);
let sceneEntry = new render.Container();
let bg = new render.Shape();
bg.beginFill(0xFF8888);
bg.drawRect(0, 0, 300, 300);
bg.endFill();
sceneEntry.addChild(bg);
gameStage.sceneContainer.push(sceneEntry);*/
/*let dialog = new render.Container();
let dbg = new render.Shape();
dbg.beginFill(0x8888ff);
dbg.drawRect(0, 0, 100, 100);
dbg.endFill();
dialog.addChild(dbg);
gameStage.popupContainer.push(dialog);*/
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Examples</title>
</head>
<body>
</body>
</html>
\ No newline at end of file
......@@ -2,48 +2,48 @@
* 基础
*/
export abstract class HashObject {
protected _instanceId: number = 0;
protected _instanceType: string = "HashObject";
protected static _object_id = 0;
protected _instanceId: number = 0;
protected _instanceType: string = "HashObject";
protected static _object_id = 0;
constructor() {
this._instanceId = HashObject._object_id++;
}
constructor() {
this._instanceId = HashObject._object_id++;
}
/**
* 每一个对象都会有一个唯一的id码。
* @property instanceId
* @public
* @since 1.0.0
* @return {number}
* @readonly
* @example
* //获取 对象唯一码
* trace(this.instanceId);
*/
public get instanceId(): number {
return this._instanceId;
}
/**
* 每一个对象都会有一个唯一的id码。
* @property instanceId
* @public
* @since 1.0.0
* @return {number}
* @readonly
* @example
* //获取 对象唯一码
* trace(this.instanceId);
*/
public get instanceId(): number {
return this._instanceId;
}
/**
* 每一个类都有一个实例类型字符串,通过这个字符串,你能知道这个实例是从哪个类实例而来
* @property instanceType
* @since 1.0.3
* @public
* @return {string}
* @readonly
*/
public get instanceType(): string {
return this._instanceType;
}
/**
* 每一个类都有一个实例类型字符串,通过这个字符串,你能知道这个实例是从哪个类实例而来
* @property instanceType
* @since 1.0.3
* @public
* @return {string}
* @readonly
*/
public get instanceType(): string {
return this._instanceType;
}
/**
* 销毁一个对象
* 销毁之前一定要从显示对象移除,否则将会出错
* @method destroy
* @since 2.0.0
* @public
* @return {void}
*/
abstract destroy(): void;
/**
* 销毁一个对象
* 销毁之前一定要从显示对象移除,否则将会出错
* @method destroy
* @since 2.0.0
* @public
* @return {void}
*/
abstract destroy(): void;
}
......@@ -2,8 +2,8 @@
* Created by rockyl on 2018/11/5.
*/
import { HashObject } from "../HashObject";
import { DisplayObject } from "../display/DisplayObject";
import {HashObject} from "../HashObject";
import {DisplayObject} from "../display/DisplayObject";
/**
* 组件基类
......
//这里都是一些常量
/**
* 版本号
......@@ -44,27 +43,27 @@ export const devicePixelRatio: number = window.devicePixelRatio ? (window.device
*
*/
export let StageScaleMode: { EXACT_FIT: string, NO_BORDER: string, NO_SCALE: string, SHOW_ALL: string, FIXED_WIDTH: string, FIXED_HEIGHT: string } = {
EXACT_FIT: "exactFit",
NO_BORDER: "noBorder",
NO_SCALE: "noScale",
SHOW_ALL: "showAll",
FIXED_WIDTH: "fixedWidth",
FIXED_HEIGHT: "fixedHeight"
EXACT_FIT: "exactFit",
NO_BORDER: "noBorder",
NO_SCALE: "noScale",
SHOW_ALL: "showAll",
FIXED_WIDTH: "fixedWidth",
FIXED_HEIGHT: "fixedHeight"
};
/**
* 获取设备号
*/
export const osType: string = (function () {
let n = navigator.userAgent.toLocaleLowerCase();
let reg1 = /android/;
let reg2 = /iphone|ipod|ipad/;
if (reg1.test(n)) {
return "android";
} else if (reg2.test(n)) {
return "ios"
} else {
return "pc";
}
let n = navigator.userAgent.toLocaleLowerCase();
let reg1 = /android/;
let reg2 = /iphone|ipod|ipad/;
if (reg1.test(n)) {
return "android";
} else if (reg2.test(n)) {
return "ios"
} else {
return "pc";
}
})();
console.log(devicePixelRatio, osType)
......@@ -72,6 +71,7 @@ console.log(devicePixelRatio, osType)
let PI: number = Math.PI;
let HalfPI: number = PI >> 1;
let PacPI: number = PI + HalfPI;
/**
* @method cos
* @private
......@@ -79,19 +79,19 @@ let PacPI: number = PI + HalfPI;
* @return {number}
*/
export function cos(angle: number): number {
switch (angle) {
case HalfPI:
case -PacPI:
return 0;
case PI:
case -PI:
return -1;
case PacPI:
case -HalfPI:
return 0;
default:
return Math.cos(angle);
}
switch (angle) {
case HalfPI:
case -PacPI:
return 0;
case PI:
case -PI:
return -1;
case PacPI:
case -HalfPI:
return 0;
default:
return Math.cos(angle);
}
}
/**
......@@ -100,20 +100,21 @@ export function cos(angle: number): number {
* @return {number}
*/
export function sin(angle: number): number {
switch (angle) {
case HalfPI:
case -PacPI:
return 1;
case PI:
case -PI:
return 0;
case PacPI:
case -HalfPI:
return -1;
default:
return Math.sin(angle);
}
switch (angle) {
case HalfPI:
case -PacPI:
return 1;
case PI:
case -PI:
return 0;
case PacPI:
case -HalfPI:
return -1;
default:
return Math.sin(angle);
}
}
/**
* Two Pi.
*
......@@ -152,9 +153,9 @@ export const DEG_TO_RAD: number = PI / 180;
* @property {number} CANVAS - Canvas render type.
*/
export enum RENDERER_TYPE {
UNKNOWN = 0,
WEBGL,
CANVAS,
UNKNOWN = 0,
WEBGL,
CANVAS,
};
/**
......@@ -170,11 +171,11 @@ export enum RENDERER_TYPE {
* @property {number} RREC Rounded Rectangle 圆角矩形
*/
export enum SHAPES {
POLY = 0,
RECT,
CIRC,
ELIP,
RREC,
POLY = 0,
RECT,
CIRC,
ELIP,
RREC,
};
/**
......@@ -188,9 +189,9 @@ export enum SHAPES {
* @property {string} HIGH='highp'
*/
export enum PRECISION {
LOW = 'lowp',
MEDIUM = 'mediump',
HIGH = 'highp',
LOW = 'lowp',
MEDIUM = 'mediump',
HIGH = 'highp',
};
/**
......@@ -203,63 +204,63 @@ export enum PRECISION {
* @property {number} LINEAR_HORIZONTAL 垂直渐变
*/
export enum TEXT_GRADIENT {
LINEAR_VERTICAL = 0,
LINEAR_HORIZONTAL,
LINEAR_VERTICAL = 0,
LINEAR_HORIZONTAL,
};
/**
* 文本对齐方式 水平
*/
export enum TEXT_ALIGN {
CENTER = "center",
LEFT = "left",
RIGHT = "right",
CENTER = "center",
LEFT = "left",
RIGHT = "right",
}
export enum VERTICAL_ALIGN {
MIDDLE = "middle",
UP = "up",
DOWN = "down",
MIDDLE = "middle",
UP = "up",
DOWN = "down",
}
/**
* 文本类型,单行或多行
*/
export enum TEXT_lINETYPE {
SINGLE = "single",
MULTI = "multi"
SINGLE = "single",
MULTI = "multi"
}
/**
* 画线时的对齐方式
*/
export enum LINE_ALIGNMENT {
middle = 0.5,
outter = 1,
inner = 0
middle = 0.5,
outter = 1,
inner = 0
}
/**
* canvas线头
*/
export enum LINE_CAP {
BUTT = "butt",
ROUND = "round",
SQUARE = "square",
BUTT = "butt",
ROUND = "round",
SQUARE = "square",
}
/**
* canvas线连接处
*/
export enum LINE_JOIN {
MITER = "miter",
ROUND = "round",
BEVEL = "bevel"
MITER = "miter",
ROUND = "round",
BEVEL = "bevel"
}
/**
* Various blend modes supported by
* Various blend modes supported by
*
* IMPORTANT - The WebGL renderer only supports the NORMAL, ADD, MULTIPLY and SCREEN blend modes.
* Anything else will silently act like NORMAL.
......@@ -287,26 +288,26 @@ export enum LINE_JOIN {
* @property {number} LUMINOSITY
*/
export enum BLEND_MODES {
NORMAL = 0,
ADD,
MULTIPLY,
SCREEN,
OVERLAY,
DARKEN,
LIGHTEN,
COLOR_DODGE,
COLOR_BURN,
HARD_LIGHT,
SOFT_LIGHT,
DIFFERENCE,
EXCLUSION,
HUE,
SATURATION,
COLOR,
LUMINOSITY,
NORMAL_NPM,
ADD_NPM,
SCREEN_NPM,
NORMAL = 0,
ADD,
MULTIPLY,
SCREEN,
OVERLAY,
DARKEN,
LIGHTEN,
COLOR_DODGE,
COLOR_BURN,
HARD_LIGHT,
SOFT_LIGHT,
DIFFERENCE,
EXCLUSION,
HUE,
SATURATION,
COLOR,
LUMINOSITY,
NORMAL_NPM,
ADD_NPM,
SCREEN_NPM,
};
/**
......@@ -326,17 +327,17 @@ export enum BLEND_MODES {
* @property {number} TRIANGLE_FAN
*/
export enum DRAW_MODES {
POINTS = 0,
LINES,
LINE_LOOP,
LINE_STRIP,
TRIANGLES,
TRIANGLE_STRIP,
TRIANGLE_FAN,
POINTS = 0,
LINES,
LINE_LOOP,
LINE_STRIP,
TRIANGLES,
TRIANGLE_STRIP,
TRIANGLE_FAN,
};
/**
* The scale modes that are supported by
* The scale modes that are supported by
*
* The {@link settings.SCALE_MODE} scale mode affects the default scaling mode of future operations.
* It can be re-assigned to either LINEAR or NEAREST, depending upon suitability.
......@@ -349,12 +350,12 @@ export enum DRAW_MODES {
* @property {number} NEAREST Pixelating scaling
*/
export enum SCALE_MODES {
LINEAR = 0,
NEAREST,
LINEAR = 0,
NEAREST,
};
/**
* The wrap modes that are supported by
* The wrap modes that are supported by
*
* The {@link settings.WRAP_MODE} wrap mode affects the default wrapping mode of future operations.
* It can be re-assigned to either CLAMP or REPEAT, depending upon suitability.
......@@ -372,13 +373,13 @@ export enum SCALE_MODES {
* @property {number} MIRRORED_REPEAT - The texture uvs tile and repeat with mirroring
*/
export enum WRAP_MODES {
CLAMP = 33071,
REPEAT = 10497,
MIRRORED_REPEAT = 33648,
CLAMP = 33071,
REPEAT = 10497,
MIRRORED_REPEAT = 33648,
};
/**
* The gc modes that are supported by
* The gc modes that are supported by
*
* The {@link settings.GC_MODE} Garbage Collection mode for textures is AUTO
* If set to GC_MODE, the renderer will occasionally check textures usage. If they are not
......@@ -397,8 +398,8 @@ export enum WRAP_MODES {
* @property {number} MANUAL - Garbage collection will need to be called manually
*/
export enum GC_MODES {
AUTO = 0,
MANUAL,
AUTO = 0,
MANUAL,
};
/**
......
This diff is collapsed.
import { EventDispatcher } from '../events/EventDispatcher';
import {EventDispatcher} from '../events/EventDispatcher';
import Transform from '../math/Transform';
import { Rectangle } from '../math/Rectangle';
import { Point } from "../math/Point";
import { Event } from "../events/Event";
import { Component } from '../component/Component';
import {Rectangle} from '../math/Rectangle';
import {Point} from "../math/Point";
import {Event} from "../events/Event";
import {Component} from '../component/Component';
import Graphics from '../graphics/Graphics';
import { RAD_TO_DEG, DEG_TO_RAD } from '../const';
import {DEG_TO_RAD, RAD_TO_DEG} from '../const';
/**
* 基础显示对象抽象类
* @class
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
export { default as Container } from './Container';
export { DisplayObject } from './DisplayObject';
export { FloatDisplay } from "./FloatDisplay";
export { default as Sprite } from "./Sprite";
export { Stage } from "./Stage";
\ No newline at end of file
export {default as Container} from './Container';
export {DisplayObject} from './DisplayObject';
export {FloatDisplay} from "./FloatDisplay";
export {default as Sprite} from "./Sprite";
export {Stage} from "./Stage";
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
export class GDispatcher {
/**
* 事件回调池
*/
private static callbackPool: any = {};
/**
* 事件回调池
*/
private static callbackPool: any = {};
/**
* 事件作用域池
*/
private static thisObjPool: any = {};
/**
* 事件作用域池
*/
private static thisObjPool: any = {};
/**
*
* @param name 事件名
* @param callback 回调
* @param thisObj 作用域
*/
public static addEvent(name: string, callback, thisObj: any): void {
if (!this.callbackPool[name]) {
this.callbackPool[name] = [];
this.thisObjPool[name] = [];
}
const index: number = this.callbackPool[name].indexOf(callback);
if (index != -1) {
this.callbackPool[name][index] = callback;
this.thisObjPool[name][index] = thisObj;
} else {
this.callbackPool[name].push(callback);
this.thisObjPool[name].push(thisObj);
}
}
/**
*
* @param name 事件名
* @param callback 回调
* @param thisObj 作用域
*/
public static addEvent(name: string, callback, thisObj: any): void {
if (!this.callbackPool[name]) {
this.callbackPool[name] = [];
this.thisObjPool[name] = [];
}
/**
*
* @param name 事件名
* @param callback 回调
* @param thisObj 作用域
*/
public static removeEvent(name: string, callback, thisObj?: any): void {
if (this.callbackPool[name]) {
const index: number = this.callbackPool[name].indexOf(callback);
if (index != -1) {
this.callbackPool[name].splice(index, 1);
this.thisObjPool[name].splice(index, 1);
}
}
}
const index: number = this.callbackPool[name].indexOf(callback);
if (index != -1) {
this.callbackPool[name][index] = callback;
this.thisObjPool[name][index] = thisObj;
} else {
this.callbackPool[name].push(callback);
this.thisObjPool[name].push(thisObj);
}
}
/**
* 派发事件
* @param name 事件名
* @param args 任意参数
*/
public static dispatchEvent(name: string, ...args): void {
const callbacks: Function[] = this.callbackPool[name];
const thisObjs: any = this.thisObjPool[name];
if (callbacks) {
let i = 0;
const len: number = callbacks.length;
for (i; i < len; i++) {
callbacks[i].apply(thisObjs[i], args);
}
}
}
/**
*
* @param name 事件名
* @param callback 回调
* @param thisObj 作用域
*/
public static removeEvent(name: string, callback, thisObj?: any): void {
if (this.callbackPool[name]) {
const index: number = this.callbackPool[name].indexOf(callback);
if (index != -1) {
this.callbackPool[name].splice(index, 1);
this.thisObjPool[name].splice(index, 1);
}
}
}
/**
* 派发事件
* @param name 事件名
* @param args 任意参数
*/
public static dispatchEvent(name: string, ...args): void {
const callbacks: Function[] = this.callbackPool[name];
const thisObjs: any = this.thisObjPool[name];
if (callbacks) {
let i = 0;
const len: number = callbacks.length;
for (i; i < len; i++) {
callbacks[i].apply(thisObjs[i], args);
}
}
}
}
\ No newline at end of file
import { Event } from "./Event";
import { DisplayObject } from "../display/DisplayObject";
import {Event} from "./Event";
import {DisplayObject} from "../display/DisplayObject";
/**
* 鼠标事件类,电脑端鼠标,移动设备端的触摸都使用此事件来监听
* @class MouseEvent
......@@ -8,148 +9,151 @@ import { DisplayObject } from "../display/DisplayObject";
* @since 1.0.0
*/
export class MouseEvent extends Event {
/**
* 鼠标或者手指按下事件
* @property MOUSE_DOWN
* @static
* @public
* @since 1.0.0
* @type {string}
*/
public static MOUSE_DOWN: string = "onMouseDown";
/**
* 鼠标或者手指抬起事件
* @property MOUSE_UP
* @static
* @public
* @since 1.0.0
* @type {string}
*/
public static MOUSE_UP: string = "onMouseUp";
/**
* 鼠标或者手指单击
* @property CLICK
* @static
* @public
* @since 1.0.0
* @type {string}
*/
public static CLICK: string = "onMouseClick";
/**
* 鼠标或者手指移动事件
* @property MOUSE_MOVE
* @static
* @public
* @since 1.0.0
* @type {string}
*/
public static MOUSE_MOVE: string = "onMouseMove";
/**
* 鼠标或者手指移入到显示对象上里触发的事件
* @property MOUSE_OVER
* @static
* @public
* @since 1.0.0
* @type {string}
*/
public static MOUSE_OVER: string = "onMouseOver";
/**
* 鼠标或者手指移出显示对象边界触发的事件
* @property MOUSE_OUT
* @static
* @public
* @since 1.0.0
* @type {string}
*/
public static MOUSE_OUT: string = "onMouseOut";
/**
* mouse或touch事件时rootDiv坐标x点
* @property clientX
* @public
* @since 1.0.0
* @type {number}
*/
public clientX: number = 0;
/**
* mouse或touch事件时rootDiv坐标y点
* @property clientY
* @public
* @since 1.0.0
* @type {number}
*/
public clientY: number = 0;
/**
* mouse或touch事件时全局坐标x点
* @property stageX
* @public
* @since 1.0.0
* @type {number}
*/
public stageX: number = 0;
/**
* mouse或touch事件时全局坐标y点
* @property stageY
* @public
* @since 1.0.0
* @type {number}
*/
public stageY: number = 0;
/**
* mouse或touch事件时本地坐标x点
* @property localX
* @public
* @since 1.0.0
* @type {number}
*/
public localX: number = 0;
/**
* mouse或touch事件时本地坐标y点
* @property localY
* @public
* @since 1.0.0
* @type {number}
*/
public localY: number = 0;
/**
* 绑定此事件的侦听对象,一般target是最终点击的对象
* @property currentTarget
* @public
* @since 1.0.0
* @type{DisplayObject}
* @default null
*/
public currentTarget: DisplayObject = null;
/**
* 触摸或者鼠标事件的手指唯一标识
* @property identifier
* @type {number}
* @since 1.1.2
* @public
*/
public identifier: any = 0;
/**
* @method MouseEvent
* @public
* @since 1.0.0
* @param {string} type
*/
public constructor(type: string) {
super(type);
this._instanceType = "MouseEvent";
}
/**
* 事件后立即更新显示列表状态
* @method updateAfterEvent
* @since 1.0.9
* @public
*/
public updateAfterEvent() {
this.target.stage._cp = true;
}
public destroy(): void {
//清除相应的数据引用
let s = this;
s.currentTarget = null;
super.destroy();
}
/**
* 鼠标或者手指按下事件
* @property MOUSE_DOWN
* @static
* @public
* @since 1.0.0
* @type {string}
*/
public static MOUSE_DOWN: string = "onMouseDown";
/**
* 鼠标或者手指抬起事件
* @property MOUSE_UP
* @static
* @public
* @since 1.0.0
* @type {string}
*/
public static MOUSE_UP: string = "onMouseUp";
/**
* 鼠标或者手指单击
* @property CLICK
* @static
* @public
* @since 1.0.0
* @type {string}
*/
public static CLICK: string = "onMouseClick";
/**
* 鼠标或者手指移动事件
* @property MOUSE_MOVE
* @static
* @public
* @since 1.0.0
* @type {string}
*/
public static MOUSE_MOVE: string = "onMouseMove";
/**
* 鼠标或者手指移入到显示对象上里触发的事件
* @property MOUSE_OVER
* @static
* @public
* @since 1.0.0
* @type {string}
*/
public static MOUSE_OVER: string = "onMouseOver";
/**
* 鼠标或者手指移出显示对象边界触发的事件
* @property MOUSE_OUT
* @static
* @public
* @since 1.0.0
* @type {string}
*/
public static MOUSE_OUT: string = "onMouseOut";
/**
* mouse或touch事件时rootDiv坐标x点
* @property clientX
* @public
* @since 1.0.0
* @type {number}
*/
public clientX: number = 0;
/**
* mouse或touch事件时rootDiv坐标y点
* @property clientY
* @public
* @since 1.0.0
* @type {number}
*/
public clientY: number = 0;
/**
* mouse或touch事件时全局坐标x点
* @property stageX
* @public
* @since 1.0.0
* @type {number}
*/
public stageX: number = 0;
/**
* mouse或touch事件时全局坐标y点
* @property stageY
* @public
* @since 1.0.0
* @type {number}
*/
public stageY: number = 0;
/**
* mouse或touch事件时本地坐标x点
* @property localX
* @public
* @since 1.0.0
* @type {number}
*/
public localX: number = 0;
/**
* mouse或touch事件时本地坐标y点
* @property localY
* @public
* @since 1.0.0
* @type {number}
*/
public localY: number = 0;
/**
* 绑定此事件的侦听对象,一般target是最终点击的对象
* @property currentTarget
* @public
* @since 1.0.0
* @type{DisplayObject}
* @default null
*/
public currentTarget: DisplayObject = null;
/**
* 触摸或者鼠标事件的手指唯一标识
* @property identifier
* @type {number}
* @since 1.1.2
* @public
*/
public identifier: any = 0;
/**
* @method MouseEvent
* @public
* @since 1.0.0
* @param {string} type
*/
public constructor(type: string) {
super(type);
this._instanceType = "MouseEvent";
}
/**
* 事件后立即更新显示列表状态
* @method updateAfterEvent
* @since 1.0.9
* @public
*/
public updateAfterEvent() {
this.target.stage._cp = true;
}
public destroy(): void {
//清除相应的数据引用
let s = this;
s.currentTarget = null;
super.destroy();
}
}
\ No newline at end of file
/**
* Created by rockyl on 2019-11-06.
*/
export * from './Event';
export * from './EventDispatcher';
export * from './GDispatcher';
export * from './MouseEvent';
This diff is collapsed.
import Circle from "./shapes/Circle";
import { Rectangle, Matrix } from "../math";
import {Matrix, Rectangle} from "../math";
import Ellipse from "./shapes/Ellipse";
import Polygon from "./shapes/Polygon";
import RoundedRectangle from "./shapes/RoundedRectangle";
import { HashObject } from "../HashObject";
import {HashObject} from "../HashObject";
import LineStyle from "./styles/LineStyle";
import FillStyle from "./styles/FillStyle";
......@@ -13,71 +13,72 @@ import FillStyle from "./styles/FillStyle";
*/
export default class GraphicsData extends HashObject {
fillStyle: FillStyle;
lineStyle: LineStyle;
matrix: Matrix;
holes: any[];
/**
* The shape object to draw.
* @member {Circle|Ellipse|Polygon|Rectangle|RoundedRectangle}
*/
shape: any;
/**
* The type of the shape, see the Const.Shapes file for all the existing types,
* @member {number}
*/
type: number;
/**
* 点的一维数组[x,y,x1,y1,x2,y2]
* 存下shape的点数据,因为如果shape不是poly不会特意存下points
*/
points: number[]
/**
*
*/
constructor(
shape: Circle | Rectangle | Ellipse | Polygon | RoundedRectangle,
fillStyle: FillStyle = null,
lineStyle: LineStyle = null,
matrix: Matrix = null
) {
super();
this._instanceType = "GraphicsData"
fillStyle: FillStyle;
lineStyle: LineStyle;
matrix: Matrix;
holes: any[];
/**
* The shape object to draw.
* @member {Circle|Ellipse|Polygon|Rectangle|RoundedRectangle}
*/
shape: any;
/**
* The type of the shape, see the Const.Shapes file for all the existing types,
* @member {number}
*/
type: number;
/**
* 点的一维数组[x,y,x1,y1,x2,y2]
* 存下shape的点数据,因为如果shape不是poly不会特意存下points
*/
points: number[]
this.shape = shape;
this.lineStyle = lineStyle;
this.fillStyle = fillStyle;
this.matrix = matrix;
/**
*
*/
constructor(
shape: Circle | Rectangle | Ellipse | Polygon | RoundedRectangle,
fillStyle: FillStyle = null,
lineStyle: LineStyle = null,
matrix: Matrix = null
) {
super();
this._instanceType = "GraphicsData"
this.holes = [];
this.type = shape.type;
this.points = [];
}
this.shape = shape;
this.lineStyle = lineStyle;
this.fillStyle = fillStyle;
this.matrix = matrix;
/**
* Creates a new GraphicsData object with the same values as this one.
*
* @return {GraphicsData} Cloned GraphicsData object
*/
clone(): GraphicsData {
return new GraphicsData(
this.shape,
this.fillStyle,
this.lineStyle,
this.matrix
);
}
this.holes = [];
this.type = shape.type;
this.points = [];
}
/**
* Destroys the Graphics data.
*/
destroy() {
this.shape = null;
this.holes.length = 0;
this.holes = null;
this.points.length = 0;
this.points = null;
this.lineStyle = null;
this.fillStyle = null;
}
/**
* Creates a new GraphicsData object with the same values as this one.
*
* @return {GraphicsData} Cloned GraphicsData object
*/
clone(): GraphicsData {
return new GraphicsData(
this.shape,
this.fillStyle,
this.lineStyle,
this.matrix
);
}
/**
* Destroys the Graphics data.
*/
destroy() {
this.shape = null;
this.holes.length = 0;
this.holes = null;
this.points.length = 0;
this.points = null;
this.lineStyle = null;
this.fillStyle = null;
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
import { earcut } from "./earcut";
import {earcut} from "./earcut";
import Graphics from "../Graphics";
import GraphicsData from "../GraphicsData";
......@@ -15,45 +15,45 @@ import GraphicsData from "../GraphicsData";
*/
export default {
build(graphicsData: GraphicsData) {
graphicsData.points = graphicsData.shape.points.slice();
},
build(graphicsData: GraphicsData) {
graphicsData.points = graphicsData.shape.points.slice();
},
triangulate(graphicsData:GraphicsData, graphicsGeometry:Graphics) {
let points = graphicsData.points;
const holes = graphicsData.holes;
const verts = graphicsGeometry.verts;
const indices = graphicsGeometry.indices;
triangulate(graphicsData: GraphicsData, graphicsGeometry: Graphics) {
let points = graphicsData.points;
const holes = graphicsData.holes;
const verts = graphicsGeometry.verts;
const indices = graphicsGeometry.indices;
if (points.length >= 6) {
const holeArray = [];
// Process holes..
if (points.length >= 6) {
const holeArray = [];
// Process holes..
for (let i = 0; i < holes.length; i++) {
const hole = holes[i];
for (let i = 0; i < holes.length; i++) {
const hole = holes[i];
holeArray.push(points.length / 2);
points = points.concat(hole.points);
}
holeArray.push(points.length / 2);
points = points.concat(hole.points);
}
// sort color
const triangles = earcut(points, holeArray, 2);
// sort color
const triangles = earcut(points, holeArray, 2);
if (!triangles) {
return;
}
if (!triangles) {
return;
}
const vertPos = verts.length / 2;
const vertPos = verts.length / 2;
for (let i = 0; i < triangles.length; i += 3) {
indices.push(triangles[i] + vertPos);
indices.push(triangles[i + 1] + vertPos);
indices.push(triangles[i + 2] + vertPos);
}
for (let i = 0; i < triangles.length; i += 3) {
indices.push(triangles[i] + vertPos);
indices.push(triangles[i + 1] + vertPos);
indices.push(triangles[i + 2] + vertPos);
}
for (let i = 0; i < points.length; i++) {
verts.push(points[i]);
}
}
},
for (let i = 0; i < points.length; i++) {
verts.push(points[i]);
}
}
},
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
export {default as Circle} from './Circle';
export {default as Ellipse} from './Ellipse';
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
export { Matrix } from './Matrix';
export { Point } from './Point';
export { ObservablePoint } from './ObservablePoint';
export { Rectangle } from './Rectangle';
export {Matrix} from './Matrix';
export {Point} from './Point';
export {ObservablePoint} from './ObservablePoint';
export {Rectangle} from './Rectangle';
// export {default as Transform} from './Transform';
export { default as Transform } from './Transform';
export { default as GroupD8 } from './GroupD8';
\ No newline at end of file
export {default as Transform} from './Transform';
export {default as GroupD8} from './GroupD8';
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
export { VideoEntity } from "./VideoEntity";
export { MovieClip } from "./MovieClip";
\ No newline at end of file
export {VideoEntity} from "./VideoEntity";
export {MovieClip} from "./MovieClip";
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment