aboutsummaryrefslogtreecommitdiff
path: root/src/client/util
diff options
context:
space:
mode:
authoreleanor-park <eleanor_park@brown.edu>2024-09-22 15:40:19 -0400
committereleanor-park <eleanor_park@brown.edu>2024-09-22 15:40:19 -0400
commit692076b1356309111c4f2cb69cbdbf4be1a825bd (patch)
tree5f93b482c0263907b3e53573a6ec89f88bbd01ce /src/client/util
parent7f4d53ce9f8cf3932b627ab063855e3323cc3dc2 (diff)
small bug fixes for smart draw
Diffstat (limited to 'src/client/util')
-rw-r--r--src/client/util/Scripting.ts4
-rw-r--r--src/client/util/bezierFit.ts4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/client/util/Scripting.ts b/src/client/util/Scripting.ts
index c63d3d7cb..cb314e3f1 100644
--- a/src/client/util/Scripting.ts
+++ b/src/client/util/Scripting.ts
@@ -1,7 +1,7 @@
// export const ts = (window as any).ts;
// import * as typescriptlib from '!!raw-loader!../../../node_modules/typescript/lib/lib.d.ts'
// import * as typescriptes5 from '!!raw-loader!../../../node_modules/typescript/lib/lib.es5.d.ts'
-import typescriptlib from 'type_decls.d';
+// import typescriptlib from 'type_decls.d';
import * as ts from 'typescript';
import { Doc, FieldType } from '../../fields/Doc';
import { RefField } from '../../fields/RefField';
@@ -248,7 +248,7 @@ export function CompileScript(script: string, options: ScriptOptions = {}): Comp
const funcScript = `(function(${paramString})${reqTypes} { ${body} })`;
host.writeFile('file.ts', funcScript);
- if (typecheck) host.writeFile('node_modules/typescript/lib/lib.d.ts', typescriptlib);
+ // if (typecheck) host.writeFile('node_modules/typescript/lib/lib.d.ts', typescriptlib);
const program = ts.createProgram(['file.ts'], {}, host);
const testResult = program.emit();
const outputText = host.readFile('file.js');
diff --git a/src/client/util/bezierFit.ts b/src/client/util/bezierFit.ts
index 4c7f4a0ba..4aef28e6b 100644
--- a/src/client/util/bezierFit.ts
+++ b/src/client/util/bezierFit.ts
@@ -696,7 +696,7 @@ export function SVGToBezier(name: SVGType, attributes: any): Point[] {
const matches: RegExpMatchArray[] = Array.from(
attributes.d.matchAll(/Q(-?\d+\.?\d*),(-?\d+\.?\d*) (-?\d+\.?\d*),(-?\d+\.?\d*)|C(-?\d+\.?\d*),(-?\d+\.?\d*) (-?\d+\.?\d*),(-?\d+\.?\d*) (-?\d+\.?\d*),(-?\d+\.?\d*)|L(-?\d+\.?\d*),(-?\d+\.?\d*)/g)
);
- let lastPt: Point = { X: 0, Y: 0 };
+ let lastPt: Point = startPt;
matches.forEach(match => {
if (match[0].startsWith('Q')) {
coordList.push({ X: parseInt(match[1]), Y: parseInt(match[2]) });
@@ -711,7 +711,7 @@ export function SVGToBezier(name: SVGType, attributes: any): Point[] {
coordList.push({ X: parseInt(match[9]), Y: parseInt(match[10]) });
lastPt = { X: parseInt(match[9]), Y: parseInt(match[10]) };
} else {
- coordList.push(lastPt || { X: parseInt(startPt[1]), Y: parseInt(startPt[2]) });
+ coordList.push(lastPt);
coordList.push({ X: parseInt(match[11]), Y: parseInt(match[12]) });
coordList.push({ X: parseInt(match[11]), Y: parseInt(match[12]) });
coordList.push({ X: parseInt(match[11]), Y: parseInt(match[12]) });