@meta2d/core
Advanced tools
Comparing version 1.0.34 to 1.0.35
{ | ||
"name": "@meta2d/core", | ||
"version": "1.0.34", | ||
"version": "1.0.35", | ||
"description": "@meta2d/core: Powerful, Beautiful, Simple, Open - Web-Based 2D At Its Best .", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -83,2 +83,3 @@ import { Pen, IValue } from '../pen'; | ||
canMoveLine: boolean; | ||
randomIdObj: object; | ||
/** | ||
@@ -193,2 +194,9 @@ * @deprecated 改用 beforeAddPens | ||
/** | ||
* @description 调整pen的坐标,让pen按照网格自动对齐 | ||
* @author Joseph Ho | ||
* @date 14/11/2023 | ||
* @memberof Canvas | ||
*/ | ||
alignPenToGrid(pen: Pen): void; | ||
/** | ||
* 拖拽结束,数据更新到 active.pens | ||
@@ -195,0 +203,0 @@ */ |
@@ -88,2 +88,3 @@ var __values = (this && this.__values) || function(o) { | ||
var e_1, _a; | ||
var _b; | ||
if (this.bgPatchFlags) { | ||
@@ -100,3 +101,8 @@ var ctx = this.bgOffscreen.getContext('2d'); | ||
ctx.fillStyle = background; | ||
if (width && height) { | ||
if (width && height && x && y) { | ||
ctx.globalAlpha = (_b = this.store.data.globalAlpha) !== null && _b !== void 0 ? _b : this.store.options.globalAlpha; | ||
ctx.shadowOffsetX = this.store.options.shadowOffsetX; | ||
ctx.shadowOffsetY = this.store.options.shadowOffsetY; | ||
ctx.shadowBlur = this.store.options.shadowBlur; | ||
ctx.shadowColor = this.store.options.shadowColor; | ||
ctx.fillRect(this.store.data.origin.x + x, this.store.data.origin.y + y, width * this.store.data.scale, height * this.store.data.scale); | ||
@@ -122,4 +128,4 @@ } | ||
try { | ||
for (var _b = __values(this.store.data.pens), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var pen = _c.value; | ||
for (var _c = __values(this.store.data.pens), _d = _c.next(); !_d.done; _d = _c.next()) { | ||
var pen = _d.value; | ||
if (!isFinite(pen.x)) { | ||
@@ -148,3 +154,3 @@ continue; | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
if (_d && !_d.done && (_a = _c.return)) _a.call(_c); | ||
} | ||
@@ -166,3 +172,3 @@ finally { if (e_1) throw e_1.error; } | ||
var _a = this.store, data = _a.data, options = _a.options; | ||
var grid = data.grid, gridRotate = data.gridRotate, gridColor = data.gridColor, gridSize = data.gridSize, scale = data.scale; | ||
var grid = data.grid, gridRotate = data.gridRotate, gridColor = data.gridColor, gridSize = data.gridSize, scale = data.scale, origin = data.origin; | ||
if (!(grid !== null && grid !== void 0 ? grid : options.grid)) { | ||
@@ -173,3 +179,6 @@ // grid false 时不绘制, undefined 时看 options.grid | ||
ctx.save(); | ||
var _b = this.canvas, width = _b.width, height = _b.height; | ||
var width = (data.width || options.width) * scale; | ||
var height = (data.height || options.height) * scale; | ||
var startX = (data.x || options.x || 0) + origin.x; | ||
var startY = (data.y || options.y || 0) + origin.y; | ||
if (gridRotate) { | ||
@@ -184,11 +193,33 @@ ctx.translate(width / 2, height / 2); | ||
var size = (gridSize || options.gridSize) * scale; | ||
var longSide = Math.max(width, height); | ||
var count = Math.ceil(longSide / size); | ||
for (var i = -size * count; i < longSide * 2; i += size) { | ||
ctx.moveTo(i, -longSide); | ||
ctx.lineTo(i, longSide * 2); | ||
if (!width || !height) { | ||
var ratio = this.store.dpiRatio; | ||
var cW = this.canvas.width / ratio; | ||
var cH = this.canvas.height / ratio; | ||
var m = startX / size; | ||
var n = startY / size; | ||
var offset = size * 10; //补偿值 | ||
var newX = (startX - Math.ceil(m) * size); | ||
var newY = (startY - Math.ceil(n) * size); | ||
var endX = cW + newX + offset; | ||
var endY = cH + newY + offset; | ||
for (var i = newX; i <= endX; i += size) { | ||
ctx.moveTo(i, newY); | ||
ctx.lineTo(i, cH + newY + offset); | ||
} | ||
for (var i = newY; i <= endY; i += size) { | ||
ctx.moveTo(newX, i); | ||
ctx.lineTo(cW + newX + offset, i); | ||
} | ||
} | ||
for (var i = -size * count; i < longSide * 2; i += size) { | ||
ctx.moveTo(-longSide, i); | ||
ctx.lineTo(longSide * 2, i); | ||
else { | ||
var endX = width + startX; | ||
var endY = height + startY; | ||
for (var i = startX; i <= endX; i += size) { | ||
ctx.moveTo(i, startY); | ||
ctx.lineTo(i, height + startY); | ||
} | ||
for (var i = startY; i <= endY; i += size) { | ||
ctx.moveTo(startX, i); | ||
ctx.lineTo(width + startX, i); | ||
} | ||
} | ||
@@ -195,0 +226,0 @@ ctx.stroke(); |
@@ -6,3 +6,3 @@ import { EventType, Handler, WildcardHandler } from 'mitt'; | ||
import { Point } from './point'; | ||
import { EditAction, register, registerAnchors, registerCanvasDraw, Meta2dData, Meta2dStore, Network } from './store'; | ||
import { EditAction, register, registerAnchors, registerCanvasDraw, Meta2dData, Meta2dStore, Network, HttpOptions } from './store'; | ||
import { Padding } from './utils'; | ||
@@ -90,2 +90,3 @@ import { Rect } from './rect'; | ||
drawLine(lineName?: string): void; | ||
alignPenToGrid(pen: Pen): void; | ||
drawingPencil(): void; | ||
@@ -195,2 +196,3 @@ stopPencil(): void; | ||
connectHttp(): void; | ||
oldRequestHttp(_req: HttpOptions): Promise<void>; | ||
sendDatabyHttp(data: string): Promise<void>; | ||
@@ -197,0 +199,0 @@ closeHttp(): void; |
@@ -279,9 +279,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
if (!pen.calculative.img) { | ||
var img = new Image(); | ||
img.crossOrigin = | ||
var img_1 = new Image(); | ||
img_1.crossOrigin = | ||
pen.crossOrigin === 'undefined' | ||
? undefined | ||
: pen.crossOrigin || 'anonymous'; | ||
img.src = pen.thumbImg; | ||
pen.calculative.img = img; | ||
if (pen.calculative.canvas.store.options.cdn && | ||
!(pen.thumbImg.startsWith('http') || | ||
pen.thumbImg.startsWith('//') || | ||
pen.thumbImg.startsWith('data:image'))) { | ||
img_1.src = pen.calculative.canvas.store.options.cdn + pen.thumbImg; | ||
} | ||
else { | ||
img_1.src = pen.thumbImg; | ||
} | ||
img_1.onerror = function (e) { | ||
img_1.remove(); | ||
pen.calculative.img = undefined; | ||
}; | ||
pen.calculative.img = img_1; | ||
} | ||
@@ -288,0 +300,0 @@ } |
@@ -36,2 +36,3 @@ import { TextAlign, TextBaseline, Pen } from './pen'; | ||
autoAnchor?: boolean; | ||
autoAlignGrid?: boolean; | ||
disableEmptyLine?: boolean; | ||
@@ -48,2 +49,7 @@ disableRepeatLine?: boolean; | ||
background?: string; | ||
shadowOffsetX?: number; | ||
shadowOffsetY?: number; | ||
shadowBlur?: number; | ||
shadowColor?: string; | ||
globalAlpha?: number; | ||
grid?: boolean; | ||
@@ -50,0 +56,0 @@ gridColor?: string; |
@@ -36,4 +36,10 @@ export var KeydownType; | ||
autoAnchor: true, | ||
autoAlignGrid: false, | ||
animateColor: '#ff4d4f', | ||
ruleLineColor: '#FF4101', | ||
shadowOffsetX: 0, | ||
shadowOffsetY: 13, | ||
shadowBlur: 64, | ||
shadowColor: "#00000014", | ||
globalAlpha: 1, | ||
defaultAnchors: [ | ||
@@ -40,0 +46,0 @@ { |
@@ -198,2 +198,3 @@ import { Point } from '../point'; | ||
reverseProgress?: boolean; | ||
progressGradientColors?: string; | ||
externElement?: boolean; | ||
@@ -243,2 +244,3 @@ autoPolyline?: boolean; | ||
progressColor?: string; | ||
progressGradientColors?: string; | ||
worldRect?: Rect; | ||
@@ -384,2 +386,3 @@ worldAnchors?: Point[]; | ||
}; | ||
lastConnected?: any; | ||
textDecoration?: string; | ||
@@ -386,0 +389,0 @@ textDecorationDash?: number[]; |
@@ -36,3 +36,3 @@ /// <reference types="offscreencanvas" /> | ||
export declare function ctxRotate(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, pen: Pen, noFlip?: boolean): void; | ||
export declare function renderPen(ctx: CanvasRenderingContext2D, pen: Pen): void; | ||
export declare function renderPen(ctx: CanvasRenderingContext2D, pen: Pen, download?: boolean): void; | ||
/** | ||
@@ -51,3 +51,3 @@ * 更改 ctx 的 lineCap 属性 | ||
*/ | ||
export declare function renderPenRaw(ctx: CanvasRenderingContext2D, pen: Pen, rect?: Rect): void; | ||
export declare function renderPenRaw(ctx: CanvasRenderingContext2D, pen: Pen, rect?: Rect, download?: boolean): void; | ||
/** | ||
@@ -54,0 +54,0 @@ * 根据 path2D 绘制 path |
@@ -26,2 +26,3 @@ import { Emitter } from 'mitt'; | ||
background?: string; | ||
globalAlpha?: number; | ||
socketCbJs?: string; | ||
@@ -63,2 +64,4 @@ initJs?: string; | ||
template?: string; | ||
cancelFirstConnect?: boolean; | ||
component?: boolean; | ||
} | ||
@@ -65,0 +68,0 @@ export interface Network { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1674002
23879