Jump to content

Text with multiple gradients


Stack

Recommended Posts

I'm trying to create gradient text for a business card project, and I came across this old post from 2013. The code has been adapted and is working, however our gradient is a gold color on the left and right, white in the middle:Screenshot2024-04-25at3_25_14PM.png.567134383d1e97d3e3bd39f9e78cbe5e.png

Our work around has been to create two rules; "Address 1 &Address 2" is one rule, ", City, State ZIP" is the other rule and the Start/End colors are reversed for each. Both are inserted and centered in a text box so it looks like the gradient transitions gold-white-gold. Obviously this doesn't look too great, the white portion won't always be centered within the text box since the Addresses and City/State/Zip will almost always have different character lengths. Is there a way to adapt the code to include a third (or more) color to the gradient?

Link to comment
Share on other sites

Tried to update the post above with the code but it was too late. Below is the code from our template, for reference:




var FieldName= "CompleteAddress";
var End = [1,1,1,0]; 
var Start = [15,28,62,0]; 

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("Gradient_01_"+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="Gradient_01_'+c+'">'+Mid(Rule(FieldName), c+1, 1);
   }
}

Result = Result + "<\span>";

return Result;

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...