@leafer/interface 1.0.0-alpha.1 → 1.0.0-alpha.6

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 CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "@leafer/interface",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.6",
4
4
  "description": "@leafer/interface",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
7
  "main": "src/index.ts",
8
- "files": ["src"],
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
+ }
@@ -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 CanvasFillRule = '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'
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 Path2D extends CanvasPath {
14
+ export interface IPath2D extends CanvasPath {
15
15
  /** Adds to the path the path given by the argument. */
16
- addPath(path: Path2D, transform?: DOMMatrix2DInit): void
16
+ addPath(path: IPath2D, transform?: DOMMatrix2DInit): void
17
17
  }
18
18
 
19
- export declare var Path2D: {
20
- prototype: Path2D
21
- new(path?: Path2D | string): Path2D
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?: CanvasFillRule): void
39
- clip(path: Path2D, fillRule?: CanvasFillRule): void
40
- fill(fillRule?: CanvasFillRule): void
41
- fill(path: Path2D, fillRule?: CanvasFillRule): void
42
- isPointInPath(x: number, y: number, fillRule?: CanvasFillRule): boolean
43
- isPointInPath(path: Path2D, x: number, y: number, fillRule?: CanvasFillRule): boolean
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: Path2D, x: number, y: number): boolean
45
+ isPointInStroke(path: IPath2D, x: number, y: number): boolean
46
46
  stroke(): void
47
- stroke(path: Path2D): void
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 CanvasRenderingContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform, CanvasUserInterface {
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 CanvasRenderingContext2D: {
146
- prototype: CanvasRenderingContext2D
147
- new(): CanvasRenderingContext2D
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: Path2D, element: any): void
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 TextMetrics {
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: TextMetrics
188
- new(): TextMetrics
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): TextMetrics
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?(x: number, y: number, width: number, height: number, radius?: number | number[]): void
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 { CanvasRenderingContext2D, CanvasFillRule, Path2D, TextMetrics, CanvasGradient, CanvasPattern } from './ICanvas'
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 CanvasRenderingContext2D {
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?: Path2D | CanvasFillRule, rule?: CanvasFillRule): void
71
- stroke(path?: Path2D): void
72
- clip(path?: Path2D | CanvasFillRule, rule?: CanvasFillRule): void
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): TextMetrics
98
+ measureText(text: string): ITextMetrics
99
99
  strokeText(text: string, x: number, y: number, maxWidth?: number): void
100
100
 
101
101
  // custom
@@ -1,5 +1,5 @@
1
1
  import { IEvent, IFunction, IObject } from '@leafer/interface'
2
- import { LeafEventer } from '../display/module/ILeafEventer'
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 LeafEventer {
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 { CanvasFillRule, CanvasRenderingContext2D, TextMetrics, Path2D } from './canvas/ICanvas'
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'