From e85c74bb10527149f3cbe91ab5355c90168729e3 Mon Sep 17 00:00:00 2001 From: electricjay Date: Thu, 19 Apr 2012 16:22:59 -0700 Subject: [PATCH] Initial Checkin of select_intersecting_objects select_intersecting_objects selects all paths in the document who's bounding box overlaps the geometry of the current selection. --- Organify.js | 90 +-------------------------------- Select_intersecting_objects.jsx | 1 + 2 files changed, 2 insertions(+), 89 deletions(-) create mode 100644 Select_intersecting_objects.jsx diff --git a/Organify.js b/Organify.js index c70c247..e6d3baf 100644 --- a/Organify.js +++ b/Organify.js @@ -1,89 +1 @@ -///////////////////////////////////////////////////////////////// -//Organify 2.0 -- CS, CS2 -//>=-------------------------------------- -//Randomizes all selected anchors by a selected number of points. -// -// Enter small numbers to make objects look hand drawn. -// Enter larger numbers to make objects look organic. -// Enter even larger numbers to distort beyond recognition. -// -// V.2 now offers a choice for randomizing 'Anchors Only', 'Control Handles Only' or both. -// (click here to view sample image.) -//>=-------------------------------------- -// JS code (c) copyright: John Wundes ( john@wundes.com ) www.wundes.com -//copyright full text here: http://www.wundes.com/js4ai/copyright.txt -////////////////////////////////////////////////////////////////// - -var docRef= app.activeDocument; - -if ( app.documents.length > 0) -{ - sel = activeDocument.selection; - max = sel.length; - - rvar = prompt("How much stray? (in points)",30); - uchoice= prompt("Enter\t'1' for anchors only (Spikey),\n\t'2' for handles only (Bulbous), or\n\t'3' for both anchors and handles (Chaotic)",3); - - for(var cpi=0;cpi=-------------------------------------- //Randomizes all selected anchors by a selected number of points. // // Enter small numbers to make objects look hand drawn. // Enter larger numbers to make objects look organic. // Enter even larger numbers to distort beyond recognition. // // V.2 now offers a choice for randomizing 'Anchors Only', 'Control Handles Only' or both. // (click here to view sample image.) //>=-------------------------------------- // JS code (c) copyright: John Wundes ( john@wundes.com ) www.wundes.com //copyright full text here: http://www.wundes.com/js4ai/copyright.txt ////////////////////////////////////////////////////////////////// var organify_options = { move_handles: false, move_anchors: true, stray_distance: 30 /*in points */, create_dialog: function() { var win = if ( app.documents.length > 0) { sel = activeDocument.selection; max = sel.length; rvar = prompt("How much stray? (in points)",30); uchoice= prompt("Enter\t'1' for anchors only (Spikey),\n\t'2' for handles only (Bulbous), or\n\t'3' for both anchors and handles (Chaotic)",3); for(var cpi=0;cpi box[2]) { var tmp = box[0]; box[0] = box[2]; box[2] = tmp; } if (box[1] > box[3]) { var tmp = box[1]; box[1] = box[3]; box[3] = tmp; } for (var i = 1; i < objects.length; i++) { obox = objects[i].visibleBounds; if (obox[0] < box[0]) box[0] = obox[0]; if (obox[2] < box[0]) box[0] = obox[2]; if (obox[1] < box[1]) box[1] = obox[1]; if (obox[3] < box[1]) box[1] = obox[3]; if (obox[0] > box[2]) box[2] = obox[0]; if (obox[2] > box[2]) box[2] = obox[2]; if (obox[1] > box[3]) box[3] = obox[1]; if (obox[3] > box[3]) box[3] = obox[3]; } return box; } function get_indexes_of_selected(objects) { var indexes = []; for (i = 0; i < objects.length; i++) { if (objects[i].selected) { indexes.push(i); //dump_object_alert(objects[i]); } } return indexes; } function dump_object_alert(obj) { var expanded = ''; for (i in obj) { try{ expanded += i + ": " + obj[i] + "\n"; } catch(e) { expanded += i + ": \n"; } } alert (expanded); } function rects_overlap(a, b) { if ((a[0] > b[0] != a[0] > b[2]) || (a[2] > b[0] != a[2] > b[2])) if ((a[1] > b[1] != a[1] > b[3]) || (a[3] > b[1] != a[3] > b[3])) return true; // check if a competely encloses b if ((b[0] > a[0] != b[0] > a[2]) && (b[1] > a[1] != b[1] > a[3])) return true; return false; } /* Makes sure the rect is atleast 1pt wide and tall (the minimum artboard size) */ function scale_rect_to_minimum_artboard_size(r) { if (Math.abs(r[0] - r[2]) < 1) { var center = (r[0] + r[2]) /2.0; r[0] = center -.5; r[2] = center +.5; } if (Math.abs(r[1] - r[3]) < 1) { var center = (r[1] + r[3]) /2.0; r[1] = center -.5; r[3] = center +.5; } } \ No newline at end of file