diff --git a/.gitignore b/.gitignore index 50494cb..5768aa4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ node_modules .vscode-test/ *.vsix examples.txt +.DS_Store + diff --git a/.vscode/settings.json b/.vscode/settings.json index ffeaf91..843f267 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,22 @@ // Place your settings in this file to overwrite default and user settings. { "files.exclude": { - "out": false // set this to true to hide the "out" folder with the compiled JS files + "**/*.vo": true, + "**/*.vok": true, + "**/*.vos": true, + "**/*.aux": true, + "**/*.glob": true, + "**/.git": true, + "**/.svn": true, + "**/.hg": true, + "**/CVS": true, + "**/.DS_Store": true, + "**/Thumbs.db": true, + "**/.classpath": true, + "**/.project": true, + "**/.settings": true, + "**/.factorypath": true, + "out": false }, "search.exclude": { "out": true // set this to false to include "out" folder in search results diff --git a/package.json b/package.json index 15d2e31..e01ce74 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vizx", "displayName": "ViZX", "description": "Visualizer for the ZX calculus", - "version": "0.1.2", + "version": "0.1.3", "repository": "https://github.com/inQWIRE/ViZX/", "publisher": "inQWIRE", "engines": { @@ -21,27 +21,19 @@ "commands": [ { "command": "vizx.render", - "title": "Render expressions with ViZX" - }, - { - "command": "vizx.scaleUp", - "title": "Scale size of diagrams UP" - }, - { - "command": "vizx.scaleDown", - "title": "Scale size of diagrams DOWN" + "title": "ZXViz: Render expressions with ZXViz" }, { "command": "vizx.lspRender", - "title": "Render expressions with ViZX using CoqLSP information" + "title": "ZXViz: Render expressions with ZXViz using CoqLSP information" }, { "command": "vizx.activateRendering", - "title": "Activate ZXViz automatic rendering" + "title": "ZXViz: Activate ZXViz automatic rendering" }, { "command": "vizx.deactivateRendering", - "title": "Deactivate ZXViz automatic rendering" + "title": "ZXViz: Deactivate ZXViz automatic rendering" } ] }, diff --git a/src/constants/variableconsts.ts b/src/constants/variableconsts.ts index caf46e4..67d3536 100644 --- a/src/constants/variableconsts.ts +++ b/src/constants/variableconsts.ts @@ -1,47 +1,3 @@ -export function scaleUp() { - SCALE = SCALE * 1.1; - CANVAS_WIDTH = CANVAS_WIDTH * 1.1; - CANVAS_HEIGHT = CANVAS_HEIGHT * 1.1; - BASE_SIZE = 1 * SCALE; - PAD_SIZE = 0.1 * SCALE; - PROPTO_SIZE = 0.2 * SCALE; - CAST_SIZE = 0.3 * SCALE; - TEXT_PAD_SIZE = 0.08 * SCALE; - DOTS_PAD_SIZE = 0.1 * SCALE; - FUNC_ARG_SIZE = 0.7 * SCALE; - REALLY_SMALL_TEXT = (SCALE / 15).toString().concat("px"); - SMALL_TEXT = (SCALE / 10).toString().concat("px"); - MEDIUM_TEXT = (SCALE / 7).toString().concat("px"); - LARGE_TEXT = (SCALE / 2).toString().concat("px"); - STACK_DASH = [0.06 * SCALE, 0.06 * SCALE]; - COMPOSE_DASH = [0.16 * SCALE, 0.16 * SCALE]; - CAST_DASH = [0.02 * SCALE, 0.02 * SCALE]; - PROPTO_DASH = [0.005 * SCALE, 0.005 * SCALE]; - FUNCTION_DASH = [0.03 * SCALE, 0.01 * SCALE]; -} - -export function scaleDown() { - SCALE = SCALE * 0.9; - CANVAS_WIDTH = CANVAS_WIDTH * 0.9; - CANVAS_HEIGHT = CANVAS_HEIGHT * 0.9; - BASE_SIZE = 1 * SCALE; - PAD_SIZE = 0.1 * SCALE; - PROPTO_SIZE = 0.2 * SCALE; - CAST_SIZE = 0.3 * SCALE; - TEXT_PAD_SIZE = 0.08 * SCALE; - DOTS_PAD_SIZE = 0.1 * SCALE; - FUNC_ARG_SIZE = 0.7 * SCALE; - REALLY_SMALL_TEXT = (SCALE / 15).toString().concat("px"); - SMALL_TEXT = (SCALE / 10).toString().concat("px"); - MEDIUM_TEXT = (SCALE / 7).toString().concat("px"); - LARGE_TEXT = (SCALE / 2).toString().concat("px"); - STACK_DASH = [0.06 * SCALE, 0.06 * SCALE]; - COMPOSE_DASH = [0.16 * SCALE, 0.16 * SCALE]; - CAST_DASH = [0.02 * SCALE, 0.02 * SCALE]; - PROPTO_DASH = [0.005 * SCALE, 0.005 * SCALE]; - FUNCTION_DASH = [0.03 * SCALE, 0.01 * SCALE]; -} - export let CANVAS_WIDTH = 100; export let CANVAS_HEIGHT = 100; @@ -55,11 +11,11 @@ export let CAST_SIZE = 0.3 * SCALE; export let TEXT_PAD_SIZE = 0.08 * SCALE; export let DOTS_PAD_SIZE = 0.1 * SCALE; export let FUNC_ARG_SIZE = 0.7 * SCALE; -export let REALLY_SMALL_TEXT = (SCALE / 15).toString().concat("px"); -export let SMALL_TEXT = (SCALE / 10).toString().concat("px"); -export let MEDIUM_TEXT = (SCALE / 7).toString().concat("px"); -export let LARGE_TEXT = (SCALE / 2).toString().concat("px"); -export let MONOSPACE_FONT = "Monospace"; +export let REALLY_SMALL_TEXT = (SCALE / 10).toString().concat("px"); +export let SMALL_TEXT = (SCALE / 8).toString().concat("px"); +export let MEDIUM_TEXT = (SCALE / 5).toString().concat("px"); +export let LARGE_TEXT = (SCALE / 2.5).toString().concat("px"); +export let MONOSPACE_FONT = "Helvetica"; export let ARIAL_FONT = "Arial"; export let HOR_PAD = 0.1 * SCALE; export let VER_PAD = 0.1 * SCALE; diff --git a/src/extension.ts b/src/extension.ts index 5d9fd3d..5ae234b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -7,8 +7,6 @@ import * as coord from "./parsing/coords"; import { boundary, setCanvasWidthHeight, - scaleUp, - scaleDown, } from "./constants/variableconsts"; import * as vconsts from "./constants/variableconsts"; import * as ast from "./parsing/ast"; @@ -51,30 +49,6 @@ export function activate(context: vscode.ExtensionContext) { } ); context.subscriptions.push(disposable); - disposable = vscode.commands.registerCommand("vizx.scaleUp", () => { - scaleUp(); - console.log( - "SCALE: ", - vconsts.SCALE, - " HEIGHT: ", - vconsts.CANVAS_HEIGHT, - "WIDTH: ", - vconsts.CANVAS_WIDTH - ); - }); - context.subscriptions.push(disposable); - disposable = vscode.commands.registerCommand("vizx.scaleDown", () => { - scaleDown(); - console.log( - "SCALE: ", - vconsts.SCALE, - " HEIGHT: ", - vconsts.CANVAS_HEIGHT, - "WIDTH: ", - vconsts.CANVAS_WIDTH - ); - }); - context.subscriptions.push(disposable); } function renderCallback(context: vscode.ExtensionContext, expr: any) { diff --git a/src/rendering/render.ts b/src/rendering/render.ts index 40facd9..8f3a8f7 100644 --- a/src/rendering/render.ts +++ b/src/rendering/render.ts @@ -399,7 +399,7 @@ function drawBaseNode(node: ast.ASTNode) { ctx.save(); ctx.translate(right.x - TEXT_PAD_SIZE, right.y); max_width = undefined; - if (outputs.length > 4) { + if (outputs.length > 2) { ctx.rotate(-Math.PI / 2); max_width = node.ver_len! - 2 * TEXT_PAD_SIZE; } @@ -430,7 +430,7 @@ function drawBaseNode(node: ast.ASTNode) { ctx.save(); max_width = undefined; ctx.translate(left.x + TEXT_PAD_SIZE, left.y); - if (inputs.length > 4) { + if (inputs.length > 2) { max_width = node.ver_len! - 2 * TEXT_PAD_SIZE; ctx.rotate(Math.PI / 2); }