Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fyge_for_tb
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王剑峰
fyge_for_tb
Commits
eb22fbd4
Commit
eb22fbd4
authored
Apr 27, 2020
by
wjf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
l
parent
6e24b57e
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
85 additions
and
66 deletions
+85
-66
fyge.min.js
dist/fyge.min.js
+1
-1
fyge.min.js.map
dist/fyge.min.js.map
+1
-1
package-lock.json
package-lock.json
+9
-24
package.json
package.json
+1
-1
Stage.ts
src/2d/display/Stage.ts
+4
-4
TextField.ts
src/2d/text/TextField.ts
+3
-1
BaseTexture.ts
src/2d/texture/BaseTexture.ts
+34
-15
Texture.ts
src/2d/texture/Texture.ts
+19
-9
tbminiAdapte.ts
src/2d/utils/tbminiAdapte.ts
+11
-9
index.ts
src/index.ts
+2
-1
No files found.
dist/fyge.min.js
View file @
eb22fbd4
This source diff could not be displayed because it is too large. You can
view the blob
instead.
dist/fyge.min.js.map
View file @
eb22fbd4
This diff is collapsed.
Click to expand it.
package-lock.json
View file @
eb22fbd4
...
@@ -1429,14 +1429,12 @@
...
@@ -1429,14 +1429,12 @@
"balanced-match"
:
{
"balanced-match"
:
{
"version"
:
"1.0.0"
,
"version"
:
"1.0.0"
,
"bundled"
:
true
,
"bundled"
:
true
,
"dev"
:
true
,
"dev"
:
true
"optional"
:
true
},
},
"brace-expansion"
:
{
"brace-expansion"
:
{
"version"
:
"1.1.11"
,
"version"
:
"1.1.11"
,
"bundled"
:
true
,
"bundled"
:
true
,
"dev"
:
true
,
"dev"
:
true
,
"optional"
:
true
,
"requires"
:
{
"requires"
:
{
"balanced-match"
:
"^1.0.0"
,
"balanced-match"
:
"^1.0.0"
,
"concat-map"
:
"0.0.1"
"concat-map"
:
"0.0.1"
...
@@ -1451,20 +1449,17 @@
...
@@ -1451,20 +1449,17 @@
"code-point-at"
:
{
"code-point-at"
:
{
"version"
:
"1.1.0"
,
"version"
:
"1.1.0"
,
"bundled"
:
true
,
"bundled"
:
true
,
"dev"
:
true
,
"dev"
:
true
"optional"
:
true
},
},
"concat-map"
:
{
"concat-map"
:
{
"version"
:
"0.0.1"
,
"version"
:
"0.0.1"
,
"bundled"
:
true
,
"bundled"
:
true
,
"dev"
:
true
,
"dev"
:
true
"optional"
:
true
},
},
"console-control-strings"
:
{
"console-control-strings"
:
{
"version"
:
"1.1.0"
,
"version"
:
"1.1.0"
,
"bundled"
:
true
,
"bundled"
:
true
,
"dev"
:
true
,
"dev"
:
true
"optional"
:
true
},
},
"core-util-is"
:
{
"core-util-is"
:
{
"version"
:
"1.0.2"
,
"version"
:
"1.0.2"
,
...
@@ -1581,8 +1576,7 @@
...
@@ -1581,8 +1576,7 @@
"inherits"
:
{
"inherits"
:
{
"version"
:
"2.0.4"
,
"version"
:
"2.0.4"
,
"bundled"
:
true
,
"bundled"
:
true
,
"dev"
:
true
,
"dev"
:
true
"optional"
:
true
},
},
"ini"
:
{
"ini"
:
{
"version"
:
"1.3.5"
,
"version"
:
"1.3.5"
,
...
@@ -1594,7 +1588,6 @@
...
@@ -1594,7 +1588,6 @@
"version"
:
"1.0.0"
,
"version"
:
"1.0.0"
,
"bundled"
:
true
,
"bundled"
:
true
,
"dev"
:
true
,
"dev"
:
true
,
"optional"
:
true
,
"requires"
:
{
"requires"
:
{
"number-is-nan"
:
"^1.0.0"
"number-is-nan"
:
"^1.0.0"
}
}
...
@@ -1609,7 +1602,6 @@
...
@@ -1609,7 +1602,6 @@
"version"
:
"3.0.4"
,
"version"
:
"3.0.4"
,
"bundled"
:
true
,
"bundled"
:
true
,
"dev"
:
true
,
"dev"
:
true
,
"optional"
:
true
,
"requires"
:
{
"requires"
:
{
"brace-expansion"
:
"^1.1.7"
"brace-expansion"
:
"^1.1.7"
}
}
...
@@ -1617,14 +1609,12 @@
...
@@ -1617,14 +1609,12 @@
"minimist"
:
{
"minimist"
:
{
"version"
:
"1.2.5"
,
"version"
:
"1.2.5"
,
"bundled"
:
true
,
"bundled"
:
true
,
"dev"
:
true
,
"dev"
:
true
"optional"
:
true
},
},
"minipass"
:
{
"minipass"
:
{
"version"
:
"2.9.0"
,
"version"
:
"2.9.0"
,
"bundled"
:
true
,
"bundled"
:
true
,
"dev"
:
true
,
"dev"
:
true
,
"optional"
:
true
,
"requires"
:
{
"requires"
:
{
"safe-buffer"
:
"^5.1.2"
,
"safe-buffer"
:
"^5.1.2"
,
"yallist"
:
"^3.0.0"
"yallist"
:
"^3.0.0"
...
@@ -1643,7 +1633,6 @@
...
@@ -1643,7 +1633,6 @@
"version"
:
"0.5.3"
,
"version"
:
"0.5.3"
,
"bundled"
:
true
,
"bundled"
:
true
,
"dev"
:
true
,
"dev"
:
true
,
"optional"
:
true
,
"requires"
:
{
"requires"
:
{
"minimist"
:
"^1.2.5"
"minimist"
:
"^1.2.5"
}
}
...
@@ -1705,8 +1694,7 @@
...
@@ -1705,8 +1694,7 @@
"npm-normalize-package-bin"
:
{
"npm-normalize-package-bin"
:
{
"version"
:
"1.0.1"
,
"version"
:
"1.0.1"
,
"bundled"
:
true
,
"bundled"
:
true
,
"dev"
:
true
,
"dev"
:
true
"optional"
:
true
},
},
"npm-packlist"
:
{
"npm-packlist"
:
{
"version"
:
"1.4.8"
,
"version"
:
"1.4.8"
,
...
@@ -1734,8 +1722,7 @@
...
@@ -1734,8 +1722,7 @@
"number-is-nan"
:
{
"number-is-nan"
:
{
"version"
:
"1.0.1"
,
"version"
:
"1.0.1"
,
"bundled"
:
true
,
"bundled"
:
true
,
"dev"
:
true
,
"dev"
:
true
"optional"
:
true
},
},
"object-assign"
:
{
"object-assign"
:
{
"version"
:
"4.1.1"
,
"version"
:
"4.1.1"
,
...
@@ -1747,7 +1734,6 @@
...
@@ -1747,7 +1734,6 @@
"version"
:
"1.4.0"
,
"version"
:
"1.4.0"
,
"bundled"
:
true
,
"bundled"
:
true
,
"dev"
:
true
,
"dev"
:
true
,
"optional"
:
true
,
"requires"
:
{
"requires"
:
{
"wrappy"
:
"1"
"wrappy"
:
"1"
}
}
...
@@ -1861,7 +1847,6 @@
...
@@ -1861,7 +1847,6 @@
"version"
:
"1.0.2"
,
"version"
:
"1.0.2"
,
"bundled"
:
true
,
"bundled"
:
true
,
"dev"
:
true
,
"dev"
:
true
,
"optional"
:
true
,
"requires"
:
{
"requires"
:
{
"code-point-at"
:
"^1.0.0"
,
"code-point-at"
:
"^1.0.0"
,
"is-fullwidth-code-point"
:
"^1.0.0"
,
"is-fullwidth-code-point"
:
"^1.0.0"
,
...
@@ -4147,4 +4132,4 @@
...
@@ -4147,4 +4132,4 @@
}
}
}
}
}
}
}
}
\ No newline at end of file
package.json
View file @
eb22fbd4
...
@@ -24,4 +24,4 @@
...
@@ -24,4 +24,4 @@
"keywords"
:
[
"keywords"
:
[
"淘宝小程序,canvas"
"淘宝小程序,canvas"
]
]
}
}
\ No newline at end of file
src/2d/display/Stage.ts
View file @
eb22fbd4
...
@@ -293,9 +293,9 @@ export class Stage extends Container {
...
@@ -293,9 +293,9 @@ export class Stage extends Container {
* @private
* @private
*/
*/
private
_mouseEventTypes
:
any
=
{
private
_mouseEventTypes
:
any
=
{
//
touchstart: "onMouseDown",
touchstart
:
"onMouseDown"
,
//
touchmove: "onMouseMove",
touchmove
:
"onMouseMove"
,
// touchend: "onMouseUp"
touchend
:
"onMouseUp"
,
touchStart
:
"onMouseDown"
,
//小程序返回的时间名是驼峰的
touchStart
:
"onMouseDown"
,
//小程序返回的时间名是驼峰的
touchMove
:
"onMouseMove"
,
touchMove
:
"onMouseMove"
,
touchEnd
:
"onMouseUp"
touchEnd
:
"onMouseUp"
...
@@ -581,7 +581,7 @@ export class Stage extends Container {
...
@@ -581,7 +581,7 @@ export class Stage extends Container {
*/
*/
public
static
addFPS
(
canvasId
:
string
)
{
public
static
addFPS
(
canvasId
:
string
)
{
//@ts-ignore
//@ts-ignore
Stage
.
_stats
=
new
Stats
(
canvasId
);
if
(
my
)
Stage
.
_stats
=
new
Stats
(
canvasId
);
}
}
/**
/**
...
...
src/2d/text/TextField.ts
View file @
eb22fbd4
...
@@ -504,7 +504,7 @@ export class TextField extends Sprite {
...
@@ -504,7 +504,7 @@ export class TextField extends Sprite {
let
hardLines
:
any
=
s
.
_text
.
toString
().
split
(
/
(?:\r\n
|
\r
|
\n)
/
);
let
hardLines
:
any
=
s
.
_text
.
toString
().
split
(
/
(?:\r\n
|
\r
|
\n)
/
);
let
realLines
:
any
=
[];
let
realLines
:
any
=
[];
s
.
realLines
=
realLines
;
s
.
realLines
=
realLines
;
// s._prepContext(ctx);
s
.
_prepContext
(
ctx
);
//因为不用canvas的api量文本宽度,所以这里执行不重要
let
textWidth
=
s
.
_textWidth
;
let
textWidth
=
s
.
_textWidth
;
// let lineH = s._lineSpacing + s.size;
// let lineH = s._lineSpacing + s.size;
...
@@ -639,6 +639,8 @@ export class TextField extends Sprite {
...
@@ -639,6 +639,8 @@ export class TextField extends Sprite {
}
}
public
destroy
():
void
{
public
destroy
():
void
{
this
.
canvas
=
null
;
this
.
context
=
null
;
super
.
destroy
();
super
.
destroy
();
//todo
//todo
}
}
...
...
src/2d/texture/BaseTexture.ts
View file @
eb22fbd4
...
@@ -173,9 +173,9 @@ export default class BaseTexture extends EventDispatcher {
...
@@ -173,9 +173,9 @@ export default class BaseTexture extends EventDispatcher {
_sourceChange
(
source
)
{
_sourceChange
(
source
)
{
//赋值
//赋值
this
.
source
=
source
;
this
.
source
=
source
;
//路径,暂时没用,需要时再处理
//路径,暂时没用,需要时再处理
,先找src 再path(基本没有)
this
.
imageUrl
=
source
.
path
||
null
;
this
.
imageUrl
=
source
.
src
||
source
.
path
||
null
;
//更新类型,暂时没用
//更新类型,暂时没用
,也没做,需要是处理
this
.
imageType
=
this
.
source
.
type
||
null
;
this
.
imageType
=
this
.
source
.
type
||
null
;
//加载完成
//加载完成
this
.
hasLoaded
=
true
;
this
.
hasLoaded
=
true
;
...
@@ -211,7 +211,7 @@ export default class BaseTexture extends EventDispatcher {
...
@@ -211,7 +211,7 @@ export default class BaseTexture extends EventDispatcher {
//辅助静态方法
//辅助静态方法
/**
/**
*
*
根据路径
* @param {string} url 路径
* @param {string} url 路径
*/
*/
static
fromUrl
(
url
:
string
)
{
static
fromUrl
(
url
:
string
)
{
...
@@ -227,8 +227,12 @@ export default class BaseTexture extends EventDispatcher {
...
@@ -227,8 +227,12 @@ export default class BaseTexture extends EventDispatcher {
return
baseTexture
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 {
...
@@ -246,23 +250,38 @@ export default class BaseTexture extends EventDispatcher {
}
}
return
baseTexture
;
return
baseTexture
;
}
}
/**
* 根据图片
* @param image
*/
static
fromImage
(
image
:
HTMLImageElement
)
{
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形式
//不包括data形式
,data用
static
from
(
any
T
hing
:
string
|
HTMLCanvasElement
|
HTMLImageElement
)
{
static
from
(
any
t
hing
:
string
|
HTMLCanvasElement
|
HTMLImageElement
)
{
//路径
//路径
if
(
typeof
anyThing
===
'string'
)
{
if
(
typeof
anything
===
'string'
)
{
return
BaseTexture
.
fromUrl
(
anyThing
);
return
BaseTexture
.
fromUrl
(
anything
);
}
//@ts-ignore
else
if
(
anything
.
data
)
{
return
BaseTexture
.
fromData
(
anything
);
}
}
//@ts-ignore canvas
//@ts-ignore canvas
else
if
(
any
T
hing
.
getContext
)
{
else
if
(
any
t
hing
.
getContext
)
{
//@ts-ignore
//@ts-ignore
return
BaseTexture
.
fromCanvas
(
any
T
hing
);
return
BaseTexture
.
fromCanvas
(
any
t
hing
);
}
else
{
}
else
{
//@ts-ignore
//@ts-ignore
return
BaseTexture
.
fromImage
(
any
T
hing
);
return
BaseTexture
.
fromImage
(
any
t
hing
);
}
}
}
}
...
...
src/2d/texture/Texture.ts
View file @
eb22fbd4
...
@@ -371,26 +371,36 @@ export default class Texture extends EventDispatcher {
...
@@ -371,26 +371,36 @@ export default class Texture extends EventDispatcher {
return
new
Texture
(
BaseTexture
.
fromCanvas
(
canvas
,
origin
))
return
new
Texture
(
BaseTexture
.
fromCanvas
(
canvas
,
origin
))
}
}
static
from
Source
(
source
)
{
static
from
Data
(
data
)
{
return
new
Texture
(
BaseTexture
.
from
Source
(
source
))
return
new
Texture
(
BaseTexture
.
from
Data
(
data
))
}
}
static
fromImage
(
image
:
HTMLImageElement
)
{
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形式
//不包括data形式
static
from
(
any
T
hing
:
string
|
HTMLCanvasElement
|
HTMLImageElement
)
{
static
from
(
any
t
hing
:
string
|
HTMLCanvasElement
|
HTMLImageElement
)
{
//路径
//路径
if
(
typeof
anyThing
===
'string'
)
{
if
(
typeof
anything
===
'string'
)
{
return
Texture
.
fromUrl
(
anyThing
);
return
Texture
.
fromUrl
(
anything
);
}
//@ts-ignore
else
if
(
anything
.
data
)
{
return
Texture
.
fromData
(
anything
);
}
}
//@ts-ignore canvas
//@ts-ignore canvas
else
if
(
any
T
hing
.
getContext
)
{
else
if
(
any
t
hing
.
getContext
)
{
//@ts-ignore
//@ts-ignore
return
Texture
.
fromCanvas
(
any
T
hing
);
return
Texture
.
fromCanvas
(
any
t
hing
);
}
else
{
}
else
{
//@ts-ignore
//@ts-ignore
return
Texture
.
fromImage
(
any
T
hing
);
return
Texture
.
fromImage
(
any
t
hing
);
}
}
}
}
...
...
src/2d/utils/tbminiAdapte.ts
View file @
eb22fbd4
/**
/**
* ios还有问题,先别用
* ios还有问题,先别用
*/
*/
export
function
createCanvas
():
HTMLCanvasElement
{
export
function
createCanvas
():
HTMLCanvasElement
{
//@ts-ignore
//@ts-ignore
return
my
.
_createOffscreenCanvas
(
)
return
my
&&
my
.
_createOffscreenCanvas
()
||
document
.
createElement
(
"canvas"
)
}
}
//每次都要重置
//每次都要重置
let
backupCanvasContext
:
CanvasRenderingContext2D
let
backupCanvasContext
:
CanvasRenderingContext2D
...
@@ -36,18 +36,20 @@ export function initedByCanvas(canvas) {
...
@@ -36,18 +36,20 @@ export function initedByCanvas(canvas) {
}
}
}
}
export
function
destroyCanvasContent
()
{
export
function
destroyCanvasContent
()
{
contentByCanvas
.
createImage
=
null
;
if
(
contentByCanvas
)
{
contentByCanvas
.
requestAnimationFrame
=
null
;
contentByCanvas
.
createImage
=
null
;
contentByCanvas
.
cancelAnimationFrame
=
null
;
contentByCanvas
.
requestAnimationFrame
=
null
;
contentByCanvas
=
null
contentByCanvas
.
cancelAnimationFrame
=
null
;
contentByCanvas
=
null
}
}
}
export
function
getCreateImage
()
{
export
function
getCreateImage
()
{
return
contentByCanvas
&&
contentByCanvas
.
createImage
return
contentByCanvas
&&
contentByCanvas
.
createImage
||
(()
=>
{
return
new
Image
()
})
}
}
export
function
getRequestAnimationFrame
()
{
export
function
getRequestAnimationFrame
()
{
return
contentByCanvas
&&
contentByCanvas
.
requestAnimationFrame
return
contentByCanvas
&&
contentByCanvas
.
requestAnimationFrame
||
window
.
requestAnimationFrame
}
}
export
function
getCancelAnimationFrame
()
{
export
function
getCancelAnimationFrame
()
{
return
contentByCanvas
&&
contentByCanvas
.
cancelAnimationFrame
return
contentByCanvas
&&
contentByCanvas
.
cancelAnimationFrame
||
window
.
cancelAnimationFrame
}
}
src/index.ts
View file @
eb22fbd4
...
@@ -63,7 +63,8 @@ export * from "./tween";
...
@@ -63,7 +63,8 @@ export * from "./tween";
* 7、loader有大修改
* 7、loader有大修改
* 8、去掉了svga,到时能取外域文件再说
* 8、去掉了svga,到时能取外域文件再说
* 9、ios一帧多buffer绘制在小程序上有问题,先去掉了,原因在查,暂时应该无影响,有影响再说
* 9、ios一帧多buffer绘制在小程序上有问题,先去掉了,原因在查,暂时应该无影响,有影响再说
* 10、
* 10、安卓端createImage()返回的对象拿不到src属性,注意
* 11、
*/
*/
// function aa(){
// function aa(){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment