@egret/runtime 0.0.0-stage → 7.0.1-rc.3
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/LICENSE +201 -0
- package/NOTICE +21 -0
- package/README.md +70 -2
- package/README.zh-CN.md +71 -0
- package/dist/AssetLease.d.ts +23 -0
- package/dist/AssetLease.js +69 -0
- package/dist/AssetManager.d.ts +56 -0
- package/dist/AssetManager.js +451 -0
- package/dist/AssetRef.d.ts +20 -0
- package/dist/AssetRef.js +32 -0
- package/dist/Bitmap.d.ts +40 -0
- package/dist/Bitmap.js +545 -0
- package/dist/ByteReader.d.ts +30 -0
- package/dist/ByteReader.js +177 -0
- package/dist/ByteWriter.d.ts +29 -0
- package/dist/ByteWriter.js +180 -0
- package/dist/CancellationController.d.ts +10 -0
- package/dist/CancellationController.js +66 -0
- package/dist/DisplayObject.d.ts +89 -0
- package/dist/DisplayObject.js +340 -0
- package/dist/DisplayObjectContainer.d.ts +28 -0
- package/dist/DisplayObjectContainer.js +226 -0
- package/dist/EgretError.d.ts +11 -0
- package/dist/EgretError.js +36 -0
- package/dist/Event.d.ts +45 -0
- package/dist/Event.js +84 -0
- package/dist/EventDispatcher.d.ts +24 -0
- package/dist/EventDispatcher.js +178 -0
- package/dist/Graphics.d.ts +106 -0
- package/dist/Graphics.js +504 -0
- package/dist/Mesh2D.d.ts +27 -0
- package/dist/Mesh2D.js +200 -0
- package/dist/NineSliceBitmap.d.ts +24 -0
- package/dist/NineSliceBitmap.js +164 -0
- package/dist/NineSliceGeometry2D.d.ts +18 -0
- package/dist/NineSliceGeometry2D.js +126 -0
- package/dist/Scope.d.ts +18 -0
- package/dist/Scope.js +133 -0
- package/dist/SequencePlayer.d.ts +12 -0
- package/dist/SequencePlayer.js +69 -0
- package/dist/Sprite.d.ts +8 -0
- package/dist/Sprite.js +12 -0
- package/dist/Stage.d.ts +14 -0
- package/dist/Stage.js +31 -0
- package/dist/Texture.d.ts +29 -0
- package/dist/Texture.js +177 -0
- package/dist/assetManagerOwnerState.d.ts +36 -0
- package/dist/assetManagerOwnerState.js +115 -0
- package/dist/assetState.d.ts +44 -0
- package/dist/assetState.js +2 -0
- package/dist/atlasFrameLayout.d.ts +21 -0
- package/dist/atlasFrameLayout.js +48 -0
- package/dist/bitmapDisplayState.d.ts +24 -0
- package/dist/bitmapDisplayState.js +22 -0
- package/dist/coordinateInverse.d.ts +4 -0
- package/dist/coordinateInverse.js +107 -0
- package/dist/diagnostics.d.ts +4 -0
- package/dist/diagnostics.js +13 -0
- package/dist/displayBounds.d.ts +9 -0
- package/dist/displayBounds.js +181 -0
- package/dist/displayCoordinates.d.ts +8 -0
- package/dist/displayCoordinates.js +81 -0
- package/dist/displayHitState.d.ts +18 -0
- package/dist/displayHitState.js +97 -0
- package/dist/displayHitTest.d.ts +8 -0
- package/dist/displayHitTest.js +219 -0
- package/dist/displayInputOperations.d.ts +12 -0
- package/dist/displayInputOperations.js +71 -0
- package/dist/displayTransform.d.ts +5 -0
- package/dist/displayTransform.js +38 -0
- package/dist/displayTreeState.d.ts +90 -0
- package/dist/displayTreeState.js +450 -0
- package/dist/displayVisualState.d.ts +74 -0
- package/dist/displayVisualState.js +140 -0
- package/dist/errorHelp.d.ts +14 -0
- package/dist/errorHelp.js +432 -0
- package/dist/errorHelpZh.d.ts +5 -0
- package/dist/errorHelpZh.js +340 -0
- package/dist/graphicsFill.d.ts +37 -0
- package/dist/graphicsFill.js +302 -0
- package/dist/graphicsShape.d.ts +144 -0
- package/dist/graphicsShape.js +755 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +28 -0
- package/dist/input/PointerRouter.d.ts +4 -0
- package/dist/input/PointerRouter.js +453 -0
- package/dist/input/index.d.ts +3 -0
- package/dist/input/index.js +3 -0
- package/dist/input/types.d.ts +58 -0
- package/dist/input/types.js +3 -0
- package/dist/meshCaptureSnapshot.d.ts +5 -0
- package/dist/meshCaptureSnapshot.js +13 -0
- package/dist/meshDisplayState.d.ts +18 -0
- package/dist/meshDisplayState.js +21 -0
- package/dist/ownership.d.ts +75 -0
- package/dist/ownership.js +157 -0
- package/dist/paragraph/Paragraph.d.ts +13 -0
- package/dist/paragraph/Paragraph.js +193 -0
- package/dist/paragraph/ParagraphCache.d.ts +5 -0
- package/dist/paragraph/ParagraphCache.js +354 -0
- package/dist/paragraph/geometry.d.ts +4 -0
- package/dist/paragraph/geometry.js +180 -0
- package/dist/paragraph/index.d.ts +3 -0
- package/dist/paragraph/index.js +3 -0
- package/dist/paragraph/request.d.ts +6 -0
- package/dist/paragraph/request.js +191 -0
- package/dist/paragraph/types.d.ts +183 -0
- package/dist/paragraph/types.js +2 -0
- package/dist/preparedDisplaySubtree.d.ts +7 -0
- package/dist/preparedDisplaySubtree.js +205 -0
- package/dist/renderEffect.d.ts +47 -0
- package/dist/renderEffect.js +87 -0
- package/dist/sequenceClip.d.ts +42 -0
- package/dist/sequenceClip.js +196 -0
- package/dist/sharedFrameCapture.d.ts +24 -0
- package/dist/sharedFrameCapture.js +1069 -0
- package/dist/spriteSheet.d.ts +34 -0
- package/dist/spriteSheet.js +321 -0
- package/dist/srgbBytes.d.ts +3 -0
- package/dist/srgbBytes.js +64 -0
- package/dist/text/TextField.d.ts +13 -0
- package/dist/text/TextField.js +261 -0
- package/dist/text/TextRasterCache.d.ts +5 -0
- package/dist/text/TextRasterCache.js +1191 -0
- package/dist/text/budget.d.ts +51 -0
- package/dist/text/budget.js +116 -0
- package/dist/text/index.d.ts +4 -0
- package/dist/text/index.js +3 -0
- package/dist/text/plan.d.ts +16 -0
- package/dist/text/plan.js +238 -0
- package/dist/text/request.d.ts +44 -0
- package/dist/text/request.js +303 -0
- package/dist/text/types.d.ts +179 -0
- package/dist/text/types.js +2 -0
- package/dist/textDisplayState.d.ts +21 -0
- package/dist/textDisplayState.js +27 -0
- package/dist/ui/displayCommit.d.ts +43 -0
- package/dist/ui/displayCommit.js +376 -0
- package/dist/ui/editing.d.ts +3 -0
- package/dist/ui/editing.js +3 -0
- package/dist/ui/heightIndex.d.ts +35 -0
- package/dist/ui/heightIndex.js +295 -0
- package/dist/ui/index.d.ts +6 -0
- package/dist/ui/index.js +6 -0
- package/dist/ui/layout.d.ts +9 -0
- package/dist/ui/layout.js +349 -0
- package/dist/ui/managedState.d.ts +12 -0
- package/dist/ui/managedState.js +44 -0
- package/dist/ui/textEditState.d.ts +4 -0
- package/dist/ui/textEditState.js +206 -0
- package/dist/ui/textEditTypes.d.ts +48 -0
- package/dist/ui/textEditTypes.js +2 -0
- package/dist/ui/types.d.ts +99 -0
- package/dist/ui/types.js +2 -0
- package/package.json +44 -4
package/dist/Event.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { EgretError } from "./EgretError.js";
|
|
2
|
+
/** Matching uses descriptor object identity; equal key strings do not alias types. */
|
|
3
|
+
export function createEventType(key, options = {}) {
|
|
4
|
+
return Object.freeze({ key, bubbles: options.bubbles ?? false, cancelable: options.cancelable ?? false });
|
|
5
|
+
}
|
|
6
|
+
const states = new WeakMap();
|
|
7
|
+
function stateOf(event) {
|
|
8
|
+
const state = states.get(event);
|
|
9
|
+
if (state === undefined)
|
|
10
|
+
throw new EgretError("INVALID_EVENT");
|
|
11
|
+
return state;
|
|
12
|
+
}
|
|
13
|
+
/** One typed payload with synchronous dispatch state; concurrent reuse is rejected. */
|
|
14
|
+
export class Event {
|
|
15
|
+
type;
|
|
16
|
+
payload;
|
|
17
|
+
constructor(type, payload) {
|
|
18
|
+
this.type = type;
|
|
19
|
+
this.payload = payload;
|
|
20
|
+
states.set(this, {
|
|
21
|
+
active: false,
|
|
22
|
+
stopped: false,
|
|
23
|
+
immediate: false,
|
|
24
|
+
prevented: false,
|
|
25
|
+
target: undefined,
|
|
26
|
+
currentTarget: undefined,
|
|
27
|
+
phase: undefined
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
get target() {
|
|
31
|
+
return stateOf(this).target;
|
|
32
|
+
}
|
|
33
|
+
get currentTarget() {
|
|
34
|
+
return stateOf(this).currentTarget;
|
|
35
|
+
}
|
|
36
|
+
get eventPhase() {
|
|
37
|
+
return stateOf(this).phase;
|
|
38
|
+
}
|
|
39
|
+
get defaultPrevented() {
|
|
40
|
+
return stateOf(this).prevented;
|
|
41
|
+
}
|
|
42
|
+
stopPropagation() {
|
|
43
|
+
const state = stateOf(this);
|
|
44
|
+
if (state.active)
|
|
45
|
+
state.stopped = true;
|
|
46
|
+
}
|
|
47
|
+
stopImmediatePropagation() {
|
|
48
|
+
const state = stateOf(this);
|
|
49
|
+
if (!state.active)
|
|
50
|
+
return;
|
|
51
|
+
state.stopped = true;
|
|
52
|
+
state.immediate = true;
|
|
53
|
+
}
|
|
54
|
+
preventDefault() {
|
|
55
|
+
const state = stateOf(this);
|
|
56
|
+
if (state.active && this.type.cancelable)
|
|
57
|
+
state.prevented = true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Package-internal state operations, omitted from @egret/engine exports. */
|
|
61
|
+
export function beginDispatch(event, target) {
|
|
62
|
+
const state = stateOf(event);
|
|
63
|
+
if (state.active)
|
|
64
|
+
throw new EgretError("EVENT_ACTIVE");
|
|
65
|
+
state.active = true;
|
|
66
|
+
state.stopped = false;
|
|
67
|
+
state.immediate = false;
|
|
68
|
+
state.prevented = false;
|
|
69
|
+
state.target = target;
|
|
70
|
+
return state;
|
|
71
|
+
}
|
|
72
|
+
export function visitDispatch(event, current, phase) {
|
|
73
|
+
const state = stateOf(event);
|
|
74
|
+
state.currentTarget = current;
|
|
75
|
+
state.phase = phase;
|
|
76
|
+
}
|
|
77
|
+
/** Keep target/defaultPrevented for inspection; clear transient dispatch pointers. */
|
|
78
|
+
export function endDispatch(event) {
|
|
79
|
+
const state = stateOf(event);
|
|
80
|
+
state.active = false;
|
|
81
|
+
state.currentTarget = undefined;
|
|
82
|
+
state.phase = undefined;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=Event.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CancellationSignal } from "@egret/contracts";
|
|
2
|
+
import { Event } from "./Event.js";
|
|
3
|
+
import type { EventType } from "./Event.js";
|
|
4
|
+
export interface EventListenerOptions {
|
|
5
|
+
readonly signal?: CancellationSignal;
|
|
6
|
+
readonly capture?: boolean;
|
|
7
|
+
readonly once?: boolean;
|
|
8
|
+
readonly priority?: number;
|
|
9
|
+
}
|
|
10
|
+
/** Internal caller has admitted this complete route through private display state. */
|
|
11
|
+
export declare function dispatchDisplayInputEvent<T>(target: EventDispatcher, event: Event<T>, ancestors: readonly EventDispatcher[]): boolean;
|
|
12
|
+
/** Synchronous typed listeners with a frozen route and per-dispatch candidates. */
|
|
13
|
+
export declare class EventDispatcher {
|
|
14
|
+
constructor();
|
|
15
|
+
protected assertUsable(): void;
|
|
16
|
+
protected eventParent(): EventDispatcher | undefined;
|
|
17
|
+
/** Async handlers are excluded by types and rejected if returned at runtime. */
|
|
18
|
+
on<T, H extends (event: Event<T>) => unknown>(type: EventType<T>, handler: H & (Extract<ReturnType<H>, PromiseLike<unknown>> extends never ? unknown : never), options?: EventListenerOptions): () => void;
|
|
19
|
+
private candidates;
|
|
20
|
+
/** Ordinary public dispatch retains subclass preflight and route hooks. */
|
|
21
|
+
dispatchEvent<T>(event: Event<T>): boolean;
|
|
22
|
+
protected clearListeners(): void;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=EventDispatcher.d.ts.map
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { EgretError } from "./EgretError.js";
|
|
2
|
+
import { Event, beginDispatch, endDispatch, visitDispatch } from "./Event.js";
|
|
3
|
+
import { engineOf } from "./ownership.js";
|
|
4
|
+
import { assertLive, isDisplayNode } from "./displayTreeState.js";
|
|
5
|
+
// Input dispatch never establishes listener authority through instance fields.
|
|
6
|
+
const dispatcherStates = new WeakMap();
|
|
7
|
+
function stateOf(dispatcher) {
|
|
8
|
+
const state = dispatcherStates.get(dispatcher);
|
|
9
|
+
if (state === undefined)
|
|
10
|
+
throw new EgretError("INVALID_EVENT_DISPATCHER");
|
|
11
|
+
return state;
|
|
12
|
+
}
|
|
13
|
+
function candidatesOf(dispatcher, type, capture) {
|
|
14
|
+
return [...stateOf(dispatcher).subscriptions]
|
|
15
|
+
.filter(entry => entry.type === type && entry.capture === capture)
|
|
16
|
+
.sort((a, b) => b.priority - a.priority || a.sequence - b.sequence);
|
|
17
|
+
}
|
|
18
|
+
function isCancelled(signal) {
|
|
19
|
+
return signal?.aborted === true;
|
|
20
|
+
}
|
|
21
|
+
/** Both routes share ordering, active flags and genuine Event dispatch state. */
|
|
22
|
+
function executeDispatch(target, event, route, select) {
|
|
23
|
+
const state = beginDispatch(event, target);
|
|
24
|
+
try {
|
|
25
|
+
const ancestors = route();
|
|
26
|
+
const visits = [];
|
|
27
|
+
for (let index = ancestors.length - 1; index >= 0; index--) {
|
|
28
|
+
const node = ancestors[index];
|
|
29
|
+
if (node !== undefined)
|
|
30
|
+
visits.push({ node, phase: "capturing", candidates: select(node, event.type, true) });
|
|
31
|
+
}
|
|
32
|
+
// Target groups share one visit so stopPropagation preserves both groups.
|
|
33
|
+
visits.push({
|
|
34
|
+
node: target,
|
|
35
|
+
phase: "atTarget",
|
|
36
|
+
candidates: [...select(target, event.type, true), ...select(target, event.type, false)]
|
|
37
|
+
});
|
|
38
|
+
if (event.type.bubbles) {
|
|
39
|
+
for (const node of ancestors)
|
|
40
|
+
visits.push({ node, phase: "bubbling", candidates: select(node, event.type, false) });
|
|
41
|
+
}
|
|
42
|
+
for (const visit of visits) {
|
|
43
|
+
visitDispatch(event, visit.node, visit.phase);
|
|
44
|
+
for (const candidate of visit.candidates) {
|
|
45
|
+
if (state.immediate)
|
|
46
|
+
break;
|
|
47
|
+
if (!candidate.active)
|
|
48
|
+
continue;
|
|
49
|
+
// Remove once-listeners before invocation to prevent reentrant duplicates.
|
|
50
|
+
if (candidate.once)
|
|
51
|
+
candidate.unsubscribe();
|
|
52
|
+
const returned = candidate.invoke(event);
|
|
53
|
+
if (returned !== null &&
|
|
54
|
+
(typeof returned === "object" || typeof returned === "function") &&
|
|
55
|
+
"then" in returned &&
|
|
56
|
+
typeof returned.then === "function") {
|
|
57
|
+
// Invalid asynchronous handlers must not create an unhandled rejection.
|
|
58
|
+
void Promise.resolve(returned).catch((cause) => {
|
|
59
|
+
engineOf(target)?.report({
|
|
60
|
+
code: "ASYNC_EVENT_HANDLER_REJECTED",
|
|
61
|
+
phase: "engine",
|
|
62
|
+
severity: "error",
|
|
63
|
+
cause
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
throw new EgretError("ASYNC_EVENT_HANDLER");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (state.stopped)
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
return !state.prevented;
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
endDispatch(event);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** Internal caller has admitted this complete route through private display state. */
|
|
79
|
+
export function dispatchDisplayInputEvent(target, event, ancestors) {
|
|
80
|
+
return executeDispatch(target, event, () => ancestors, candidatesOf);
|
|
81
|
+
}
|
|
82
|
+
/** Synchronous typed listeners with a frozen route and per-dispatch candidates. */
|
|
83
|
+
export class EventDispatcher {
|
|
84
|
+
constructor() {
|
|
85
|
+
dispatcherStates.set(this, { subscriptions: new Set(), nextSequence: 0 });
|
|
86
|
+
}
|
|
87
|
+
assertUsable() { }
|
|
88
|
+
eventParent() {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
/** Async handlers are excluded by types and rejected if returned at runtime. */
|
|
92
|
+
on(type, handler, options = {}) {
|
|
93
|
+
this.assertUsable();
|
|
94
|
+
const priority = options.priority ?? 0;
|
|
95
|
+
if (!Number.isFinite(priority) || !Number.isInteger(priority))
|
|
96
|
+
throw new EgretError("INVALID_PRIORITY");
|
|
97
|
+
const signal = options.signal;
|
|
98
|
+
if (isCancelled(signal))
|
|
99
|
+
return () => { };
|
|
100
|
+
const state = stateOf(this);
|
|
101
|
+
const subscription = {
|
|
102
|
+
type,
|
|
103
|
+
// Descriptor identity is checked before invoking this erased closure.
|
|
104
|
+
invoke: (event) => handler(event),
|
|
105
|
+
capture: options.capture ?? false,
|
|
106
|
+
once: options.once ?? false,
|
|
107
|
+
priority,
|
|
108
|
+
sequence: state.nextSequence++,
|
|
109
|
+
active: true,
|
|
110
|
+
unsubscribe: () => {
|
|
111
|
+
if (!subscription.active)
|
|
112
|
+
return;
|
|
113
|
+
subscription.active = false;
|
|
114
|
+
state.subscriptions.delete(subscription);
|
|
115
|
+
signal?.removeEventListener("abort", subscription.unsubscribe);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
if (isDisplayNode(this))
|
|
119
|
+
assertLive(this);
|
|
120
|
+
state.subscriptions.add(subscription);
|
|
121
|
+
try {
|
|
122
|
+
signal?.addEventListener("abort", subscription.unsubscribe, { once: true });
|
|
123
|
+
// Covers adapters whose cancellation occurs while registering.
|
|
124
|
+
if (isCancelled(signal))
|
|
125
|
+
subscription.unsubscribe();
|
|
126
|
+
if (isDisplayNode(this))
|
|
127
|
+
assertLive(this);
|
|
128
|
+
}
|
|
129
|
+
catch (cause) {
|
|
130
|
+
// Local rollback has no adapter callbacks: the handler becomes unreachable
|
|
131
|
+
// before attempting a possibly failing physical abort-listener removal.
|
|
132
|
+
subscription.active = false;
|
|
133
|
+
state.subscriptions.delete(subscription);
|
|
134
|
+
const cleanupErrors = [];
|
|
135
|
+
try {
|
|
136
|
+
signal?.removeEventListener("abort", subscription.unsubscribe);
|
|
137
|
+
}
|
|
138
|
+
catch (rollbackCause) {
|
|
139
|
+
cleanupErrors.push(rollbackCause);
|
|
140
|
+
}
|
|
141
|
+
throw new EgretError("EVENT_SUBSCRIPTION_FAILED", { cause, cleanupErrors });
|
|
142
|
+
}
|
|
143
|
+
return subscription.unsubscribe;
|
|
144
|
+
}
|
|
145
|
+
candidates(type, capture) {
|
|
146
|
+
return candidatesOf(this, type, capture);
|
|
147
|
+
}
|
|
148
|
+
/** Ordinary public dispatch retains subclass preflight and route hooks. */
|
|
149
|
+
dispatchEvent(event) {
|
|
150
|
+
this.assertUsable();
|
|
151
|
+
return executeDispatch(this, event, () => {
|
|
152
|
+
const ancestors = [];
|
|
153
|
+
for (let parent = this.eventParent(); parent !== undefined; parent = parent.eventParent())
|
|
154
|
+
ancestors.push(parent);
|
|
155
|
+
return ancestors;
|
|
156
|
+
}, (node, type, capture) => node.candidates(type, capture));
|
|
157
|
+
}
|
|
158
|
+
clearListeners() {
|
|
159
|
+
const failures = [];
|
|
160
|
+
const engine = engineOf(this);
|
|
161
|
+
for (const subscription of [...stateOf(this).subscriptions]) {
|
|
162
|
+
try {
|
|
163
|
+
subscription.unsubscribe();
|
|
164
|
+
}
|
|
165
|
+
catch (cause) {
|
|
166
|
+
if (engine === undefined)
|
|
167
|
+
failures.push(cause);
|
|
168
|
+
else {
|
|
169
|
+
engine.captureCleanup(cause);
|
|
170
|
+
engine.report({ code: "EVENT_LISTENER_CLEANUP_FAILED", phase: "display-tree", severity: "error", cause });
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (failures.length !== 0)
|
|
175
|
+
throw new EgretError("EVENT_LISTENER_CLEANUP_FAILED", { cause: failures[0], cleanupErrors: failures.slice(1) });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=EventDispatcher.js.map
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { DisplayObject } from "./DisplayObject.js";
|
|
2
|
+
import type { AssetLease } from "./AssetLease.js";
|
|
3
|
+
import type { Texture } from "./Texture.js";
|
|
4
|
+
import type { LineCaps, LineJoints } from "./graphicsShape.js";
|
|
5
|
+
/** How a line's ends and corners are drawn, and its dashes. */
|
|
6
|
+
export interface LineStyleOptions {
|
|
7
|
+
/** The ends of an open line: flat at the point ("none", as before), a half circle, or a half square. */
|
|
8
|
+
readonly caps?: LineCaps;
|
|
9
|
+
/** The outside of a corner: a point ("miter", as before), an arc, or a flat cut. */
|
|
10
|
+
readonly joints?: LineJoints;
|
|
11
|
+
/** A mitre longer than this many half-widths is cut flat. 4 unless given; at least 1. */
|
|
12
|
+
readonly miterLimit?: number;
|
|
13
|
+
/** The lengths of a dash and of a gap, in turn, in the node's units. An odd count is taken twice over. */
|
|
14
|
+
readonly dash?: readonly number[];
|
|
15
|
+
}
|
|
16
|
+
/** A colour of a gradient: where it is, from 0 at the start to 1 at the end, its colour, and its alpha, 1 unless given. */
|
|
17
|
+
export interface GradientColorStop {
|
|
18
|
+
readonly offset: number;
|
|
19
|
+
readonly color: number;
|
|
20
|
+
readonly alpha?: number;
|
|
21
|
+
}
|
|
22
|
+
/** The matrix of an older gradient call: it places a square 1638.4 units wide, centred on the origin, in the node. */
|
|
23
|
+
export interface GradientBoxMatrix {
|
|
24
|
+
readonly a: number;
|
|
25
|
+
readonly b: number;
|
|
26
|
+
readonly c: number;
|
|
27
|
+
readonly d: number;
|
|
28
|
+
readonly tx: number;
|
|
29
|
+
readonly ty: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Drawing state belongs to one node; every shape snapshots its fill and its line. A node that draws only filled
|
|
33
|
+
* rectangles keeps them as rectangles. Any other shape, and any line, makes the node's drawing one list of triangles
|
|
34
|
+
* in drawing order, and a curve is drawn as straight pieces within a quarter unit of it. Edges are a stair of pixels
|
|
35
|
+
* unless `smoothing` is set.
|
|
36
|
+
*/
|
|
37
|
+
export declare class Graphics {
|
|
38
|
+
private readonly owner;
|
|
39
|
+
private fill;
|
|
40
|
+
private line;
|
|
41
|
+
private soft;
|
|
42
|
+
constructor(owner: DisplayObject);
|
|
43
|
+
/**
|
|
44
|
+
* How far, in the node's units, the edge of each shape and line drawn from now on fades to nothing: 0, which it is
|
|
45
|
+
* at first, to 8. One unit smooths an edge at the size it was drawn. A band of triangles is added around the shape,
|
|
46
|
+
* which is that much larger. A fill under a line has no band of its own. Filled rectangles alone stay rectangles,
|
|
47
|
+
* and an image fill has no band.
|
|
48
|
+
*/
|
|
49
|
+
get smoothing(): number;
|
|
50
|
+
set smoothing(value: number);
|
|
51
|
+
private edged;
|
|
52
|
+
beginFill(value: number, alpha?: number): this;
|
|
53
|
+
/** The line of the shapes drawn after it: its width in the node's units, colour and alpha. No width, or 0, ends the line. */
|
|
54
|
+
lineStyle(thickness?: number, value?: number, alpha?: number, options?: LineStyleOptions): this;
|
|
55
|
+
/** A fill whose colour runs along the line from one point to another, and stays the end colours beyond them. */
|
|
56
|
+
beginLinearGradientFill(x0: number, y0: number, x1: number, y1: number, stops: readonly GradientColorStop[]): this;
|
|
57
|
+
/** A fill whose colour runs from a centre out to a circle, or to an ellipse when `radiusY` is given, and stays the last colour beyond it. */
|
|
58
|
+
beginRadialGradientFill(x: number, y: number, radius: number, stops: readonly GradientColorStop[], radiusY?: number): this;
|
|
59
|
+
/**
|
|
60
|
+
* A gradient fill as older code gives it: "linear" or "radial", colours, alphas, ratios from 0 to 255, and a matrix
|
|
61
|
+
* that places the gradient's square of 1638.4 units, centred on the origin, in the node. Without a matrix that
|
|
62
|
+
* square is where it is.
|
|
63
|
+
*/
|
|
64
|
+
beginGradientFill(type: "linear" | "radial", colors: readonly number[], alphas: readonly number[], ratios: readonly number[], matrix?: GradientBoxMatrix): this;
|
|
65
|
+
drawRect(x: number, y: number, width: number, height: number): this;
|
|
66
|
+
drawCircle(x: number, y: number, radius: number): this;
|
|
67
|
+
/** An ellipse inside the rectangle of this corner and size. */
|
|
68
|
+
drawEllipse(x: number, y: number, width: number, height: number): this;
|
|
69
|
+
/** A rectangle whose corners are quarter ellipses: `ellipseWidth` and `ellipseHeight` are the whole widths and heights of those ellipses. */
|
|
70
|
+
drawRoundRect(x: number, y: number, width: number, height: number, ellipseWidth: number, ellipseHeight?: number): this;
|
|
71
|
+
/** Starts a new part of the path at a point. A path is filled and lined with the fill and line it was begun under. */
|
|
72
|
+
moveTo(x: number, y: number): this;
|
|
73
|
+
lineTo(x: number, y: number): this;
|
|
74
|
+
/** A curve from where the path is to an anchor, bent towards one control point. */
|
|
75
|
+
curveTo(controlX: number, controlY: number, anchorX: number, anchorY: number): this;
|
|
76
|
+
/** A curve from where the path is to an anchor, bent towards two control points. */
|
|
77
|
+
cubicCurveTo(controlX1: number, controlY1: number, controlX2: number, controlY2: number, anchorX: number, anchorY: number): this;
|
|
78
|
+
/** An arc of a circle, in radians from the positive x axis, clockwise on the screen unless `anticlockwise`. A path already begun is joined to its start by a line. */
|
|
79
|
+
drawArc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): this;
|
|
80
|
+
/** Ends the fill. A path drawn under it is filled as it stands. */
|
|
81
|
+
endFill(): this;
|
|
82
|
+
/** Removes everything drawn and ends the fill and the line. Returns the graphics, so drawing can follow at once. */
|
|
83
|
+
clear(): this;
|
|
84
|
+
/**
|
|
85
|
+
* A fill of an image. `lease` is the lease of a texture that is a whole image, not a part of an atlas. `matrix`
|
|
86
|
+
* places the image in the node: its pixel (x, y) is drawn at `a·x + c·y + tx`, `b·x + d·y + ty`; without it a pixel
|
|
87
|
+
* is one unit and the image starts at the node's origin. The image repeats unless `repeat` is false, and then its
|
|
88
|
+
* edge pixels go on outwards. Keep the lease for as long as the drawing is shown.
|
|
89
|
+
*/
|
|
90
|
+
beginBitmapFill(lease: AssetLease<Texture>, matrix?: GradientBoxMatrix, repeat?: boolean): this;
|
|
91
|
+
private gradient;
|
|
92
|
+
private paintRequired;
|
|
93
|
+
/** The node's triangles, begun with the rectangles it has drawn so far. */
|
|
94
|
+
private shape;
|
|
95
|
+
private path;
|
|
96
|
+
/** The part of the path being drawn; a path that was not begun with moveTo begins at the origin. */
|
|
97
|
+
private current;
|
|
98
|
+
/** A path becomes triangles when its fill or line ends, or another shape is drawn over it. */
|
|
99
|
+
private finishPath;
|
|
100
|
+
private outline;
|
|
101
|
+
/** What the node's drawing is before a shape or a point is added, so that one that does not fit can be taken back. */
|
|
102
|
+
private mark;
|
|
103
|
+
/** Refuses a drawing one geometry could not hold, leaving the node as it was, then publishes the change. */
|
|
104
|
+
private changed;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=Graphics.d.ts.map
|