/////////////////////////////////////////////////////////////////
//Text Tweaker v2.0 -- CS, CS2
//>=--------------------------------------
//
// This script randomly tweaks each letter in all selected text fields.
// Text lines remain unbroken, and text remains editable.
//
// Current tweakable attributes are:
// 1) baselineShift
// 2) horizontalScale
// 3) verticalScale
// 4) rotation
// 5) size
// 6) strokeWeight
// 7) tracking
// 8) leading
//
// New in version 1.1
// Select a linear range to scale text smoothly from 10 to 50.
// New in version 2.0
// smoother transitions between states, and basic (bow and spike) envelope shapes.
// random setting is now set between start and end values rather than from 0
// uses cubic easing for all (non random) transforms
//
//>=--------------------------------------
// JS code (c) copyright: John Wundes ( john@wundes.com ) www.wundes.com
// copyright full text here: http://www.wundes.com/js4ai/copyright.txt
//
// Cubic Easing formulae from:
// Robert Penner's Easing Equations v1.5 (c) 2003
// see his work here http://www.robertpenner.com/
//////////////////////////////////////////////////////////////////
if ( app.documents.length > 0 && activeDocument.selection.length>0)
{
//set defaults
var start = 100;
var finish = 200;
var easeThis = prompt("Enter the number of the attribute to change:\n1) baselineShift\t2) HScale\t3) VScale\t4) rotation\t\t5) size \t6) strokeWeight\t\t7) tracking\t8) leading","5")*1;
//var andRet = true;
var adder = 0;
var ui = prompt("Enter Start and Finish Text Point Sizes separated by a comma.",start+","+finish);
var rand = confirm("Would you like to randomize the output?");
start = (ui.split(",")[0]*1);
finish = (ui.split(",")[1]*1);
if(rand!=true){
var andRet = confirm("Do you want the line to change to "+finish+" in the middle, and return to "+start+"?");
/*
1 = bow Left
2 = full bow
3 = bow right
4 = spike
*/
if(andRet==true){
var waveShape = prompt("Enter 1-4 for transform shape (1)left, (2)bow, (3)right,or (4)spike.","4")*1;
}else{
var waveShape = prompt("Enter (1) to bow or (4) to spike","4")*1;
}
}
var docRef = activeDocument;
var sel = docRef.selection;
for(all in sel){
textRef = sel[all];
if(textRef.typename == "TextFrame"){
//activeDocument.selection[0].textRange.characters[1].characterAttributes
var charCount = textRef.textRange.characters.length;
var dif = finish-start;
var gain = dif / (charCount-1);
var size = start;
if (rand==true){
//Randomize Text
randomizeText(charCount,dif,start,easeThis);
}else if(andRet==true){
//if we want to wave up and back:
var cc2 = Math.floor(charCount/2);
//if line is not an even number of characters
if(!(cc2 == charCount/2)){
adder = 1;
}
charCount = cc2;
dif = finish-start;
gain = dif / (charCount-1);
size = start;
//going up....
easeText(0,charCount,easeThis);
//
//reset everything half way...
var hold = start;
start = finish;
finish=hold;
//
dif = finish-start;
gain = dif / (charCount-1);
//
size = start;
//now back down...
easeText(charCount,(charCount*2)+adder,easeThis);
} else {
//wave one direction only
easeText(0,charCount,easeThis);
}
}else{
//alert("Selection is not a Text Frame");
}
}
}else{
alert("No open Documents or Nothing Selected.");
}
//--Randomize Data
function randomizeText(ct,d,st,easeMe){
//charcount difference start
for(i=0; i