kei-lisp-plugin-graphics 1.0.0 → 1.1.0
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/README.md +10 -2
- package/dist/index.cjs +375 -376
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +65 -59
- package/dist/index.d.ts +65 -59
- package/dist/index.js +375 -376
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -5,17 +5,23 @@ import { Cons, InterpretedSymbol, KeiLispPlugin, LispValue, PluginContext } from
|
|
|
5
5
|
* @class
|
|
6
6
|
* @classdesc Canvas2D drawing plugin for the kei-lisp interpreter. Implements
|
|
7
7
|
* the `KeiLispPlugin` contract (`name` / `has` / `apply`) and
|
|
8
|
-
* exposes
|
|
8
|
+
* exposes 45 `g…` Lisp functions that proxy to a 2D rendering
|
|
9
9
|
* context.
|
|
10
10
|
* @author Keisuke Ikeda
|
|
11
11
|
* @this {GraphicsPlugin}
|
|
12
12
|
*/
|
|
13
13
|
declare class GraphicsPlugin extends Object implements KeiLispPlugin {
|
|
14
|
+
#private;
|
|
14
15
|
/**
|
|
15
16
|
* Dispatch map from a Lisp function name (InterpretedSymbol) to the name of
|
|
16
17
|
* the GraphicsPlugin method that implements it.
|
|
17
18
|
*/
|
|
18
19
|
static readonly buildInFunctions: Map<InterpretedSymbol, string>;
|
|
20
|
+
/**
|
|
21
|
+
* Builds the dispatch table.
|
|
22
|
+
* @return the dispatch table
|
|
23
|
+
*/
|
|
24
|
+
static setup(): Map<InterpretedSymbol, string>;
|
|
19
25
|
/**
|
|
20
26
|
* Plugin identifier, used for diagnostics.
|
|
21
27
|
*/
|
|
@@ -38,18 +44,18 @@ declare class GraphicsPlugin extends Object implements KeiLispPlugin {
|
|
|
38
44
|
/**
|
|
39
45
|
* Dispatches the given symbol to the matching `g…` method.
|
|
40
46
|
* @param aSymbol - the call symbol
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
47
|
+
* @param arguments_ - the evaluated argument list
|
|
48
|
+
* @param _context - the interpreter context (unused by this plugin)
|
|
43
49
|
* @return the method's result, or `Cons.nil` if dispatch fails
|
|
44
50
|
*/
|
|
45
|
-
apply(aSymbol: InterpretedSymbol,
|
|
51
|
+
apply(aSymbol: InterpretedSymbol, arguments_: Cons, _context: PluginContext): LispValue;
|
|
46
52
|
/**
|
|
47
53
|
* Resolves the procedure name and invokes the matching method.
|
|
48
54
|
* @param procedure - the Lisp symbol
|
|
49
|
-
* @param
|
|
55
|
+
* @param arguments_ - the evaluated argument list
|
|
50
56
|
* @return the method's result, or `Cons.nil` if not registered
|
|
51
57
|
*/
|
|
52
|
-
selectProcedure(procedure: InterpretedSymbol,
|
|
58
|
+
selectProcedure(procedure: InterpretedSymbol, arguments_: Cons): LispValue;
|
|
53
59
|
/**
|
|
54
60
|
* Looks up and invokes the JS method that implements the given Lisp symbol.
|
|
55
61
|
* Throws `TypeError` when the dispatch table points to a method that does
|
|
@@ -57,10 +63,10 @@ declare class GraphicsPlugin extends Object implements KeiLispPlugin {
|
|
|
57
63
|
* Ramda `R.invoker(1, methodName)(args, this)` call would surface the same
|
|
58
64
|
* error by attempting to call `undefined`.
|
|
59
65
|
* @param procedure - the Lisp symbol
|
|
60
|
-
* @param
|
|
66
|
+
* @param arguments_ - the evaluated argument list
|
|
61
67
|
* @return the method's result
|
|
62
68
|
*/
|
|
63
|
-
buildInFunction(procedure: InterpretedSymbol,
|
|
69
|
+
buildInFunction(procedure: InterpretedSymbol, arguments_: Cons): LispValue;
|
|
64
70
|
/**
|
|
65
71
|
* Checks whether the canvas exposes a usable 2D context, and narrows
|
|
66
72
|
* `this.ctx` to non-null for the caller when it returns true.
|
|
@@ -69,72 +75,72 @@ declare class GraphicsPlugin extends Object implements KeiLispPlugin {
|
|
|
69
75
|
checkSupport(): this is GraphicsPlugin & {
|
|
70
76
|
ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
|
71
77
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
* browser kei-lisp host (e.g. kei-lisp-web) the host typically swaps
|
|
77
|
-
* `process.stderr.write` for a sink that routes to the REPL output panel,
|
|
78
|
-
* so the same call reaches the user via the host's normal output channel.
|
|
79
|
-
* @param line - the line to write
|
|
80
|
-
*/
|
|
81
|
-
_print(line: string): void;
|
|
82
|
-
gAlpha(args: Cons): LispValue;
|
|
83
|
-
gArc(args: Cons): LispValue;
|
|
84
|
-
gArcTo(args: Cons): LispValue;
|
|
85
|
-
gBezCurveTo(args: Cons): LispValue;
|
|
78
|
+
gAlpha(arguments_: Cons): LispValue;
|
|
79
|
+
gArc(arguments_: Cons): LispValue;
|
|
80
|
+
gArcTo(arguments_: Cons): LispValue;
|
|
81
|
+
gBezCurveTo(arguments_: Cons): LispValue;
|
|
86
82
|
gClear(): LispValue;
|
|
87
83
|
gClose(): LispValue;
|
|
88
|
-
gColor(
|
|
84
|
+
gColor(arguments_: Cons): LispValue;
|
|
89
85
|
gFill(): LispValue;
|
|
90
|
-
gFillColor(
|
|
91
|
-
gFillRect(
|
|
92
|
-
gFillText(
|
|
93
|
-
gFillTri(
|
|
86
|
+
gFillColor(arguments_: Cons): LispValue;
|
|
87
|
+
gFillRect(arguments_: Cons): LispValue;
|
|
88
|
+
gFillText(arguments_: Cons): LispValue;
|
|
89
|
+
gFillTri(arguments_: Cons): LispValue;
|
|
94
90
|
gFinishPath(): LispValue;
|
|
95
|
-
gImage(
|
|
96
|
-
gLineTo(
|
|
97
|
-
gLineCap(
|
|
98
|
-
gLineJoin(
|
|
99
|
-
gLineWidth(
|
|
100
|
-
gMoveTo(
|
|
91
|
+
gImage(arguments_: Cons): LispValue;
|
|
92
|
+
gLineTo(arguments_: Cons): LispValue;
|
|
93
|
+
gLineCap(arguments_: Cons): LispValue;
|
|
94
|
+
gLineJoin(arguments_: Cons): LispValue;
|
|
95
|
+
gLineWidth(arguments_: Cons): LispValue;
|
|
96
|
+
gMoveTo(arguments_: Cons): LispValue;
|
|
101
97
|
gOpen(): LispValue;
|
|
102
|
-
gPattern(
|
|
103
|
-
gQuadCurveTo(
|
|
98
|
+
gPattern(arguments_: Cons): LispValue;
|
|
99
|
+
gQuadCurveTo(arguments_: Cons): LispValue;
|
|
104
100
|
gSaveJpeg(): LispValue;
|
|
105
101
|
gSavePng(): LispValue;
|
|
106
|
-
gScale(
|
|
107
|
-
gShadowBlur(
|
|
108
|
-
gShadowColor(
|
|
109
|
-
gShadowOffsetX(
|
|
110
|
-
gShadowOffsetY(
|
|
111
|
-
gSleep(
|
|
102
|
+
gScale(arguments_: Cons): LispValue;
|
|
103
|
+
gShadowBlur(arguments_: Cons): LispValue;
|
|
104
|
+
gShadowColor(arguments_: Cons): LispValue;
|
|
105
|
+
gShadowOffsetX(arguments_: Cons): LispValue;
|
|
106
|
+
gShadowOffsetY(arguments_: Cons): LispValue;
|
|
107
|
+
gSleep(arguments_: Cons): LispValue;
|
|
112
108
|
gStartPath(): LispValue;
|
|
113
109
|
gStroke(): LispValue;
|
|
114
|
-
gStrokeColor(
|
|
115
|
-
gStrokeRect(
|
|
116
|
-
gStrokeText(
|
|
117
|
-
gStrokeTri(
|
|
118
|
-
gTextAlign(
|
|
119
|
-
gTextBaseline(
|
|
120
|
-
gTextDirection(
|
|
121
|
-
gTextFont(
|
|
122
|
-
gTranslate(
|
|
123
|
-
gRect(
|
|
124
|
-
gRotate(
|
|
110
|
+
gStrokeColor(arguments_: Cons): LispValue;
|
|
111
|
+
gStrokeRect(arguments_: Cons): LispValue;
|
|
112
|
+
gStrokeText(arguments_: Cons): LispValue;
|
|
113
|
+
gStrokeTri(arguments_: Cons): LispValue;
|
|
114
|
+
gTextAlign(arguments_: Cons): LispValue;
|
|
115
|
+
gTextBaseline(arguments_: Cons): LispValue;
|
|
116
|
+
gTextDirection(arguments_: Cons): LispValue;
|
|
117
|
+
gTextFont(arguments_: Cons): LispValue;
|
|
118
|
+
gTranslate(arguments_: Cons): LispValue;
|
|
119
|
+
gRect(arguments_: Cons): LispValue;
|
|
120
|
+
gRotate(arguments_: Cons): LispValue;
|
|
121
|
+
/**
|
|
122
|
+
* Pushes the current drawing state (styles, transform, clip) onto the
|
|
123
|
+
* context's state stack. Pairs with `gRestore` to let Lisp callers manage
|
|
124
|
+
* state explicitly. Replaces the legacy per-method `ctx.save()` calls, which
|
|
125
|
+
* pushed state on every draw with no matching `restore()` and grew the stack
|
|
126
|
+
* unbounded.
|
|
127
|
+
* @return `t` on success, `Cons.nil` otherwise
|
|
128
|
+
*/
|
|
129
|
+
gSave(): LispValue;
|
|
130
|
+
/**
|
|
131
|
+
* Pops the most recently saved drawing state off the context's state stack.
|
|
132
|
+
* Pairs with `gSave`. Popping an empty stack is a no-op per the Canvas spec.
|
|
133
|
+
* @return `t` on success, `Cons.nil` otherwise
|
|
134
|
+
*/
|
|
135
|
+
gRestore(): LispValue;
|
|
125
136
|
/**
|
|
126
137
|
* Parses a color spec from the head of the argument Cons. Accepts
|
|
127
138
|
* (1 string), (3 numbers — rgb), or (4 numbers — rgba); falls back to
|
|
128
139
|
* `'black'` on anything else (legacy behavior).
|
|
129
|
-
* @param
|
|
140
|
+
* @param arguments_ - the argument Cons to parse
|
|
130
141
|
* @return CSS color string
|
|
131
142
|
*/
|
|
132
|
-
selectColor(
|
|
133
|
-
/**
|
|
134
|
-
* Builds the dispatch table.
|
|
135
|
-
* @return the dispatch table
|
|
136
|
-
*/
|
|
137
|
-
static setup(): Map<InterpretedSymbol, string>;
|
|
143
|
+
selectColor(arguments_: Cons): string;
|
|
138
144
|
}
|
|
139
145
|
//#endregion
|
|
140
146
|
//#region src/index.d.ts
|