diff --git a/ea-scripts/Golden Ratio.md b/ea-scripts/Golden Ratio.md new file mode 100644 index 0000000..caa3434 --- /dev/null +++ b/ea-scripts/Golden Ratio.md @@ -0,0 +1,604 @@ +/* +The script performs two different functions depending on the elements selected in the view. +1) In case you select text elements, the script will cycle through a set of font scales. First the 2 larger fonts following the Fibonacci sequence (fontsize * φ; fonsize * φ^2), then the 2 smaller fonts (fontsize / φ; fontsize / φ^2), finally the original size, followed again by the 2 larger fonts. If you wait 2 seconds, the sequence clears and starts from which ever font size you are on. So if you want the 3rd larges font, then toggle twice, wait 2 sec, then toggle again. +2) In case you select a single rectangle, the script will open the "Golden Grid", "Golden Spiral" window, where you can set up the type of grid or spiral you want to insert into the document. + +![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/golden-ratio.jpg) + +Gravitational point of spiral: $$\left[x,y\right]=\left[ x + \frac{{\text{width} \cdot \phi^2}}{{\phi^2 + 1}}\;, \; y + \frac{{\text{height} \cdot \phi^2}}{{\phi^2 + 1}} \right]$$ +Dimensions of inner rectangles in case of Double Spiral: $$[width, height] = \left[\frac{width\cdot(\phi^2+1)}{2\phi^2}\;, \;\frac{height\cdot(\phi^2+1)}{2\phi^2}\right]$$ + +```js*/ +const phi = (1 + Math.sqrt(5)) / 2; // Golden Ratio (φ) +const inversePhi = (1-1/phi); +const pointsPerCurve = 20; // Number of points per curve segment +const ownerWindow = ea.targetView.ownerWindow; +const hostLeaf = ea.targetView.leaf; +let dirty = false; +const ids = []; + +const textEls = ea.getViewSelectedElements().filter(el=>el.type === "text"); +let rect = ea.getViewSelectedElements().length === 1 ? ea.getViewSelectedElement() : null; +if(!rect || rect.type !== "rectangle") { + //Fontsize cycle + if(textEls.length>0) { + if(window.excalidrawGoldenRatio) { + clearTimeout(window.excalidrawGoldenRatio?.timer); + } else { + window.excalidrawGoldenRatio = {timer: null, cycle:-1}; + } + window.excalidrawGoldenRatio.timer = setTimeout(()=>{delete window.excalidrawGoldenRatio;},2000); + window.excalidrawGoldenRatio.cycle = (window.excalidrawGoldenRatio.cycle+1)%5; + + ea.copyViewElementsToEAforEditing(textEls); + ea.getElements().forEach(el=> { + el.fontSize = window.excalidrawGoldenRatio.cycle === 2 + ? el.fontSize / Math.pow(phi,4) + : el.fontSize * phi; + const font = ExcalidrawLib.getFontString(el); + const lineHeight = ExcalidrawLib.getDefaultLineHeight(el.fontFamily); + const {width, height, baseline} = ExcalidrawLib.measureText(el.originalText, font, lineHeight); + el.width = width; + el.height = height; + el.baseline = baseline; + }); + ea.addElementsToView(); + return; + } + new Notice("Select text elements, or a select a single rectangle"); + return; +} +ea.copyViewElementsToEAforEditing([rect]); +rect = ea.getElement(rect.id); +ids.push(rect.id); +ea.style.strokeColor = rect.strokeColor; +ea.style.strokeWidth = rect.strokeWidth; +ea.style.roughness = rect.roughness; +let {x,y,width,height} = rect; + +// -------------------------------------------- +// Load Settings +// -------------------------------------------- +let settings = ea.getScriptSettings(); +if(!settings["Horizontal Grid"]) { + settings = { + "Horizontal Grid" : { + value: "left-right", + valueset: ["none","letf-right","right-left","center-out","center-in"] + }, + "Vertical Grid": { + value: "none", + valueset: ["none","top-down","bottom-up","center-out","center-in"] + }, + "Size": { + value: "6", + valueset: ["2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"] + }, + "Aspect Choice": { + value: "none", + valueset: ["none","adjust-width","adjust-height"] + }, + "Type": "grid", + "Spiral Orientation": { + value: "top-left", + valueset: ["double","top-left","top-right","bottom-right","bottom-left"] + }, + "Lock Elements": false, + "Send to Back": false, + "Update Style": false, + "Bold Spiral": false, + }; + await ea.setScriptSettings(settings); +} + +let hDirection = settings["Horizontal Grid"].value; +let vDirection = settings["Vertical Grid"].value; +let aspectChoice = settings["Aspect Choice"].value; +let type = settings["Type"]; +let spiralOrientation = settings["Spiral Orientation"].value; +let lockElements = settings["Lock Elements"]; +let sendToBack = settings["Send to Back"]; +let size = parseInt(settings["Size"].value); +let updateStyle = settings["Update Style"]; +let boldSpiral = settings["Bold Spiral"]; + +// -------------------------------------------- +// Grid +// -------------------------------------------- +const calculateGoldenSum = (baseOfGoldenGrid, pow) => { + const ratio = 1 / phi; + const geometricSum = baseOfGoldenGrid * ((1 - Math.pow(ratio, pow)) / (1 - ratio)); + return geometricSum; +}; + +const findBaseForGoldenGrid = (targetValue, n, scenario) => { + const ratio = 1 / phi; + if (scenario === "center-out") { + return targetValue * (2-2*ratio) / (1 + ratio + 2*Math.pow(ratio,n)); + } else if (scenario === "center-in") { + return targetValue*2*(1-ratio)*Math.pow(phi,n-1) /(2*Math.pow(phi,n-1)*(1-Math.pow(ratio,n))-1+ratio); + } else { + return targetValue * (1-ratio)/(1-Math.pow(ratio,n)); + } +} + +const calculateOffsetVertical = (scenario, base) => { + if (scenario === "center-out") return base / 2; + if (scenario === "center-in") return base / Math.pow(phi, size + 1) / 2; + return 0; +}; + +const horizontal = (direction, scenario) => { + const base = findBaseForGoldenGrid(width, size + 1, scenario); + const totalGridWidth = calculateGoldenSum(base, size + 1); + + for (i = 1; i <= size; i++) { + const offset = + scenario === "center-out" + ? totalGridWidth - calculateGoldenSum(base, i) + : calculateGoldenSum(base, size + 1 - i); + + const x2 = + direction === "left" + ? x + offset + : x + width - offset; + + ids.push( + ea.addLine([ + [x2, y], + [x2, y + height], + ]) + ); + } +}; + +const vertical = (direction, scenario) => { + const base = findBaseForGoldenGrid(height, size + 1, scenario); + const totalGridWidth = calculateGoldenSum(base, size + 1); + + for (i = 1; i <= size; i++) { + const offset = + scenario === "center-out" + ? totalGridWidth - calculateGoldenSum(base, i) + : calculateGoldenSum(base, size + 1 - i); + + const y2 = + direction === "top" + ? y + offset + : y + height - offset; + + ids.push( + ea.addLine([ + [x, y2], + [x+width, y2], + ]) + ); + } +}; + +const centerHorizontal = (scenario) => { + width = width / 2; + horizontal("left", scenario); + x += width; + horizontal("right", scenario); + x -= width; + width = 2*width; + +}; + +const centerVertical = (scenario) => { + height = height / 2; + vertical("top", scenario); + y += height; + vertical("bottom", scenario); + y -= height; + height = 2*height; +}; + +const drawGrid = () => { + switch(hDirection) { + case "none": break; + case "left-right": horizontal("left"); break; + case "right-left": horizontal("right"); break; + case "center-out": centerHorizontal("center-out"); break; + case "center-in": centerHorizontal("center-in"); break; + } + switch(vDirection) { + case "none": break; + case "top-down": vertical("top"); break; + case "bottom-up": vertical("bottom"); break; + case "center-out": centerVertical("center-out"); break; + case "center-in": centerVertical("center-in"); break; + } +} + +// -------------------------------------------- +// Draw Spiral +// -------------------------------------------- +const drawSpiral = () => { + let nextX, nextY, nextW, nextH; + let spiralPoints = []; + let curveEndX, curveEndY, curveX, curveY; + + const phaseShift = { + "bottom-right": 0, + "bottom-left": 2, + "top-left": 2, + "top-right": 0, + }[spiralOrientation]; + + let curveStartX = { + "bottom-right": x, + "bottom-left": x+width, + "top-left": x+width, + "top-right": x, + }[spiralOrientation]; + + let curveStartY = { + "bottom-right": y+height, + "bottom-left": y+height, + "top-left": y, + "top-right": y, + }[spiralOrientation]; + + const mirror = spiralOrientation === "bottom-left" || spiralOrientation === "top-right"; + for (let i = phaseShift; i < size+phaseShift; i++) { + const curvePhase = i%4; + const linePhase = mirror?[0,3,2,1][curvePhase]:curvePhase; + const longHorizontal = width/phi; + const shortHorizontal = width*inversePhi; + const longVertical = height/phi; + const shortVertical = height*inversePhi; + switch(linePhase) { + case 0: //right + nextX = x + longHorizontal; + nextY = y; + nextW = shortHorizontal; + nextH = height; + break; + case 1: //down + nextX = x; + nextY = y + longVertical; + nextW = width; + nextH = shortVertical; + break; + case 2: //left + nextX = x; + nextY = y; + nextW = shortHorizontal; + nextH = height; + break; + case 3: //up + nextX = x; + nextY = y; + nextW = width; + nextH = shortVertical; + break; + } + + switch(curvePhase) { + case 0: //right + curveEndX = nextX; + curveEndY = mirror ? nextY + nextH : nextY; + break; + case 1: //down + curveEndX = nextX + nextW; + curveEndY = mirror ? nextY + nextH : nextY; + break; + case 2: //left + curveEndX = nextX + nextW; + curveEndY = mirror ? nextY : nextY + nextH; + break; + case 3: //up + curveEndX = nextX; + curveEndY = mirror ? nextY : nextY + nextH; + break; + } + + // Add points for the curve segment + + for (let j = 0; j <= pointsPerCurve; j++) { + const t = j / pointsPerCurve; + const angle = -Math.PI / 2 * t; + + switch(curvePhase) { + case 0: + curveX = curveEndX + (curveStartX - curveEndX) * Math.cos(angle); + curveY = curveStartY + (curveStartY - curveEndY) * Math.sin(angle); + break; + case 1: + curveX = curveStartX + (curveStartX - curveEndX) * Math.sin(angle); + curveY = curveEndY + (curveStartY - curveEndY) * Math.cos(angle); + break; + case 2: + curveX = curveEndX + (curveStartX - curveEndX) * Math.cos(angle); + curveY = curveStartY + (curveStartY - curveEndY) * Math.sin(angle); + break; + case 3: + curveX = curveStartX + (curveStartX - curveEndX) * Math.sin(angle); + curveY = curveEndY + (curveStartY - curveEndY) * Math.cos(angle); + break; + } + spiralPoints.push([curveX, curveY]); + } + x = nextX; + y = nextY; + curveStartX = curveEndX; + curveStartY = curveEndY; + width = nextW; + height = nextH; + switch(linePhase) { + case 0: ids.push(ea.addLine([[x,y],[x,y+height]]));break; + case 1: ids.push(ea.addLine([[x,y],[x+width,y]]));break; + case 2: ids.push(ea.addLine([[x+width,y],[x+width,y+height]]));break; + case 3: ids.push(ea.addLine([[x,y+height],[x+width,y+height]]));break; + } + } + const strokeWidth = ea.style.strokeWidth; + ea.style.strokeWidth = strokeWidth * (boldSpiral ? 3 : 1) + ids.push(ea.addLine(spiralPoints)); + ea.style.strokeWidth = strokeWidth; +} + +// -------------------------------------------- +// Update Aspect Ratio +// -------------------------------------------- +const updateAspectRatio = () => { + switch(aspectChoice) { + case "none": break; + case "adjust-width": rect.width = rect.height/phi; break; + case "adjust-height": rect.height = rect.width/phi; break; + } + ({x,y,width,height} = rect); +} +// -------------------------------------------- +// UI +// -------------------------------------------- +draw = async () => { + if(updateStyle) { + ea.style.strokeWidth = 0.5; rect.strokeWidth; + ea.style.roughness = 0; rect.roughness; + ea.style.roundness = null; + rect.strokeWidth = 0.5; + rect.roughness = 0; + rect.roundness = null; + } + updateAspectRatio(); + switch(type) { + case "grid": drawGrid(); break; + case "spiral": + if(spiralOrientation === "double") { + wInner = width * (Math.pow(phi,2)+1)/(2*Math.pow(phi,2)); + hInner = height * (Math.pow(phi,2)+1)/(2*Math.pow(phi,2)); + x2 = width - wInner + x; + y2 = height - hInner + y; + width = wInner; + height = hInner; + ids.push(ea.addRect(x,y,width,height)); + spiralOrientation = "bottom-right"; + drawSpiral(); + x = x2; + y = y2; + width = wInner; + height = hInner; + ids.push(ea.addRect(x,y,width,height)); + spiralOrientation = "top-left"; + drawSpiral(); + } else { + drawSpiral(); + } + break; + } + ea.addToGroup(ids); + lockElements && ea.getElements().forEach(el=>{el.locked = true;}); + await ea.addElementsToView(false,false,!sendToBack); + !lockElements && ea.selectElementsInView(ea.getViewElements().filter(el => ids.includes(el.id))); +} + +const modal = new ea.obsidian.Modal(app); + +const fragWithHTML = (html) => createFragment((frag) => (frag.createDiv().innerHTML = html)); + +const keydownListener = (e) => { + if(hostLeaf !== app.workspace.activeLeaf) return; + if(hostLeaf.width === 0 && hostLeaf.height === 0) return; + if(e.key === "Enter" && (e.ctrlKey || e.shiftKey || e.metaKey || e.altKey)) { + e.preventDefault(); + modal.close(); + draw() + } +} +ownerWindow.addEventListener('keydown',keydownListener); + +modal.onOpen = async () => { + const contentEl = modal.contentEl; + contentEl.createEl("h1", {text: "Golden Ratio"}); + + new ea.obsidian.Setting(contentEl) + .setName("Adjust Rectangle Aspect Ratio to Golden Ratio") + .addDropdown(dropdown=>dropdown + .addOption("none","None") + .addOption("adjust-width","Adjust Width") + .addOption("adjust-height","Adjust Height") + .setValue(aspectChoice) + .onChange(value => { + aspectChoice = value; + dirty = true; + }) + ); + + new ea.obsidian.Setting(contentEl) + .setName("Change Line Style To: thin, architect, sharp") + .addToggle(toggle=> + toggle + .setValue(updateStyle) + .onChange(value => { + dirty = true; + updateStyle = value; + }) + ) + + let sizeEl; + new ea.obsidian.Setting(contentEl) + .setName("Number of lines") + .addSlider(slider => slider + .setLimits(2, 20, 1) + .setValue(size) + .onChange(value => { + sizeEl.innerText = ` ${value.toString()}`; + size = value; + dirty = true; + }), + ) + .settingEl.createDiv("", el => { + sizeEl = el; + el.style.minWidth = "2.3em"; + el.style.textAlign = "right"; + el.innerText = ` ${size.toString()}`; + }); + + new ea.obsidian.Setting(contentEl) + .setName("Lock Rectangle and Gridlines") + .addToggle(toggle=> + toggle + .setValue(lockElements) + .onChange(value => { + dirty = true; + lockElements = value; + }) + ) + + new ea.obsidian.Setting(contentEl) + .setName("Send to Back") + .addToggle(toggle=> + toggle + .setValue(sendToBack) + .onChange(value => { + dirty = true; + sendToBack = value; + }) + ) + + let bGrid, bSpiral; + let sHGrid, sVGrid, sSpiral, sBoldSpiral; + const showGridSettings = (value) => { + value + ? (bGrid.setCta(), bSpiral.removeCta()) + : (bGrid.removeCta(), bSpiral.setCta()); + sHGrid.settingEl.style.display = value ? "" : "none"; + sVGrid.settingEl.style.display = value ? "" : "none"; + sSpiral.settingEl.style.display = !value ? "" : "none"; + sBoldSpiral.settingEl.style.display = !value ? "" : "none"; + } + + new ea.obsidian.Setting(contentEl) + .setName(fragWithHTML("

