From 6242be458d60bfc0e019286ff20ede8492cd140f Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 25 Aug 2020 19:17:18 -0400 Subject: fixed ink warnings. double-click turns on control point editing - esc reverts. made aliasing ink strokes possible & working. --- .../collectionFreeForm/FormatShapePane.tsx | 39 ++++++++-------------- 1 file changed, 13 insertions(+), 26 deletions(-) (limited to 'src/client/views/collections') diff --git a/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx b/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx index 1d3604d7f..91efe139e 100644 --- a/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx +++ b/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx @@ -118,9 +118,7 @@ export class FormatShapePane extends AntimodeMenu { this._lock && (i.rootDoc._height = (i.rootDoc._width / oldWidth * NumCast(i.rootDoc._height))); const doc = Document(i.rootDoc); if (doc.type === DocumentType.INK && doc.x && doc.y && doc._height && doc._width) { - console.log(doc.x, doc.y, doc._height, doc._width); const ink = Cast(doc.data, InkField)?.inkData; - console.log(ink); if (ink) { const newPoints: { X: number, Y: number }[] = []; ink.forEach(i => { @@ -129,7 +127,7 @@ export class FormatShapePane extends AntimodeMenu { const newY = ((doc.y || 0) - oldY) + (i.Y * (doc._height || 0)) / oldHeight; newPoints.push({ X: newX, Y: newY }); }); - doc.data = new InkField(newPoints); + Doc.GetProto(doc).data = new InkField(newPoints); } } }); @@ -142,9 +140,7 @@ export class FormatShapePane extends AntimodeMenu { this._lock && (i.rootDoc._width = (i.rootDoc._height / oldHeight * NumCast(i.rootDoc._width))); const doc = Document(i.rootDoc); if (doc.type === DocumentType.INK && doc.x && doc.y && doc._height && doc._width) { - console.log(doc.x, doc.y, doc._height, doc._width); const ink = Cast(doc.data, InkField)?.inkData; - console.log(ink); if (ink) { const newPoints: { X: number, Y: number }[] = []; ink.forEach(i => { @@ -153,7 +149,7 @@ export class FormatShapePane extends AntimodeMenu { const newY = ((doc.y || 0) - oldY) + (i.Y * (doc._height || 0)) / oldHeight; newPoints.push({ X: newX, Y: newY }); }); - doc.data = new InkField(newPoints); + Doc.GetProto(doc).data = new InkField(newPoints); } } }); @@ -179,7 +175,7 @@ export class FormatShapePane extends AntimodeMenu { const spNum = Math.floor(counter / 2) * 4 + 2; for (var i = 0; i < spNum; i++) { - newPoints.push({ X: ink[i].X, Y: ink[i].Y }); + ink[i] && newPoints.push({ X: ink[i].X, Y: ink[i].Y }); } for (var j = 0; j < 4; j++) { newPoints.push({ X: x, Y: y }); @@ -189,7 +185,7 @@ export class FormatShapePane extends AntimodeMenu { newPoints.push({ X: ink[i].X, Y: ink[i].Y }); } this._currPoint = -1; - doc.data = new InkField(newPoints); + Doc.GetProto(doc).data = new InkField(newPoints); } } } @@ -206,25 +202,21 @@ export class FormatShapePane extends AntimodeMenu { const ink = Cast(doc.data, InkField)?.inkData; if (ink && ink.length > 4) { const newPoints: { X: number, Y: number }[] = []; - - console.log(ink.length, this._currPoint, Math.floor((this._currPoint + 2) / 4)); - const toRemove = Math.floor(((this._currPoint + 2) / 4)); for (var i = 0; i < ink.length; i++) { if (Math.floor((i + 2) / 4) !== toRemove) { - console.log(i, toRemove); newPoints.push({ X: ink[i].X, Y: ink[i].Y }); } } this._currPoint = -1; - doc.data = new InkField(newPoints); + Doc.GetProto(doc).data = new InkField(newPoints); if (newPoints.length === 4) { const newerPoints: { X: number, Y: number }[] = []; newerPoints.push({ X: newPoints[0].X, Y: newPoints[0].Y }); newerPoints.push({ X: newPoints[0].X, Y: newPoints[0].Y }); newerPoints.push({ X: newPoints[3].X, Y: newPoints[3].Y }); newerPoints.push({ X: newPoints[3].X, Y: newPoints[3].Y }); - doc.data = new InkField(newerPoints); + Doc.GetProto(doc).data = new InkField(newerPoints); } } @@ -267,7 +259,7 @@ export class FormatShapePane extends AntimodeMenu { const newY = Math.sin(angle) * (i.X - _centerPoints[index].X) + Math.cos(angle) * (i.Y - _centerPoints[index].Y) + _centerPoints[index].Y; newPoints.push({ X: newX, Y: newY }); }); - doc.data = new InkField(newPoints); + Doc.GetProto(doc).data = new InkField(newPoints); const xs = newPoints.map(p => p.X); const ys = newPoints.map(p => p.Y); const left = Math.min(...xs); @@ -317,7 +309,7 @@ export class FormatShapePane extends AntimodeMenu { const ys = ink.map(p => p.Y); const left = Math.min(...xs); const top = Math.min(...ys); - doc.data = new InkField(newPoints); + Doc.GetProto(doc).data = new InkField(newPoints); const xs2 = newPoints.map(p => p.X); const ys2 = newPoints.map(p => p.Y); const left2 = Math.min(...xs2); @@ -363,7 +355,7 @@ export class FormatShapePane extends AntimodeMenu { inputBox = (key: string, value: any, setter: (val: string) => {}) => { return <> setter(e.target.value)))} autoFocus /> {title2 === "" ? "" : <> setter2(e.target.value)} autoFocus />

; @@ -488,8 +479,6 @@ export class FormatShapePane extends AntimodeMenu { {this._fillBtn || this._lineBtn ? "" :
} {(this.solidStk || this.dashdStk) ? "Width" : ""} {(this.solidStk || this.dashdStk) ? this.stkInput : ""} - - {(this.solidStk || this.dashdStk) ? this.widthStk = e.target.value))} /> : (null)}
{(this.solidStk || this.dashdStk) ? <> @@ -499,10 +488,8 @@ export class FormatShapePane extends AntimodeMenu { this.markTail = this.markTail ? "" : "arrow"))} style={{ position: "absolute", right: 0, width: 20 }} />
: ""} - Dash: this.dashdStk = this.dashdStk === "2" ? "0" : "2"))} style={{ position: "absolute", right: 110, width: 20 }} /> - - - + Dash: + this.dashdStk = this.dashdStk === "2" ? "0" : "2"))} style={{ position: "absolute", right: 110, width: 20 }} /> ; -- cgit v1.2.3-70-g09d2