Skip to content

Commit

Permalink
Merge pull request #19 from inQWIRE/bhakti-branch
Browse files Browse the repository at this point in the history
font changes from monospace to arial, + sizing changes
  • Loading branch information
bhaktishh authored Nov 14, 2023
2 parents 23067e5 + 71faf69 commit 89ce033
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 91 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ node_modules
.vscode-test/
*.vsix
examples.txt
.DS_Store

17 changes: 16 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 5 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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"
}
]
},
Expand Down
54 changes: 5 additions & 49 deletions src/constants/variableconsts.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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;
Expand Down
26 changes: 0 additions & 26 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/rendering/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 89ce033

Please sign in to comment.