Output Type

")) + .addButton(button => { + bGrid = button; + button + .setButtonText("Grid") + .setCta(type === "grid") + .onClick(event => { + type = "grid"; + showGridSettings(true); + dirty = true; + }) + }) + .addButton(button => { + bSpiral = button; + button + .setButtonText("Spiral") + .setCta(type === "spiral") + .onClick(event => { + type = "spiral"; + showGridSettings(false); + dirty = true; + }) + }); + + sSpiral = new ea.obsidian.Setting(contentEl) + .setName("Spiral Orientation") + .addDropdown(dropdown=>dropdown + .addOption("double","Double") + .addOption("top-left","Top left") + .addOption("top-right","Top right") + .addOption("bottom-right","Bottom right") + .addOption("bottom-left","Bottom left") + .setValue(spiralOrientation) + .onChange(value => { + spiralOrientation = value; + dirty = true; + }) + ); + + sBoldSpiral = new ea.obsidian.Setting(contentEl) + .setName("Spiral with Bold Line") + .addToggle(toggle=> + toggle + .setValue(boldSpiral) + .onChange(value => { + dirty = true; + boldSpiral = value; + }) + ) + + sHGrid = new ea.obsidian.Setting(contentEl) + .setName("Horizontal Grid") + .addDropdown(dropdown=>dropdown + .addOption("none","None") + .addOption("left-right","Left to right") + .addOption("right-left","Right to left") + .addOption("center-out","Center out") + .addOption("center-in","Center in") + .setValue(hDirection) + .onChange(value => { + hDirection = value; + dirty = true; + }) + ); + + sVGrid = new ea.obsidian.Setting(contentEl) + .setName("Vertical Grid") + .addDropdown(dropdown=>dropdown + .addOption("none","None") + .addOption("top-down","Top down") + .addOption("bottom-up","Bootom up") + .addOption("center-out","Center out") + .addOption("center-in","Center in") + .setValue(vDirection) + .onChange(value => { + vDirection = value; + dirty = true; + }) + ); + + showGridSettings(type === "grid"); + new ea.obsidian.Setting(contentEl) + .addButton(button => button + .setButtonText("Run") + .setCta(true) + .onClick(async (event) => { + draw(); + modal.close(); + }) + ); +} + +modal.onClose = () => { + if(dirty) { + settings["Horizontal Grid"].value = hDirection; + settings["Vertical Grid"].value = vDirection; + settings["Size"].value = size.toString(); + settings["Aspect Choice"].value = aspectChoice; + settings["Type"] = type; + settings["Spiral Orientation"].value = spiralOrientation; + settings["Lock Elements"] = lockElements; + settings["Send to Back"] = sendToBack; + settings["Update Style"] = updateStyle; + settings["Bold Spiral"] = boldSpiral; + ea.setScriptSettings(settings); + } + ownerWindow.removeEventListener('keydown',keydownListener); +} + +modal.open(); \ No newline at end of file diff --git a/ea-scripts/Golden Ratio.svg b/ea-scripts/Golden Ratio.svg new file mode 100644 index 0000000..6d36614 --- /dev/null +++ b/ea-scripts/Golden Ratio.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ea-scripts/directory-info.json b/ea-scripts/directory-info.json index ea7bd60..4207624 100644 --- a/ea-scripts/directory-info.json +++ b/ea-scripts/directory-info.json @@ -1 +1 @@ -[{"fname":"Mindmap connector.md","mtime":1658686599427},{"fname":"Mindmap connector.svg","mtime":1658686599427},{"fname":"Add Connector Point.md","mtime":1645305706000},{"fname":"Add Connector Point.svg","mtime":1645944722000},{"fname":"Add Link to Existing File and Open.md","mtime":1647807918345},{"fname":"Add Link to Existing File and Open.svg","mtime":1645964261000},{"fname":"Add Link to New Page and Open.md","mtime":1654168862138},{"fname":"Add Link to New Page and Open.svg","mtime":1645960639000},{"fname":"Add Next Step in Process.md","mtime":1688304760357},{"fname":"Add Next Step in Process.svg","mtime":1645960639000},{"fname":"Box Each Selected Groups.md","mtime":1645305706000},{"fname":"Box Each Selected Groups.svg","mtime":1645967510000},{"fname":"Box Selected Elements.md","mtime":1645305706000},{"fname":"Box Selected Elements.svg","mtime":1645960639000},{"fname":"Change shape of selected elements.md","mtime":1652701169236},{"fname":"Change shape of selected elements.svg","mtime":1645960775000},{"fname":"Connect elements.md","mtime":1645305706000},{"fname":"Connect elements.svg","mtime":1645960639000},{"fname":"Convert freedraw to line.md","mtime":1645305706000},{"fname":"Convert freedraw to line.svg","mtime":1645960639000},{"fname":"Convert selected text elements to sticky notes.md","mtime":1670169501383},{"fname":"Convert selected text elements to sticky notes.svg","mtime":1645960639000},{"fname":"Convert text to link with folder and alias.md","mtime":1641639819000},{"fname":"Convert text to link with folder and alias.svg","mtime":1645960639000},{"fname":"Copy Selected Element Styles to Global.md","mtime":1642232088000},{"fname":"Copy Selected Element Styles to Global.svg","mtime":1645960639000},{"fname":"Create new markdown file and embed into active drawing.md","mtime":1640866935000},{"fname":"Create new markdown file and embed into active drawing.svg","mtime":1645960639000},{"fname":"Darken background color.md","mtime":1663059051059},{"fname":"Darken background color.svg","mtime":1645960639000},{"fname":"Elbow connectors.md","mtime":1671126911490},{"fname":"Elbow connectors.svg","mtime":1645960639000},{"fname":"Expand rectangles horizontally keep text centered.md","mtime":1646563692000},{"fname":"Expand rectangles horizontally keep text centered.svg","mtime":1645967510000},{"fname":"Expand rectangles horizontally.md","mtime":1644950235000},{"fname":"Expand rectangles horizontally.svg","mtime":1645967510000},{"fname":"Expand rectangles vertically keep text centered.md","mtime":1646563692000},{"fname":"Expand rectangles vertically keep text centered.svg","mtime":1645967510000},{"fname":"Expand rectangles vertically.md","mtime":1658686599427},{"fname":"Expand rectangles vertically.svg","mtime":1645967510000},{"fname":"Fixed horizontal distance between centers.md","mtime":1646743234000},{"fname":"Fixed horizontal distance between centers.svg","mtime":1645960639000},{"fname":"Fixed inner distance.md","mtime":1646743234000},{"fname":"Fixed inner distance.svg","mtime":1645960639000},{"fname":"Fixed spacing.md","mtime":1646743234000},{"fname":"Fixed spacing.svg","mtime":1645967510000},{"fname":"Fixed vertical distance between centers.md","mtime":1646743234000},{"fname":"Fixed vertical distance between centers.svg","mtime":1645967510000},{"fname":"Fixed vertical distance.md","mtime":1646743234000},{"fname":"Fixed vertical distance.svg","mtime":1645967510000},{"fname":"Lighten background color.md","mtime":1663059051059},{"fname":"Lighten background color.svg","mtime":1645959546000},{"fname":"Modify background color opacity.md","mtime":1644924415000},{"fname":"Modify background color opacity.svg","mtime":1645944722000},{"fname":"Normalize Selected Arrows.md","mtime":1670403743278},{"fname":"Normalize Selected Arrows.svg","mtime":1645960639000},{"fname":"Organic Line.md","mtime":1672920172531},{"fname":"Organic Line.svg","mtime":1645964261000},{"fname":"Organic Line Legacy.md","mtime":1690607372668},{"fname":"Organic Line Legacy.svg","mtime":1690607372668},{"fname":"README.md","mtime":1645175700000},{"fname":"Repeat Elements.md","mtime":1663059051059},{"fname":"Repeat Elements.svg","mtime":1645960639000},{"fname":"Reverse arrows.md","mtime":1645305706000},{"fname":"Reverse arrows.svg","mtime":1645960639000},{"fname":"Scribble Helper.md","mtime":1682228345043},{"fname":"Scribble Helper.svg","mtime":1645944722000},{"fname":"Select Elements of Type.md","mtime":1643464321000},{"fname":"Select Elements of Type.svg","mtime":1645960639000},{"fname":"Set Dimensions.md","mtime":1645305706000},{"fname":"Set Dimensions.svg","mtime":1645944722000},{"fname":"Set Font Family.md","mtime":1645305706000},{"fname":"Set Font Family.svg","mtime":1645944722000},{"fname":"Set Grid.md","mtime":1693725826368},{"fname":"Set Grid.svg","mtime":1645960639000},{"fname":"Set Link Alias.md","mtime":1645305706000},{"fname":"Set Link Alias.svg","mtime":1645960639000},{"fname":"Set Stroke Width of Selected Elements.md","mtime":1645305706000},{"fname":"Set Stroke Width of Selected Elements.svg","mtime":1645960639000},{"fname":"Set Text Alignment.md","mtime":1645305706000},{"fname":"Set Text Alignment.svg","mtime":1645960639000},{"fname":"Set background color of unclosed line object by adding a shadow clone.md","mtime":1681665030892},{"fname":"Set background color of unclosed line object by adding a shadow clone.svg","mtime":1645960639000},{"fname":"Split text by lines.md","mtime":1645305706000},{"fname":"Split text by lines.svg","mtime":1645944722000},{"fname":"Zoom to Fit Selected Elements.md","mtime":1640770602000},{"fname":"Zoom to Fit Selected Elements.svg","mtime":1645960639000},{"fname":"directory-info.json","mtime":1646583437000},{"fname":"index-new.md","mtime":1645986149000},{"fname":"index.md","mtime":1645175700000},{"fname":"Grid Selected Images.md","mtime":1701630797839},{"fname":"Grid Selected Images.svg","mtime":1649614401982},{"fname":"Palette loader.md","mtime":1686511890942},{"fname":"Palette loader.svg","mtime":1649614401982},{"fname":"Rename Image.md","mtime":1663678478785},{"fname":"Rename Image.svg","mtime":1663678478785},{"fname":"Text Arch.md","mtime":1664095143846},{"fname":"Text Arch.svg","mtime":1670403743278},{"fname":"Deconstruct selected elements into new drawing.md","mtime":1693733190088},{"fname":"Deconstruct selected elements into new drawing.svg","mtime":1668541145255},{"fname":"Slideshow.md","mtime":1700511998048},{"fname":"Slideshow.svg","mtime":1670017348333},{"fname":"Auto Layout.md","mtime":1670403743278},{"fname":"Auto Layout.svg","mtime":1670175947081},{"fname":"Uniform size.md","mtime":1670175947081},{"fname":"Uniform size.svg","mtime":1670175947081},{"fname":"Mindmap format.md","mtime":1684484694228},{"fname":"Mindmap format.svg","mtime":1674944958059},{"fname":"Text to Sticky Notes.md","mtime":1678537561724},{"fname":"Text to Sticky Notes.svg","mtime":1678537561724},{"fname":"Folder Note Core - Make Current Drawing a Folder.md","mtime":1678973697470},{"fname":"Folder Note Core - Make Current Drawing a Folder.svg","mtime":1678973697470},{"fname":"Invert colors.md","mtime":1678973697470},{"fname":"Invert colors.svg","mtime":1678973697470},{"fname":"Auto Draw for Pen.md","mtime":1680418321236},{"fname":"Auto Draw for Pen.svg","mtime":1680418321236},{"fname":"Hardware Eraser Support.md","mtime":1680418321236},{"fname":"Hardware Eraser Support.svg","mtime":1680418321236},{"fname":"PDF Page Text to Clipboard.md","mtime":1683984041712},{"fname":"PDF Page Text to Clipboard.svg","mtime":1680418321236},{"fname":"Excalidraw Collaboration Frame.md","mtime":1687881495985},{"fname":"Excalidraw Collaboration Frame.svg","mtime":1687881495985},{"fname":"Create DrawIO file.md","mtime":1688243858267},{"fname":"Create DrawIO file.svg","mtime":1688243858267},{"fname":"Ellipse Selected Elements.md","mtime":1690131476331},{"fname":"Ellipse Selected Elements.svg","mtime":1690131476331},{"fname":"Select Similar Elements.md","mtime":1691270949338},{"fname":"Select Similar Elements.svg","mtime":1691270949338},{"fname":"Toggle Grid.md","mtime":1692125382945},{"fname":"Toggle Grid.svg","mtime":1692124753386},{"fname":"Split Ellipse.md","mtime":1693134104356},{"fname":"Split Ellipse.svg","mtime":1693134104356},{"fname":"Text Aura.md","mtime":1693731979540},{"fname":"Text Aura.svg","mtime":1693731979540},{"fname":"Boolean Operations.md","mtime":1695746839537},{"fname":"Boolean Operations.svg","mtime":1695746839537},{"fname":"Concatenate lines.md","mtime":1696175301525},{"fname":"Concatenate lines.svg","mtime":1696175301525},{"fname":"GPT-Draw-a-UI.md","mtime":1702241631730},{"fname":"GPT-Draw-a-UI.svg","mtime":1700511998048},{"fname":"ExcaliAI.md","mtime":1702241631730},{"fname":"ExcaliAI.svg","mtime":1701011028767},{"fname":"Repeat Texts.md","mtime":1701969627758},{"fname":"Repeat Texts.svg","mtime":1701969627758},{"fname":"Relative Font Size Cycle.md","mtime":1701969627758},{"fname":"Relative Font Size Cycle.svg","mtime":1701969627758}] \ No newline at end of file +[{"fname":"Mindmap connector.md","mtime":1658686599427},{"fname":"Mindmap connector.svg","mtime":1658686599427},{"fname":"Add Connector Point.md","mtime":1645305706000},{"fname":"Add Connector Point.svg","mtime":1645944722000},{"fname":"Add Link to Existing File and Open.md","mtime":1647807918345},{"fname":"Add Link to Existing File and Open.svg","mtime":1645964261000},{"fname":"Add Link to New Page and Open.md","mtime":1654168862138},{"fname":"Add Link to New Page and Open.svg","mtime":1645960639000},{"fname":"Add Next Step in Process.md","mtime":1688304760357},{"fname":"Add Next Step in Process.svg","mtime":1645960639000},{"fname":"Box Each Selected Groups.md","mtime":1645305706000},{"fname":"Box Each Selected Groups.svg","mtime":1645967510000},{"fname":"Box Selected Elements.md","mtime":1645305706000},{"fname":"Box Selected Elements.svg","mtime":1645960639000},{"fname":"Change shape of selected elements.md","mtime":1652701169236},{"fname":"Change shape of selected elements.svg","mtime":1645960775000},{"fname":"Connect elements.md","mtime":1645305706000},{"fname":"Connect elements.svg","mtime":1645960639000},{"fname":"Convert freedraw to line.md","mtime":1645305706000},{"fname":"Convert freedraw to line.svg","mtime":1645960639000},{"fname":"Convert selected text elements to sticky notes.md","mtime":1670169501383},{"fname":"Convert selected text elements to sticky notes.svg","mtime":1645960639000},{"fname":"Convert text to link with folder and alias.md","mtime":1641639819000},{"fname":"Convert text to link with folder and alias.svg","mtime":1645960639000},{"fname":"Copy Selected Element Styles to Global.md","mtime":1642232088000},{"fname":"Copy Selected Element Styles to Global.svg","mtime":1645960639000},{"fname":"Create new markdown file and embed into active drawing.md","mtime":1640866935000},{"fname":"Create new markdown file and embed into active drawing.svg","mtime":1645960639000},{"fname":"Darken background color.md","mtime":1663059051059},{"fname":"Darken background color.svg","mtime":1645960639000},{"fname":"Elbow connectors.md","mtime":1671126911490},{"fname":"Elbow connectors.svg","mtime":1645960639000},{"fname":"Expand rectangles horizontally keep text centered.md","mtime":1646563692000},{"fname":"Expand rectangles horizontally keep text centered.svg","mtime":1645967510000},{"fname":"Expand rectangles horizontally.md","mtime":1644950235000},{"fname":"Expand rectangles horizontally.svg","mtime":1645967510000},{"fname":"Expand rectangles vertically keep text centered.md","mtime":1646563692000},{"fname":"Expand rectangles vertically keep text centered.svg","mtime":1645967510000},{"fname":"Expand rectangles vertically.md","mtime":1658686599427},{"fname":"Expand rectangles vertically.svg","mtime":1645967510000},{"fname":"Fixed horizontal distance between centers.md","mtime":1646743234000},{"fname":"Fixed horizontal distance between centers.svg","mtime":1645960639000},{"fname":"Fixed inner distance.md","mtime":1646743234000},{"fname":"Fixed inner distance.svg","mtime":1645960639000},{"fname":"Fixed spacing.md","mtime":1646743234000},{"fname":"Fixed spacing.svg","mtime":1645967510000},{"fname":"Fixed vertical distance between centers.md","mtime":1646743234000},{"fname":"Fixed vertical distance between centers.svg","mtime":1645967510000},{"fname":"Fixed vertical distance.md","mtime":1646743234000},{"fname":"Fixed vertical distance.svg","mtime":1645967510000},{"fname":"Lighten background color.md","mtime":1663059051059},{"fname":"Lighten background color.svg","mtime":1645959546000},{"fname":"Modify background color opacity.md","mtime":1644924415000},{"fname":"Modify background color opacity.svg","mtime":1645944722000},{"fname":"Normalize Selected Arrows.md","mtime":1670403743278},{"fname":"Normalize Selected Arrows.svg","mtime":1645960639000},{"fname":"Organic Line.md","mtime":1672920172531},{"fname":"Organic Line.svg","mtime":1645964261000},{"fname":"Organic Line Legacy.md","mtime":1690607372668},{"fname":"Organic Line Legacy.svg","mtime":1690607372668},{"fname":"README.md","mtime":1645175700000},{"fname":"Repeat Elements.md","mtime":1663059051059},{"fname":"Repeat Elements.svg","mtime":1645960639000},{"fname":"Reverse arrows.md","mtime":1645305706000},{"fname":"Reverse arrows.svg","mtime":1645960639000},{"fname":"Scribble Helper.md","mtime":1682228345043},{"fname":"Scribble Helper.svg","mtime":1645944722000},{"fname":"Select Elements of Type.md","mtime":1643464321000},{"fname":"Select Elements of Type.svg","mtime":1645960639000},{"fname":"Set Dimensions.md","mtime":1645305706000},{"fname":"Set Dimensions.svg","mtime":1645944722000},{"fname":"Set Font Family.md","mtime":1645305706000},{"fname":"Set Font Family.svg","mtime":1645944722000},{"fname":"Set Grid.md","mtime":1693725826368},{"fname":"Set Grid.svg","mtime":1645960639000},{"fname":"Set Link Alias.md","mtime":1645305706000},{"fname":"Set Link Alias.svg","mtime":1645960639000},{"fname":"Set Stroke Width of Selected Elements.md","mtime":1645305706000},{"fname":"Set Stroke Width of Selected Elements.svg","mtime":1645960639000},{"fname":"Set Text Alignment.md","mtime":1645305706000},{"fname":"Set Text Alignment.svg","mtime":1645960639000},{"fname":"Set background color of unclosed line object by adding a shadow clone.md","mtime":1681665030892},{"fname":"Set background color of unclosed line object by adding a shadow clone.svg","mtime":1645960639000},{"fname":"Split text by lines.md","mtime":1645305706000},{"fname":"Split text by lines.svg","mtime":1645944722000},{"fname":"Zoom to Fit Selected Elements.md","mtime":1640770602000},{"fname":"Zoom to Fit Selected Elements.svg","mtime":1645960639000},{"fname":"directory-info.json","mtime":1646583437000},{"fname":"index-new.md","mtime":1645986149000},{"fname":"index.md","mtime":1645175700000},{"fname":"Grid Selected Images.md","mtime":1701630797839},{"fname":"Grid Selected Images.svg","mtime":1649614401982},{"fname":"Palette loader.md","mtime":1686511890942},{"fname":"Palette loader.svg","mtime":1649614401982},{"fname":"Rename Image.md","mtime":1663678478785},{"fname":"Rename Image.svg","mtime":1663678478785},{"fname":"Text Arch.md","mtime":1664095143846},{"fname":"Text Arch.svg","mtime":1670403743278},{"fname":"Deconstruct selected elements into new drawing.md","mtime":1693733190088},{"fname":"Deconstruct selected elements into new drawing.svg","mtime":1668541145255},{"fname":"Slideshow.md","mtime":1700511998048},{"fname":"Slideshow.svg","mtime":1670017348333},{"fname":"Auto Layout.md","mtime":1670403743278},{"fname":"Auto Layout.svg","mtime":1670175947081},{"fname":"Uniform size.md","mtime":1670175947081},{"fname":"Uniform size.svg","mtime":1670175947081},{"fname":"Mindmap format.md","mtime":1684484694228},{"fname":"Mindmap format.svg","mtime":1674944958059},{"fname":"Text to Sticky Notes.md","mtime":1678537561724},{"fname":"Text to Sticky Notes.svg","mtime":1678537561724},{"fname":"Folder Note Core - Make Current Drawing a Folder.md","mtime":1678973697470},{"fname":"Folder Note Core - Make Current Drawing a Folder.svg","mtime":1678973697470},{"fname":"Invert colors.md","mtime":1678973697470},{"fname":"Invert colors.svg","mtime":1678973697470},{"fname":"Auto Draw for Pen.md","mtime":1680418321236},{"fname":"Auto Draw for Pen.svg","mtime":1680418321236},{"fname":"Hardware Eraser Support.md","mtime":1680418321236},{"fname":"Hardware Eraser Support.svg","mtime":1680418321236},{"fname":"PDF Page Text to Clipboard.md","mtime":1683984041712},{"fname":"PDF Page Text to Clipboard.svg","mtime":1680418321236},{"fname":"Excalidraw Collaboration Frame.md","mtime":1687881495985},{"fname":"Excalidraw Collaboration Frame.svg","mtime":1687881495985},{"fname":"Create DrawIO file.md","mtime":1688243858267},{"fname":"Create DrawIO file.svg","mtime":1688243858267},{"fname":"Ellipse Selected Elements.md","mtime":1690131476331},{"fname":"Ellipse Selected Elements.svg","mtime":1690131476331},{"fname":"Select Similar Elements.md","mtime":1691270949338},{"fname":"Select Similar Elements.svg","mtime":1691270949338},{"fname":"Toggle Grid.md","mtime":1692125382945},{"fname":"Toggle Grid.svg","mtime":1692124753386},{"fname":"Split Ellipse.md","mtime":1693134104356},{"fname":"Split Ellipse.svg","mtime":1693134104356},{"fname":"Text Aura.md","mtime":1693731979540},{"fname":"Text Aura.svg","mtime":1693731979540},{"fname":"Boolean Operations.md","mtime":1695746839537},{"fname":"Boolean Operations.svg","mtime":1695746839537},{"fname":"Concatenate lines.md","mtime":1696175301525},{"fname":"Concatenate lines.svg","mtime":1696175301525},{"fname":"GPT-Draw-a-UI.md","mtime":1702241631730},{"fname":"GPT-Draw-a-UI.svg","mtime":1700511998048},{"fname":"ExcaliAI.md","mtime":1702241631730},{"fname":"ExcaliAI.svg","mtime":1701011028767},{"fname":"Repeat Texts.md","mtime":1701969627758},{"fname":"Repeat Texts.svg","mtime":1701969627758},{"fname":"Relative Font Size Cycle.md","mtime":1701969627758},{"fname":"Relative Font Size Cycle.svg","mtime":1701969627758},{"fname":"Golden Ratio.md","mtime":1702795979820},{"fname":"Golden Ratio.svg","mtime":1702795979820}] \ No newline at end of file diff --git a/ea-scripts/index-new.md b/ea-scripts/index-new.md index 276c30e..4af2086 100644 --- a/ea-scripts/index-new.md +++ b/ea-scripts/index-new.md @@ -44,6 +44,7 @@ I would love to include your contribution in the script library. If you have a s |
|[[#Fixed spacing]]| |
|[[#Fixed vertical distance between centers]]| |
|[[#Fixed vertical distance]]| +|
|[[#Golden Ratio]]| |
|[[#Grid selected images]]| |
|[[#Mindmap format]]| |
|[[#Zoom to Fit Selected Elements]]| @@ -348,6 +349,14 @@ https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea ```
Author@zsviczian
SourceFile on GitHub
DescriptionThis script adds the `Folder Note Core: Make current document folder note` function to Excalidraw drawings. Running this script will convert the active Excalidraw drawing into a folder note. If you already have embedded images in your drawing, those attachments will not be moved when the folder note is created. You need to take care of those attachments separately, or convert the drawing to a folder note prior to adding the attachments. The script requires the Folder Note Core plugin.
+## Golden Ratio +```excalidraw-script-install +https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Golden%20Ratio.md +``` +
Author@zsviczian
SourceFile on GitHub
DescriptionThe script performs two different functions depending on the elements selected in the view.
+1) In case you select text elements, the script will cycle through a set of font scales. First the 2 larger fonts following the Fibonacci sequence (fontsize * φ; fonsize * φ^2), then the 2 smaller fonts (fontsize / φ; fontsize / φ^2), finally the original size, followed again by the 2 larger fonts. If you wait 2 seconds, the sequence clears and starts from which ever font size you are on. So if you want the 3rd larges font, then toggle twice, wait 2 sec, then toggle again.
+2) In case you select a single rectangle, the script will open the "Golden Grid", "Golden Spiral" window, where you can set up the type of grid or spiral you want to insert into the document.
+ ## Grid selected images ```excalidraw-script-install https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Grid%20Selected%20Images.md