Commit eb22fbd4 authored by wjf's avatar wjf

l

parent 6e24b57e
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -1429,14 +1429,12 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
......@@ -1451,20 +1449,17 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"core-util-is": {
"version": "1.0.2",
......@@ -1581,8 +1576,7 @@
"inherits": {
"version": "2.0.4",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"ini": {
"version": "1.3.5",
......@@ -1594,7 +1588,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
......@@ -1609,7 +1602,6 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
......@@ -1617,14 +1609,12 @@
"minimist": {
"version": "1.2.5",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"minipass": {
"version": "2.9.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
......@@ -1643,7 +1633,6 @@
"version": "0.5.3",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "^1.2.5"
}
......@@ -1705,8 +1694,7 @@
"npm-normalize-package-bin": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"npm-packlist": {
"version": "1.4.8",
......@@ -1734,8 +1722,7 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"object-assign": {
"version": "4.1.1",
......@@ -1747,7 +1734,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
......@@ -1861,7 +1847,6 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
......
......@@ -293,9 +293,9 @@ export class Stage extends Container {
* @private
*/
private _mouseEventTypes: any = {
// touchstart: "onMouseDown",
// touchmove: "onMouseMove",
// touchend: "onMouseUp"
touchstart: "onMouseDown",
touchmove: "onMouseMove",
touchend: "onMouseUp",
touchStart: "onMouseDown",//小程序返回的时间名是驼峰的
touchMove: "onMouseMove",
touchEnd: "onMouseUp"
......@@ -581,7 +581,7 @@ export class Stage extends Container {
*/
public static addFPS(canvasId: string) {
//@ts-ignore
Stage._stats = new Stats(canvasId);
if (my) Stage._stats = new Stats(canvasId);
}
/**
......
......@@ -504,7 +504,7 @@ export class TextField extends Sprite {
let hardLines: any = s._text.toString().split(/(?:\r\n|\r|\n)/);
let realLines: any = [];
s.realLines = realLines;
// s._prepContext(ctx);
s._prepContext(ctx);//因为不用canvas的api量文本宽度,所以这里执行不重要
let textWidth = s._textWidth;
// let lineH = s._lineSpacing + s.size;
......@@ -639,6 +639,8 @@ export class TextField extends Sprite {
}
public destroy(): void {
this.canvas = null;
this.context = null;
super.destroy();
//todo
}
......
......@@ -173,9 +173,9 @@ export default class BaseTexture extends EventDispatcher {
_sourceChange(source) {
//赋值
this.source = source;
//路径,暂时没用,需要时再处理
this.imageUrl = source.path || null;
//更新类型,暂时没用
//路径,暂时没用,需要时再处理,先找src 再path(基本没有)
this.imageUrl = source.src || source.path || null;
//更新类型,暂时没用,也没做,需要是处理
this.imageType = this.source.type || null;
//加载完成
this.hasLoaded = true;
......@@ -211,7 +211,7 @@ export default class BaseTexture extends EventDispatcher {
//辅助静态方法
/**
*
* 根据路径
* @param {string} url 路径
*/
static fromUrl(url: string) {
......@@ -227,8 +227,12 @@ export default class BaseTexture extends EventDispatcher {
return baseTexture
}
static fromSource(source) {
return new BaseTexture(source);
/**
* 随便啥形式的,比如data,
* @param data
*/
static fromData(data) {
return new BaseTexture(data);
}
/**
......@@ -246,23 +250,38 @@ export default class BaseTexture extends EventDispatcher {
}
return baseTexture;
}
/**
* 根据图片
* @param image
*/
static fromImage(image: HTMLImageElement) {
return new BaseTexture(image);
//图片标签
const imageUrl = image.src;
let baseTexture = BaseTextureCache[imageUrl];
if (!baseTexture) {
baseTexture = new BaseTexture(image);
//不缓存base64,如需要,设名字,手动缓存
if (imageUrl && imageUrl.indexOf('data:') !== 0) BaseTexture.addToCache(baseTexture, imageUrl);
}
return baseTexture;
}
//不包括data形式
static from(anyThing: string | HTMLCanvasElement | HTMLImageElement) {
//不包括data形式,data用
static from(anything: string | HTMLCanvasElement | HTMLImageElement) {
//路径
if (typeof anyThing === 'string') {
return BaseTexture.fromUrl(anyThing);
if (typeof anything === 'string') {
return BaseTexture.fromUrl(anything);
}
//@ts-ignore
else if (anything.data) {
return BaseTexture.fromData(anything);
}
//@ts-ignore canvas
else if (anyThing.getContext) {
else if (anything.getContext) {
//@ts-ignore
return BaseTexture.fromCanvas(anyThing);
return BaseTexture.fromCanvas(anything);
} else {
//@ts-ignore
return BaseTexture.fromImage(anyThing);
return BaseTexture.fromImage(anything);
}
}
......
......@@ -371,26 +371,36 @@ export default class Texture extends EventDispatcher {
return new Texture(BaseTexture.fromCanvas(canvas, origin))
}
static fromSource(source) {
return new Texture(BaseTexture.fromSource(source))
static fromData(data) {
return new Texture(BaseTexture.fromData(data))
}
static fromImage(image: HTMLImageElement) {
return new Texture(BaseTexture.fromImage(image));
var imageUrl = image.src;
let texture: Texture = TextureCache[imageUrl];
if (!texture) {
texture = new Texture(BaseTexture.fromImage(image));
if (imageUrl && imageUrl.indexOf('data:') !== 0) Texture.addToCache(texture, imageUrl);
}
return texture;
}
//不包括data形式
static from(anyThing: string | HTMLCanvasElement | HTMLImageElement) {
static from(anything: string | HTMLCanvasElement | HTMLImageElement) {
//路径
if (typeof anyThing === 'string') {
return Texture.fromUrl(anyThing);
if (typeof anything === 'string') {
return Texture.fromUrl(anything);
}
//@ts-ignore
else if (anything.data) {
return Texture.fromData(anything);
}
//@ts-ignore canvas
else if (anyThing.getContext) {
else if (anything.getContext) {
//@ts-ignore
return Texture.fromCanvas(anyThing);
return Texture.fromCanvas(anything);
} else {
//@ts-ignore
return Texture.fromImage(anyThing);
return Texture.fromImage(anything);
}
}
......
/**
* ios还有问题,先别用
*/
export function createCanvas():HTMLCanvasElement {
export function createCanvas(): HTMLCanvasElement {
//@ts-ignore
return my._createOffscreenCanvas()
return my && my._createOffscreenCanvas() || document.createElement("canvas")
}
//每次都要重置
let backupCanvasContext: CanvasRenderingContext2D
......@@ -36,18 +36,20 @@ export function initedByCanvas(canvas) {
}
}
export function destroyCanvasContent() {
if (contentByCanvas) {
contentByCanvas.createImage = null;
contentByCanvas.requestAnimationFrame = null;
contentByCanvas.cancelAnimationFrame = null;
contentByCanvas = null
}
}
export function getCreateImage() {
return contentByCanvas && contentByCanvas.createImage
return contentByCanvas && contentByCanvas.createImage || (() => { return new Image() })
}
export function getRequestAnimationFrame() {
return contentByCanvas && contentByCanvas.requestAnimationFrame
return contentByCanvas && contentByCanvas.requestAnimationFrame || window.requestAnimationFrame
}
export function getCancelAnimationFrame() {
return contentByCanvas && contentByCanvas.cancelAnimationFrame
return contentByCanvas && contentByCanvas.cancelAnimationFrame || window.cancelAnimationFrame
}
......@@ -63,7 +63,8 @@ export * from "./tween";
* 7、loader有大修改
* 8、去掉了svga,到时能取外域文件再说
* 9、ios一帧多buffer绘制在小程序上有问题,先去掉了,原因在查,暂时应该无影响,有影响再说
* 10、
* 10、安卓端createImage()返回的对象拿不到src属性,注意
* 11、
*/
// function aa(){
......
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