From a12e2003c731910f3bb986bdf35ceb9a57f20168 Mon Sep 17 00:00:00 2001 From: Dan MacKinnon Date: Thu, 15 May 2025 10:12:08 -0400 Subject: [PATCH 1/9] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a4ecf53..1acbb1a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ -# celtic +# celticbook +A LaTeX learning project. The plan (not currently executed) is to create a book similar to dmackinnon1/Truchet-Book that covers some small +set of celtic patterns created using the grid method. + +## Original notes (dmackinnon1/celtic) Generator and editors for Celtic Knot patterns. Please see the live example here: https://dmackinnon1.github.io/celtic. See these blog posts: From b028158e629ec55a49ddc6b4bee5c9cb67f898af Mon Sep 17 00:00:00 2001 From: Dan MacKinnon Date: Tue, 24 Jun 2025 15:49:47 -0400 Subject: [PATCH 2/9] refactor --- .idea/.gitignore | 8 + .idea/celticbook.iml | 12 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + celtic/celtic.js | 1784 ++++++++++++++++++++++++++++++++++ ch1_generated_files/0000.tex | 34 + ch1_generated_files/0001.tex | 30 + ch1_generated_files/0002.tex | 30 + ch1_generated_files/0011.tex | 26 + ch1_generated_files/0012.tex | 26 + ch1_generated_files/0022.tex | 26 + ch1_generated_files/0111.tex | 22 + ch1_generated_files/0112.tex | 22 + ch1_generated_files/0122.tex | 22 + ch1_generated_files/0222.tex | 22 + ch1_generated_files/1111.tex | 18 + ch1_generated_files/1112.tex | 18 + ch1_generated_files/1122.tex | 18 + ch1_generated_files/1222.tex | 18 + ch1_generated_files/2222.tex | 18 + ch1_list.tex | 31 + index.html | 16 +- index.js | 199 ++++ js/bldrs.js | 58 -- js/celtic_base.js | 395 -------- js/celtic_calc.js | 526 ---------- js/celtic_display.js | 546 ----------- js/celtic_editor.js | 157 --- js/evnts.js | 23 - js/latex-builders.js | 168 ---- js/tikZBldr.js | 77 -- test.html | 68 -- 32 files changed, 2406 insertions(+), 2026 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/celticbook.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 celtic/celtic.js create mode 100644 ch1_generated_files/0000.tex create mode 100644 ch1_generated_files/0001.tex create mode 100644 ch1_generated_files/0002.tex create mode 100644 ch1_generated_files/0011.tex create mode 100644 ch1_generated_files/0012.tex create mode 100644 ch1_generated_files/0022.tex create mode 100644 ch1_generated_files/0111.tex create mode 100644 ch1_generated_files/0112.tex create mode 100644 ch1_generated_files/0122.tex create mode 100644 ch1_generated_files/0222.tex create mode 100644 ch1_generated_files/1111.tex create mode 100644 ch1_generated_files/1112.tex create mode 100644 ch1_generated_files/1122.tex create mode 100644 ch1_generated_files/1222.tex create mode 100644 ch1_generated_files/2222.tex create mode 100644 ch1_list.tex create mode 100644 index.js delete mode 100644 js/bldrs.js delete mode 100644 js/celtic_base.js delete mode 100644 js/celtic_calc.js delete mode 100644 js/celtic_display.js delete mode 100644 js/celtic_editor.js delete mode 100644 js/evnts.js delete mode 100644 js/latex-builders.js delete mode 100644 js/tikZBldr.js delete mode 100644 test.html diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/celticbook.iml b/.idea/celticbook.iml new file mode 100644 index 0000000..24643cc --- /dev/null +++ b/.idea/celticbook.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..84ed080 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/celtic/celtic.js b/celtic/celtic.js new file mode 100644 index 0000000..58df360 --- /dev/null +++ b/celtic/celtic.js @@ -0,0 +1,1784 @@ +"use strict"; +/** + * Builders to be used for HTML construction. + * + */ +class Bldr { + constructor(name) { + this.name = name; + this.attributes = []; + this.elements = []; + } + att(name, value) { + let att = new Attribute(name, value); + this.attributes.push(att); + return this; + } + // add element allows you to add a builder to a builder + elem(bldr) { + this.elements.push(bldr); + return this; + } + text(text) { + this.elements.push (new RawHtml(text)); + return this; + } + build() { + let s = "<" + this.name; + for(let i = 0; i< this.attributes.length; i++) { + s += " " + this.attributes[i].toString(); + } + s += ">"; + for(let i = 0; i< this.elements.length; i++) { + s += " " + this.elements[i].build(); + } + s += ""; + return s; + } +}; + +class Attribute { + constructor(name, value) { + this.name = name; + this.value = value; + } + + toString() { + return "" + this.name + "='" + this.value + "'"; + } +}; + +class RawHtml { + constructor(raw) { + this.raw = raw; + } + build() { + return this.raw; + } +}; + + +/** + * Builders to be used for LaTeX construction. + * + */ + +class LaTeXEnv { + + constructor(l=null){ + this.label = l; + this.b = null; + this.content = []; + this.parent = null; + } + + begin(tag){ + this.b = tag; + return this; + } + + p(text){ + this.content.push(new LaTeXParagraph(text)); + return this; + } + + env(label){ + let environ = new LaTeXEnv(label); + this.content.push(environ); + return environ; + } + + command(c,a, nl=false){ + this.content.push(new LaTeXCommand(c,a, nl)); + return this; + } + + build(){ + let result = ""; + if (this.label != null){ + result += "%" + this.label + " \n"; + } + if (this.b !== null){ + result += "\\begin{" + this.b + "}\n"; + } + for (let i in this.content){ + result += this.content[i].build(); + } + if (this.b !== null){ + result += "\\end{" + this.b + "}\n"; + } + return result; + } +} + +class LaTeXCommand{ + constructor(c, a=null, nl=false){ + this.command = c; + this.argument = a; + this.newline = nl; + } + + build(){ + let result = "\\" + this.command; + if (this.argument !== null){ + result += "{" + this.argument + "}"; + } + if (this.newline){ + result +="\n"; + } + return result; + } + +} + +class LaTeXParagraph { + constructor(t, lb=false){ + this.text = t; + this.linebreak = lb; + return this; + } + + build(){ + let result = "" + if (this.linebreak){ + result += "\n"; + } + result += this.text; + if (this.linebreak){ + result += "\\\\"; + result += "\n "; + } + return result; + } +} + +class LaTeXDoc { + constructor(dc = "article"){ + this.content = []; + this.packages = []; + this.documentclass = dc; + } + clear(){ + this.content = []; + this.packages = []; + } + env(label){ + let environ = new LaTeXEnv(label); + this.content.push(environ); + environ.parent = this; + return environ; + } + p(content, lb=false){ + this.content.push(); + return this; + } + command(c,a){ + this.content.push(new LaTeXCommand(c,a)); + return this; + } + + package(name, arg = null){ + this.packages.push(new LaTeXPackage(name,arg)); + return this; + } + + defaultPackages(){ + this.package("inputenc","utf8"); + return this; + } + + frontMatter(){ + let fm = "\\documentclass{" + this.documentclass + "}\n"; + for (let i in this.packages){ + fm += this.packages[i].build() + "\n"; + } + return fm; + } + + input(fileName){ + let s = new LaTeXCommand("input", fileName, true); + this.content.push(s); + return this; + } + + build(){ + let result = this.frontMatter(); + for (let i in this.content){ + result += this.content[i].build() + "\n"; + } + return result; + } + +} +class LaTeXPackage { + constructor(n, a = null){ + this.name = n; + this.argument = a; + } + build(){ + let result = "\\usepackage"; + if (this.argument != null){ + result += "["+this.argument +"]"; + } + result += "{" + this.name + "}"; + return result; + } +} + +//for node export +try{ + module.exports = new LaTeXDoc(); +} catch(err){ + console.log("non-node execution context"); +} + +"use strict"; + +class TikZBuilder { + + constructor(){ + this.components = []; + } + + build(){ + let s = this.buildOpen(); + + for(let c in this.components) { + s += " " + this.components[c].build(); + } + + s += this.buildClose(); + return s; + } + + buildOpen(){ + let s = ""; + s+= "\\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}]\n"; + return s; + } + + buildClose(){ + let s = ""; + s += "\\end{tikzpicture} \n"; + return s; + } + + addLine(x1, y1, x2, y2){ + let start = new TikZPoint(x1, y1); + let end = new TikZPoint(x2,y2); + this.components.push(new TikZLine(start,end)); + } +} + +class TikZComponent { + + constructor(){ + this.body = ""; + } + + build(){ + return this.body; + } +} + +class TikZLine extends TikZComponent { + + constructor(s, e){ + super(); + this.start = s; + this.end = e; + } + + build(){ + let s = "\\draw [line width=3pt, line cap=round] " + this.start.build() + " -- " + this.end.build() + "; \n" + return s; + } +} + +class TikZPoint { + constructor(x,y){ + this.x = x; + this.y = y; + } + + build(){ + return "(" + this.x + "," + this.y + ")"; + } + +} + + +/* +* A point on the primary grid. +*/ +class Point{ + constructor(x,y,grid){ + this.x = x; + this.y = y; + this.grid = grid; + this.junctions=[]; + this.decorator = null; + } + + setDecorator(d){ + this.decorator = d; + return this; + } + + distance(point){ + return Math.sqrt(Math.pow((this.x - point.x),2) + Math.pow((this.y - point.y), 2)); + } + west(){ + if (this.x == 0) return null; + return this.grid.primaryGrid[this.x-1][this.y] + } + east(){ + if (this.x == this.grid.xdim-1) return null; + return this.grid.primaryGrid[this.x+1][this.y] + } + north(){ + if (this.y == 0) return null; + return this.grid.primaryGrid[this.x][this.y-1] + } + south(){ + if (this.y == this.grid.ydim-1) return null; + return this.grid.primaryGrid[this.x][this.y+1] + } + junction(junction){ + this.junctions.push(junction); + } + + hasNSJunction(){ + if (this.junctions.length == 0) return false; + for (let j in this.junctions){ + if (this.junctions[j].dir =="NS") return true; + } + return false; + } + + hasEWJunction(){ + if (this.junctions.length == 0) return false; + for (let j in this.junctions){ + if (this.junctions[j].dir =="EW") return true; + } + return false; + } + isEven(){ + return this.x%2==0; + } + + isOdd(){ + return !this.isEven(); + } + + isOnSecondary(){ + return (this.x%2==0 && this.y%2 ==0)||(this.x%2==1 && this.y%2 ==1); + } +} + + +/* +* Points on the secondary grid play a different role, they +* have polygons drawn on them and are the connectors for the secondary lines. +*/ +class Node extends Point { + constructor(x,y,grid){ + super(x,y,grid); + } + + directionalRelationship(other){ + if (this.x == other.x){ + return "NS"; + } + if (this.y == other.y){ + return "EW"; + } + return null; + } + + isNodeNeighbor(node){ + if (this.distance(node) == 2){ + return true; + } + return false; + } + + isNorthNeighbor(node){ + return (this.isNodeNeighbor(node) && this.y == (node.y+2)); + } + + isSouthNeighbor(node){ + return (this.isNodeNeighbor(node) && this.y == (node.y-2)); + } + + isEastNeighbor(node){ + return (this.isNodeNeighbor(node) && this.x == (node.x-2)); + } + + isWestNeighbor(node){ + return (this.isNodeNeighbor(node) && this.x == (node.x+2)); + } + + northNorth(){ + if (this.north()!= null){ + return this.north().north(); + } + return null; + } + + southSouth(){ + if (this.south()!= null){ + return this.south().south(); + } + return null; + } + + westWest(){ + if (this.west()!= null){ + return this.west().west(); + } + return null; + } + + eastEast(){ + if (this.east()!= null){ + return this.east().east(); + } + return null; + } + + hasNSJunction(){ + if (this.north() !== null && this.north().hasNSJunction()){ + return true; + } + if (this.south() !== null && this.south().hasNSJunction()){ + return true; + } + return false; + } + + hasEWJunction(){ + if (this.east() !== null && this.east().hasEWJunction()){ + return true; + } + if (this.west() !== null && this.west().hasEWJunction()){ + return true; + } + return false; + } + + hasJunction(){ + return this.hasNSJunction() || this.hasEWJunction(); + } + + getOneStepConnected(){ + let connected = [this]; + if (this.north() !== null && this.north().hasNSJunction()){ + connected.push(this.northNorth()); + } + if (this.south() !== null && this.south().hasNSJunction()){ + connected.push(this.southSouth()); + } + if (this.east() !== null && this.east().hasEWJunction()){ + connected.push(this.eastEast()); + } + if (this.west() !== null && this.west().hasEWJunction()){ + connected.push(this.westWest()); + } + return connected; + } + + getFullConnected(){ + let connectedSet = new Set(this.getOneStepConnected()); + let currentSize = connectedSet.size; + let nextSet = new Set(connectedSet); + do { + connectedSet = new Set(nextSet); + connectedSet.forEach(function(value1, value2, set){ + let others = value2.getOneStepConnected(); + for (let x in others){ + nextSet.add(others[x]); + } + }); + } while (nextSet.size != connectedSet.size); + return nextSet; + } +} + +/* +* A connector between two secondary nodes, passes through +* a primary node. +*/ +class Junction { + constructor(sourceNode, medianPoint, targetNode, dir){ + this.sourceNode = sourceNode; + this.targetNode = targetNode; + this.medianPoint = medianPoint; + this.dir = dir; + medianPoint.junction(this); + } +} + +/* +* A helper class used to draw junctions in scripts. +*/ +class JunctionEnd { + constructor(grid, x, y){ + this.grid = grid; + this.x = x; + this.y = y; + } + + to(otherX, otherY){ + let p1 = new Point(this.x, this.y); + let p2 = new Point(otherX, otherY); + this.grid.boxFrame(p1,p2); + } +} + +/* +* The main class for the knot - consists of +* primary and secondary grids of points and knots, and junctions +* between them. +*/ +class Grid { + constructor(ydim, xdim){ + this.ydim = 2*ydim - 1; + this.xdim = 2*xdim - 1; + this.primaryGrid = []; + this.secondaryGrid = []; + this.nodes = []; + this.points = []; + this.junctions = []; + } + + initialize(){ + //set up points + for (let i = 0; i < this.xdim; i++){ + this.primaryGrid[i] = [] + this.secondaryGrid[i] = []; + for (let j= 0; j < this.ydim; j++){ + let p = new Point(i,j, this); + this.primaryGrid[i][j] = p; + this.points.push(p) + if ((i%2==0 && j%2 ==0)||(i%2==1 && j%2 ==1)){ + let n = new Node(i,j, this); + this.nodes.push(n); + this.secondaryGrid[i][j] = n; + this.primaryGrid[i][j] = n + } + } + } + return this; + } + + //used to draw junctions in scripts + from(x, y){ + return new JunctionEnd(this, x, y); + } + + boxFrame(p1, p2){ + let xMax = Math.max(p1.x,p2.x); + let xMin = Math.min(p1.x,p2.x); + let yMin = Math.min(p1.y,p2.y); + let yMax = Math.max(p1.y,p2.y); + + //only form a frame if both frames are same mod 2 + if ((p1.isEven() && p2.isOdd())||(p1.isOdd()&&p2.isEven())){ + return; + } + + for (let i = xMin; i < xMax; i = i+2){ + let node = this.secondaryGrid[i][yMin]; + if (node == undefined) break; + if (node.east() == null || node.eastEast() == null) break; + if (node.east().junctions.length!=0) continue; + let junction = new Junction(node, node.east(), node.eastEast(), "EW"); + this.junctions.push(junction); + } + for (let i = xMin; i < xMax; i = i+2){ + let node = this.secondaryGrid[i][yMax]; + if (node == undefined) break; + if (node.east() == null || node.eastEast() == null) break; + if (node.east().junctions.length!=0) continue; + let junction = new Junction(node, node.east(), node.eastEast(), "EW"); + this.junctions.push(junction); + } + for (let i = yMin; i < yMax; i = i+2){ + let node = this.secondaryGrid[xMin][i]; + if (node == undefined) break; + if (node.south() == null || node.southSouth() == null) break; + if (node.south().junctions.length!=0) continue; + let junction = new Junction(node, node.south(), node.southSouth(), "NS"); + this.junctions.push(junction); + } + for (let i = yMin; i < yMax ; i = i+2){ + let node = this.secondaryGrid[xMax][i]; + if (node == undefined) break; + if (node.south() == null || node.southSouth() == null) break; + if (node.south().junctions.length!=0) continue; + let junction = new Junction(node, node.south(), node.southSouth(), "NS"); + this.junctions.push(junction); + } + return this; + } + + borders(){ + return this.boxFrame(new Point(0,0), new Point(this.xdim-1, this.ydim-1)); + } + + innerFrame(step){ + return this.boxFrame(new Point(2*step,2*step), new Point(this.xdim-(2*step +1), this.ydim-(2*step + 1))); + } + + nodeAt(x,y){ + return this.secondaryGrid[x][y]; + } + + pointAt(x,y){ + return this.primaryGrid[x][y]; + } + + removeJunctionAt(i,j){ + let selected = this.pointAt(i,j); + if (i == this.xdim -1 || j == this.ydim -1 || i == 0 || j == 0){ + return; + } + if (selected.junctions.length == 0){ + return; + } + for (let k in selected.junctions){ + let jr = selected.junctions[k]; + this.junctions.splice(this.junctions.indexOf(jr),1); + } + selected.junctions = []; + } + + randomLines(probability = 50){ + //random lines + for (let n in this.nodes){ + let node = this.nodes[n]; + let junction = null; + if (randomInt(100) > probability) continue; + let r = randomInt(4); + if (r == 0) { + if (node.south() != null && node.southSouth() != null) { + if (node.south().junctions.length==0){ + junction = new Junction(node, node.south(), node.southSouth(), "NS"); + this.junctions.push(junction); + } else { + this.removeJunctionAt(node.south().x, node.south().y); + } + } + } else if (r == 1){ + if (node.east() != null && node.eastEast() != null){ + if (node.east().junctions.length==0){ + junction = new Junction(node, node.east(), node.eastEast(), "EW"); + this.junctions.push(junction); + } else { + this.removeJunctionAt(node.east().x, node.east().y); + } + } + } else if (r == 2){ + if (node.north() != null && node.northNorth() != null && node.north().junctions.length==0){ + junction = new Junction(node, node.north(), node.northNorth(),"NS"); + this.junctions.push(junction); + } + } else { + if (node.west() != null && node.westWest() != null && node.west().junctions.length==0){ + junction = new Junction(node, node.west(), node.westWest(),"EW"); + this.junctions.push(junction); + } + } + } + return this; + } +} + +//randomization utility +function randomInt(lessThan){ + let r = Math.floor(Math.random()*lessThan); + return r; +}; + +"use strict"; +/** + * Classes and functions in this script file are to provide + * decorative renderings of knots - dependencies is on celtic_base.celtic and bldrs.celtic. + * + * + * KnotDisplay classes provide different ways of displaying + * the knot defined by a Grid object. They use DisplayData objects + * to store display information about the grid before generating + * svg representations. + * + * KnotDisplay - just shows the raw primary and secondary grid + * and any junctions between secondary grid points. + * + * BasicKnotDisplay & DisplayData - draws a primitive knot pattern using the + * 'negative space' algorithm, which makes secondary points into + * gaps between the knot bands and draws gaps where the bands + * overlap. + * + * BeveledKnotDisplay & BeveledDisplayData - follows the + * 'negative space' algorithm but truncates the polygons drawn at + * secondary points so that the knot bands appear to bend. + * + * PositiveKnotDisplay PositiveDisplayData- folllows the 'positive space' + * algorithm, drawing lines and circles between the secondary points. + * + * RibbonKnotDisplay - adds multiple layers of thhe 'positive space' + * algorithm. + */ +class KnotDisplay { + + constructor(g, scale,foreground = "white", background = "black"){ + this.g = g; + this.scale = scale; + this.foregroundColor = foreground; + this.backgroundColor = background; + this.edge = scale/8; + this.junctionMultiplier = 2; + } + + init(){ + let height = (this.g.ydim-1)*this.scale; + let width = (this.g.xdim -1)*this.scale; + this.svgBldr = new Bldr("svg"); + this.svgBldr.att("version", "1.1").att("xmlns", "http://www.w3.org/2000/svg").att("xmlns:xlink", "http://www.w3.org/1999/xlink"); + this.svgBldr.att("align", "center").att("width", width).att("height", height); + this.svgBldr.elem(new Bldr("rect").att("width", width).att("height",height).att("fill",this.foregroundColor)); + return this; + } + + build(){ + this.buildStructure(); + this.buildSVG(); + return this.svgBldr.build(); + } + + + buildStructure(){ + //no calculation required + } + + buildSVG(){ + this.junctions(); + this.secondaryGrid(); + this.primaryGrid(); + + } + + primaryGrid(){ + for (let p in this.g.points){ + let point = this.g.points[p]; + let dot = new Bldr("circle").att("cx",point.x*this.scale).att("cy", point.y*this.scale); + dot.att("r",this.scale/8).att("stroke-width",0).att("fill","grey"); + this.svgBldr.elem(dot); + } + return this; + } + + secondaryGrid(){ + for (let p in this.g.nodes){ + let point = this.g.nodes[p]; + let dot = new Bldr("circle").att("cx",point.x*this.scale).att("cy", point.y*this.scale); + dot.att("r",this.scale/4).att("stroke-width",this.scale/8).att("fill",this.backgroundColor); + this.svgBldr.elem(dot); + } + return this; + } + + junctions(){ + for (let j in this.g.junctions){ + let junction = this.g.junctions[j]; + let line = new Bldr("line").att("x1", junction.sourceNode.x*this.scale).att("y1", junction.sourceNode.y*this.scale) + .att("x2", junction.targetNode.x*this.scale).att("y2", junction.targetNode.y*this.scale); + line.att("stroke-width",this.edge*this.junctionMultiplier).att("stroke", this.backgroundColor) + .att("stroke-linecap","round"); + this.svgBldr.elem(line); + } + return this; + } +} + +/* +* A helper for drawing SVG lines. Expects two points to connect. +*/ +class Line { + constructor(source, target){ + this.source = source; + this.target = target; + this.decorator - null; + } + setDecorator(d){ + this.decorator = d; + return this; + } +} + +class DisplayData { + constructor(){ + this.lines = []; + this.polygon = []; + } + + polyCalc(node){ + this.polygon = []; //reset polygon + this.polygon.push(new Point(node.x+(1/2),node.y)); + this.polygon.push(new Point(node.x, node.y+(1/2))); + this.polygon.push(new Point(node.x-(1/2), node.y)); + this.polygon.push(new Point(node.x, node.y-(1/2))); + } + + lineCalc(node){ + this.lines = []; + if (node.x%2==0){ + if (node.east() != null && node.east().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x+(1/2), node.y), + new Point(node.x+1, node.y-(1/2)))); + } + if (node.south() != null && node.south().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x, node.y+(1/2)), + new Point(node.x+(1/2), node.y +1))); + } + if (node.west() != null && node.west().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x-(1/2), node.y), + new Point(node.x-1, node.y +(1/2)))); + } + if (node.north() != null && node.north().junctions.length == 0) { + this.lines.push(new Line(new Point(node.x, node.y-(1/2)), + new Point(node.x-(1/2), node.y-1))); + } + } else { + if (node.east() != null && node.east().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x+(1/2), node.y), + new Point(node.x+1, node.y +(1/2)))); + } + if (node.south() != null && node.south().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x, node.y+(1/2)), + new Point(node.x-(1/2), node.y +1))); + } + if (node.west() !== null && node.west().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x-(1/2), node.y), + new Point(node.x-1, node.y -(1/2)))); + } + if (node.north() != null && node.north().junctions.length == 0) { + this.lines.push(new Line(new Point(node.x, node.y-(1/2)), + new Point(node.x+(1/2), node.y-1))); + } + } + } +} + +class BasicKnotDisplay extends KnotDisplay { + constructor(g, scale,foreground = "white", background = "black"){ + super(g, scale, foreground, background); + this.displayData = []; + } + + newDisplayData(){ + return new DisplayData(); + } + + buildStructure(){ + for(let n in this.g.nodes){ + let node = this.g.nodes[n]; + let d = this.newDisplayData(); + d.polyCalc(node); + d.lineCalc(node); + this.displayData.push(d); + } + } + + buildSVG(){ + this.nodes(); + this.junctions(); + this.lines(); + } + + nodes(){ + for (let n in this.displayData){ + let node = this.displayData[n]; + let plist = ""; + for (let p in node.polygon){ + let point = node.polygon[p]; + plist += "" + (point.x*this.scale) + "," +(point.y*this.scale) +" "; + } + let dot = new Bldr("polygon").att("points",plist); + dot.att("stroke-width",this.edge).att("fill",this.backgroundColor).att("stroke", this.backgroundColor); + this.svgBldr.elem(dot); + } + return this; + } + + junctions(){ + for (let j in this.g.junctions){ + let junction = this.g.junctions[j]; + let line = new Bldr("line").att("x1", junction.sourceNode.x*this.scale).att("y1", junction.sourceNode.y*this.scale) + .att("x2", junction.targetNode.x*this.scale).att("y2", junction.targetNode.y*this.scale); + line.att("stroke-width",this.edge*this.junctionMultiplier).att("stroke", this.backgroundColor) + .att("stroke-linecap","round"); + this.svgBldr.elem(line); + } + return this; + } + + lines(){ + for (let n in this.displayData){ + let node = this.displayData[n]; + for (let l in node.lines){ + let secLine = node.lines[l]; + let line = new Bldr("line").att("x1",secLine.source.x*this.scale) + .att("y1", secLine.source.y*this.scale) + .att("x2", secLine.target.x*this.scale) + .att("y2", secLine.target.y*this.scale) + .att("stroke-width",this.edge*1.1).att("stroke", this.backgroundColor) + .att("stroke-linecap","round"); + this.svgBldr.elem(line); + } + } + return this; + } +} + +class BeveledDisplayData extends DisplayData { + + constructor(){ + super(); + this.bevel = 1/4; + } + + polyCalc(node){ + this.polygon = []; //reset polygon + let sideCount = 0; + //north + if (node.north() != null && !node.north().hasEWJunction()){ + this.polygon.push(new Point(node.x, node.y - (1/2))); + } else { + sideCount ++; + this.polygon.push(new Point(node.x - this.bevel, node.y - this.bevel )); + this.polygon.push(new Point(node.x + this.bevel, node.y - this.bevel )); + } + //corner + if(node.north() != null && node.north().hasNSJunction() + && node.east() != null && node.east().hasEWJunction()){ + this.polygon.push(new Point(node.x, node.y)); + } + //east + if (node.east() != null && !node.east().hasNSJunction()){ + this.polygon.push(new Point(node.x + (1/2), node.y)); + } else { + sideCount ++; + this.polygon.push(new Point(node.x + this.bevel, node.y - this.bevel )); + this.polygon.push(new Point(node.x + this.bevel, node.y + this.bevel )); + } + //corner + if(node.east() != null && node.east().hasEWJunction() + && node.south() != null && node.south().hasNSJunction()){ + this.polygon.push(new Point(node.x, node.y)); + } + //south + if (node.south() != null && !node.south().hasEWJunction()){ + this.polygon.push(new Point(node.x, node.y+(1/2))); + } else { + sideCount ++; + this.polygon.push(new Point(node.x + this.bevel, node.y + this.bevel)); + this.polygon.push(new Point(node.x - this.bevel, node.y + this.bevel)); + } + //corner + if(node.south() != null && node.south().hasNSJunction() + && node.west() != null && node.west().hasEWJunction()){ + this.polygon.push(new Point(node.x, node.y)); + } + //west + if (node.west() != null && !node.west().hasNSJunction()){ + this.polygon.push(new Point(node.x - (1/2), node.y)); + } else { + sideCount ++; + this.polygon.push(new Point(node.x - this.bevel, node.y + this.bevel)); + this.polygon.push(new Point(node.x - this.bevel, node.y - this.bevel)); + } + //corner + if(node.west() != null && node.west().hasEWJunction() + && node.north() != null && node.north().hasNSJunction()){ + this.polygon.push(new Point(node.x, node.y)); + } + } + + +} + +class BeveledKnotDisplay extends BasicKnotDisplay { + + newDisplayData(){ + return new BeveledDisplayData(); + } +} + +class PositiveDisplayData extends DisplayData { + constructor(){ + super(); + this.circles = []; + } + + polyCalc(node){ + //do nothing + } + + lineCalc(node){ + this.lines = []; + if (node.x%2==0){ + if (node.east() != null && node.east().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x+1, node.y), + new Point(node.x+(1/2), node.y+(1/2)))); + } else if (node.east() != null && node.east().junctions.length != 0 && node.east().hasNSJunction()){ + this.lines.push(new Line(new Point(node.x+(1/2), node.y -(1/2)), + new Point(node.x+(1/2), node.y+(1/2)))); + this.circles.push(new Point(node.x+(1/2), node.y -(1/2))); + this.circles.push(new Point(node.x+(1/2), node.y+(1/2))); + if(node.south() != null && node.south().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x+(1/2), node.y+(1/2)), + new Point(node.x+(1/4), node.y+(3/4)))); + } + } + if (node.south() != null && node.south().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x, node.y+1), + new Point(node.x-(1/2), node.y +(1/2)))); + } else if (node.south() != null && node.south().junctions.length != 0 && node.south().hasEWJunction()){ + this.lines.push(new Line(new Point(node.x +(1/2), node.y+(1/2)), + new Point(node.x-(1/2), node.y +(1/2)))); + this.circles.push(new Point(node.x +(1/2), node.y+(1/2))); + this.circles.push(new Point(node.x-(1/2), node.y +(1/2))); + if (node.west() != null && node.west().junctions.length ==0){ + this.lines.push(new Line( new Point(node.x-(1/2), node.y +(1/2)), + new Point(node.x -(3/4), node.y+(1/4)))); + } + } + if (node.west() != null && node.west().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x-1, node.y), + new Point(node.x-(1/2), node.y - (1/2)))); + } else if (node.west() != null && node.west().junctions.length != 0 && node.west().hasNSJunction()) { + this.lines.push(new Line(new Point(node.x-(1/2), node.y +(1/2)), + new Point(node.x-(1/2), node.y - (1/2)))); + this.circles.push(new Point(node.x-(1/2), node.y +(1/2))); + this.circles.push(new Point(node.x-(1/2), node.y - (1/2))); + if (node.north!=null && node.north().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x-(1/2), node.y - (1/2)), + new Point(node.x-(1/4), node.y - (3/4)))); + } + } + if (node.north() != null && node.north().junctions.length == 0) { + this.lines.push(new Line(new Point(node.x, node.y-1), + new Point(node.x+(1/2), node.y-(1/2)))); + } else if (node.north() != null && node.north().junctions.length != 0 && node.north().hasEWJunction()){ + this.lines.push(new Line(new Point(node.x-(1/2), node.y-(1/2)), + new Point(node.x+(1/2), node.y-(1/2)))); + this.circles.push(new Point(node.x-(1/2), node.y -(1/2))); + this.circles.push(new Point(node.x+(1/2), node.y - (1/2))); + if (node.east()!=null && node.east().junctions.length==0){ + this.lines.push(new Line(new Point(node.x+(1/2), node.y-(1/2)), + new Point(node.x+(3/4), node.y-(1/4)))); + } + } + } else { + if (node.east() != null && node.east().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x+1, node.y), + new Point(node.x+(1/2), node.y-(1/2)))); + this.circles.push(new Point(node.x+(1/2), node.y -(1/2))); + if (node.north()!=null && node.north().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x+(1/2), node.y -(1/2)), + new Point(node.x+(1/4), node.y-(3/4)))); + } + } else if (node.east() != null && node.east().junctions.length != 0 && node.east().hasNSJunction()){ + this.lines.push(new Line(new Point(node.x+(1/2), node.y -(1/2)), + new Point(node.x+(1/2), node.y+(1/2)))); + this.circles.push(new Point(node.x+(1/2), node.y -(1/2))); + this.circles.push(new Point(node.x+(1/2), node.y +(1/2))); + if (node.north() != null && node.north().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x+(1/2), node.y -(1/2)), + new Point(node.x+(1/4), node.y-(3/4)))); + } + } + if (node.south() != null && node.south().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x, node.y+1), + new Point(node.x+(1/2), node.y +(1/2)))); + this.circles.push(new Point(node.x+(1/2), node.y +(1/2))); + if (node.east()!= null && node.east().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x+(1/2), node.y +(1/2)), + new Point(node.x+(3/4), node.y +(1/4)))); + } + } else if (node.south() != null && node.south().junctions.length != 0 && node.south().hasEWJunction()){ + this.lines.push(new Line(new Point(node.x +(1/2), node.y+(1/2)), + new Point(node.x-(1/2), node.y +(1/2)))); + this.circles.push(new Point(node.x+(1/2), node.y +(1/2))); + this.circles.push(new Point(node.x-(1/2), node.y +(1/2))); + if (node.east() != null && node.east().junctions.length ==0){ + this.lines.push(new Line(new Point(node.x +(1/2), node.y+(1/2)), + new Point(node.x+(3/4), node.y +(1/4)))); + } + } + if (node.west() != null && node.west().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x-1, node.y), + new Point(node.x-(1/2), node.y + (1/2)))); + this.circles.push(new Point(node.x-(1/2), node.y +(1/2))); + if (node.south()!=null && node.south().junctions.length ==0){ + this.lines.push(new Line(new Point(node.x-(1/2), node.y+(1/2)), + new Point(node.x-(1/4), node.y +(3/4)))); + } + } else if (node.west() != null && node.west().junctions.length != 0 && node.west().hasNSJunction()) { + this.lines.push(new Line(new Point(node.x-(1/2), node.y +(1/2)), + new Point(node.x-(1/2), node.y - (1/2)))); + this.circles.push(new Point(node.x-(1/2), node.y+(1/2))); + this.circles.push(new Point(node.x-(1/2), node.y-(1/2))); + if(node.south() !=null && node.south().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x-(1/2), node.y +(1/2)), + new Point(node.x-(1/4), node.y + (3/4)))); + } + } + if (node.north() != null && node.north().junctions.length == 0) { + this.lines.push(new Line(new Point(node.x, node.y-1), + new Point(node.x-(1/2), node.y-(1/2)))); + this.circles.push(new Point(node.x-(1/2), node.y -(1/2))); + if (node.west()!=null && node.west().junctions.length == 0){ + this.lines.push(new Line(new Point(node.x-(1/2), node.y-(1/2)), + new Point(node.x-(3/4), node.y-(1/4)))); + } + } else if (node.north() != null && node.north().junctions.length != 0 && node.north().hasEWJunction()){ + this.lines.push(new Line(new Point(node.x-(1/2), node.y-(1/2)), + new Point(node.x+(1/2), node.y-(1/2)))); + this.circles.push(new Point(node.x-(1/2), node.y -(1/2))); + this.circles.push(new Point(node.x+(1/2), node.y -(1/2))); + if (node.west()!= null && node.west().junctions.length ==0){ + this.lines.push(new Line(new Point(node.x-(1/2), node.y-(1/2)), + new Point(node.x-(3/4), node.y-(1/4)))); + } + } + } + } +} + +class PositiveKnotDisplay extends BasicKnotDisplay { + + buildSVG(){ + this.edge = this.scale/2; + this.lines(); + //console.log(this.buildTikZ()); + } + + newDisplayData(){ + return new PositiveDisplayData(); + } + + lines(){ + for (let n in this.displayData){ + let node = this.displayData[n]; + for (let l in node.lines){ + let secLine = node.lines[l]; + let line = new Bldr("line").att("x1",secLine.source.x*this.scale) + .att("y1", secLine.source.y*this.scale) + .att("x2", secLine.target.x*this.scale) + .att("y2", secLine.target.y*this.scale) + .att("stroke-width",this.edge).att("stroke", this.backgroundColor) + .att("stroke-linecap","butt"); + this.svgBldr.elem(line); + } + for (let j in node.circles){ + let joint = node.circles[j]; + let circle = new Bldr("circle").att("cx",joint.x*this.scale) + .att("cy", joint.y*this.scale) + .att("r", (this.edge/2)*(0.95)) + .att("fill", this.backgroundColor); + //.att("stroke-width",this.edge/3).att("stroke", this.backgroundColor); + this.svgBldr.elem(circle); + } + } + return this; + } + + buildTikZ() { + this.build();//ToDo: builds unnecessary svg structures + let tikZ = new TikZBuilder(); + let newScale = this.scale/40; //scaling factor - need to reduce size for tikZ + for (let n in this.displayData){ + let node = this.displayData[n]; + for (let l in node.lines){ + let secLine = node.lines[l]; + tikZ.addLine(secLine.source.x*newScale, + secLine.source.y*newScale, + secLine.target.x*newScale, + secLine.target.y*newScale); + } + } + return tikZ.build(); + } +} + +class RibbonKnotDisplay extends PositiveKnotDisplay { + + buildSVG(){ + super.buildSVG(); + this.stripeLines(this.edge/3, this.foregroundColor); + + } + + stripeLines(width, color){ + for (let n in this.displayData){ + let node = this.displayData[n]; + for (let l in node.lines){ + let secLine = node.lines[l]; + let line = new Bldr("line").att("x1",secLine.source.x*this.scale) + .att("y1", secLine.source.y*this.scale) + .att("x2", secLine.target.x*this.scale) + .att("y2", secLine.target.y*this.scale) + .att("stroke-width",width).att("stroke", color) + .att("stroke-linecap","butt"); + this.svgBldr.elem(line); + } + for (let j in node.circles){ + let joint = node.circles[j]; + let circle = new Bldr("circle").att("cx",joint.x*this.scale) + .att("cy", joint.y*this.scale) + .att("r", width/2) + .att("fill", color); + this.svgBldr.elem(circle); + } + } + return this; + } +} + +/** + * OLD CELTIC CALC FILE + * Classes and functions in this script file are for + * performing calculations on knots. Only dependency should + * be on celtic_base.celtic. + */ + +function crossingCount(grid){ + let count = 0; + for (let p in grid.points){ + let point = grid.points[p]; + if (!point.isOnSecondary() && point.junctions.length == 0){ + count++; + } + } + return count; +}; + +function setsOverlap(setA,setB){ + let arrayA = Array.from(setA); + for (let a in arrayA){ + let element = arrayA[a]; + if (setB.has(element)){ + return true; + } + } + return false; +}; + +function regionCount(grid){ + let regions = []; + for (let n in grid.nodes){ + let node = grid.nodes[n]; + let newSet = node.getFullConnected(); + let overlap = false; + for (let r in regions){ + let existingSet = regions[r]; + if (setsOverlap(newSet, existingSet)){ + overlap = true; + break; + } + } + if (!overlap){ + regions.push(newSet); + } + } + return regions.length; +} +/* Loop count calculation is more involved than crossing +* or region count, and involves a number of classes and +* functions defined below. +*/ + +/** + * The function loopCount() creates a PathBuilder which + * uses the Grid provided to build all paths and count them. + * It does this by looking at the set of primary points of the + * grid, and determines the individual "strands" of paths + * that pass by each Point. + * + * A Strand represents a fragment of a Path that exists + * in the neighbourhood of a primary Grid Point. Strands + * around a primary grid point are collected in StrandGroups + * The structure of the Strands around a primary Point is completely + * determined by the Junctions that go through the primary Point. + * Once all the StrandGroups are calculated, the individual Strands + * can be collected together into closed Paths, and the + * Paths can be counted. + */ + +class Strand { + constructor(end1, end2, group){ + this.ends = []; + this.ends.push(end1); + this.ends.push(end2); + this.group = group; + } + + toString() { + let s = "(" + this.group.point.x + ", " + this.group.point.y +")"; + s += "[" + this.ends +"] "; + return s; + } + + hasEnd(end){ + for(let e in this.ends){ + if (this.ends[e] === end) { + return true; + } + } + return false; + } + + getOtherEnd(end){ + for(let e in this.ends){ + if (this.ends[e] != end) { + return this.ends[e]; + } + } + } +} + +class StrandGroup { + + constructor(primaryPoint){ + this.point = primaryPoint; + this.strands = []; + } + + toString(){ + let s = "(" + this.point.x + ", " + this.point.y +")"; + s += " {" + this.strands + "} "; + return s; + } + + getStrandPair(end){ + let foundStrand = null; + for (let s in this.strands){ + if (this.strands[s].hasEnd(end)){ + foundStrand = this.strands[s]; + break; + } + } + let pair = [foundStrand, end]; + return pair; + } + + getStrand(end1, end2){ + for (let s in this.strands){ + let strand = this.strands[s]; + if (strand.hasEnd(end1) && strand.hasEnd(end2)){ + return strand; + } + } + return null; + } + + calculateStrands(){ + if (this.point.junctions.length === 0){ + this.strands.push(new Strand(0,2, this)); + this.strands.push(new Strand(1,3, this)); + } else if (this.point.hasNSJunction()){ + if (this.point.east() != null){ + this.strands.push(new Strand(1,2, this)); + } + if (this.point.west() != null){ + this.strands.push(new Strand(0,3, this)); + } + } else if (this.point.hasEWJunction()){ + if (this.point.north() != null){ + this.strands.push(new Strand(0,1, this)); + } + if (this.point.south() != null){ + this.strands.push(new Strand(2, 3, this)); + } + } + } +} + +class PathBuilder { + constructor(grid){ + this.grid = grid; + this.allStrands = []; + this.allPaths = []; + this.strandGroups = new Map(); + } + + buildAllStrands(){ + this.strandGroups.clear(); + for (let p in this.grid.points){ + let point = this.grid.points[p]; + if (point.isOnSecondary()){ + continue; + } + let group = new StrandGroup(point); + this.strandGroups.set(point,group); + group.calculateStrands(); + this.allStrands.push.apply(this.allStrands, group.strands); + } + } + + isFreshStrand(strand){ + for (let p in this.allPaths){ + let path = this.allPaths[p]; + if (path.contains(strand)){ + return false; + } + } + return true; + } + + buildAllPaths(){ + let pathIndex = 0; + for (let s in this.allStrands){ + let strand = this.allStrands[s]; + if (this.isFreshStrand(strand)){ + let p = new Path(strand, this, pathIndex); + pathIndex ++; + p.buildPath(); + this.allPaths.push(p); + } + } + } + + getNE(strandGroup){ + return this.strandGroups.get(strandGroup.point.north().east()); + } + + getNW(strandGroup){ + return this.strandGroups.get(strandGroup.point.north().west()); + } + + getSE(strandGroup){ + return this.strandGroups.get(strandGroup.point.south().east()); + } + + getSW(strandGroup){ + return this.strandGroups.get(strandGroup.point.south().west()); + } +} + +class Path { + constructor(start, pathBuilder, i = 0){ + this.startStrand = start; + this.strands = [this.startStrand]; + this.pathBuilder = pathBuilder; + this.index = i; + this.startStrand.index = this.index; + } + + contains(strand){ + for(let s in this.strands){ + if (this.strands[s] == strand){ + return true; + } + } + return false; + } + + length(){ + return this.strands.length + } + + findNextStrand(strand, end){ + if (!strand.hasEnd(end)){ + return null; + } + let nextEnd = strand.getOtherEnd(end); + let targetEnd = 0; + let nextGroup = null; + if (nextEnd === 0){ + nextGroup = this.pathBuilder.getNW(strand.group); + targetEnd = 2; + } else if (nextEnd === 1){ + nextGroup = this.pathBuilder.getNE(strand.group); + targetEnd = 3; + } else if (nextEnd === 2){ + nextGroup = this.pathBuilder.getSE(strand.group); + targetEnd = 0; + } else if (nextEnd === 3){ + nextGroup = this.pathBuilder.getSW(strand.group); + targetEnd = 1; + } + return nextGroup.getStrandPair(targetEnd); + } + + buildPath(){ + let currentStrand = this.startStrand; + let currentEnd = currentStrand.ends[0]; //pick one end + while(true){ + let result = this.findNextStrand(currentStrand, currentEnd); + + currentStrand = result[0]; + currentEnd = result[1]; + if (this.contains(currentStrand)){ + break; + } + currentStrand.index = this.index; + this.strands.push(currentStrand); + } + } + + totalPathLengths() { + let pl = 0; + for (let p in this.allPaths){ + pl += this.allPaths[p].length(); + } + return pl; + } + +} + +function loopCount(grid){ + let pb = new PathBuilder(grid); + pb.buildAllStrands(); + pb.buildAllPaths(); + return pb.allPaths.length; +} + +/** + * Below is a display type that uses the path calculation. + */ + +class PrimaryDisplayData extends DisplayData { + constructor(){ + super(); + this.lines = []; + this.circles = []; + this.crossing = null; + this.center = []; + this.rounded = true; + } + + polyCalc(strandGroup){ + let x = strandGroup.point.x; + let y = strandGroup.point.y; + this.center.push(new Point(x, y-(1/4))); + this.center.push(new Point(x+(1/4), y)); + this.center.push(new Point(x, y+(1/4))); + this.center.push(new Point(x-(1/4), y)); + } + + lineCalc(strandGroup){ + this.lines = []; + let x = strandGroup.point.x; + let y = strandGroup.point.y; + let strand = strandGroup.getStrand(0,1); + let d = null; + if (strand != null) { + d = new Decorator(strand.index); + if (!this.rounded){ + this.lines.push(new Line(new Point(x-(1/2), y-(1/2)),new Point(x+(1/2), y-(1/2))).setDecorator(d)); + } else { + this.lines.push(new Line(new Point(x-(1/2), y-(1/2)),new Point(x, y-(1/3))).setDecorator(d)); + this.lines.push(new Line(new Point(x, y-(1/3)),new Point(x+(1/2), y-(1/2))).setDecorator(d)); + this.circles.push(new Point(x,y-(1/3)).setDecorator(d)); + } + this.circles.push(new Point(x-(1/2),y-(1/2)).setDecorator(d)); + this.circles.push(new Point(x+(1/2),y-(1/2)).setDecorator(d)); + } + + strand = strandGroup.getStrand(0,2); + if (strand != null) { + d = new Decorator(strand.index); + this.lines.push(new Line(new Point(x-(1/2), y-(1/2)),new Point(x+(1/2), y+(1/2))).setDecorator(d)); + this.circles.push(new Point(x-(1/2),y-(1/2)).setDecorator(d)); + this.circles.push(new Point(x+(1/2),y+(1/2)).setDecorator(d)); + if (strandGroup.point.x % 2 == 0){ + this.crossing = new Line(new Point(x-(1/2), y-(1/2)),new Point(x+(1/2), y+(1/2))); + this.crossing.setDecorator(d); + } + } + + strand = strandGroup.getStrand(1,3); + if (strand != null) { + d = new Decorator(strand.index); + this.lines.push(new Line(new Point(x+(1/2), y-(1/2)),new Point(x-(1/2), y+(1/2))).setDecorator(d)); + this.circles.push(new Point(x+(1/2),y-(1/2)).setDecorator(d)); + this.circles.push(new Point(x-(1/2),y+(1/2)).setDecorator(d)); + if (strandGroup.point.x % 2 == 1){ + this.crossing = new Line(new Point(x+(1/2), y-(1/2)),new Point(x-(1/2), y+(1/2))); + this.crossing.setDecorator(d); + } + } + + strand = strandGroup.getStrand(0,3); + if (strand != null) { + d = new Decorator(strand.index); + if (!this.rounded){ + this.lines.push(new Line(new Point(x-(1/2), y-(1/2)),new Point(x-(1/2), y+(1/2))).setDecorator(d)); + } else { + this.lines.push(new Line(new Point(x-(1/2), y-(1/2)),new Point(x-(1/3), y)).setDecorator(d)); + this.lines.push(new Line(new Point(x-(1/3), y), new Point(x-(1/2), y+(1/2))).setDecorator(d)); + this.circles.push(new Point(x-(1/3),y).setDecorator(d)); + } + this.circles.push(new Point(x-(1/2),y-(1/2)).setDecorator(d)); + this.circles.push(new Point(x-(1/2),y+(1/2)).setDecorator(d)); + } + + strand = strandGroup.getStrand(1,2); + if (strand != null) { + d = new Decorator(strand.index); + if (!this.rounded){ + this.lines.push(new Line(new Point(x+(1/2), y-(1/2)),new Point(x+(1/2), y+(1/2))).setDecorator(d)); + } else { + this.lines.push(new Line(new Point(x+(1/2), y-(1/2)),new Point(x+(1/3), y)).setDecorator(d)); + this.lines.push(new Line(new Point(x+(1/3), y), new Point(x+(1/2), y+(1/2))).setDecorator(d)); + this.circles.push(new Point(x+(1/3),y).setDecorator(d)); + } + this.circles.push(new Point(x+(1/2),y-(1/2)).setDecorator(d)); + this.circles.push(new Point(x+(1/2),y+(1/2)).setDecorator(d)); + } + + strand = strandGroup.getStrand(2,3); + if (strand != null) { + d = new Decorator(strand.index); + if (!this.rounded){ + this.lines.push(new Line(new Point(x+(1/2), y+(1/2)),new Point(x-(1/2), y+(1/2))).setDecorator(d)); + } else { + this.lines.push(new Line(new Point(x+(1/2), y+(1/2)),new Point(x, y+(1/3))).setDecorator(d)); + this.lines.push(new Line(new Point(x, y+(1/3)), new Point(x-(1/2), y+(1/2))).setDecorator(d)); + this.circles.push(new Point(x,y+(1/3)).setDecorator(d)); + } + this.circles.push(new Point(x+(1/2),y+(1/2)).setDecorator(d)); + this.circles.push(new Point(x-(1/2),y+(1/2)).setDecorator(d)); + } + + } +} + +class Decorator { + constructor(i){ + this.index = i; + } + decorate(){ + //let colors = ['blue','red','pink','lightgreen','green']; + let colors = ['#a2b9bc', '#b2ad7f','#878f99','#6b5b95','#d6cbd3','#eca1a6','#bdcebe','#82b74b','#405d27']; + if (interactive.colorPallette != undefined){ + colors = interactive.colorPallette; + } + return colors[this.index%colors.length]; + } +} + +class PrimaryKnotDisplay extends BasicKnotDisplay { + + buildSVG(){ + this.edge = this.scale/2; + this.lines(); + } + + newDisplayData(){ + return new PrimaryDisplayData(); + } + + buildStructure(){ + let pb = new PathBuilder(this.g); + pb.buildAllStrands(); + pb.buildAllPaths(); + let v = pb.strandGroups.values() + let val = v.next().value; + while(val !== undefined) { + let d = this.newDisplayData(); + d.lineCalc(val); + d.polyCalc(val); + this.displayData.push(d); + val = v.next().value; + } + + } + + lines(){ + for (let n in this.displayData){ + let node = this.displayData[n]; + for (let l in node.lines){ + let secLine = node.lines[l]; + let line = new Bldr("line").att("x1",secLine.source.x*this.scale) + .att("y1", secLine.source.y*this.scale) + .att("x2", secLine.target.x*this.scale) + .att("y2", secLine.target.y*this.scale) + .att("stroke-linecap","butt"); + if (secLine.decorator != null){ + line.att("stroke-width",this.edge).att("stroke", secLine.decorator.decorate()); + } else { + line.att("stroke-width",this.edge).att("stroke", this.backgroundColor); + } + this.svgBldr.elem(line); + } + for (let j in node.circles){ + let joint = node.circles[j]; + let circle = new Bldr("circle").att("cx",joint.x*this.scale) + .att("cy", joint.y*this.scale) + .att("r", (this.edge/2)*(0.96)); + if (joint.decorator != null){ + circle.att("fill",joint.decorator.decorate()); + } else { + circle.att("fill", this.backgroundColor); + //.att("stroke-width",this.edge/3).att("stroke", this.backgroundColor); + } + this.svgBldr.elem(circle); + } + let xline = node.crossing; + if (xline != null) { + let plist = ""; + for (let p in node.center){ + let point = node.center[p]; + plist += "" + (point.x*this.scale) + "," +(point.y*this.scale) +" "; + } + + let crossing1 = new Bldr("polygon").att("points",plist); + crossing1.att("stroke-width",this.edge/2).att("fill",this.foregroundColor).att("stroke", this.foregroundColor); + + this.svgBldr.elem(crossing1); + + let crossing2 = new Bldr("line").att("x1",xline.source.x*this.scale) + .att("y1", xline.source.y*this.scale) + .att("x2", xline.target.x*this.scale) + .att("y2", xline.target.y*this.scale) + .att("stroke-linecap","butt"); + if (xline.decorator != null){ + let d = xline.decorator; + crossing2.att("stroke-width",this.edge).att("fill", d.decorate()).att("stroke", d.decorate()); + } else { + crossing2.att("stroke-width",this.edge/2).att("fill",this.foregroundColor).att("stroke", this.foregroundColor); + } + this.svgBldr.elem(crossing2); + } + } + return this; + } +} + +let pallettes = { + 'blues':['#011f4b','#03396c','#005b96','#6497b1','#b3cde0'], + 'gryffindor': ['#740001','#ae0001','#eeba30','#d3a625','#000000'], + 'greys':['#999999','#777777','#555555','#333333','#111111'], + 'pinks':['#ff00a9','#fb9f9f','#ff0065','#ffbfd3','#fb5858'], + 'metro':['#d11141','#00b159','#00aedb', '#f37735','#ffc425'], + 'pastel':['#ffb3ba','#ffdfba','#ffffba','#baffc9','#bae1ff'], + 'ravenclaw': ['#0e1a40','#222f5b','#5d5d5d','#946b2d','#000000'], + 'slytherin':['#1a472a','#2a623d','#5d5d5d','#aaaaaa','#000000'], + 'hufflepuff':['#ecb939','#f0c75e','#726255','#372e29','#000000'], + 'neon' : ['#fe0000','#fdfe02','#0bff01','#011efe','#fe00f6'], + 'seafoam' :['#a3c1ad','#a0d6b4','#5f9ea0','#317873','#49796b'] +} + +//for node export +try{ + module.exports.Grid = Grid; + module.exports.PositiveKnotDisplay = PositiveKnotDisplay; + module.exports.LaTeXDoc = LaTeXDoc; +} catch(err){ + console.log("non-node execution context"); +} diff --git a/ch1_generated_files/0000.tex b/ch1_generated_files/0000.tex new file mode 100644 index 0000000..5474a43 --- /dev/null +++ b/ch1_generated_files/0000.tex @@ -0,0 +1,34 @@ +\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.375,0.875); + \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (1,1.5) -- (0.75,1.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.625,1.125); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.875,1.625); + \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1,1.5) -- (0.75,1.25); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1,1.5) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.375,0.875); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.125,0.375); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.625,1.125); + \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1,1.5) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.25,1.25) -- (1.125,1.375); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.75,0.75); +\end{tikzpicture} diff --git a/ch1_generated_files/0001.tex b/ch1_generated_files/0001.tex new file mode 100644 index 0000000..631b7ef --- /dev/null +++ b/ch1_generated_files/0001.tex @@ -0,0 +1,30 @@ +\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.375,0.875); + \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); + \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.25,1.25) -- (0.75,1.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.625,1.125); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.375,0.875); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.125,0.375); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.625,1.125); + \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.75,0.75); +\end{tikzpicture} diff --git a/ch1_generated_files/0002.tex b/ch1_generated_files/0002.tex new file mode 100644 index 0000000..9ef1599 --- /dev/null +++ b/ch1_generated_files/0002.tex @@ -0,0 +1,30 @@ +\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.375,0.875); + \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.625,1.125); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); + \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.375,0.875); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.125,0.375); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.625,1.125); + \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.75,0.75); +\end{tikzpicture} diff --git a/ch1_generated_files/0011.tex b/ch1_generated_files/0011.tex new file mode 100644 index 0000000..377ca08 --- /dev/null +++ b/ch1_generated_files/0011.tex @@ -0,0 +1,26 @@ +\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.375,0.875); + \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); + \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,1.25) -- (0.75,1.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.625,1.125); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.75) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.125,0.375); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.25,1.25) -- (1.75,1.25); +\end{tikzpicture} diff --git a/ch1_generated_files/0012.tex b/ch1_generated_files/0012.tex new file mode 100644 index 0000000..09cc743 --- /dev/null +++ b/ch1_generated_files/0012.tex @@ -0,0 +1,26 @@ +\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.375,0.875); + \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.625,1.125); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); + \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.75) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.125,0.375); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.25,1.25) -- (1.75,1.25); +\end{tikzpicture} diff --git a/ch1_generated_files/0022.tex b/ch1_generated_files/0022.tex new file mode 100644 index 0000000..8f8917f --- /dev/null +++ b/ch1_generated_files/0022.tex @@ -0,0 +1,26 @@ +\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.375,0.875); + \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.625,1.125); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); + \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.125,0.375); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,0.75); +\end{tikzpicture} diff --git a/ch1_generated_files/0111.tex b/ch1_generated_files/0111.tex new file mode 100644 index 0000000..d3daac8 --- /dev/null +++ b/ch1_generated_files/0111.tex @@ -0,0 +1,22 @@ +\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.25,0.75); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); + \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); + \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.25,1.25) -- (0.75,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,1.25) -- (0.75,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.75) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.125,0.375); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.25,1.25) -- (1.75,1.25); +\end{tikzpicture} diff --git a/ch1_generated_files/0112.tex b/ch1_generated_files/0112.tex new file mode 100644 index 0000000..1884983 --- /dev/null +++ b/ch1_generated_files/0112.tex @@ -0,0 +1,22 @@ +\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.25,0.75); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); + \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); + \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.25,1.25) -- (0.75,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.75) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.125,0.375); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.25,1.25) -- (1.75,1.25); +\end{tikzpicture} diff --git a/ch1_generated_files/0122.tex b/ch1_generated_files/0122.tex new file mode 100644 index 0000000..2193292 --- /dev/null +++ b/ch1_generated_files/0122.tex @@ -0,0 +1,22 @@ +\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.25,0.75); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); + \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); + \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.25,1.25) -- (0.75,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.125,0.375); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,0.75); +\end{tikzpicture} diff --git a/ch1_generated_files/0222.tex b/ch1_generated_files/0222.tex new file mode 100644 index 0000000..5dc32b7 --- /dev/null +++ b/ch1_generated_files/0222.tex @@ -0,0 +1,22 @@ +\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); + \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); + \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.125,0.375); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,0.75); +\end{tikzpicture} diff --git a/ch1_generated_files/1111.tex b/ch1_generated_files/1111.tex new file mode 100644 index 0000000..503f4b3 --- /dev/null +++ b/ch1_generated_files/1111.tex @@ -0,0 +1,18 @@ +\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.25,0.75); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); + \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); + \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.25,1.25) -- (0.75,1.25); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,1.25) -- (0.75,1.25); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.75) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.25,1.25) -- (1.75,1.25); +\end{tikzpicture} diff --git a/ch1_generated_files/1112.tex b/ch1_generated_files/1112.tex new file mode 100644 index 0000000..ad37779 --- /dev/null +++ b/ch1_generated_files/1112.tex @@ -0,0 +1,18 @@ +\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.25,0.75); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); + \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); + \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.25,1.25) -- (0.75,1.25); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.75) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.25,1.25) -- (1.75,1.25); +\end{tikzpicture} diff --git a/ch1_generated_files/1122.tex b/ch1_generated_files/1122.tex new file mode 100644 index 0000000..914f3bd --- /dev/null +++ b/ch1_generated_files/1122.tex @@ -0,0 +1,18 @@ +\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.25,0.75); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); + \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); + \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.25,1.25) -- (0.75,1.25); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,0.75); +\end{tikzpicture} diff --git a/ch1_generated_files/1222.tex b/ch1_generated_files/1222.tex new file mode 100644 index 0000000..3e006e1 --- /dev/null +++ b/ch1_generated_files/1222.tex @@ -0,0 +1,18 @@ +\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); + \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); + \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,0.75); +\end{tikzpicture} diff --git a/ch1_generated_files/2222.tex b/ch1_generated_files/2222.tex new file mode 100644 index 0000000..bd98f81 --- /dev/null +++ b/ch1_generated_files/2222.tex @@ -0,0 +1,18 @@ +\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.75,0.25) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); + \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); + \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.25,0.25); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,0.75); +\end{tikzpicture} diff --git a/ch1_list.tex b/ch1_list.tex new file mode 100644 index 0000000..4ed37e8 --- /dev/null +++ b/ch1_list.tex @@ -0,0 +1,31 @@ +\documentclass{article} +\input{ch1_generated_files/0000.tex} + +\input{ch1_generated_files/0001.tex} + +\input{ch1_generated_files/0002.tex} + +\input{ch1_generated_files/0011.tex} + +\input{ch1_generated_files/0012.tex} + +\input{ch1_generated_files/0022.tex} + +\input{ch1_generated_files/0111.tex} + +\input{ch1_generated_files/0112.tex} + +\input{ch1_generated_files/0122.tex} + +\input{ch1_generated_files/0222.tex} + +\input{ch1_generated_files/1111.tex} + +\input{ch1_generated_files/1112.tex} + +\input{ch1_generated_files/1122.tex} + +\input{ch1_generated_files/1222.tex} + +\input{ch1_generated_files/2222.tex} + diff --git a/index.html b/index.html index 0bbc708..0e92e44 100644 --- a/index.html +++ b/index.html @@ -19,14 +19,14 @@ text-align: center; } - - - - - - - - + + + + + + + + - -Celtic Knots - - - - - - - -
- From 083be9d65345f08221ceba6571e3c6b3b95510f1 Mon Sep 17 00:00:00 2001 From: Dan MacKinnon Date: Tue, 24 Jun 2025 16:59:39 -0400 Subject: [PATCH 3/9] Updates from Overleaf --- ch1_list.tex | 16 +---- main.tex | 30 +++++++++ preamble.tex | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 205 insertions(+), 13 deletions(-) create mode 100644 main.tex create mode 100644 preamble.tex diff --git a/ch1_list.tex b/ch1_list.tex index 4ed37e8..e7fee20 100644 --- a/ch1_list.tex +++ b/ch1_list.tex @@ -1,31 +1,21 @@ -\documentclass{article} +\noindent \input{ch1_generated_files/0000.tex} - \input{ch1_generated_files/0001.tex} - \input{ch1_generated_files/0002.tex} - \input{ch1_generated_files/0011.tex} - \input{ch1_generated_files/0012.tex} +\noindent \input{ch1_generated_files/0022.tex} - \input{ch1_generated_files/0111.tex} - \input{ch1_generated_files/0112.tex} - \input{ch1_generated_files/0122.tex} - \input{ch1_generated_files/0222.tex} +\noindent \input{ch1_generated_files/1111.tex} - \input{ch1_generated_files/1112.tex} - \input{ch1_generated_files/1122.tex} - \input{ch1_generated_files/1222.tex} - \input{ch1_generated_files/2222.tex} diff --git a/main.tex b/main.tex new file mode 100644 index 0000000..8670b2a --- /dev/null +++ b/main.tex @@ -0,0 +1,30 @@ +\documentclass{tufte-book} +\input{preamble.tex} + +% Book metadata +\title{Celtic Cellular Patterns} +%\subtitle{\texorpdfstring{$4\times4$}{4x4} patterns with four-fold rotational symmetry} +\author[]{Dan MacKinnon} +\publisher{\texorpdfstring{\url{https://github.com/dmackinnon1/SOMEREPO}}{}} +\begin{document} +\maketitle + + +% v.4 copyright page +\newpage +\begin{fullwidth} +~\vfill +\thispagestyle{empty} +\setlength{\parindent}{0pt} +%\setlength{\parskip}{\baselineskip} +\textit{Current printing, \today}\\ +\textit{Source, \url{https://github.com/dmackinnon1/SOMEREPO}}\\ +\textit{Contact, \href{mailto://dmackinnon1@gmail.com}{dmackinnon1@gmail.com}} +\end{fullwidth} + +\cleardoublepage + +\chapter*{Introduction} +\input{ch1_list} + +\end{document} \ No newline at end of file diff --git a/preamble.tex b/preamble.tex new file mode 100644 index 0000000..9a5b861 --- /dev/null +++ b/preamble.tex @@ -0,0 +1,172 @@ +\usepackage{tikz} +\usepackage{tikz-cd} +\usepackage{amsmath} +\usetikzlibrary{positioning} +\usetikzlibrary {matrix} +\usetikzlibrary{backgrounds} + +\hypersetup{colorlinks}% uncomment this line if you prefer colored hyperlinks (e.g., for onscreen viewing) + +%% + + +%\usepackage{microtype} + +%% +% Just some sample text +%\usepackage{lipsum} + +%% +% For nicely typeset tabular material +%\usepackage{booktabs} + +%% +% For graphics / images +\usepackage{graphicx} +\setkeys{Gin}{width=\linewidth,totalheight=\textheight,keepaspectratio} +\graphicspath{{graphics/}} + +% The fancyvrb package lets us customize the formatting of verbatim +% environments. We use a slightly smaller font. +\usepackage{fancyvrb} +\fvset{fontsize=\normalsize} + +%% +% Prints argument within hanging parentheses (i.e., parentheses that take +% up no horizontal space). Useful in tabular environments. +\newcommand{\hangp}[1]{\makebox[0pt][r]{(}#1\makebox[0pt][l]{)}} + +%% +% Prints an asterisk that takes up no horizontal space. +% Useful in tabular environments. +\newcommand{\hangstar}{\makebox[0pt][l]{*}} + +%% +% Prints a trailing space in a smart way. +\usepackage{xspace} + +%% +% Some shortcuts for Tufte's book titles. The lowercase commands will +% produce the initials of the book title in italics. The all-caps commands +% will print out the full title of the book in italics. +% \newcommand{\vdqi}{\textit{VDQI}\xspace} +% \newcommand{\ei}{\textit{EI}\xspace} +% \newcommand{\ve}{\textit{VE}\xspace} +% \newcommand{\be}{\textit{BE}\xspace} +% \newcommand{\VDQI}{\textit{The Visual Display of Quantitative Information}\xspace} +% \newcommand{\EI}{\textit{Envisioning Information}\xspace} +% \newcommand{\VE}{\textit{Visual Explanations}\xspace} +% \newcommand{\BE}{\textit{Beautiful Evidence}\xspace} + + \newcommand{\TL}{Tufte-\LaTeX\xspace} + +% Prints the month name (e.g., January) and the year (e.g., 2008) +\newcommand{\monthyear}{% + \ifcase\month\or January\or February\or March\or April\or May\or June\or + July\or August\or September\or October\or November\or + December\fi\space\number\year +} + + +% Prints an epigraph and speaker in sans serif, all-caps type. +\newcommand{\openepigraph}[2]{% + %\sffamily\fontsize{14}{16}\selectfont + \begin{fullwidth} + \sffamily\large + \begin{doublespace} + \noindent\allcaps{#1}\\% epigraph + \noindent\allcaps{#2}% author + \end{doublespace} + \end{fullwidth} +} + +% Inserts a blank page +\newcommand{\blankpage}{\newpage\hbox{}\thispagestyle{empty}\newpage} + +\usepackage{units} + +% Typesets the font size, leading, and measure in the form of 10/12x26 pc. +\newcommand{\measure}[3]{#1/#2$\times$\unit[#3]{pc}} + +% Macros for typesetting the documentation +\newcommand{\hlred}[1]{\textcolor{Maroon}{#1}}% prints in red +\newcommand{\hangleft}[1]{\makebox[0pt][r]{#1}} +\newcommand{\hairsp}{\hspace{1pt}}% hair space +\newcommand{\hquad}{\hskip0.5em\relax}% half quad space +\newcommand{\TODO}{\textcolor{red}{\bf TODO!}\xspace} +\newcommand{\ie}{\textit{i.\hairsp{}e.}\xspace} +\newcommand{\eg}{\textit{e.\hairsp{}g.}\xspace} +\newcommand{\na}{\quad--}% used in tables for N/A cells +\providecommand{\XeLaTeX}{X\lower.5ex\hbox{\kern-0.15em\reflectbox{E}}\kern-0.1em\LaTeX} +\newcommand{\tXeLaTeX}{\XeLaTeX\index{XeLaTeX@\protect\XeLaTeX}} +% \index{\texttt{\textbackslash xyz}@\hangleft{\texttt{\textbackslash}}\texttt{xyz}} +\newcommand{\tuftebs}{\symbol{'134}}% a backslash in tt type in OT1/T1 +\newcommand{\doccmdnoindex}[2][]{\texttt{\tuftebs#2}}% command name -- adds backslash automatically (and doesn't add cmd to the index) +\newcommand{\doccmddef}[2][]{% + \hlred{\texttt{\tuftebs#2}}\label{cmd:#2}% + \ifthenelse{\isempty{#1}}% + {% add the command to the index + \index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2}}% command name + }% + {% add the command and package to the index + \index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2} (\texttt{#1} package)}% command name + \index{#1 package@\texttt{#1} package}\index{packages!#1@\texttt{#1}}% package name + }% +}% command name -- adds backslash automatically +\newcommand{\doccmd}[2][]{% + \texttt{\tuftebs#2}% + \ifthenelse{\isempty{#1}}% + {% add the command to the index + \index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2}}% command name + }% + {% add the command and package to the index + \index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2} (\texttt{#1} package)}% command name + \index{#1 package@\texttt{#1} package}\index{packages!#1@\texttt{#1}}% package name + }% +}% command name -- adds backslash automatically +\newcommand{\docopt}[1]{\ensuremath{\langle}\textrm{\textit{#1}}\ensuremath{\rangle}}% optional command argument +\newcommand{\docarg}[1]{\textrm{\textit{#1}}}% (required) command argument +\newenvironment{docspec}{\begin{quotation}\ttfamily\parskip0pt\parindent0pt\ignorespaces}{\end{quotation}}% command specification environment +\newcommand{\docenv}[1]{\texttt{#1}\index{#1 environment@\texttt{#1} environment}\index{environments!#1@\texttt{#1}}}% environment name +\newcommand{\docenvdef}[1]{\hlred{\texttt{#1}}\label{env:#1}\index{#1 environment@\texttt{#1} environment}\index{environments!#1@\texttt{#1}}}% environment name +\newcommand{\docpkg}[1]{\texttt{#1}\index{#1 package@\texttt{#1} package}\index{packages!#1@\texttt{#1}}}% package name +\newcommand{\doccls}[1]{\texttt{#1}}% document class name +\newcommand{\docclsopt}[1]{\texttt{#1}\index{#1 class option@\texttt{#1} class option}\index{class options!#1@\texttt{#1}}}% document class option name +\newcommand{\docclsoptdef}[1]{\hlred{\texttt{#1}}\label{clsopt:#1}\index{#1 class option@\texttt{#1} class option}\index{class options!#1@\texttt{#1}}}% document class option name defined +\newcommand{\docmsg}[2]{\bigskip\begin{fullwidth}\noindent\ttfamily#1\end{fullwidth}\medskip\par\noindent#2} +\newcommand{\docfilehook}[2]{\texttt{#1}\index{file hooks!#2}\index{#1@\texttt{#1}}} +\newcommand{\doccounter}[1]{\texttt{#1}\index{#1 counter@\texttt{#1} counter}} + +\makeatletter +\newcommand{\plainsubtitle}{}% plain-text-only subtitle +\newcommand{\subtitle}[1]{% + \gdef\@subtitle{#1}% + \renewcommand{\plainsubtitle}{#1}% use provided plain-text title + \ifthenelse{\isundefined{\hypersetup}}% + {}% hyperref is not loaded; do nothing + {\hypersetup{pdftitle={\plaintitle: \plainsubtitle{}}}}% set the PDF metadata title +} +\renewcommand{\maketitlepage}[0]{% + \cleardoublepage% + {% + \sffamily% + \begin{fullwidth}% + \fontsize{18}{20}\selectfont\par\noindent\textcolor{darkgray}{\allcaps{\thanklessauthor}}% + \vspace{11.5pc}% + \fontsize{36}{40}\selectfont\par\noindent\textcolor{darkgray}{\allcaps{\thanklesstitle}}% + \vspace{2pc}% + \fontsize{18}{22}\selectfont\par\noindent\textcolor{darkgray}{{\plainsubtitle}}% %\alcaps + \vfill% + \fontsize{14}{16}\selectfont\par\noindent\allcaps{\thanklesspublisher}% + \end{fullwidth}% + } + \thispagestyle{empty}% + \clearpage% +} +\makeatother + +% Generates the index +%\usepackage{makeidx} +%\makeindex + +\newtheorem{theorem}{Theorem} \ No newline at end of file From d7793cb87800ae060be92dc95b8f425ab6fca445 Mon Sep 17 00:00:00 2001 From: Dan MacKinnon Date: Tue, 24 Jun 2025 21:58:11 -0400 Subject: [PATCH 4/9] trying again --- ch1_generated_files/1112.tex | 18 ------------------ ch1_generated_files/1122.tex | 18 ------------------ ch1_generated_files/1222.tex | 18 ------------------ ch1_generated_files/2222.tex | 18 ------------------ 4 files changed, 72 deletions(-) delete mode 100644 ch1_generated_files/1112.tex delete mode 100644 ch1_generated_files/1122.tex delete mode 100644 ch1_generated_files/1222.tex delete mode 100644 ch1_generated_files/2222.tex diff --git a/ch1_generated_files/1112.tex b/ch1_generated_files/1112.tex deleted file mode 100644 index ad37779..0000000 --- a/ch1_generated_files/1112.tex +++ /dev/null @@ -1,18 +0,0 @@ -\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] - \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.25,0.75); - \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); - \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); - \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); - \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (0.25,1.25) -- (0.75,1.25); - \draw [line width=3pt, line cap=round] (1.25,0.25) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.75,0.75) -- (1.25,0.75); - \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); - \draw [line width=3pt, line cap=round] (1.75,0.75) -- (1.25,0.75); - \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); - \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); - \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); - \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); - \draw [line width=3pt, line cap=round] (1.25,1.25) -- (1.75,1.25); -\end{tikzpicture} diff --git a/ch1_generated_files/1122.tex b/ch1_generated_files/1122.tex deleted file mode 100644 index 914f3bd..0000000 --- a/ch1_generated_files/1122.tex +++ /dev/null @@ -1,18 +0,0 @@ -\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] - \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.25,0.75); - \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); - \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); - \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); - \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (0.25,1.25) -- (0.75,1.25); - \draw [line width=3pt, line cap=round] (1.25,0.25) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.25,1.25); - \draw [line width=3pt, line cap=round] (0.75,0.75) -- (1.25,0.75); - \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); - \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); - \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); - \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); - \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); - \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,0.75); -\end{tikzpicture} diff --git a/ch1_generated_files/1222.tex b/ch1_generated_files/1222.tex deleted file mode 100644 index 3e006e1..0000000 --- a/ch1_generated_files/1222.tex +++ /dev/null @@ -1,18 +0,0 @@ -\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] - \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); - \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); - \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); - \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (1.25,0.25) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.25,1.25); - \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,0.75); - \draw [line width=3pt, line cap=round] (0.75,0.75) -- (1.25,0.75); - \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); - \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); - \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); - \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); - \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); - \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,0.75); -\end{tikzpicture} diff --git a/ch1_generated_files/2222.tex b/ch1_generated_files/2222.tex deleted file mode 100644 index bd98f81..0000000 --- a/ch1_generated_files/2222.tex +++ /dev/null @@ -1,18 +0,0 @@ -\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] - \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (0.75,0.25) -- (0.75,0.75); - \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); - \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); - \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); - \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.25,1.25); - \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,0.75); - \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); - \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.25,0.25); - \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); - \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); - \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); - \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); - \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,0.75); -\end{tikzpicture} From ec22066f90f9fd89b5fb0480ba42fd551e561b78 Mon Sep 17 00:00:00 2001 From: Dan MacKinnon Date: Tue, 24 Jun 2025 22:00:33 -0400 Subject: [PATCH 5/9] update --- .DS_Store | Bin 0 -> 6148 bytes celtic/celtic.js | 2 +- ch1_list.tex | 75 ++++++++++++++++++++++++++++++++++++++++++----- index.js | 23 +++++++++------ 4 files changed, 83 insertions(+), 17 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..7607fb404608da9806ccff580e62dcf79b47bcc1 GIT binary patch literal 6148 zcmeHKIZgvX5Ud6VmPjm-5Y89;gOz1ozymnET+#|l81jvH7f+-5NLCApB@(Mz>ZzHY zt{F`Q+uHza^VzR~6@Vq(5nn#c&G+4Bc2*H1(s{-+9`Qzh$Nen(_keRRvBL}2xSjAn zcuvpQ6J9ZJe&`Ro;bFfYoFbC~Qa}nw0VyB_j#Quu>GI-8zGzZF3Y@M2{(We4$F6Wp zj86xLXaR@|hQm0IUV_*>KCsl2oJ Date: Tue, 24 Jun 2025 22:03:30 -0400 Subject: [PATCH 6/9] hmm. --- ch1_list.tex | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/ch1_list.tex b/ch1_list.tex index 0cdc210..6d23d2e 100644 --- a/ch1_list.tex +++ b/ch1_list.tex @@ -1,33 +1,24 @@ +\noindent \input{ch1_generated_files/0000.tex} - \input{ch1_generated_files/0001.tex} - \input{ch1_generated_files/0002.tex} - \input{ch1_generated_files/0001.tex} +\noindent \input{ch1_generated_files/0011.tex} - \input{ch1_generated_files/0012.tex} - \input{ch1_generated_files/0002.tex} - \input{ch1_generated_files/0012.tex} - \input{ch1_generated_files/0022.tex} +\noindent \input{ch1_generated_files/0001.tex} - \input{ch1_generated_files/0011.tex} - \input{ch1_generated_files/0012.tex} - \input{ch1_generated_files/0011.tex} \input{ch1_generated_files/0111.tex} - \input{ch1_generated_files/0112.tex} - \input{ch1_generated_files/0012.tex} \input{ch1_generated_files/0112.tex} From 66bfc98cc3d3cc099d0d00d1c10c40c835c73039 Mon Sep 17 00:00:00 2001 From: Dan MacKinnon Date: Tue, 24 Jun 2025 22:06:48 -0400 Subject: [PATCH 7/9] update --- ch1_list.tex | 55 ++-------------------------------------------------- index.js | 4 +++- 2 files changed, 5 insertions(+), 54 deletions(-) diff --git a/ch1_list.tex b/ch1_list.tex index 6d23d2e..fb1d58b 100644 --- a/ch1_list.tex +++ b/ch1_list.tex @@ -1,73 +1,22 @@ -\noindent \input{ch1_generated_files/0000.tex} -\input{ch1_generated_files/0001.tex} -\input{ch1_generated_files/0002.tex} -\input{ch1_generated_files/0001.tex} -\noindent -\input{ch1_generated_files/0011.tex} -\input{ch1_generated_files/0012.tex} -\input{ch1_generated_files/0002.tex} -\input{ch1_generated_files/0012.tex} -\input{ch1_generated_files/0022.tex} - -\noindent \input{ch1_generated_files/0001.tex} -\input{ch1_generated_files/0011.tex} -\input{ch1_generated_files/0012.tex} -\input{ch1_generated_files/0011.tex} - -\input{ch1_generated_files/0111.tex} -\input{ch1_generated_files/0112.tex} -\input{ch1_generated_files/0012.tex} - -\input{ch1_generated_files/0112.tex} - -\input{ch1_generated_files/0122.tex} \input{ch1_generated_files/0002.tex} -\input{ch1_generated_files/0012.tex} - -\input{ch1_generated_files/0022.tex} - -\input{ch1_generated_files/0012.tex} - -\input{ch1_generated_files/0112.tex} - -\input{ch1_generated_files/0122.tex} - -\input{ch1_generated_files/0022.tex} - -\input{ch1_generated_files/0122.tex} - -\input{ch1_generated_files/0222.tex} - -\input{ch1_generated_files/0001.tex} - \input{ch1_generated_files/0011.tex} \input{ch1_generated_files/0012.tex} -\input{ch1_generated_files/0011.tex} +\input{ch1_generated_files/0022.tex} \input{ch1_generated_files/0111.tex} \input{ch1_generated_files/0112.tex} -\input{ch1_generated_files/0012.tex} - -\input{ch1_generated_files/0112.tex} - \input{ch1_generated_files/0122.tex} -\input{ch1_generated_files/0011.tex} - -\input{ch1_generated_files/0111.tex} - -\input{ch1_generated_files/0112.tex} - -\input{ch1_generated_files/0111.tex} +\input{ch1_generated_files/0222.tex} \input{ch1_generated_files/1111.tex} diff --git a/index.js b/index.js index 70bce70..c71a78a 100644 --- a/index.js +++ b/index.js @@ -108,7 +108,7 @@ for (var a in [0,1,2]) { duplicateFound=true; } } - if (!duplicateFound){ + if (!duplicateFound && !listInListOfLists(candidate, keep)){ keep.push(coerce(candidate)); } /*if (listInListOfLists(candidate, keep)) { @@ -124,6 +124,8 @@ for (var a in [0,1,2]) { } } +console.log(keep.length) + // generate 2x2 cell from its signature function twoXtwoLaTeX(fourTuple){ let grid = new celtic.Grid(3,3); From 0de7f593ccf7cd51a452a86e91a0ba1476857a32 Mon Sep 17 00:00:00 2001 From: Dan MacKinnon Date: Wed, 25 Jun 2025 09:25:58 -0400 Subject: [PATCH 8/9] hmm --- ch1_generated_files/0001.tex | 16 ++++++------ ch1_generated_files/0002.tex | 30 ---------------------- ch1_generated_files/0011.tex | 16 ++++++------ ch1_generated_files/0012.tex | 22 ++++++++-------- ch1_generated_files/0022.tex | 26 ------------------- ch1_generated_files/0112.tex | 10 ++++---- ch1_generated_files/0122.tex | 22 ---------------- ch1_generated_files/1112.tex | 18 +++++++++++++ ch1_generated_files/{0222.tex => 1122.tex} | 12 +++------ ch1_list.tex | 10 +++----- index.js | 27 +++++++++++++------ 11 files changed, 76 insertions(+), 133 deletions(-) delete mode 100644 ch1_generated_files/0002.tex delete mode 100644 ch1_generated_files/0022.tex delete mode 100644 ch1_generated_files/0122.tex create mode 100644 ch1_generated_files/1112.tex rename ch1_generated_files/{0222.tex => 1122.tex} (63%) diff --git a/ch1_generated_files/0001.tex b/ch1_generated_files/0001.tex index 631b7ef..9e3fc93 100644 --- a/ch1_generated_files/0001.tex +++ b/ch1_generated_files/0001.tex @@ -1,21 +1,19 @@ \begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.25,0.75); \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); - \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.375,0.875); \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (1,1.5) -- (0.75,1.25); \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.875,1.625); \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.25,1.25) -- (0.75,1.25); \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); \draw [line width=3pt, line cap=round] (1.5,1) -- (1.25,1.25); - \draw [line width=3pt, line cap=round] (1.25,1.25) -- (0.75,1.25); - \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.625,1.125); - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (1,1.5) -- (0.75,1.25); \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); - \draw [line width=3pt, line cap=round] (0.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1,1.5) -- (1.25,1.75); \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); \draw [line width=3pt, line cap=round] (1.5,1) -- (1.75,0.75); \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); @@ -25,6 +23,8 @@ \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.625,1.125); \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1,1.5) -- (1.25,1.75); \draw [line width=3pt, line cap=round] (1.5,1) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.25,1.25) -- (1.125,1.375); \draw [line width=3pt, line cap=round] (1.5,1) -- (1.75,0.75); \end{tikzpicture} diff --git a/ch1_generated_files/0002.tex b/ch1_generated_files/0002.tex deleted file mode 100644 index 9ef1599..0000000 --- a/ch1_generated_files/0002.tex +++ /dev/null @@ -1,30 +0,0 @@ -\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); - \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); - \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); - \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.375,0.875); - \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); - \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.625,1.125); - \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); - \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (1.5,1) -- (1.25,1.25); - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); - \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); - \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); - \draw [line width=3pt, line cap=round] (1.5,1) -- (1.75,0.75); - \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); - \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.375,0.875); - \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); - \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.125,0.375); - \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); - \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.625,1.125); - \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); - \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); - \draw [line width=3pt, line cap=round] (1.5,1) -- (1.25,1.25); - \draw [line width=3pt, line cap=round] (1.5,1) -- (1.75,0.75); -\end{tikzpicture} diff --git a/ch1_generated_files/0011.tex b/ch1_generated_files/0011.tex index 377ca08..c8eb312 100644 --- a/ch1_generated_files/0011.tex +++ b/ch1_generated_files/0011.tex @@ -1,26 +1,26 @@ \begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.25,0.75); \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); - \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.375,0.875); \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.25,1.25) -- (0.75,1.25); \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.25,1.25); \draw [line width=3pt, line cap=round] (1.25,1.25) -- (0.75,1.25); - \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.625,1.125); - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); \draw [line width=3pt, line cap=round] (0.75,1.75) -- (1.25,1.75); \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); - \draw [line width=3pt, line cap=round] (1.75,0.75) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.75,0.75); \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.375,0.875); \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.125,0.375); \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.625,1.125); \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); - \draw [line width=3pt, line cap=round] (1.25,1.25) -- (1.75,1.25); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.75,0.75); \end{tikzpicture} diff --git a/ch1_generated_files/0012.tex b/ch1_generated_files/0012.tex index 09cc743..6bea740 100644 --- a/ch1_generated_files/0012.tex +++ b/ch1_generated_files/0012.tex @@ -1,26 +1,26 @@ \begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,1.25); \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); - \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); - \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.375,0.875); \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); - \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.625,1.125); \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.25,1.25) -- (0.75,1.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (1.25,1.75); \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); - \draw [line width=3pt, line cap=round] (1.75,0.75) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.75,0.75); \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.375,0.875); \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.125,0.375); \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.625,1.125); \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); - \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); - \draw [line width=3pt, line cap=round] (1.25,1.25) -- (1.75,1.25); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.5,1) -- (1.75,0.75); \end{tikzpicture} diff --git a/ch1_generated_files/0022.tex b/ch1_generated_files/0022.tex deleted file mode 100644 index 8f8917f..0000000 --- a/ch1_generated_files/0022.tex +++ /dev/null @@ -1,26 +0,0 @@ -\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); - \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); - \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); - \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.375,0.875); - \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); - \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.625,1.125); - \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); - \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.25,1.25); - \draw [line width=3pt, line cap=round] (0.5,1) -- (0.75,0.75); - \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); - \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); - \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); - \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); - \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.125,0.375); - \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); - \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); - \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); - \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,0.75); -\end{tikzpicture} diff --git a/ch1_generated_files/0112.tex b/ch1_generated_files/0112.tex index 1884983..b1ed613 100644 --- a/ch1_generated_files/0112.tex +++ b/ch1_generated_files/0112.tex @@ -1,15 +1,16 @@ \begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,1.25); \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.25,0.75); - \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (0.25,1.25) -- (0.75,1.25); \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,1.25) -- (0.75,1.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (1.25,1.75); \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); \draw [line width=3pt, line cap=round] (1.75,0.75) -- (1.25,0.75); \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); @@ -17,6 +18,5 @@ \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.125,0.375); \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); - \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); \draw [line width=3pt, line cap=round] (1.25,1.25) -- (1.75,1.25); \end{tikzpicture} diff --git a/ch1_generated_files/0122.tex b/ch1_generated_files/0122.tex deleted file mode 100644 index 2193292..0000000 --- a/ch1_generated_files/0122.tex +++ /dev/null @@ -1,22 +0,0 @@ -\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] - \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.25,0.75); - \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); - \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); - \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); - \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); - \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (0.25,1.25) -- (0.75,1.25); - \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.25,1.25); - \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); - \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); - \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); - \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); - \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.125,0.375); - \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); - \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); - \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); - \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,0.75); -\end{tikzpicture} diff --git a/ch1_generated_files/1112.tex b/ch1_generated_files/1112.tex new file mode 100644 index 0000000..a3c72c9 --- /dev/null +++ b/ch1_generated_files/1112.tex @@ -0,0 +1,18 @@ +\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); + \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); + \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (0.75,0.25); + \draw [line width=3pt, line cap=round] (1.25,1.25) -- (0.75,1.25); + \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,0.75); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (0.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.75) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); + \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); + \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); + \draw [line width=3pt, line cap=round] (1.25,1.25) -- (1.75,1.25); +\end{tikzpicture} diff --git a/ch1_generated_files/0222.tex b/ch1_generated_files/1122.tex similarity index 63% rename from ch1_generated_files/0222.tex rename to ch1_generated_files/1122.tex index 5dc32b7..705e81d 100644 --- a/ch1_generated_files/0222.tex +++ b/ch1_generated_files/1122.tex @@ -1,22 +1,18 @@ \begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=black}] \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); \draw [line width=3pt, line cap=round] (0.25,0.75) -- (0.25,0.25); \draw [line width=3pt, line cap=round] (0.25,0.25) -- (0.75,0.25); \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,1.75); \draw [line width=3pt, line cap=round] (0.75,1.75) -- (0.25,1.75); \draw [line width=3pt, line cap=round] (0.25,1.75) -- (0.25,1.25); - \draw [line width=3pt, line cap=round] (1,0.5) -- (0.75,0.25); - \draw [line width=3pt, line cap=round] (1.25,0.75) -- (1.25,1.25); + \draw [line width=3pt, line cap=round] (1.25,0.25) -- (0.75,0.25); \draw [line width=3pt, line cap=round] (0.75,1.25) -- (0.75,0.75); - \draw [line width=3pt, line cap=round] (0.75,0.75) -- (0.875,0.625); - \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (0.75,0.75) -- (1.25,0.75); \draw [line width=3pt, line cap=round] (1.75,0.25) -- (1.75,0.75); - \draw [line width=3pt, line cap=round] (1,0.5) -- (1.25,0.75); + \draw [line width=3pt, line cap=round] (1.75,0.75) -- (1.25,0.75); \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.75,0.25); - \draw [line width=3pt, line cap=round] (1.25,0.25) -- (1.125,0.375); \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,1.75); \draw [line width=3pt, line cap=round] (1.75,1.75) -- (1.25,1.75); \draw [line width=3pt, line cap=round] (1.25,1.75) -- (1.25,1.25); - \draw [line width=3pt, line cap=round] (1.75,1.25) -- (1.75,0.75); + \draw [line width=3pt, line cap=round] (1.25,1.25) -- (1.75,1.25); \end{tikzpicture} diff --git a/ch1_list.tex b/ch1_list.tex index fb1d58b..569445a 100644 --- a/ch1_list.tex +++ b/ch1_list.tex @@ -2,21 +2,17 @@ \input{ch1_generated_files/0001.tex} -\input{ch1_generated_files/0002.tex} - \input{ch1_generated_files/0011.tex} \input{ch1_generated_files/0012.tex} -\input{ch1_generated_files/0022.tex} - \input{ch1_generated_files/0111.tex} \input{ch1_generated_files/0112.tex} -\input{ch1_generated_files/0122.tex} +\input{ch1_generated_files/1111.tex} -\input{ch1_generated_files/0222.tex} +\input{ch1_generated_files/1112.tex} -\input{ch1_generated_files/1111.tex} +\input{ch1_generated_files/1122.tex} diff --git a/index.js b/index.js index c71a78a..5698d0a 100644 --- a/index.js +++ b/index.js @@ -29,6 +29,14 @@ function signature(list){ return string; } +function printListOfLists(lists){ + let string = " | "; + for (let i = 0; i < lists.length; i++) { + string += lists[i] + " | "; + } + return string; +} + function listInListOfLists(list, listOfLists){ for (let i = 0; i < listOfLists.length; i++){ let listFromList = listOfLists[i]; @@ -99,12 +107,13 @@ for (var a in [0,1,2]) { for (var d in [0,1,2]) { let candidate = [a,b,c,d]; console.log("testing " + candidate); - let rotations = allRotations(candidate); + let rotations = allRotations(coerce(candidate)); + console.log(" - for " + candidate +" rotations are: " + printListOfLists(rotations)); let duplicateFound = false; for (let i = 0; i < rotations.length; i++){ let r = rotations[i]; if (listInListOfLists(r, keep)){ - console.log("found rotation: " + r); + console.log(" -- for " + candidate + ", found rotation: " + r); duplicateFound=true; } } @@ -140,21 +149,21 @@ function twoXtwoLaTeX(fourTuple){ } let second = fourTuple[1]; if (second === 1){ - grid.from(0,2).to(2,2); + grid.from(2,2).to(4,2); } else if (second === 2){ - grid.from(1,1).to(1,3); + grid.from(3,1).to(3,3); } let third = fourTuple[2]; if (third === 1){ - grid.from(2,2).to(4,2); + grid.from(1,3).to(3,3); } else if (third === 2){ - grid.from(3,1).to(3,3); + grid.from(2,2).to(2,4); } let fourth = fourTuple[3]; if (fourth === 1){ - grid.from(1,3).to(3,3); + grid.from(0,2).to(2,2); } else if (fourth === 2){ - grid.from(2,2).to(2,4); + grid.from(1,1).to(1,3); } let knotDisplay = new celtic.PositiveKnotDisplay(grid, 20, 'white', 'darkblue'); knotDisplay.init(); @@ -204,3 +213,5 @@ fs.writeFile(mainFile, mainDoc.build(), function(err) { } }); +let test = [1,2,2,2]; +console.log("for test: " + test + " rotation: " + rotate(test)); \ No newline at end of file From 1913970809f624fb903c9cd4b918d1d959570038 Mon Sep 17 00:00:00 2001 From: Dan MacKinnon Date: Wed, 25 Jun 2025 09:26:22 -0400 Subject: [PATCH 9/9] Updates from Overleaf --- ch1_list.tex | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/ch1_list.tex b/ch1_list.tex index fb1d58b..a170045 100644 --- a/ch1_list.tex +++ b/ch1_list.tex @@ -1,22 +1,17 @@ +\noindent \input{ch1_generated_files/0000.tex} - \input{ch1_generated_files/0001.tex} - \input{ch1_generated_files/0002.tex} - \input{ch1_generated_files/0011.tex} - \input{ch1_generated_files/0012.tex} +\noindent \input{ch1_generated_files/0022.tex} - \input{ch1_generated_files/0111.tex} - \input{ch1_generated_files/0112.tex} - \input{ch1_generated_files/0122.tex} - \input{ch1_generated_files/0222.tex} +\noindent \input{ch1_generated_files/1111.tex}