@leafer/interface 1.0.0-alpha.1 → 1.0.0-alpha.5
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/package.json +5 -3
- package/src/canvas/ICanvas.ts +27 -27
- package/src/canvas/ICanvasPathDrawer.ts +1 -1
- package/src/canvas/ILeaferCanvas.ts +6 -6
- package/src/event/IEventer.ts +2 -2
- package/src/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/interface",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.5",
|
|
4
4
|
"description": "@leafer/interface",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.ts",
|
|
8
|
-
"files": [
|
|
8
|
+
"files": [
|
|
9
|
+
"src"
|
|
10
|
+
],
|
|
9
11
|
"repository": {
|
|
10
12
|
"type": "git",
|
|
11
13
|
"url": "https://github.com/leaferjs/leafer.git"
|
|
@@ -16,4 +18,4 @@
|
|
|
16
18
|
"leafer",
|
|
17
19
|
"leaferjs"
|
|
18
20
|
]
|
|
19
|
-
}
|
|
21
|
+
}
|
package/src/canvas/ICanvas.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
type GlobalCompositeOperation = 'color' | 'color-burn' | 'color-dodge' | 'copy' | 'darken' | 'destination-atop' | 'destination-in' | 'destination-out' | 'destination-over' | 'difference' | 'exclusion' | 'hard-light' | 'hue' | 'lighten' | 'lighter' | 'luminosity' | 'multiply' | 'overlay' | 'saturation' | 'screen' | 'soft-light' | 'source-atop' | 'source-in' | 'source-out' | 'source-over' | 'xor'
|
|
2
2
|
type CanvasDirection = 'inherit' | 'ltr' | 'rtl'
|
|
3
|
-
export type
|
|
4
|
-
type CanvasFontKerning = 'auto' | 'none' | 'normal'
|
|
5
|
-
type CanvasFontStretch = 'condensed' | 'expanded' | 'extra-condensed' | 'extra-expanded' | 'normal' | 'semi-condensed' | 'semi-expanded' | 'ultra-condensed' | 'ultra-expanded'
|
|
6
|
-
type CanvasFontVariantCaps = 'all-petite-caps' | 'all-small-caps' | 'normal' | 'petite-caps' | 'small-caps' | 'titling-caps' | 'unicase'
|
|
3
|
+
export type ICanvasFillRule = 'evenodd' | 'nonzero'
|
|
4
|
+
// type CanvasFontKerning = 'auto' | 'none' | 'normal'
|
|
5
|
+
// type CanvasFontStretch = 'condensed' | 'expanded' | 'extra-condensed' | 'extra-expanded' | 'normal' | 'semi-condensed' | 'semi-expanded' | 'ultra-condensed' | 'ultra-expanded'
|
|
6
|
+
// type CanvasFontVariantCaps = 'all-petite-caps' | 'all-small-caps' | 'normal' | 'petite-caps' | 'small-caps' | 'titling-caps' | 'unicase'
|
|
7
7
|
type CanvasLineCap = 'butt' | 'round' | 'square'
|
|
8
8
|
type CanvasLineJoin = 'bevel' | 'miter' | 'round'
|
|
9
9
|
type CanvasTextAlign = 'center' | 'end' | 'left' | 'right' | 'start'
|
|
10
10
|
type CanvasTextBaseline = 'alphabetic' | 'bottom' | 'hanging' | 'ideographic' | 'middle' | 'top'
|
|
11
|
-
type CanvasTextRendering = 'auto' | 'geometricPrecision' | 'optimizeLegibility' | 'optimizeSpeed'
|
|
11
|
+
//type CanvasTextRendering = 'auto' | 'geometricPrecision' | 'optimizeLegibility' | 'optimizeSpeed'
|
|
12
12
|
|
|
13
13
|
/** This Canvas 2D API interface is used to declare a path that can then be used on a CanvasRenderingContext2D object. The path methods of the CanvasRenderingContext2D interface are also present on this interface, which gives you the convenience of being able to retain and replay your path whenever desired. */
|
|
14
|
-
interface
|
|
14
|
+
export interface IPath2D extends CanvasPath {
|
|
15
15
|
/** Adds to the path the path given by the argument. */
|
|
16
|
-
addPath(path:
|
|
16
|
+
addPath(path: IPath2D, transform?: DOMMatrix2DInit): void
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
prototype:
|
|
21
|
-
new(path?:
|
|
19
|
+
declare var IPath2D: {
|
|
20
|
+
prototype: IPath2D
|
|
21
|
+
new(path?: IPath2D | string): IPath2D
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
interface CanvasCompositing {
|
|
@@ -35,16 +35,16 @@ interface CanvasDrawImage {
|
|
|
35
35
|
|
|
36
36
|
interface CanvasDrawPath {
|
|
37
37
|
beginPath(): void
|
|
38
|
-
clip(fillRule?:
|
|
39
|
-
clip(path:
|
|
40
|
-
fill(fillRule?:
|
|
41
|
-
fill(path:
|
|
42
|
-
isPointInPath(x: number, y: number, fillRule?:
|
|
43
|
-
isPointInPath(path:
|
|
38
|
+
clip(fillRule?: ICanvasFillRule): void
|
|
39
|
+
clip(path: IPath2D, fillRule?: ICanvasFillRule): void
|
|
40
|
+
fill(fillRule?: ICanvasFillRule): void
|
|
41
|
+
fill(path: IPath2D, fillRule?: ICanvasFillRule): void
|
|
42
|
+
isPointInPath(x: number, y: number, fillRule?: ICanvasFillRule): boolean
|
|
43
|
+
isPointInPath(path: IPath2D, x: number, y: number, fillRule?: ICanvasFillRule): boolean
|
|
44
44
|
isPointInStroke(x: number, y: number): boolean
|
|
45
|
-
isPointInStroke(path:
|
|
45
|
+
isPointInStroke(path: IPath2D, x: number, y: number): boolean
|
|
46
46
|
stroke(): void
|
|
47
|
-
stroke(path:
|
|
47
|
+
stroke(path: IPath2D): void
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
interface CanvasFillStrokeStyles {
|
|
@@ -137,14 +137,14 @@ interface CanvasRenderingContext2DSettings {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
/** The CanvasRenderingContext2D interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a <canvas> element. It is used for drawing shapes, text, images, and other objects. */
|
|
140
|
-
export interface
|
|
140
|
+
export interface ICanvasRenderingContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform, CanvasUserInterface {
|
|
141
141
|
readonly canvas: HTMLCanvasElement
|
|
142
142
|
getContextAttributes(): CanvasRenderingContext2DSettings
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
declare var
|
|
146
|
-
prototype:
|
|
147
|
-
new():
|
|
145
|
+
declare var ICanvasRenderingContext2D: {
|
|
146
|
+
prototype: ICanvasRenderingContext2D
|
|
147
|
+
new(): ICanvasRenderingContext2D
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
interface CanvasShadowStyles {
|
|
@@ -161,12 +161,12 @@ interface CanvasState {
|
|
|
161
161
|
|
|
162
162
|
interface CanvasUserInterface {
|
|
163
163
|
drawFocusIfNeeded(element: any): void
|
|
164
|
-
drawFocusIfNeeded(path:
|
|
164
|
+
drawFocusIfNeeded(path: IPath2D, element: any): void
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
|
|
168
168
|
/** The dimensions of a piece of text in the canvas, as created by the CanvasRenderingContext2D.measureText() method. */
|
|
169
|
-
export interface
|
|
169
|
+
export interface ITextMetrics {
|
|
170
170
|
/** Returns the measurement described below. */
|
|
171
171
|
readonly actualBoundingBoxAscent: number
|
|
172
172
|
/** Returns the measurement described below. */
|
|
@@ -184,13 +184,13 @@ export interface TextMetrics {
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
declare var TextMetrics: {
|
|
187
|
-
prototype:
|
|
188
|
-
new():
|
|
187
|
+
prototype: ITextMetrics
|
|
188
|
+
new(): ITextMetrics
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
interface CanvasText {
|
|
192
192
|
fillText(text: string, x: number, y: number, maxWidth?: number): void
|
|
193
|
-
measureText(text: string):
|
|
193
|
+
measureText(text: string): ITextMetrics
|
|
194
194
|
strokeText(text: string, x: number, y: number, maxWidth?: number): void
|
|
195
195
|
}
|
|
196
196
|
|
|
@@ -12,5 +12,5 @@ export interface ICanvasDrawPath {
|
|
|
12
12
|
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void
|
|
13
13
|
|
|
14
14
|
rect(x: number, y: number, width: number, height: number): void
|
|
15
|
-
roundRect
|
|
15
|
+
roundRect(x: number, y: number, width: number, height: number, radius?: number | number[]): void
|
|
16
16
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { IObject } from '../data/IData'
|
|
2
2
|
import { IBounds, IMatrixData, IBoundsData, IAutoBoundsData, IAutoBounds, IScreenSizeData, IMatrixWithBoundsData, IPointData } from '../math/IMath'
|
|
3
|
-
import {
|
|
3
|
+
import { ICanvasRenderingContext2D, ICanvasFillRule, IPath2D, ITextMetrics, CanvasGradient, CanvasPattern } from './ICanvas'
|
|
4
4
|
import { IResizeEventListener } from '../event/IEvent'
|
|
5
5
|
import { ICanvasDrawPath } from './ICanvasPathDrawer'
|
|
6
6
|
import { InnerId } from '../event/IEventer'
|
|
7
7
|
import { ICanvasManager } from './ICanvasManager'
|
|
8
8
|
|
|
9
|
-
export interface ILeaferCanvasContext extends
|
|
9
|
+
export interface ILeaferCanvasContext extends ICanvasRenderingContext2D {
|
|
10
10
|
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -67,9 +67,9 @@ interface ICanvasMethod {
|
|
|
67
67
|
save(): void
|
|
68
68
|
restore(): void
|
|
69
69
|
|
|
70
|
-
fill(path?:
|
|
71
|
-
stroke(path?:
|
|
72
|
-
clip(path?:
|
|
70
|
+
fill(path?: IPath2D | ICanvasFillRule, rule?: ICanvasFillRule): void
|
|
71
|
+
stroke(path?: IPath2D): void
|
|
72
|
+
clip(path?: IPath2D | ICanvasFillRule, rule?: ICanvasFillRule): void
|
|
73
73
|
|
|
74
74
|
fillRect(x: number, y: number, width: number, height: number): void
|
|
75
75
|
strokeRect(x: number, y: number, width: number, height: number): void
|
|
@@ -95,7 +95,7 @@ interface ICanvasMethod {
|
|
|
95
95
|
// text
|
|
96
96
|
|
|
97
97
|
fillText(text: string, x: number, y: number, maxWidth?: number): void
|
|
98
|
-
measureText(text: string):
|
|
98
|
+
measureText(text: string): ITextMetrics
|
|
99
99
|
strokeText(text: string, x: number, y: number, maxWidth?: number): void
|
|
100
100
|
|
|
101
101
|
// custom
|
package/src/event/IEventer.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IEvent, IFunction, IObject } from '@leafer/interface'
|
|
2
|
-
import {
|
|
2
|
+
import { ILeafEventer } from '../display/module/ILeafEventer'
|
|
3
3
|
|
|
4
4
|
export type IEventListener = IFunction
|
|
5
5
|
|
|
@@ -24,7 +24,7 @@ export interface IEventListenerId {
|
|
|
24
24
|
|
|
25
25
|
export type InnerId = number
|
|
26
26
|
|
|
27
|
-
export interface IEventer extends
|
|
27
|
+
export interface IEventer extends ILeafEventer {
|
|
28
28
|
|
|
29
29
|
readonly innerId: InnerId
|
|
30
30
|
__captureMap?: IEventListenerMap
|
package/src/index.ts
CHANGED
|
@@ -31,7 +31,7 @@ export { IPlugin } from './plugin/IPlugin'
|
|
|
31
31
|
|
|
32
32
|
export { ILeaferCanvas, IHitCanvas, ICanvasAttr, ICanvasStrokeOptions, ILeaferCanvasContext, ILeaferCanvasConfig, IHitCanvasConfig } from './canvas/ILeaferCanvas'
|
|
33
33
|
export { ICanvasDrawPath } from './canvas/ICanvasPathDrawer'
|
|
34
|
-
export {
|
|
34
|
+
export { ICanvasFillRule as ICanvasFillRule, ICanvasRenderingContext2D, ITextMetrics, IPath2D } from './canvas/ICanvas'
|
|
35
35
|
export { CanvasPathCommand, IPathCommandData, MCommandData, HCommandData, VCommandData, LCommandData, CCommandData, SCommandData, QCommandData, TCommandData, ZCommandData, ACommandData, RectCommandData, RoundRectCommandData, EllipseCommandData, ArcCommandData, ArcToCommandData } from './path/IPathCommand'
|
|
36
36
|
|
|
37
37
|
export { ILeaferImage, ILeaferImageConfig } from './image/ILeaferImage'
|