Skip to content

Instantly share code, notes, and snippets.

View milligramme's full-sized avatar

milligramme milligramme

View GitHub Profile
void setup() {
size(screen.width, screen.height,P3D);
smooth();
frameRate(60);
}
void draw() {
background(2,5,2);
translate(150, 240, 100*sin(radians(frameCount%360)));
//println(mouseY);
//@target indesign
// 合成フォントを含むidmlをひらくと、すでにひらいているinddの同名合成フォント情報まで破壊する
app.documents.everyItem().close(SaveOptions.NO)
var indd_file = File(Folder.desktop + "/foo.indd")
var idml_file = File(Folder.desktop + "/foo.idml")
var doc = app.documents.add()
doc.save(indd_file)
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
var img = obj.place(File(file_path));
// set anchor
obj.frameFittingOptions.fittingAlignment = AnchorPoint.CENTER_ANCHOR;
// fit
img[0].fit(FitOptions.CENTER_CONTENT);
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
@milligramme
milligramme / toggle_target_display_mode.scpt
Last active June 8, 2017 01:51
use iMac as external display with target display mode
tell application "System Events"
key code 122 using command down # Cmd-F2
end tell
-- rescue untouchable application frame
tell application "Adobe InDesign CC"
set rescue_bound to {32, 0, 400, 400}
if not use application frame of general preferences then
set use application frame of general preferences to true
end if
if not exists active window then
make new document
//@target "indesign"
var sel = app.selection[0];
var ret = find_parent(sel, 'Group');
function find_parent (obj, constructor) {
if (obj.parent.parent.constructor.name !== constructor) {
return obj.parent
}
else {
return arguments.callee(obj.parent, constructor);
@milligramme
milligramme / ind_bug_pathpoint_anchor_handling.jsx
Last active February 2, 2017 00:43
InDesign TextPreferences.insetSpacing bug test
/*
フレーム内マージンが設定されたテキストフレーム
のアンカーの位置を操作するとマージン分余計に動いてしまう
*/
var test = function (doc, opts) {
var textframe = doc.textFrames.add({
geometricBounds: opts['frame_bon']
});
// フレーム内マージン!!!
@milligramme
milligramme / ind_read_with_guess.jsx
Last active December 19, 2016 00:54
read textfile with cp932, on mojibake try with utf-8
//@target "indesign"
var read_with_guess = function (path, encoding) {
var f = File(path);
f.encoding = encoding || "cp932";
if (f.open("r")) {
var r = f.read();
// TODO regexp pattern
if (r.match(/[縲縺繧翫]+/)) {
//@target "indesign"
$.writeln(app.version);
var doc = app.documents.add();
app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
var tf = doc.textFrames.add({geometricBounds:[10,10,50,100]});
var tbl = tf.tables.add({bodyRowCount:4, columnCount:4});
var cr= tbl.rows[0];
r.autoGrow = false;
//@target "indesign"
$.writeln(app.version);
var doc = app.documents.add();
app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
var tf = doc.textFrames.add({geometricBounds:[10,10,50,100]});
var tbl = tf.tables.add({bodyRowCount:4, columnCount:4});
var c = tbl.columns[0];
var i = 4;
while (i-=0.0001) {