@leafer/canvas
Advanced tools
+9
-9
| { | ||
| "name": "@leafer/canvas", | ||
| "version": "1.7.0", | ||
| "version": "1.8.0", | ||
| "description": "@leafer/canvas", | ||
@@ -25,13 +25,13 @@ "author": "Chao (Leafer) Wan", | ||
| "dependencies": { | ||
| "@leafer/file": "1.7.0", | ||
| "@leafer/list": "1.7.0", | ||
| "@leafer/math": "1.7.0", | ||
| "@leafer/data": "1.7.0", | ||
| "@leafer/path": "1.7.0", | ||
| "@leafer/debug": "1.7.0", | ||
| "@leafer/platform": "1.7.0" | ||
| "@leafer/file": "1.8.0", | ||
| "@leafer/list": "1.8.0", | ||
| "@leafer/math": "1.8.0", | ||
| "@leafer/data": "1.8.0", | ||
| "@leafer/path": "1.8.0", | ||
| "@leafer/debug": "1.8.0", | ||
| "@leafer/platform": "1.8.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@leafer/interface": "1.7.0" | ||
| "@leafer/interface": "1.8.0" | ||
| } | ||
| } |
+6
-4
@@ -6,6 +6,8 @@ import { ICanvasAttr, ITextMetrics, ICanvasContext2D, IPath2D, IObject, InnerId, IMatrixData, IFunction, IWindingRule, IBlendMode } from '@leafer/interface' | ||
| if (!realName) realName = key | ||
| Object.defineProperty(target, key, { | ||
| get() { return (this.context as IObject)[realName] }, | ||
| set(value: unknown) { (this.context as IObject)[realName] = value } | ||
| } as ThisType<Canvas>) | ||
| const property = { | ||
| get() { return ((this as unknown as Canvas).context as IObject)[realName] }, | ||
| set(value: unknown) { ((this as unknown as Canvas).context as IObject)[realName] = value } | ||
| } | ||
| if (key === 'strokeCap') (property as any).set = function (value: unknown) { ((this as unknown as Canvas).context as IObject)[realName] = value === 'none' ? 'butt' : value } | ||
| Object.defineProperty(target, key, property) | ||
| } | ||
@@ -12,0 +14,0 @@ } |
+18
-10
@@ -28,4 +28,4 @@ import { IBounds, ILeaferCanvas, ICanvasStrokeOptions, ILeaferCanvasConfig, IWindingRuleData, IExportOptions, IMatrixData, IBoundsData, IAutoBounds, IScreenSizeData, IResizeEventListener, IMatrixWithBoundsData, IPointData, InnerId, ICanvasManager, IWindingRule, IBlendMode, IExportImageType, IExportFileType, IBlob, ICursorType, ILeaferCanvasView, IRadiusPointData, IObject, IMatrixWithOptionHalfData } from '@leafer/interface' | ||
| public get pixelRatio(): number { return this.size.pixelRatio } | ||
| public get pixelWidth(): number { return this.width * this.pixelRatio } | ||
| public get pixelHeight(): number { return this.height * this.pixelRatio } | ||
| public get pixelWidth(): number { return this.width * this.pixelRatio || 0 } // 防止出现 NaN | ||
| public get pixelHeight(): number { return this.height * this.pixelRatio || 0 } | ||
@@ -159,14 +159,22 @@ public get pixelSnap(): boolean { return this.config.pixelSnap } | ||
| public setStroke(color: string | object, strokeWidth: number, options?: ICanvasStrokeOptions): void { | ||
| public setStroke(color: string | object, strokeWidth: number, options?: ICanvasStrokeOptions, childOptions?: ICanvasStrokeOptions): void { | ||
| if (strokeWidth) this.strokeWidth = strokeWidth | ||
| if (color) this.strokeStyle = color | ||
| if (options) this.setStrokeOptions(options) | ||
| if (options) this.setStrokeOptions(options, childOptions) | ||
| } | ||
| public setStrokeOptions(options: ICanvasStrokeOptions): void { | ||
| this.strokeCap = options.strokeCap === 'none' ? 'butt' : options.strokeCap | ||
| this.strokeJoin = options.strokeJoin | ||
| this.dashPattern = options.dashPattern | ||
| this.dashOffset = options.dashOffset | ||
| this.miterLimit = options.miterLimit | ||
| public setStrokeOptions(options: ICanvasStrokeOptions, childOptions?: ICanvasStrokeOptions): void { | ||
| let { strokeCap, strokeJoin, dashPattern, dashOffset, miterLimit } = options | ||
| if (childOptions) { | ||
| if (childOptions.strokeCap) strokeCap = childOptions.strokeCap | ||
| if (childOptions.strokeJoin) strokeJoin = childOptions.strokeJoin | ||
| if (childOptions.dashPattern !== undefined) dashPattern = childOptions.dashPattern | ||
| if (childOptions.dashOffset !== undefined) dashOffset = childOptions.dashOffset | ||
| if (childOptions.miterLimit) miterLimit = childOptions.miterLimit | ||
| } | ||
| this.strokeCap = strokeCap | ||
| this.strokeJoin = strokeJoin | ||
| this.dashPattern = dashPattern | ||
| this.dashOffset = dashOffset | ||
| this.miterLimit = miterLimit | ||
| } | ||
@@ -173,0 +181,0 @@ |
+2
-2
@@ -123,4 +123,4 @@ import { ICanvasManager, ILeaferCanvas, IScreenSizeData, ICanvasAttr, InnerId, ICanvasContext2D, IBlendMode, IMatrixData, IPath2D, IWindingRule, ITextMetrics, IBounds, IBoundsData, ILeaferCanvasConfig, ILeaferCanvasView, IExportFileType, IExportOptions, IBlob, IExportImageType, IAutoBounds, IResizeEventListener, ICursorType, IMatrixWithOptionHalfData, ICanvasStrokeOptions, IPointData, IRadiusPointData, IMatrixWithBoundsData, IWindingRuleData, IPathDrawer } from '@leafer/interface'; | ||
| useWorldTransform(worldTransform?: IMatrixData): void; | ||
| setStroke(color: string | object, strokeWidth: number, options?: ICanvasStrokeOptions): void; | ||
| setStrokeOptions(options: ICanvasStrokeOptions): void; | ||
| setStroke(color: string | object, strokeWidth: number, options?: ICanvasStrokeOptions, childOptions?: ICanvasStrokeOptions): void; | ||
| setStrokeOptions(options: ICanvasStrokeOptions, childOptions?: ICanvasStrokeOptions): void; | ||
| saveBlendMode(blendMode: IBlendMode): void; | ||
@@ -127,0 +127,0 @@ restoreBlendMode(): void; |
33945
2.71%667
1.52%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated
Updated
Updated
Updated