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