Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
renderingEngine
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
王剑峰
renderingEngine
Commits
d711ec43
Commit
d711ec43
authored
Nov 06, 2019
by
wjf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
l
parent
81c8fc27
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
66 deletions
+65
-66
Container.ts
src/2d/display/Container.ts
+19
-19
Sprite.ts
src/2d/display/Sprite.ts
+25
-26
Graphics.ts
src/2d/graphics/Graphics.ts
+20
-20
Shape.ts
src/2d/graphics/Shape.ts
+1
-1
No files found.
src/2d/display/Container.ts
View file @
d711ec43
import
{
DisplayObject
}
from
'./DisplayObject'
;
import
{
DisplayObject
}
from
'./DisplayObject'
;
import
{
Rectangle
}
from
"../math/Rectangle"
;
import
{
Rectangle
}
from
"../math/Rectangle"
;
import
{
Point
}
from
'../math'
;
import
{
Point
}
from
'../math'
;
import
CanvasRenderer
from
'../renderers/CanvasRenderer'
;
import
CanvasRenderer
from
'../renderers/CanvasRenderer'
;
import
{
Event
}
from
"../events/Event"
import
{
Event
}
from
"../events/Event"
import
{
WebglRenderer
}
from
'../renderers/WebglRenderer'
;
import
{
WebglRenderer
}
from
'../renderers/WebglRenderer'
;
/**
/**
* 容器类
* 容器类
...
@@ -538,17 +538,17 @@ export default class Container extends DisplayObject {
...
@@ -538,17 +538,17 @@ export default class Container extends DisplayObject {
* @member {number}
* @member {number}
*/
*/
get
width
()
{
get
width
()
{
return
this
.
scale
.
x
*
this
.
getLocalBounds
().
width
;
return
this
.
_width
||
this
.
scale
.
x
*
this
.
getLocalBounds
().
width
;
}
}
set
width
(
value
)
{
set
width
(
value
)
{
const
width
=
this
.
getLocalBounds
().
width
;
//
const width = this.getLocalBounds().width;
if
(
width
!==
0
)
{
//
if (width !== 0) {
this
.
scale
.
x
=
value
/
width
;
//
this.scale.x = value / width;
}
else
{
//
} else {
this
.
scale
.
x
=
1
;
//
this.scale.x = 1;
}
//
}
//子类有用,有_width,才需设置scaleX
//子类有用,有_width,才需设置scaleX
this
.
_width
=
value
this
.
_width
=
value
}
}
...
@@ -558,17 +558,17 @@ export default class Container extends DisplayObject {
...
@@ -558,17 +558,17 @@ export default class Container extends DisplayObject {
* @member {number}
* @member {number}
*/
*/
get
height
()
{
get
height
()
{
return
this
.
scale
.
y
*
this
.
getLocalBounds
().
height
;
return
this
.
_height
||
this
.
scale
.
y
*
this
.
getLocalBounds
().
height
;
}
}
set
height
(
value
)
{
set
height
(
value
)
{
const
height
=
this
.
getLocalBounds
().
height
;
//
const height = this.getLocalBounds().height;
if
(
height
!==
0
)
{
//
if (height !== 0) {
this
.
scale
.
y
=
value
/
height
;
//
this.scale.y = value / height;
}
else
{
//
} else {
this
.
scale
.
y
=
1
;
//
this.scale.y = 1;
}
//
}
this
.
_height
=
value
this
.
_height
=
value
}
}
...
...
src/2d/display/Sprite.ts
View file @
d711ec43
...
@@ -122,15 +122,14 @@ export default class Sprite extends Container {
...
@@ -122,15 +122,14 @@ export default class Sprite extends Container {
this
.
_textureTrimmedID
=
-
1
;
this
.
_textureTrimmedID
=
-
1
;
//可用才赋值uv
//可用才赋值uv
if
(
this
.
_texture
.
valid
)
this
.
uvs
=
this
.
_texture
.
_uvs
.
uvsFloat32
;
if
(
this
.
_texture
.
valid
)
this
.
uvs
=
this
.
_texture
.
_uvs
.
uvsFloat32
;
//设置过宽高的话,就需要改变缩放值
//设置过宽高的话,就需要改变缩放值,废弃先
// so if _width is 0 then width was not set..
// if (this._width) {
if
(
this
.
_width
)
{
// this.scale.x = sign(this.scale.x) * this._width / this._texture.orig.width;
this
.
scale
.
x
=
sign
(
this
.
scale
.
x
)
*
this
.
_width
/
this
.
_texture
.
orig
.
width
;
// }
}
if
(
this
.
_height
)
{
//
if (this._height) {
this
.
scale
.
y
=
sign
(
this
.
scale
.
y
)
*
this
.
_height
/
this
.
_texture
.
orig
.
height
;
//
this.scale.y = sign(this.scale.y) * this._height / this._texture.orig.height;
}
//
}
//修改_localBoundsSelf
//修改_localBoundsSelf
const
width
=
this
.
_texture
.
orig
.
width
;
const
width
=
this
.
_texture
.
orig
.
width
;
...
@@ -369,34 +368,34 @@ export default class Sprite extends Container {
...
@@ -369,34 +368,34 @@ export default class Sprite extends Container {
}
}
/**
/**
* 重写Container父类
* 重写Container父类
,废弃先
* texture的宽度和缩放乘积
* texture的宽度和缩放乘积
* @member {number}
* @member {number}
*/
*/
get
width
()
{
//
get width() {
return
Math
.
abs
(
this
.
scale
.
x
)
*
this
.
_texture
.
orig
.
width
;
//
return Math.abs(this.scale.x) * this._texture.orig.width;
}
//
}
set
width
(
value
)
{
//
set width(value) {
const
s
=
sign
(
this
.
scale
.
x
)
||
1
;
//
const s = sign(this.scale.x) || 1;
this
.
scale
.
x
=
s
*
value
/
this
.
_texture
.
orig
.
width
;
//
this.scale.x = s * value / this._texture.orig.width;
this
.
_width
=
value
;
//
this._width = value;
}
//
}
/**
/**
* texture的高度和缩放乘积
* texture的高度和缩放乘积
* @member {number}
* @member {number}
*/
*/
get
height
()
{
//
get height() {
return
Math
.
abs
(
this
.
scale
.
y
)
*
this
.
_texture
.
orig
.
height
;
//
return Math.abs(this.scale.y) * this._texture.orig.height;
}
//
}
set
height
(
value
)
{
//
set height(value) {
const
s
=
sign
(
this
.
scale
.
y
)
||
1
;
//
const s = sign(this.scale.y) || 1;
this
.
scale
.
y
=
s
*
value
/
this
.
_texture
.
orig
.
height
;
//
this.scale.y = s * value / this._texture.orig.height;
this
.
_height
=
value
;
//
this._height = value;
}
//
}
/**
/**
* 0,0标识左上角,0.5,0.5表示中间,1,1表示右下角
* 0,0标识左上角,0.5,0.5表示中间,1,1表示右下角
...
...
src/2d/graphics/Graphics.ts
View file @
d711ec43
...
@@ -1378,36 +1378,36 @@ export default class Graphics extends Container {
...
@@ -1378,36 +1378,36 @@ export default class Graphics extends Container {
/**
/**
*
The width of the sprite, setting this will actually modify the scale to achieve the value set
*
废弃先
* @member {number}
* @member {number}
*/
*/
get
width
()
{
//
get width() {
this
.
updateLocalBoundsSelf
()
//
this.updateLocalBoundsSelf()
return
Math
.
abs
(
this
.
scale
.
x
)
*
this
.
_localBoundsSelf
.
width
;
//
return Math.abs(this.scale.x) * this._localBoundsSelf.width;
}
//
}
set
width
(
value
)
{
//
set width(value) {
const
s
=
sign
(
this
.
scale
.
x
)
||
1
;
//
const s = sign(this.scale.x) || 1;
this
.
scale
.
x
=
s
*
value
/
this
.
_localBoundsSelf
.
width
;
//
this.scale.x = s * value / this._localBoundsSelf.width;
this
.
_width
=
value
;
//
this._width = value;
}
//
}
/**
/**
* The height of the sprite, setting this will actually modify the scale to achieve the value set
* The height of the sprite, setting this will actually modify the scale to achieve the value set
*
*
* @member {number}
* @member {number}
*/
*/
get
height
()
{
//
get height() {
this
.
updateLocalBoundsSelf
()
//
this.updateLocalBoundsSelf()
return
Math
.
abs
(
this
.
scale
.
y
)
*
this
.
_localBoundsSelf
.
height
;
//
return Math.abs(this.scale.y) * this._localBoundsSelf.height;
}
//
}
set
height
(
value
)
{
//
set height(value) {
const
s
=
sign
(
this
.
scale
.
y
)
||
1
;
//
const s = sign(this.scale.y) || 1;
this
.
scale
.
y
=
s
*
value
/
this
.
_localBoundsSelf
.
height
;
//
this.scale.y = s * value / this._localBoundsSelf.height;
this
.
_height
=
value
;
//
this._height = value;
}
//
}
/**
/**
* Process the holes data.
* Process the holes data.
...
...
src/2d/graphics/Shape.ts
View file @
d711ec43
...
@@ -27,7 +27,7 @@ export class Shape extends Sprite {
...
@@ -27,7 +27,7 @@ export class Shape extends Sprite {
constructor
()
{
constructor
()
{
super
();
super
();
this
.
_instanceType
=
"Shape
Node
"
;
this
.
_instanceType
=
"Shape"
;
var
canvas
=
document
.
createElement
(
'canvas'
);
var
canvas
=
document
.
createElement
(
'canvas'
);
canvas
.
width
=
3
;
canvas
.
width
=
3
;
canvas
.
height
=
3
;
canvas
.
height
=
3
;
...
...
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