@leafer-ui/display 1.0.7 → 1.0.9

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/display",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "@leafer-ui/display",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,14 +22,14 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.0.7",
26
- "@leafer-ui/data": "1.0.7",
27
- "@leafer-ui/display-module": "1.0.7",
28
- "@leafer-ui/decorator": "1.0.7",
29
- "@leafer-ui/external": "1.0.7"
25
+ "@leafer/core": "1.0.9",
26
+ "@leafer-ui/data": "1.0.9",
27
+ "@leafer-ui/display-module": "1.0.9",
28
+ "@leafer-ui/decorator": "1.0.9",
29
+ "@leafer-ui/external": "1.0.9"
30
30
  },
31
31
  "devDependencies": {
32
- "@leafer/interface": "1.0.7",
33
- "@leafer-ui/interface": "1.0.7"
32
+ "@leafer/interface": "1.0.9",
33
+ "@leafer-ui/interface": "1.0.9"
34
34
  }
35
35
  }
package/src/Leafer.ts CHANGED
@@ -166,10 +166,10 @@ export class Leafer extends Group implements ILeafer {
166
166
  public start(): void {
167
167
  clearTimeout(this.__startTimer)
168
168
  if (!this.running && this.canvas) {
169
+ this.running = true
169
170
  this.ready ? this.emitLeafer(LeaferEvent.RESTART) : this.emitLeafer(LeaferEvent.START)
170
171
  this.__controllers.forEach(item => item.start())
171
172
  if (!this.isApp) this.renderer.render()
172
- this.running = true
173
173
  }
174
174
  }
175
175
 
@@ -280,11 +280,8 @@ export class Leafer extends Group implements ILeafer {
280
280
 
281
281
  protected __changeFill(newValue: string): void {
282
282
  this.config.fill = newValue as string
283
- if (this.canvas.allowBackgroundColor) {
284
- this.canvas.backgroundColor = newValue as string
285
- } else {
286
- this.forceRender()
287
- }
283
+ if (this.canvas.allowBackgroundColor) this.canvas.backgroundColor = newValue as string
284
+ else this.forceRender()
288
285
  }
289
286
 
290
287
  protected __onCreated(): void {
@@ -352,11 +349,8 @@ export class Leafer extends Group implements ILeafer {
352
349
  public waitViewCompleted(item: IFunction, bind?: IObject): void {
353
350
  if (bind) item = item.bind(bind)
354
351
  this.__viewCompletedWait.push(item)
355
- if (this.viewCompleted) {
356
- this.__checkViewCompleted(false)
357
- } else {
358
- if (!this.running) this.start()
359
- }
352
+ if (this.viewCompleted) this.__checkViewCompleted(false)
353
+ else if (!this.running) this.start()
360
354
  }
361
355
 
362
356
  public nextRender(item: IFunction, bind?: IObject, off?: 'off'): void {
@@ -366,9 +360,7 @@ export class Leafer extends Group implements ILeafer {
366
360
  for (let i = 0; i < list.length; i++) {
367
361
  if (list[i] === item) { list.splice(i, 1); break }
368
362
  }
369
- } else {
370
- list.push(item)
371
- }
363
+ } else list.push(item)
372
364
  }
373
365
 
374
366
  // need view plugin
@@ -434,9 +426,7 @@ export class Leafer extends Group implements ILeafer {
434
426
  this.emitEvent(new LeaferEvent(LeaferEvent.END, this))
435
427
  this.__removeListenEvents()
436
428
 
437
- this.__controllers.forEach(item => {
438
- if (!(this.parent && item === this.interaction)) item.destroy()
439
- })
429
+ this.__controllers.forEach(item => !(this.parent && item === this.interaction) && item.destroy())
440
430
  this.__controllers.length = 0
441
431
 
442
432
  if (!this.parent) {
package/src/Pen.ts CHANGED
@@ -6,7 +6,7 @@ import { PenData } from '@leafer-ui/data'
6
6
  import { Group } from './Group'
7
7
  import { Path } from './Path'
8
8
 
9
- @useModule(PathCreator, ['set', 'beginPath', 'path', 'paint'])
9
+ @useModule(PathCreator, ['set', 'path', 'paint'])
10
10
  @registerUI()
11
11
  export class Pen extends Group implements IPen {
12
12
 
@@ -35,14 +35,10 @@ export class Pen extends Group implements IPen {
35
35
  return this
36
36
  }
37
37
 
38
- public beginPath(): Pen {
39
- this.__path.length = 0
40
- this.paint()
41
- return this
42
- }
43
-
44
38
  // svg and canvas
45
39
 
40
+ public beginPath(): Pen { return this }
41
+
46
42
  public moveTo(_x: number, _y: number): Pen { return this }
47
43
 
48
44
  public lineTo(_x: number, _y: number): Pen { return this }
@@ -75,7 +71,8 @@ export class Pen extends Group implements IPen {
75
71
 
76
72
  public drawPoints(_points: number[], _curve?: boolean | number, _close?: boolean): Pen { return this }
77
73
 
78
- public clearPath(): Pen { return this }
74
+ public clearPath(): Pen { return this } // = beginPath()
75
+
79
76
 
80
77
  public paint(): void {
81
78
  if (!this.pathElement.__layout.boxChanged) this.pathElement.forceUpdate('path')
package/src/Text.ts CHANGED
@@ -119,21 +119,8 @@ export class Text extends UI implements IText {
119
119
 
120
120
  public __updateTextDrawData(): void {
121
121
  const data = this.__
122
- data.__textDrawData = TextConvert.getDrawData(data.text, this.__)
123
-
124
- }
125
-
126
- public __updateBoxBounds(): void {
127
-
128
- const data = this.__
129
- const layout = this.__layout
130
122
  const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data
131
123
 
132
- const autoWidth = data.__autoWidth
133
- const autoHeight = data.__autoHeight
134
-
135
- // compute
136
-
137
124
  data.__lineHeight = UnitConvert.number(lineHeight, fontSize)
138
125
  data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize)
139
126
  data.__padding = padding ? MathHelper.fourNumber(padding) : undefined
@@ -141,7 +128,16 @@ export class Text extends UI implements IText {
141
128
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`
142
129
  data.__clipText = textOverflow !== 'show' && !data.__autoSize
143
130
 
144
- this.__updateTextDrawData()
131
+ data.__textDrawData = TextConvert.getDrawData(data.text, this.__)
132
+ }
133
+
134
+ public __updateBoxBounds(): void {
135
+
136
+ const data = this.__
137
+ const layout = this.__layout
138
+ const { fontSize, italic, padding, __autoWidth: autoWidth, __autoHeight: autoHeight } = data
139
+
140
+ this.__updateTextDrawData() // layout text
145
141
 
146
142
  const { bounds } = data.__textDrawData
147
143
  const b = layout.boxBounds
@@ -156,19 +152,11 @@ export class Text extends UI implements IText {
156
152
 
157
153
  if (padding) {
158
154
  const [top, right, bottom, left] = data.__padding
159
- if (autoWidth) {
160
- b.x -= left
161
- b.width += (right + left)
162
- }
163
- if (autoHeight) {
164
- b.y -= top
165
- b.height += (bottom + top)
166
- }
155
+ if (autoWidth) b.x -= left, b.width += (right + left)
156
+ if (autoHeight) b.y -= top, b.height += (bottom + top)
167
157
  }
168
158
  this.__updateNaturalSize()
169
- } else {
170
- super.__updateBoxBounds()
171
- }
159
+ } else super.__updateBoxBounds()
172
160
 
173
161
  if (italic) b.width += fontSize * 0.16 // 倾斜会导致文本的bounds增大
174
162
 
package/src/UI.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IMaskType, IEraserType, IValue, IWindingRule, IPathCreator, IFourNumber, IBoundsData, IFlowType, IGap, IFlowWrap, IAxis, IConstraint, IAutoBoxData, IFlowBoxType, IPointGap, IFlowAlign, IFlowAxisAlign, IFindCondition, IAutoSize, IRangeSize, IAlign, IUnitPointData, IObject, IScaleData, IUnitData, IPathCommandObject } from '@leafer/interface'
2
2
  import { Leaf, PathDrawer, surfaceType, dataType, positionType, boundsType, pathType, scaleType, rotationType, opacityType, visibleType, sortType, maskType, dataProcessor, registerUI, useModule, rewrite, rewriteAble, UICreator, PathCorner, hitType, strokeType, PathConvert, eraserType, cursorType, autoLayoutType, pen, naturalBoundsType, pathInputType, MathHelper, needPlugin } from '@leafer/core'
3
3
 
4
- import { IUI, IShadowEffect, IBlurEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString, IUIInputData, IExportOptions, IExportResult, IFill, IStroke, IArrowType, IFindUIMethod, ILeafer, IEditorConfig, IEditorConfigFunction, IEditToolFunction, IKeyframe, IAnimation, IAnimate, IStates, IStateName, ITransition, IAnimateType } from '@leafer-ui/interface'
4
+ import { IUI, IShadowEffect, IBlurEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString, IUIInputData, IExportOptions, IExportResult, IFill, IStroke, IArrowType, IFindUIMethod, ILeafer, IEditorConfig, IEditorConfigFunction, IEditToolFunction, IKeyframe, IAnimation, IAnimate, IStates, IStateName, ITransition, IAnimateType, IEffect } from '@leafer-ui/interface'
5
5
  import { effectType, zoomLayerType } from '@leafer-ui/decorator'
6
6
 
7
7
  import { UIData } from '@leafer-ui/data'
@@ -284,6 +284,8 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
284
284
  @effectType()
285
285
  public grayscale?: INumber | IGrayscaleEffect
286
286
 
287
+ public filter?: IEffect | IEffect[]
288
+
287
289
 
288
290
  // @leafer-in/animate rewrite
289
291
 
@@ -407,8 +409,8 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
407
409
  return curve ? PathConvert.toCanvasData(path, true) : path
408
410
  }
409
411
 
410
- public getPathString(curve?: boolean, pathForRender?: boolean): IPathString {
411
- return PathConvert.stringify(this.getPath(curve, pathForRender))
412
+ public getPathString(curve?: boolean, pathForRender?: boolean, floatLength?: number): IPathString {
413
+ return PathConvert.stringify(this.getPath(curve, pathForRender), floatLength)
412
414
  }
413
415
 
414
416
 
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { IString, INumber, IBoolean, IMaskType, IEraserType, IAlign, IUnitPointData, IPathCommandData, IPathCommandObject, IPathString, IWindingRule, IFlowType, IFourNumber, IGap, IPointGap, IFlowAlign, IFlowAxisAlign, IFlowWrap, IFlowBoxType, IAutoSize, IAutoBoxData, IConstraint, IRangeSize, IAxis, IBoundsData, IHitType, ICursorType, IUnitData, IObject, IPointData, IPathCreator, IValue, IFindCondition, ILeaferCanvas, IPathDrawer, IExportFileType, IJSONOptions, IPickOptions, IPickResult, IRenderer, IWatcher, ILayouter, ISelector, IInteraction, ICanvasManager, IHitCanvasManager, ILeaferConfig, IAutoBounds, IBounds, IEventListenerId, ITimer, IControl, ILeaferType, IScreenSizeData, IResizeEvent, IZoomType, IClientPointData, IRenderOptions, ILeaferImage, ICanvasContext2DSettings, ICanvasContext2D } from '@leafer/interface';
2
2
  import { Leaf, LeafList } from '@leafer/core';
3
- import { IUI, IUIData, IUIInputData, ILeafer, IGroup, IBlendMode, IFill, IStroke, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, IArrowType, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IAnimation, ITransition, IStates, IStateName, IAnimate, IEditorConfig, IFindUIMethod, IKeyframe, IAnimateType, IExportOptions, IExportResult, IEditorConfigFunction, IEditToolFunction, IGroupData, IGroupInputData, IUIJSONData, IFindCondition as IFindCondition$1, ILeaferData, IApp, IEditorBase, IFunction, ILeaferInputData, IBox, IBoxData, IOverflow, IBoxInputData, IFrame, IFrameData, IFrameInputData, IRect, IRectData, IRectInputData, IEllipse, IEllipseData, IEllipseInputData, IPolygon, IPolygonData, IPolygonInputData, IStar, IStarData, IStarInputData, ILine, ILineData, ILineInputData, IImage, IImageData, IImageInputData, ICanvas, ICanvasData, ICanvasInputData, IText, ITextData, IHitType as IHitType$1, IFontWeight, ITextCase, ITextDecoration, ITextAlign, IVerticalAlign, ITextWrap, ITextDrawData, ITextInputData, IPath, IPathData, IPathInputData, IPen, IPenData, IPathCommandData as IPathCommandData$1, IPenInputData } from '@leafer-ui/interface';
3
+ import { IUI, IUIData, IUIInputData, ILeafer, IGroup, IBlendMode, IFill, IStroke, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, IArrowType, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IEffect, IAnimation, ITransition, IStates, IStateName, IAnimate, IEditorConfig, IFindUIMethod, IKeyframe, IAnimateType, IExportOptions, IExportResult, IEditorConfigFunction, IEditToolFunction, IGroupData, IGroupInputData, IUIJSONData, IFindCondition as IFindCondition$1, ILeaferData, IApp, IEditorBase, IFunction, ILeaferInputData, IBox, IBoxData, IOverflow, IBoxInputData, IFrame, IFrameData, IFrameInputData, IRect, IRectData, IRectInputData, IEllipse, IEllipseData, IEllipseInputData, IPolygon, IPolygonData, IPolygonInputData, IStar, IStarData, IStarInputData, ILine, ILineData, ILineInputData, IImage, IImageData, IImageInputData, ICanvas, ICanvasData, ICanvasInputData, IText, ITextData, IHitType as IHitType$1, IFontWeight, ITextCase, ITextDecoration, ITextAlign, IVerticalAlign, ITextWrap, ITextDrawData, ITextInputData, IPath, IPathData, IPathInputData, IPen, IPenData, IPathCommandData as IPathCommandData$1, IPenInputData } from '@leafer-ui/interface';
4
4
 
5
5
  declare class UI extends Leaf implements IUI {
6
6
  __: IUIData;
@@ -85,6 +85,7 @@ declare class UI extends Leaf implements IUI {
85
85
  blur?: INumber | IBlurEffect;
86
86
  backgroundBlur?: INumber | IBlurEffect;
87
87
  grayscale?: INumber | IGrayscaleEffect;
88
+ filter?: IEffect | IEffect[];
88
89
  animation?: IAnimation;
89
90
  animationOut?: IAnimation;
90
91
  transition?: ITransition;
@@ -121,7 +122,7 @@ declare class UI extends Leaf implements IUI {
121
122
  findOne(_condition: number | string | IFindCondition | IFindUIMethod, _options?: any): IUI | undefined;
122
123
  findId(id: number | string): IUI | undefined;
123
124
  getPath(curve?: boolean, pathForRender?: boolean): IPathCommandData;
124
- getPathString(curve?: boolean, pathForRender?: boolean): IPathString;
125
+ getPathString(curve?: boolean, pathForRender?: boolean, floatLength?: number): IPathString;
125
126
  load(): void;
126
127
  __onUpdateSize(): void;
127
128
  __updateRenderPath(): void;