Skip to content

Instantly share code, notes, and snippets.

View trych's full-sized avatar

trych

View GitHub Profile
@trych
trych / ES_IndentFirstLineToPrevious.js
Created November 7, 2015 19:15
ExtendScript: Fit firstLineIndent to previous paragraph
// fits the firstLineIndent of a paragraph to the end of the previous paragraph
// as asked here: https://graphicdesign.stackexchange.com/questions/62916/
#target InDesign
var defaultIndent = 5;
//Checks if a text frame with 2 or more paragraphs was selected.
if (app.selection.length < 1 || !(app.selection[0].parentStory.paragraphs.length > 1)) {
alert("Error\nSelect a text frame with at least 2 paragraphs and try again.");
@trych
trych / RemoveRecentSU.jsx
Last active December 21, 2015 22:45
InDesign Remove Recent Items StartUp-Script
#target InDesign
#targetengine "removeRecentItems"
var menuName = "Remove Recent";
var removeAction = app.scriptMenuActions.add(menuName);
removeAction.eventListeners.add("onInvoke", removeRecentItems);
removeAction.eventListeners.add("beforeDisplay", recentAvailable);
var mainMenu = app.menus.itemByName("$ID/Main");
@trych
trych / RemoveRecent.jsx
Created December 21, 2015 22:47
InDesign Remove Recent Items
#target InDesign
var userOR = app.generalPreferences.openRecentLength;
app.generalPreferences.openRecentLength = 0;
app.generalPreferences.openRecentLength = userOR;
@trych
trych / Bundschnitt.js
Last active August 2, 2016 22:37
Bundschnitt erstellen
#target indesign
var doc = app.activeDocument;
doc.viewPreferences.rulerOrigin = RulerOrigin.SPREAD_ORIGIN;
doc.documentPreferences.allowPageShuffle = false;
cleanDocument(doc);
// @includepath "~/Documents/;%USERPROFILE%Documents";
// @include "basiljs/basil.js";
// HOW TO USE:
// - to run the script, you first need to install basil.js: http://basiljs.ch
// - Make sure, you're on the first page of your doc
// - select the page item that you want to appear in the fore edge
// - rotate it accordingly
// - if using text, convert to outlines
// - run the script, enter the required # of pages
@trych
trych / DottedCircle.pde
Created June 8, 2018 23:02
A dotted circle in Processing. Note that the dotted line is only faked by drawing lines in the background color on top.
size(512, 512);
background(255);
strokeWeight(20);
translate(width / 2, height / 2);
ellipse(0, 0, 400, 400);
stroke(255);
@trych
trych / ExportMailAdresses.scpt
Last active July 26, 2019 09:38
Exports all "From" addresses of a specific email inbox to Numbers for further processing. Duplicates are still present and need to be removed in the spreadsheet app.
tell application "Numbers"
set LinkRemoval to make new document
set theSheet to active sheet of LinkRemoval
tell table 1 of theSheet
set the value of cell 1 of column "A" to "From"
end tell
end tell
@trych
trych / getLastInlineRange.js
Last active September 6, 2019 14:43
Demonstrates how to retrieve a text object resembling the last text style range *within* a single line.
#target indesign
// use on some text frame with several text style ranges in the first line
// if the text range continues into the second line, only the range within the first line will be returned
var l = app.activeDocument.textFrames.firstItem().lines.firstItem();
var lir = getLastInlineRange(l);
app.select(lir);
function getLastInlineRange(l) {
var ltsr = l.textStyleRanges.lastItem();
@trych
trych / ExtendScript.sublime-syntax
Created January 7, 2020 11:27
ExtendScript Syntax highlighting
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: ExtendScript
file_extensions:
- jsx
- jsxinc
scope: source.jsx
contexts:
main:
@trych
trych / pixi-js-slideshow.js
Created January 22, 2020 22:55
Pixi.js code that produces the blur problem
const canvasScale = 1.06;
const landscapeRatio = 0.9;
const portraitRatio = 0.5;
const targetScale = 1.2;
const blurStrength = 12;
let blurFilters = [];
var anim = {
globalOffset: 0,
globalPos: 1,