tim lindner Posted October 9, 2013 Share Posted October 9, 2013 Recently a client need some type with a horizontal gradient blend. I came up with this: // Return "FieldName" colorized from left (start color) to right (end color). // Remember to turn on "Treat returned strings as tagged text" check box. var FieldName="Field Name"; var Start = [2,63,98,1]; // Start color: [C,M,Y,K] var End = [23,85,100,16]; // End Color: [C,M,Y,K] var FieldLength = Len(Rule(FieldName)); var StepCyan = (End[0]-Start[0])/FieldLength; var StepMagenta = (End[1]-Start[1])/FieldLength; var StepYellow = (End[2]-Start[2])/FieldLength; var StepBlack = (End[3]-Start[3])/FieldLength; var myColor; var Result = "<span>"; // Build Colors for Text for (c = 0; c < FieldLength; c++) { myColor = new FusionProColor("CustomGradColor"+c, Start[0]+(StepCyan*c), Start[1]+(StepMagenta*c), Start[2]+(StepYellow*c), Start[3]+(StepBlack*c)); } // Build resulting string for (c = 0; c < FieldLength; c++) { if (Asc(Mid(Rule(FieldName), c+1, 1)) == 32) { // Special case the space character Result = Result + " "; // Use " " for a breaking space } else if (Asc(Mid(Rule(FieldName), c+1, 1)) == 38) { // Special case the ampersand character Result = Result + "&"; } else { Result = Result + '<color name="CustomGradColor'+c+'">'+Mid(Rule(FieldName), c+1, 1); } } Result = Result + "<\span>"; return Result; This does a "fake" gradient blend by colorizing each character in the string. It's really only useful for a single line of type. If the line breaks the gradient will wrap with the type. Quote Link to comment Share on other sites More sharing options...
scotts Posted August 4, 2017 Share Posted August 4, 2017 Tim, thanks for sharing. Been quite a while since you posted it, but it was just what I needed for a project I'm working on. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.