Commit 2afda240 authored by wjf's avatar wjf

l

parent f49611da
# project ignores
node_modules
jsconfig111111.json
\ No newline at end of file
node_modules
\ No newline at end of file
......@@ -2,6 +2,7 @@
node_modules
/scripts
/src
/build/fyge.min.js.map
tsConfig.json
webpack.config.js
jsconfig111111.json
\ No newline at end of file
package-lock.json
webpack.config.js
\ No newline at end of file
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules",
"bower_components",
"jspm_packages",
"tmp",
"temp"
]
}
\ No newline at end of file
......@@ -1429,12 +1429,14 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
......@@ -1449,17 +1451,20 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
......@@ -1576,7 +1581,8 @@
"inherits": {
"version": "2.0.4",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
......@@ -1588,6 +1594,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
......@@ -1602,6 +1609,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
......@@ -1609,12 +1617,14 @@
"minimist": {
"version": "1.2.5",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"minipass": {
"version": "2.9.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
......@@ -1633,6 +1643,7 @@
"version": "0.5.3",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "^1.2.5"
}
......@@ -1694,7 +1705,8 @@
"npm-normalize-package-bin": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"npm-packlist": {
"version": "1.4.8",
......@@ -1722,7 +1734,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
......@@ -1734,6 +1747,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
......@@ -1847,6 +1861,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
......@@ -4132,4 +4147,4 @@
}
}
}
}
\ No newline at end of file
}
{
"name": "fyge",
"version": "1.0.3",
"name": "fyge-tbmini",
"version": "1.0.8",
"description": "淘宝小程序canvas渲染引擎",
"main": "./dist/fyge.min.js",
"types": "./types/FYGE.d.ts",
"main": "./build/fyge.min.js",
"types": "./build/FYGE.d.ts",
"dependencies": {},
"scripts": {
"declare": "node scripts/declare.js src/index.ts",
......@@ -24,4 +24,4 @@
"keywords": [
"淘宝小程序,canvas,webgl"
]
}
\ No newline at end of file
}
......@@ -42,7 +42,7 @@ function compile(fileNames, options) {
// const content = `declare module FYGE{${allExports}}`;
const content = `declare namespace FYGE{${allExports}}\ndeclare module "fyge" {export = FYGE;}`;
fs.writeFileSync('types/FYGE.d.ts', content);
fs.writeFileSync('build/FYGE.d.ts', content);
}
compile(process.argv.slice(2), {
......
// /**
// * 相关配置信息,外部可修改,注意修改
// * 主要为了一些方法适配,以及
// */
// export const Setting = {
// createCanvas: function () {
// //@ts-ignore
// return document && document.createElement("canvas") || my._createOffscreenCanvas()
// },
// /**
// * 手动赋值,这个必须要
// */
// createImage: function (): HTMLImageElement {
// return new Image()
// },
// // createImage: function () {
// // return canvas.createImage(),
// // },
// /**
// * 手动赋值,尽量在外面自行处理
// */
// requestAnimationFrame: function (loop): any {
// return window.requestAnimationFrame(loop)
// },
// // requestAnimationFrame: function (loop) {
// // canvas.requestAnimationFrame(loop)
// // },
// /**
// * 手动赋值,尽量在外面自行处理
// */
// cancelAnimationFrame: function (loopId) {
// window.cancelAnimationFrame(loopId)
// },
// // cancelAnimationFrame: function (loop) {
// // canvas.cancelAnimationFrame(loop)
// // }
// }
......@@ -54,6 +54,14 @@ export default class Container extends DisplayObject {
this.addChildAt(child, this.children.length);
return child;
}
/**
* 批量添加child
* @param children
*/
addChildren<T extends DisplayObject>(...children: T[]): T[] {
children.forEach((child: T) => { this.addChild(child); })
return children
}
/**
* 在相应index处添加child
......@@ -252,38 +260,29 @@ export default class Container extends DisplayObject {
return child;
}
/**
* 批量移除child,
* @param children 不传参数,表示全部移除
*/
removeChildren<T extends DisplayObject>(...children: T[]): T[] {
if (!children.length) return this.spliceChildren(0);
children.forEach((child: T) => { this.removeChild(child); })
return children
}
/**
* 通过索引批量移除child
* @param {number} [beginIndex=0]
* @param {number} [endIndex=this.children.length]
* @returns {DisplayObject[]} List of removed children
*/
removeChildren(beginIndex: number = 0, endIndex: number = this.children.length): DisplayObject[] {
removeChildrenAt(beginIndex: number = 0, endIndex: number = this.children.length): DisplayObject[] {
const begin = beginIndex;
const end = typeof endIndex === 'number' ? endIndex : this.children.length;
const range = end - begin;
let removed;
if (range > 0 && range <= end) {
removed = this.children.splice(begin, range);
for (let i = 0; i < removed.length; ++i) {
removed[i].parent = null;
if (removed[i].transform) {
removed[i].transform._parentID = -1;
}
}
this._boundsID++;
this.onChildrenChange(beginIndex);
for (let i = 0; i < removed.length; ++i) {
removed[i]._onDispatchBubbledEvent(Event.REMOVED_FROM_STAGE);
}
return removed;
return this.spliceChildren(begin, range)
}
else if (range === 0 && this.children.length === 0) {
return [];
......@@ -291,6 +290,32 @@ export default class Container extends DisplayObject {
throw new RangeError('removeChildren: numeric values are outside the acceptable range.');
}
/**
* 类比splice方法
* @param beginIndex
* @param count
*/
spliceChildren<T extends DisplayObject>(beginIndex?: number, count?: number): T[] {
let removed = this.children.splice(beginIndex, count);
if (!removed.length) return [];
for (let i = 0; i < removed.length; ++i) {
removed[i].parent = null;
if (removed[i].transform) {
removed[i].transform._parentID = -1;
}
}
this._boundsID++;
this.onChildrenChange(beginIndex);
for (let i = 0; i < removed.length; ++i) {
removed[i]._onDispatchBubbledEvent(Event.REMOVED_FROM_STAGE);
}
return removed;
}
/**
* 更新矩阵
......
......@@ -246,7 +246,7 @@ export class DisplayObject extends EventDispatcher {
}
/**
* 以父级为世界坐标系的本地包围盒
* 以自身为世界坐标系的本地包围盒
* @param {Rectangle} [rect] - Optional rectangle to store the result of the bounds calculation
* @return {Rectangle} the rectangular bounding area
*/
......@@ -395,7 +395,8 @@ export class DisplayObject extends EventDispatcher {
*/
destroy() {
//移除所有监听
this.removeAllEventListener();
// this.removeAllEventListener();
super.destroy();
//如果有父级,从中移除自己
if (this.parent) {
this.parent.removeChild(this);
......
......@@ -162,12 +162,7 @@ export default class Sprite extends Container {
}
//修改_localBoundsSelf
const width = this._texture.orig.width;
const height = this._texture.orig.height;
this._localBoundsSelf.x = -width * this.anchorTexture.x;
this._localBoundsSelf.y = -height * this.anchorTexture.y;
this._localBoundsSelf.width = width;
this._localBoundsSelf.height = height;
this.updateLocalBoundsSelf();
}
/**
......@@ -175,9 +170,25 @@ export default class Sprite extends Container {
*
* @private
*/
_onAnchorUpdate() {
private _onAnchorUpdate() {
this._transformID = -1;
this._transformTrimmedID = -1;
//贴图锚点修改,也要修改自身盒子,因为鼠标点击有用到
this.updateLocalBoundsSelf();
}
/**
* 通过自身贴图修改自身盒子
* 子类可修改,比如文本不需要padding的话,暂时还没做
*/
protected updateLocalBoundsSelf() {
//修改_localBoundsSelf
const width = this._texture.orig.width;
const height = this._texture.orig.height;
this._localBoundsSelf.x = -width * this.anchorTexture.x;
this._localBoundsSelf.y = -height * this.anchorTexture.y;
this._localBoundsSelf.width = width;
this._localBoundsSelf.height = height;
}
/**
......
......@@ -9,9 +9,9 @@ import { DisplayObject } from "./DisplayObject";
import { MouseEvent } from "../events/MouseEvent";
import { WebglRenderer } from "../renderers/WebglRenderer";
import { getRequestAnimationFrame, getCancelAnimationFrame } from "../utils";
import { Stats } from "../../Stats";
import { CanvasRenderer } from "../renderers/CanvasRenderer";
import { SystemRenderer } from "../renderers/SystemRenderer";
export class Stage extends Container {
......@@ -24,7 +24,7 @@ export class Stage extends Container {
* @type {IRender}
* @default null
*/
public renderObj: WebglRenderer = null;
public renderObj: SystemRenderer = null;
/**
......@@ -45,36 +45,7 @@ export class Stage extends Container {
* @private
*/
private static _stageList: any = {};
/**
* 是否暂停
* @property pause
* @static
* @type {boolean}
* @public
* @since 1.0.0
* @default false
*/
static get pause(): boolean {
return this._pause;
}
static set pause(value: boolean) {
this._pause = value;
if (value != this._pause) {
//触发事件
// GDispatcher.dispatchEvent("onStagePause", { pause: value });
}
}
/**
* @property _pause
* @type {boolean}
* @private
* @static
*/
private static _pause: boolean = false;
private static _flushId = -1;
/**
* 舞台在设备里截取后的可见区域,有些时候知道可见区域是非常重要的,因为这样你就可以根据舞台的可见区域做自适应了。
* @property viewRect
......@@ -166,16 +137,12 @@ export class Stage extends Container {
* @param {*} data desWidth,desHeight,divWidth,divHeight,canWidth,canHeight
*/
public constructor(
context: WebGLRenderingContext | CanvasRenderingContext2D,
data: {
type: RENDERER_TYPE
desWidth: number,
desHeight: number,
divWidth: number,
divHeight: number,
canWidth: number,
canHeight: number
}
canvas: HTMLCanvasElement,
desWidth: number = 750,
desHeight: number = 1624,
divWidth: number,
divHeight: number,
renderType: RENDERER_TYPE = RENDERER_TYPE.CANVAS,
) {
super();
let s: Stage = this;
......@@ -183,48 +150,49 @@ export class Stage extends Container {
Stage._stageList["canvas"] = s;
s.stage = this;
s.name = "stageInstance_" + s.instanceId;
s.desWidth = data.desWidth || 750;
s.desHeight = data.desHeight || 1206;
s.divWidth = data.divWidth;
s.divHeight = data.divHeight;
s.desWidth = desWidth || 750;
s.desHeight = desHeight || 1206;
s.divWidth = divWidth;
s.divHeight = divHeight;
s.dpi = data.canWidth / data.divWidth
// my.alert({
// title: '55729:'+data.canWidth+","+data.canHeight
// });
// s.renderObj = new CanvasRenderer(context, data.canWidth, data.canHeight);
if (data.type == RENDERER_TYPE.CANVAS) {
//@ts-ignore
s.renderObj = new CanvasRenderer(context, data.canWidth, data.canHeight);
if (renderType == RENDERER_TYPE.CANVAS) {
let context = canvas.getContext("2d");
s.renderObj = new CanvasRenderer(context, canvas.width, canvas.height);
} else {
//@ts-ignore
s.renderObj = new WebglRenderer(context, data.canWidth, data.canHeight);
let context = canvas.getContext("webgl");
s.renderObj = new WebglRenderer(context, canvas.width, canvas.height);
}
s.dpi = canvas.width / divWidth
//不加刚好置顶
s.anchorX = data.desWidth >> 1;
s.anchorY = data.desHeight >> 1;
s.x = (data.canWidth - data.desWidth) >> 1;
s.y = (data.canHeight - data.desHeight) >> 1;
s.anchorX = desWidth >> 1;
s.anchorY = desHeight >> 1;
s.x = (canvas.width - desWidth) >> 1;
s.y = (canvas.height - desHeight) >> 1;
//定宽
var scale = data.canWidth / data.desWidth;
var scale = canvas.width / desWidth;
s.scaleX = scale;
s.scaleY = scale;
s.viewRect = new Rectangle();
s.viewRect.x = (data.desWidth - data.canWidth / scale) >> 1;
s.viewRect.y = (data.desHeight - data.canHeight / scale) >> 1;
s.viewRect.width = data.desWidth - s.viewRect.x * 2;
s.viewRect.height = data.desHeight - s.viewRect.y * 2;
s.viewRect.x = (desWidth - canvas.width / scale) >> 1;
s.viewRect.y = (desHeight - canvas.height / scale) >> 1;
s.viewRect.width = desWidth - s.viewRect.x * 2;
s.viewRect.height = desHeight - s.viewRect.y * 2;
// my.alert({
// title: StageManager.ins.width
// });
setTimeout(function () {
//同时添加到主更新循环中
Stage.addUpdateObj(s);
//派发事件
s.dispatchEvent(Event.INIT_STAGE);
// }
}, 100);
}
......@@ -276,16 +244,6 @@ export class Stage extends Container {
this.renderObj.render(this);
}
/**
* 当一个stage不再需要使用,或者要从浏览器移除之前,请先停止它,避免内存泄漏
* @method kill
* @since 1.0.0
* @public
*/
public kill(): void {
Stage.removeUpdateObj(this);
}
/**
* html的鼠标或单点触摸对应的引擎事件类型名
* @property _mouseEventTypes
......@@ -527,110 +485,8 @@ export class Stage extends Container {
return this.viewRect;
}
/**
* 要循环调用 flush 函数对象列表
* @method allUpdateObjList
* @static
* @since 1.0.0
* @type {Array}
*/
private static allUpdateObjList: Array<any> = [];
static requestAnimationFrame;
static cancelAnimationFrame;
private static _stats: any
/**
* 刷新所有定时器
* @static
* @private
* @since 1.0.0
* @method flushAll
*/
static flushAll(): void {
if (!Stage.requestAnimationFrame) {
Stage.requestAnimationFrame = getRequestAnimationFrame();
Stage.cancelAnimationFrame = getCancelAnimationFrame();
}
if (!Stage.requestAnimationFrame) return;
if (!Stage._pause) {
if (Stage._stats) Stage._stats.begin();
let len = Stage.allUpdateObjList.length;
for (let i = 0; i < len; i++) {
Stage.allUpdateObjList[i] && Stage.allUpdateObjList[i].flush();
}
if (Stage._stats) Stage._stats.end();
}
Stage._flushId = Stage.requestAnimationFrame(Stage.flushAll);
}
//页面关闭时要执行,隐藏或显示只修改pause,
public static stop() {
//取消帧循环
Stage.cancelAnimationFrame(Stage._flushId);
//去掉帧率检测
Stage._stats = null;
//去掉循环函数,因为时跟着canvas的
Stage.requestAnimationFrame = null;
Stage.cancelAnimationFrame = null
}
/**
* 添加stats帧率显示
* @param canvasId
*/
public static addFPS(canvasId: string) {
//@ts-ignore
if (my) Stage._stats = new Stats(canvasId);
}
/**
* 添加一个刷新对象,这个对象里一定要有一个 flush 函数。
* 因为一但添加,这个对象的 flush 函数会以stage的fps间隔调用
* 如,你的stage是30fps 那么你这个对象的 flush 函数1秒会调用30次。
* @method addUpdateObj
* @param target 要循化调用 flush 函数的对象
* @public
* @static
* @since
*/
public static addUpdateObj(target: any): void {
let isHave: boolean = false;
let len = Stage.allUpdateObjList.length;
for (let i = 0; i < len; i++) {
if (Stage.allUpdateObjList[i] === target) {
isHave = true;
break;
}
}
if (!isHave) {
Stage.allUpdateObjList.unshift(target);
}
}
/**
* 移除掉已经添加的循环刷新对象
* @method removeUpdateObj
* @param target
* @public
* @static
* @since 1.0.0
*/
public static removeUpdateObj(target: any): void {
let len = Stage.allUpdateObjList.length;
for (let i = 0; i < len; i++) {
if (Stage.allUpdateObjList[i] === target) {
Stage.allUpdateObjList.splice(i, 1);
break;
}
}
}
public destroy(): void {
let s = this;
Stage.removeUpdateObj(s);
// s.rootDiv = null;
// s._floatDisplayList = null;
s.renderObj.destroy();
s.renderObj = null;
s.viewRect = null;
......
import { createCanvas } from "../../utils";
/**
* Creates a Canvas element of the given size.
* 其实就是一个离屏canvas,webgl模式不需要建canvas,因为可以用帧缓存
......@@ -20,11 +22,11 @@ export default class CanvasRenderTarget {
*/
constructor(width: number, height: number) {
this.canvas =createCanvas() //document.createElement('canvas');
this.canvas = createCanvas() //document.createElement('canvas');
// console.log("rd1",this.canvas)
this.resize(width, height);//要先设置尺寸?
this.context = this.canvas.getContext('2d');
// console.log("rd",this.context)
// console.log("rd",this.context)
this.resize(width, height);
}
......
import { SCALE_MODES, TEXT_ALIGN, TEXT_lINETYPE, VERTICAL_ALIGN, osType } from "../const";
import Texture from "../texture/Texture";
import { getRGBA, getBackupCanvasContext, createCanvas } from "../utils";
import { getRGBA, createCanvas } from "../utils";
import { Rectangle } from "../math";
import Sprite from "../display/Sprite";
import { BaseTexture } from "../texture";
//文本canvas上xy的偏移量
const padding = 10;
/**
......
......@@ -141,9 +141,10 @@ export default class BaseTexture extends EventDispatcher {
this._sourceChange(source);
this.dispatchEvent("loaded");
} else {
var self = this
source.onload = function () {
this._sourceChange(source);
this.dispatchEvent("loaded");
self._sourceChange(source);
self.dispatchEvent("loaded");
}
}
}
......
......@@ -142,7 +142,7 @@ export default class Texture extends EventDispatcher {
this._rotate = Number(rotate || 0);
if (baseTexture.hasLoaded) {//对于canvas形式的判断hasLoaded有问题,导致不能监听update,到时改
if (baseTexture.hasLoaded || (baseTexture.source && baseTexture.source.getContext)) {//对于canvas形式的判断hasLoaded有问题,导致不能监听update,到时改
if (this.noFrame) {
frame = new Rectangle(0, 0, baseTexture.width, baseTexture.height);
// if there is no frame we should monitor for any base texture changes..
......
import Texture from "../texture/Texture";
import { Event } from "../events/Event";
import Sprite from "../display/Sprite";
import { Container } from "../display";
/**
* 直接通过替换texture替换图片的动画帧
......@@ -8,36 +9,43 @@ import Sprite from "../display/Sprite";
* 默认按时间间隔播放
* 图片都以素材为中心为原点
*/
export class FrameAni extends Sprite {
export class FrameAni extends Container {
private showImage: Sprite
/**
* 所有的纹理
*/
texturesAll: Texture[];
private texturesAll: Texture[];
/**
* 从0开始 锁步会跳帧
* 每一帧就是一张图片,从0开始
*/
currentFrame: number;
private currentFrame: number;
/**
* 所有帧数
*/
totalFrames: number;
get totalFrames(): number {
return this.texturesAll.length
};
/**
* 是否运行中
*/
isPlay: boolean;
private isPlay: boolean;
/**
* 循环次数
*/
private loop: number = 1;
/**
* 开始时间
*/
startTime: number
private startTime: number
/**
* 所有时间,播完所用时间
*/
allTime: number
private allTime: number
/**
* 播放完的回调
*/
callback: Function;
private callback: Function;
/**
* 每秒的帧数,默认30帧
*/
......@@ -56,10 +64,12 @@ export class FrameAni extends Sprite {
*/
constructor(texturesAll: Texture[]) {
super()
this.showImage = new Sprite();
this.showImage.anchorTexture.set(0.5, 0.5);
this.addChild(this.showImage);
this.texturesAll = texturesAll;
this.changeTexture(0);
this.currentFrame = 0;
this.totalFrames = texturesAll.length;
this.addEventListener(Event.ENTER_FRAME, this.onEnterFrame, this)
this.frameRate = 30;
}
......@@ -86,36 +96,38 @@ export class FrameAni extends Sprite {
var deltaTime = dataNow - this.startTime;
var scale = deltaTime / this.allTime;
if (scale >= 1) {
this.isPlay = false
this.callback && this.callback();
//要循环时加
// this.startTime = Date.now()
// this.currentFrame = 0;
// this.changeTexture(this.currentFrame);
this.loop--;
if (this.loop == 0) {
this.isPlay = false
this.callback && this.callback();
} else {
this.startTime = Date.now()
this.currentFrame = 0;
this.changeTexture(this.currentFrame);
}
} else {
this.currentFrame = (scale * this.texturesAll.length) >> 0;
this.changeTexture(this.currentFrame);
}
}
/**
* 从0开始播
* 回调是播放完后做回收用的
* 从0开始播放
*/
play(callback) {
play(loop: number = 1, callback?: Function) {
this.startTime = Date.now();
this.isPlay = true;
this.currentFrame = 0;
this.changeTexture(0);
this.loop = loop;
this.callback = callback;
}
/**
* 重置为0
* 重置为frame,不播放
*/
reset() {
reset(frame: number = 0) {
this.isPlay = false;
this.currentFrame = 0;
this.changeTexture(0);
this.currentFrame = frame;
this.changeTexture(frame);
}
/**
* 改texture和居中
......@@ -124,11 +136,11 @@ export class FrameAni extends Sprite {
private changeTexture(index: number) {
//考虑空帧的情况
if (this.texturesAll[index]) {
this.texture = this.texturesAll[index];
this.x = -this.texture.width / 2;
this.y = -this.texture.height / 2;
this.showImage.texture = this.texturesAll[index];
// this.showImage.x = -this.texturesAll[index].width / 2;
// this.showImage.y = -this.texturesAll[index].height / 2;
} else {
this.texture = null;
this.showImage.texture = null;
}
}
......
This diff is collapsed.
......@@ -257,6 +257,8 @@ export class ScrollPage extends Container {
if (view[s.paramXY] > 0 || view[s.paramXY] < s.distance - s.maxDistance) {
s.isStop = false;
s.stopTimes = -1;
//加一个
s.isMouseDownState = 0;
}
}
}
......
export * from "./Button";
export * from "./FrameAni";
export * from "./ScrollPage"
export * from "./ScrollList"
export * from "./ShowWord"
export * from "./ScrollPage";
export * from "./ScrollList";
export * from "./ShowWord";
export * from "./MovieClip";
\ No newline at end of file
......@@ -4,6 +4,7 @@ import { nextPow2 } from "./twiddle";
import BaseTexture from "../texture/BaseTexture";
import { createCanvas } from "./tbminiAdapte";
const pool = [];
let padding = 2;
let maxSize = 4096;
......
import { createCanvas } from "./tbminiAdapte";
let result: boolean = null;
/**
* 创建带颜色的canvas
......
......@@ -2,7 +2,6 @@ import { canUseNewCanvasBlendModes } from "./canUseNewCanvasBlendModes";
import Texture from "../texture/Texture";
import { createCanvas } from "./tbminiAdapte";
/**
* Number of steps which will be used as a cap when rounding colors.
*
......
......@@ -6,7 +6,6 @@ import { RENDERER_TYPE } from "../const";
import { mapPremultipliedBlendModes } from "./mapPremultipliedBlendModes";
import { createCanvas } from "./tbminiAdapte";
export * from './twiddle';
export { default as toDisplayDataURL } from "./toDisplayDataURL";
export { default as determineCrossOrigin } from './determineCrossOrigin';
......
......@@ -3,17 +3,6 @@ export function createCanvas(): HTMLCanvasElement {
//@ts-ignore
return document && document.createElement("canvas") || my._createOffscreenCanvas() || document.createElement("canvas")
}
//每次都要重置
let backupCanvasContext: CanvasRenderingContext2D
export function setBackupCanvasContext(bc) {
backupCanvasContext = bc;
}
export function getBackupCanvasContext() {
return backupCanvasContext
}
export function destroyBackupCanvasContext() {
backupCanvasContext = null;
}
/**
* 备用的canvas上下文,用于绘制文本,图片等等
* 外面赋值
......
......@@ -4,6 +4,7 @@ import { Matrix, Rectangle } from "../math";
import { DisplayObject } from "../display/DisplayObject";
import { createCanvas } from "./tbminiAdapte";
// 作为将显示对象导出成图片的render渲染器
let _dRender: CanvasRenderer = null;
let _dCanvas
......
import { createContext } from './createContext';
import { createCanvas } from '../2d/utils';
const fragTemplate = [
'precision mediump float;',
'void main(void){',
......
import { Tween } from './tween';
import { Stage } from './2d/display';
//tween循环加入
Stage.addUpdateObj(Tween)
export * from './2d/const';
// export * from './2d/Setting';
export * from "./2d/display";
......@@ -37,8 +34,9 @@ export * from "./sound"
export * from "./tween";
if(window)window["my"]=null
// export * from "./Stats";
//如果是浏览器环境,声明个my为null,为了无声明不报错
if (window) window["my"] = null
export * from "./Stats";
/**
* ios端canvas现在是永远根据设置的width和height(不是style里的)乘以dpi返回的尺寸
......
......@@ -10,7 +10,7 @@ module.exports = {
},
output: {
path: __dirname,
filename: "dist/[name].js",
filename: "build/[name].js",
libraryTarget: 'umd',
library: 'FYGE',
},
......
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