sfml.js 0.0.1-preview.19 → 0.0.1-preview.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +0 -1
- package/lib/clock.d.ts +1 -1
- package/lib/color.d.ts +4 -2
- package/lib/drawable/circle_shape.d.ts +3 -1
- package/lib/drawable/circle_shape.js +1 -1
- package/lib/drawable/convex_shape.d.ts +3 -3
- package/lib/drawable/convex_shape.js +2 -2
- package/lib/drawable/drawable.d.ts +8 -0
- package/lib/drawable/{base.js → drawable.js} +7 -4
- package/lib/drawable/plugin_package.d.ts +31 -0
- package/lib/drawable/plugin_package.js +102 -0
- package/lib/drawable/rectangle_shape.d.ts +4 -2
- package/lib/drawable/shape.d.ts +10 -2
- package/lib/drawable/shape.js +15 -4
- package/lib/drawable/sprite.d.ts +8 -13
- package/lib/drawable/sprite.js +13 -29
- package/lib/drawable/text.d.ts +7 -5
- package/lib/drawable/text.js +17 -9
- package/lib/drawable/{common_drawable.d.ts → transformable.d.ts} +11 -16
- package/lib/drawable/transformable.js +94 -0
- package/lib/font.js +1 -1
- package/lib/keyboard.js +1 -1
- package/lib/mouse.d.ts +1 -1
- package/lib/mouse.js +1 -1
- package/lib/rect.d.ts +1 -1
- package/lib/rect.js +1 -1
- package/lib/render_window.d.ts +3 -3
- package/lib/render_window.js +3 -3
- package/lib/texture.js +2 -2
- package/lib/time.d.ts +1 -1
- package/lib/vector2.js +1 -1
- package/lib/video_mode.d.ts +1 -1
- package/package.json +2 -3
- package/src/clock.h +1 -1
- package/src/color.h +1 -1
- package/src/drawable/circle_shape.cc +2 -1
- package/src/drawable/convex_shape.cc +3 -2
- package/src/drawable/drawable.cc +25 -0
- package/src/drawable/drawable.h +15 -1
- package/src/drawable/package_plugin-inl.h +181 -0
- package/src/drawable/package_plugin.h +60 -0
- package/src/drawable/rectangle_shape.cc +3 -2
- package/src/drawable/shape.cc +18 -8
- package/src/drawable/shape.h +14 -2
- package/src/drawable/sprite.cc +18 -54
- package/src/drawable/sprite.h +11 -9
- package/src/drawable/text.cc +8 -5
- package/src/drawable/text.h +11 -2
- package/src/font.h +1 -1
- package/src/keyboard.h +5 -1
- package/src/mouse.h +5 -1
- package/src/plugins/transformable_plugin-inl.h +121 -0
- package/src/plugins/transformable_plugin.h +42 -0
- package/src/poll_event.h +2 -1
- package/src/rect.h +1 -0
- package/src/render_window.h +3 -1
- package/src/texture.h +2 -1
- package/src/time.h +2 -1
- package/src/utils.h +1 -0
- package/src/vector2.h +3 -1
- package/src/video_mode.h +2 -1
- package/lib/drawable/base.d.ts +0 -3
- package/lib/drawable/common_drawable.js +0 -116
- package/src/drawable/common_drawable-inl.h +0 -198
- package/src/drawable/common_drawable.cc +0 -14
- package/src/drawable/common_drawable.h +0 -78
package/binding.gyp
CHANGED
package/lib/clock.d.ts
CHANGED
package/lib/color.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
declare class Color {
|
|
2
2
|
constructor(color: number);
|
|
3
|
-
constructor(red: number, green: number, blue: number, alpha
|
|
3
|
+
constructor(red: number, green: number, blue: number, alpha?: number);
|
|
4
4
|
|
|
5
5
|
r: number;
|
|
6
6
|
g: number;
|
|
@@ -9,3 +9,5 @@ export = class Color {
|
|
|
9
9
|
|
|
10
10
|
toInteger(): number;
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
export = Color;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Shape from './shape';
|
|
2
|
-
import { Vector2F } from '../vector2';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
declare class CircleShape extends Shape {
|
|
5
4
|
constructor(pointCount?: number);
|
|
6
|
-
setPoint(idx: number, point: Vector2F): void;
|
|
7
5
|
}
|
|
6
|
+
|
|
7
|
+
export = CircleShape;
|
|
@@ -19,7 +19,7 @@ class ConvexShape extends Shape {
|
|
|
19
19
|
|
|
20
20
|
setPointCount(count) {
|
|
21
21
|
validateTypeOf(count, 'count', 'number');
|
|
22
|
-
this
|
|
22
|
+
this._raw().setPointCount(count);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
setPoint(idx, point) {
|
|
@@ -28,7 +28,7 @@ class ConvexShape extends Shape {
|
|
|
28
28
|
point = new Vector2F(point?.x, point?.y);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
this
|
|
31
|
+
this._raw().setPoint(idx, point);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -4,12 +4,15 @@ const binding = require('../../build/Release/binding.node');
|
|
|
4
4
|
|
|
5
5
|
const RAW = Symbol('BaseDrawable#raw');
|
|
6
6
|
|
|
7
|
-
class
|
|
7
|
+
class Drawable {
|
|
8
8
|
constructor(clzNameInBinding, ...args) {
|
|
9
9
|
this[RAW] = new (binding[clzNameInBinding])(...args);
|
|
10
10
|
}
|
|
11
|
-
}
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
// DO NOT USE THIS FUNCTION UNLESS YOU KNOW WHAT YOU ARE DOING!
|
|
13
|
+
_raw() {
|
|
14
|
+
return this[RAW];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
14
17
|
|
|
15
|
-
module.exports =
|
|
18
|
+
module.exports = Drawable;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as Color from '../color';
|
|
2
|
+
import { FloatRect } from '../rect';
|
|
3
|
+
import * as Texture from '../texture';
|
|
4
|
+
|
|
5
|
+
export interface PluginPackageTexture {
|
|
6
|
+
setTexture(texture: Texture): void;
|
|
7
|
+
getTexture(): Texture | null;
|
|
8
|
+
|
|
9
|
+
setTextureRect(rect: FloatRect): void;
|
|
10
|
+
getTextureRect(): FloatRect;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface PluginPackageBound {
|
|
14
|
+
getLocalBounds(): FloatRect;
|
|
15
|
+
getGlobalBounds(): FloatRect;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface PluginPackageColorAndThickness {
|
|
19
|
+
setFillColor(color: number | Color): void;
|
|
20
|
+
getFillColor(): Color;
|
|
21
|
+
|
|
22
|
+
setOutlineColor(color: number | Color): void;
|
|
23
|
+
getOutlineColor(): Color;
|
|
24
|
+
|
|
25
|
+
setOutlineThickness(thickness: number): void;
|
|
26
|
+
getOutlineThickness(): number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function setPluginPackageBound(proto: any): void;
|
|
30
|
+
export function setPluginPackageTexture(proto: any): void;
|
|
31
|
+
export function setPluginPackageColorAndThickness(proto: any): void;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Color = require('../color');
|
|
4
|
+
const { IntRect } = require('../rect');
|
|
5
|
+
const Texture = require('../texture');
|
|
6
|
+
const { validateTypeOf } = require('../common');
|
|
7
|
+
|
|
8
|
+
const TEXTURE = Symbol('PluginPackageTexture::texture');
|
|
9
|
+
|
|
10
|
+
function setPluginPackageTexture(proto) {
|
|
11
|
+
const ret = {
|
|
12
|
+
setTexture(texture) {
|
|
13
|
+
validateTypeOf(texture, 'texture', Texture);
|
|
14
|
+
this._raw().setTexture(texture);
|
|
15
|
+
this[TEXTURE] = texture;
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
getTexture() {
|
|
19
|
+
return this[TEXTURE] || null;
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
setTextureRect(rect) {
|
|
23
|
+
validateTypeOf(rect, 'rect', IntRect);
|
|
24
|
+
this._raw().setTextureRect(rect);
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
getTextureRect() {
|
|
28
|
+
return this._raw().getTextureRect();
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
for (const key in ret) {
|
|
33
|
+
if (!ret.hasOwnProperty(key)) continue;
|
|
34
|
+
proto[key] = ret[key];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
setPluginPackageTexture.TEXTURE = TEXTURE;
|
|
38
|
+
|
|
39
|
+
function setPluginPackageBound(proto) {
|
|
40
|
+
const ret = {
|
|
41
|
+
getLocalBounds() {
|
|
42
|
+
return this._raw().getLocalBounds();
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
getGlobalBounds() {
|
|
46
|
+
return this._raw().getGlobalBounds();
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
for (const key in ret) {
|
|
51
|
+
if (!ret.hasOwnProperty(key)) continue;
|
|
52
|
+
proto[key] = ret[key];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function setPluginPackageColorAndThickness(proto) {
|
|
57
|
+
const ret = {
|
|
58
|
+
setFillColor(color) {
|
|
59
|
+
if (!(color instanceof Color)) {
|
|
60
|
+
color = new Color(color);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
this._raw().setFillColor(color);
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
getFillColor() {
|
|
67
|
+
return this._raw().getFillColor();
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
setOutlineColor(color) {
|
|
71
|
+
if (!(color instanceof Color)) {
|
|
72
|
+
color = new Color(color);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
this._raw().setOutlineColor(color);
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
getOutlineColor() {
|
|
79
|
+
return this._raw().getOutlineColor();
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
setOutlineThickness(thickness) {
|
|
83
|
+
validateTypeOf(thickness, 'thickness', 'number');
|
|
84
|
+
this._raw().setOutlineThickness(thickness);
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
getOutlineThickness() {
|
|
88
|
+
return this._raw().getOutlineThickness();
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
for (const key in ret) {
|
|
93
|
+
if (!ret.hasOwnProperty(key)) continue;
|
|
94
|
+
proto[key] = ret[key];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
module.exports = {
|
|
99
|
+
setPluginPackageTexture,
|
|
100
|
+
setPluginPackageBound,
|
|
101
|
+
setPluginPackageColorAndThickness,
|
|
102
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as Shape from './shape';
|
|
2
|
-
import {
|
|
2
|
+
import { PointType, Vector2F } from '../vector2';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
declare class RectangleShape extends Shape {
|
|
5
5
|
constructor(size: PointType<Vector2F>);
|
|
6
6
|
}
|
|
7
|
+
|
|
8
|
+
export = RectangleShape;
|
package/lib/drawable/shape.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as Drawable from './drawable';
|
|
2
|
+
import { PluginPackageBound, PluginPackageColorAndThickness, PluginPackageTexture } from './plugin_package';
|
|
3
|
+
import { Transformable } from './transformable';
|
|
2
4
|
import { Vector2F } from '../vector2';
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
type ShapePluginPackage = Transformable & PluginPackageColorAndThickness & PluginPackageTexture & PluginPackageBound;
|
|
7
|
+
|
|
8
|
+
declare interface Shape extends ShapePluginPackage {}
|
|
9
|
+
declare class Shape extends Drawable {
|
|
5
10
|
setPointCount(count: number): void;
|
|
6
11
|
getPointCount(): number;
|
|
7
12
|
getPoint(idx: number): Vector2F;
|
|
13
|
+
setPoint(idx: number, point: Vector2F): void;
|
|
8
14
|
}
|
|
15
|
+
|
|
16
|
+
export = Shape;
|
package/lib/drawable/shape.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const Drawable = require('./drawable');
|
|
4
|
+
const {
|
|
5
|
+
setPluginPackageBound,
|
|
6
|
+
setPluginPackageColorAndThickness,
|
|
7
|
+
setPluginPackageTexture,
|
|
8
|
+
} = require('./plugin_package');
|
|
9
|
+
const { setTransformable } = require('./transformable');
|
|
4
10
|
|
|
5
|
-
class Shape extends
|
|
11
|
+
class Shape extends Drawable {
|
|
6
12
|
getPointCount() {
|
|
7
|
-
return this
|
|
13
|
+
return this._raw().getPointCount();
|
|
8
14
|
}
|
|
9
15
|
|
|
10
16
|
setPointCount() {
|
|
@@ -12,8 +18,13 @@ class Shape extends CommonDrawable {
|
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
getPoint(idx) {
|
|
15
|
-
return this
|
|
21
|
+
return this._raw().getPoint(idx);
|
|
16
22
|
}
|
|
17
23
|
}
|
|
18
24
|
|
|
25
|
+
setPluginPackageBound(Shape.prototype);
|
|
26
|
+
setPluginPackageColorAndThickness(Shape.prototype);
|
|
27
|
+
setPluginPackageTexture(Shape.prototype);
|
|
28
|
+
setTransformable(Shape.prototype);
|
|
29
|
+
|
|
19
30
|
module.exports = Shape;
|
package/lib/drawable/sprite.d.ts
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import * as Color from '../color';
|
|
2
|
-
import * as
|
|
3
|
-
import * as Texture from '../texture';
|
|
2
|
+
import * as Drawable from './drawable';
|
|
4
3
|
import { IntRect } from '../rect';
|
|
4
|
+
import { PluginPackageBound, PluginPackageTexture } from './plugin_package';
|
|
5
|
+
import * as Texture from '../texture';
|
|
6
|
+
import { Transformable } from './transformable';
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
constructor(texture?: Texture, rect?: IntRect);
|
|
8
|
-
|
|
9
|
-
setTexture(texture: Texture): void;
|
|
10
|
-
getTexture(): Texture;
|
|
11
|
-
|
|
12
|
-
setTextureRect(rect: IntRect): void;
|
|
13
|
-
getTextureRect(): IntRect;
|
|
8
|
+
type SpritePluginPackage = Transformable & PluginPackageTexture & PluginPackageBound;
|
|
14
9
|
|
|
10
|
+
declare interface Sprite extends SpritePluginPackage {}
|
|
11
|
+
declare class Sprite extends Drawable {
|
|
12
|
+
constructor(texture?: Texture, rect?: IntRect);
|
|
15
13
|
setColor(color: number | Color): void;
|
|
16
14
|
getColor(): Color;
|
|
17
|
-
|
|
18
|
-
setPoint: void;
|
|
19
|
-
setPointCount: void;
|
|
20
15
|
}
|
|
21
16
|
|
|
22
17
|
export = Sprite;
|
package/lib/drawable/sprite.js
CHANGED
|
@@ -1,64 +1,48 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const Color = require('../color');
|
|
4
|
-
const
|
|
4
|
+
const Drawable = require('./drawable');
|
|
5
5
|
const { IntRect } = require('../rect');
|
|
6
|
-
const {
|
|
6
|
+
const { setPluginPackageBound, setPluginPackageTexture } = require('./plugin_package');
|
|
7
|
+
const { setTransformable } = require('./transformable');
|
|
7
8
|
const Texture = require('../texture');
|
|
8
9
|
const { validateTypeOf } = require('../common');
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class Sprite extends CommonDrawable {
|
|
11
|
+
class Sprite extends Drawable {
|
|
13
12
|
constructor(texture, rectangle) {
|
|
14
13
|
if (arguments.length === 0) {
|
|
15
14
|
super('Sprite');
|
|
16
|
-
this[TEXTURE] = null;
|
|
15
|
+
this[setPluginPackageTexture.TEXTURE] = null;
|
|
17
16
|
} else if (arguments.length === 1) {
|
|
18
17
|
validateTypeOf(texture, 'texture', Texture);
|
|
19
18
|
super('Sprite', texture);
|
|
20
|
-
this[TEXTURE] = texture;
|
|
19
|
+
this[setPluginPackageTexture.TEXTURE] = texture;
|
|
21
20
|
} else {
|
|
22
21
|
validateTypeOf(texture, 'texture', Texture);
|
|
23
22
|
validateTypeOf(rectangle, 'rectangle', IntRect);
|
|
24
23
|
super('Sprite', texture, rectangle);
|
|
25
|
-
this[TEXTURE] = texture;
|
|
24
|
+
this[setPluginPackageTexture.TEXTURE] = texture;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
delete this.setPointCount;
|
|
29
28
|
delete this.setPoint;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
setTexture(texture) {
|
|
33
|
-
validateTypeOf(texture, 'texture', Texture);
|
|
34
|
-
this[RAW].setTexture(texture);
|
|
35
|
-
this[TEXTURE] = texture;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
getTexture() {
|
|
39
|
-
return this[RAW].getTexture();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
setTextureRect(rect) {
|
|
43
|
-
validateTypeOf(rect, 'rect', IntRect);
|
|
44
|
-
this[RAW].setTextureRect(rect);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
getTextureRect() {
|
|
48
|
-
return this[RAW].getTextureRect();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
31
|
setColor(color) {
|
|
52
32
|
if (!(color instanceof Color)) {
|
|
53
33
|
color = new Color(color);
|
|
54
34
|
}
|
|
55
35
|
|
|
56
|
-
this
|
|
36
|
+
this._raw().setColor(color);
|
|
57
37
|
}
|
|
58
38
|
|
|
59
39
|
getColor() {
|
|
60
|
-
return this
|
|
40
|
+
return this._raw().getColor();
|
|
61
41
|
}
|
|
62
42
|
}
|
|
63
43
|
|
|
44
|
+
setPluginPackageBound(Sprite.prototype);
|
|
45
|
+
setPluginPackageTexture(Sprite.prototype);
|
|
46
|
+
setTransformable(Sprite.prototype);
|
|
47
|
+
|
|
64
48
|
module.exports = Sprite;
|
package/lib/drawable/text.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as Drawable from './drawable';
|
|
2
|
+
import { PluginPackageBound, PluginPackageColorAndThickness } from './plugin_package';
|
|
3
|
+
import { Transformable } from './transformable';
|
|
2
4
|
import * as Font from '../font';
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
type TextPluginPackage = Transformable & PluginPackageColorAndThickness & PluginPackageBound;
|
|
7
|
+
|
|
8
|
+
declare interface Text extends TextPluginPackage {}
|
|
9
|
+
declare class Text extends Drawable implements PluginPackage {
|
|
5
10
|
constructor(str?: string, font?: Font, characterSize?: number = 30);
|
|
6
11
|
setString(str: string): void;
|
|
7
12
|
setFont(font: Font): void;
|
|
@@ -9,9 +14,6 @@ class Text extends CommonDrawable {
|
|
|
9
14
|
setLineSpacing(lineSpacing: number): void;
|
|
10
15
|
setLetterSpacing(letterSpacing: number): void;
|
|
11
16
|
setStyle(style: Text.Style): void;
|
|
12
|
-
|
|
13
|
-
setPoint: void;
|
|
14
|
-
setPointCount: void;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
declare namespace Text {
|
package/lib/drawable/text.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const Drawable = require('./drawable');
|
|
3
4
|
const Font = require('../font');
|
|
4
|
-
const
|
|
5
|
-
|
|
5
|
+
const {
|
|
6
|
+
setPluginPackageBound,
|
|
7
|
+
setPluginPackageColorAndThickness,
|
|
8
|
+
} = require('./plugin_package');
|
|
9
|
+
const { setTransformable } = require('./transformable');
|
|
6
10
|
const { validateTypeOf } = require('../common');
|
|
7
11
|
|
|
8
12
|
const FONT = Symbol('Text::font');
|
|
9
13
|
|
|
10
|
-
class Text extends
|
|
14
|
+
class Text extends Drawable {
|
|
11
15
|
constructor(string, font, characterSize = 30) {
|
|
12
16
|
if (string === undefined) {
|
|
13
17
|
super();
|
|
@@ -33,12 +37,12 @@ class Text extends CommonDrawable {
|
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
setString(str) {
|
|
36
|
-
this
|
|
40
|
+
this._raw().setString(`${str}`);
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
setFont(font) {
|
|
40
44
|
validateTypeOf(font, 'font', Font);
|
|
41
|
-
this
|
|
45
|
+
this._raw().setFont(font);
|
|
42
46
|
this[FONT] = font;
|
|
43
47
|
}
|
|
44
48
|
|
|
@@ -50,17 +54,17 @@ class Text extends CommonDrawable {
|
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
size = parseInt(size);
|
|
53
|
-
this
|
|
57
|
+
this._raw().setCharacterSize(size);
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
setLineSpacing(spacing) {
|
|
57
61
|
validateTypeOf(spacing, 'spacing', 'number');
|
|
58
|
-
this
|
|
62
|
+
this._raw().setLineSpacing(spacing);
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
setLetterSpacing(spacing) {
|
|
62
66
|
validateTypeOf(spacing, 'spacing', 'number');
|
|
63
|
-
this
|
|
67
|
+
this._raw().setLetterSpacing(spacing);
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
setStyle(style) {
|
|
@@ -71,10 +75,14 @@ class Text extends CommonDrawable {
|
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
style = parseInt(style);
|
|
74
|
-
this
|
|
78
|
+
this._raw().setStyle(style);
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
81
|
|
|
82
|
+
setPluginPackageBound(Text.prototype);
|
|
83
|
+
setPluginPackageColorAndThickness(Text.prototype);
|
|
84
|
+
setTransformable(Text.prototype);
|
|
85
|
+
|
|
78
86
|
Text.Style = require('../../build/Release/binding.node').Text.Style;
|
|
79
87
|
|
|
80
88
|
module.exports = Text;
|
|
@@ -1,21 +1,6 @@
|
|
|
1
|
-
import * as BaseDrawable from './base';
|
|
2
|
-
import * as Color from '../color';
|
|
3
|
-
import { FloatRect } from '../rect';
|
|
4
1
|
import { PointType, Vector2F } from '../vector2';
|
|
5
2
|
|
|
6
|
-
export
|
|
7
|
-
setFillColor(color: number | Color): void;
|
|
8
|
-
getFillColor(): Color;
|
|
9
|
-
|
|
10
|
-
setOutlineColor(color: number | Color): void;
|
|
11
|
-
getOutlineColor(): Color;
|
|
12
|
-
|
|
13
|
-
setOutlineThickness(thickness: number): void;
|
|
14
|
-
getOutlineThickness(): number;
|
|
15
|
-
|
|
16
|
-
getLocalBounds(): FloatRect;
|
|
17
|
-
getGlobalBounds(): FloatRect;
|
|
18
|
-
|
|
3
|
+
export interface Transformable {
|
|
19
4
|
setPosition(x: number, y: number): void;
|
|
20
5
|
setPosition(pos: PointType<Vector2F>): void;
|
|
21
6
|
getPosition(): Vector2F;
|
|
@@ -30,4 +15,14 @@ export = class CommonDrawable extends BaseDrawable {
|
|
|
30
15
|
setOrigin(x: number, y: number): void;
|
|
31
16
|
setOrigin(origin: PointType<Vector2F>): void;
|
|
32
17
|
getOrigin(): Vector2F;
|
|
18
|
+
|
|
19
|
+
move(x: number, y: number): void;
|
|
20
|
+
move(offset: PointType<Vector2F>): void;
|
|
21
|
+
|
|
22
|
+
scale(x: number, y: number): void;
|
|
23
|
+
scale(offset: PointType<Vector2F>): void;
|
|
24
|
+
|
|
25
|
+
rotate(angle: number): void;
|
|
33
26
|
}
|
|
27
|
+
|
|
28
|
+
export function setTransformable(proto: any): void;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { validateTypeOf } = require('../common');
|
|
4
|
+
const { Vector2F } = require('../vector2');
|
|
5
|
+
|
|
6
|
+
function setTransformable(proto) {
|
|
7
|
+
const ret = {
|
|
8
|
+
getPosition() {
|
|
9
|
+
return this._raw().getPosition();
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
setPosition(xOrPosition, y) {
|
|
13
|
+
if (arguments.length === 1) {
|
|
14
|
+
if (!(xOrPosition instanceof Vector2F)) {
|
|
15
|
+
xOrPosition = new Vector2F(xOrPosition?.x, xOrPosition?.y);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return this._raw().setPosition(xOrPosition);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
validateTypeOf(xOrPosition, 'x', 'number');
|
|
22
|
+
validateTypeOf(y, 'y', 'number');
|
|
23
|
+
return this._raw().setPosition(xOrPosition, y);
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
setRotation(rotation) {
|
|
27
|
+
validateTypeOf(rotation, 'rotation', 'number');
|
|
28
|
+
this._raw().setRotation(rotation);
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
getRotation() {
|
|
32
|
+
return this._raw().getRotation();
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
getScale() {
|
|
36
|
+
return this._raw().getScale();
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
setScale(xOrFactor, y) {
|
|
40
|
+
if (arguments.length === 1) {
|
|
41
|
+
if (!(xOrFactor instanceof Vector2F)) {
|
|
42
|
+
xOrFactor = new Vector2F(xOrFactor?.x, xOrFactor?.y);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return this._raw().setScale(xOrFactor);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
validateTypeOf(xOrFactor, 'x', 'number');
|
|
49
|
+
validateTypeOf(y, 'y', 'number');
|
|
50
|
+
return this._raw().setScale(xOrFactor, y);
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
getOrigin() {
|
|
54
|
+
return this._raw().getOrigin();
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
setOrigin(xOrOrigin, y) {
|
|
58
|
+
if (arguments.length === 1) {
|
|
59
|
+
if (!(xOrOrigin instanceof Vector2F)) {
|
|
60
|
+
xOrOrigin = new Vector2F(xOrOrigin?.x, xOrOrigin?.y);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return this._raw().setScale(xOrOrigin);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
validateTypeOf(xOrOrigin, 'x', 'number');
|
|
67
|
+
validateTypeOf(y, 'y', 'number');
|
|
68
|
+
return this._raw().setScale(xOrOrigin, y);
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
move(xOrOffset, y) {
|
|
72
|
+
if (arguments.length === 1) {
|
|
73
|
+
if (!(xOrOffset instanceof Vector2F)) {
|
|
74
|
+
xOrOffset = new Vector2F(xOrOffset?.x, xOrOffset?.y);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return this._raw().move(xOrOffset);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
validateTypeOf(xOrOffset, 'x', 'number');
|
|
81
|
+
validateTypeOf(y, 'y', 'number');
|
|
82
|
+
return this._raw().move(xOrOffset, y);
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
for (const key in ret) {
|
|
87
|
+
if (!ret.hasOwnProperty(key)) continue;
|
|
88
|
+
proto[key] = ret[key];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports = {
|
|
93
|
+
setTransformable,
|
|
94
|
+
};
|
package/lib/font.js
CHANGED
package/lib/keyboard.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {
|
|
4
|
-
setVirtualKeyboardVisible: _setVirtualKeyboardVisible,
|
|
5
4
|
isKeyPressed: _isKeyPressed,
|
|
5
|
+
setVirtualKeyboardVisible: _setVirtualKeyboardVisible,
|
|
6
6
|
} = require('../build/Release/binding.node');
|
|
7
7
|
|
|
8
8
|
exports.setVirtualKeyboardVisible = function setVirtualKeyboardVisible(visible) {
|
package/lib/mouse.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as RenderWindow from './render_window';
|
|
2
1
|
import { PointType, Vector2I } from './vector2';
|
|
2
|
+
import * as RenderWindow from './render_window';
|
|
3
3
|
|
|
4
4
|
export function isButtonPressed(button: number | string): boolean;
|
|
5
5
|
export function getPosition(window?: RenderWindow): Vector2I;
|