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
Show 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
{
Rectangle
}
from
"../math/Rectangle"
;
import
{
Point
}
from
'../math'
;
import
{
DisplayObject
}
from
'./DisplayObject'
;
import
{
Rectangle
}
from
"../math/Rectangle"
;
import
{
Point
}
from
'../math'
;
import
CanvasRenderer
from
'../renderers/CanvasRenderer'
;
import
{
Event
}
from
"../events/Event"
import
{
WebglRenderer
}
from
'../renderers/WebglRenderer'
;
import
{
Event
}
from
"../events/Event"
import
{
WebglRenderer
}
from
'../renderers/WebglRenderer'
;
/**
* 容器类
...
...
@@ -538,17 +538,17 @@ export default class Container extends DisplayObject {
* @member {number}
*/
get
width
()
{
return
this
.
scale
.
x
*
this
.
getLocalBounds
().
width
;
return
this
.
_width
||
this
.
scale
.
x
*
this
.
getLocalBounds
().
width
;
}
set
width
(
value
)
{
const
width
=
this
.
getLocalBounds
().
width
;
//
const width = this.getLocalBounds().width;
if
(
width
!==
0
)
{
this
.
scale
.
x
=
value
/
width
;
}
else
{
this
.
scale
.
x
=
1
;
}
//
if (width !== 0) {
//
this.scale.x = value / width;
//
} else {
//
this.scale.x = 1;
//
}
//子类有用,有_width,才需设置scaleX
this
.
_width
=
value
}
...
...
@@ -558,17 +558,17 @@ export default class Container extends DisplayObject {
* @member {number}
*/
get
height
()
{
return
this
.
scale
.
y
*
this
.
getLocalBounds
().
height
;
return
this
.
_height
||
this
.
scale
.
y
*
this
.
getLocalBounds
().
height
;
}
set
height
(
value
)
{
const
height
=
this
.
getLocalBounds
().
height
;
//
const height = this.getLocalBounds().height;
if
(
height
!==
0
)
{
this
.
scale
.
y
=
value
/
height
;
}
else
{
this
.
scale
.
y
=
1
;
}
//
if (height !== 0) {
//
this.scale.y = value / height;
//
} else {
//
this.scale.y = 1;
//
}
this
.
_height
=
value
}
...
...
src/2d/display/Sprite.ts
View file @
d711ec43
...
...
@@ -122,15 +122,14 @@ export default class Sprite extends Container {
this
.
_textureTrimmedID
=
-
1
;
//可用才赋值uv
if
(
this
.
_texture
.
valid
)
this
.
uvs
=
this
.
_texture
.
_uvs
.
uvsFloat32
;
//设置过宽高的话,就需要改变缩放值
// so if _width is 0 then width was not set..
if
(
this
.
_width
)
{
this
.
scale
.
x
=
sign
(
this
.
scale
.
x
)
*
this
.
_width
/
this
.
_texture
.
orig
.
width
;
}
//设置过宽高的话,就需要改变缩放值,废弃先
// if (this._width) {
// this.scale.x = sign(this.scale.x) * this._width / this._texture.orig.width;
// }
if
(
this
.
_height
)
{
this
.
scale
.
y
=
sign
(
this
.
scale
.
y
)
*
this
.
_height
/
this
.
_texture
.
orig
.
height
;
}
//
if (this._height) {
//
this.scale.y = sign(this.scale.y) * this._height / this._texture.orig.height;
//
}
//修改_localBoundsSelf
const
width
=
this
.
_texture
.
orig
.
width
;
...
...
@@ -369,34 +368,34 @@ export default class Sprite extends Container {
}
/**
* 重写Container父类
* 重写Container父类
,废弃先
* texture的宽度和缩放乘积
* @member {number}
*/
get
width
()
{
return
Math
.
abs
(
this
.
scale
.
x
)
*
this
.
_texture
.
orig
.
width
;
}
//
get width() {
//
return Math.abs(this.scale.x) * this._texture.orig.width;
//
}
set
width
(
value
)
{
const
s
=
sign
(
this
.
scale
.
x
)
||
1
;
//
set width(value) {
//
const s = sign(this.scale.x) || 1;
this
.
scale
.
x
=
s
*
value
/
this
.
_texture
.
orig
.
width
;
this
.
_width
=
value
;
}
//
this.scale.x = s * value / this._texture.orig.width;
//
this._width = value;
//
}
/**
* texture的高度和缩放乘积
* @member {number}
*/
get
height
()
{
return
Math
.
abs
(
this
.
scale
.
y
)
*
this
.
_texture
.
orig
.
height
;
}
set
height
(
value
)
{
const
s
=
sign
(
this
.
scale
.
y
)
||
1
;
this
.
scale
.
y
=
s
*
value
/
this
.
_texture
.
orig
.
height
;
this
.
_height
=
value
;
}
//
get height() {
//
return Math.abs(this.scale.y) * this._texture.orig.height;
//
}
//
set height(value) {
//
const s = sign(this.scale.y) || 1;
//
this.scale.y = s * value / this._texture.orig.height;
//
this._height = value;
//
}
/**
* 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 {
/**
*
The width of the sprite, setting this will actually modify the scale to achieve the value set
*
废弃先
* @member {number}
*/
get
width
()
{
this
.
updateLocalBoundsSelf
()
return
Math
.
abs
(
this
.
scale
.
x
)
*
this
.
_localBoundsSelf
.
width
;
}
//
get width() {
//
this.updateLocalBoundsSelf()
//
return Math.abs(this.scale.x) * this._localBoundsSelf.width;
//
}
set
width
(
value
)
{
const
s
=
sign
(
this
.
scale
.
x
)
||
1
;
//
set width(value) {
//
const s = sign(this.scale.x) || 1;
this
.
scale
.
x
=
s
*
value
/
this
.
_localBoundsSelf
.
width
;
this
.
_width
=
value
;
}
//
this.scale.x = s * value / this._localBoundsSelf.width;
//
this._width = value;
//
}
/**
* The height of the sprite, setting this will actually modify the scale to achieve the value set
*
* @member {number}
*/
get
height
()
{
this
.
updateLocalBoundsSelf
()
return
Math
.
abs
(
this
.
scale
.
y
)
*
this
.
_localBoundsSelf
.
height
;
}
set
height
(
value
)
{
const
s
=
sign
(
this
.
scale
.
y
)
||
1
;
this
.
scale
.
y
=
s
*
value
/
this
.
_localBoundsSelf
.
height
;
this
.
_height
=
value
;
}
//
get height() {
//
this.updateLocalBoundsSelf()
//
return Math.abs(this.scale.y) * this._localBoundsSelf.height;
//
}
//
set height(value) {
//
const s = sign(this.scale.y) || 1;
//
this.scale.y = s * value / this._localBoundsSelf.height;
//
this._height = value;
//
}
/**
* Process the holes data.
...
...
src/2d/graphics/Shape.ts
View file @
d711ec43
...
...
@@ -27,7 +27,7 @@ export class Shape extends Sprite {
constructor
()
{
super
();
this
.
_instanceType
=
"Shape
Node
"
;
this
.
_instanceType
=
"Shape"
;
var
canvas
=
document
.
createElement
(
'canvas'
);
canvas
.
width
=
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