Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 21st, 2013, 08:05 AM
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 869
Default Adding custom CMYK builds

I have a project with multiple templates which all use a common library of colors. The client likes to add/remove colors on occasion and sometimes edits a color's build at the last minute. I had been creating/editing colors in the Colors dialog for each of the templates, but this is getting to be quite tedious, especially when adding new templates and setting up 24+ custom colors.

I noticed on the forum that I could add tags to my text in the form of <color cmyk="00000000"> but apparently the value must be converted to hex format rather than decimal.

FEATURE REQUEST: Update the color tag to accept CMYK input in standard decimal format!

Until my feature request is implemented, I wrote a function that converts a CMYK color build to its 8-character hex format to appease the FP gods. This way I can enter my values in an OnJobStart callback rule and convert to the proper format when generating my tagged text. I can add/edit colors much easier in JavaScript than by accessing the Colors dialog, especially since I have a single, common JavaScript file that I load for every template -- I can now make the changes in one place for everything.

Code:
var color = [0,83,54,16]; // [C,M,Y,K]

function cmyk2hex(cmykArr) {
    var hexBuild = [];
    for (var i=0; i<cmykArr.length; i++) {
        var thisColor = Math.round(cmykArr[i] * 2.55);
        hexBuild[i] = thisColor.toString(16);
        if (hexBuild[i].length == 1) hexBuild[i] = "0" + thisColor;
    }
    return hexBuild.join("");
}

return cmyk2hex(color);

Last edited by esmith; June 21st, 2013 at 08:11 AM.. Reason: clarification
Reply With Quote
  #2  
Old June 21st, 2013, 10:50 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,592
Default Re: Adding custom CMYK builds

Quote:
Originally Posted by esmith View Post
I have a project with multiple templates which all use a common library of colors. The client likes to add/remove colors on occasion and sometimes edits a color's build at the last minute. I had been creating/editing colors in the Colors dialog for each of the templates, but this is getting to be quite tedious, especially when adding new templates and setting up 24+ custom colors.
If you ever find yourself doing some kind of tedious, repetitive task like this, there's almost always a way to automate it.
Quote:
Originally Posted by esmith View Post
I noticed on the forum that I could add tags to my text in the form of <color cmyk="00000000"> but apparently the value must be converted to hex format rather than decimal.

FEATURE REQUEST: Update the color tag to accept CMYK input in standard decimal format!
Well, I could quibble about whether decimal format is actually more "standard" than hexadecimal. FusionPro's tagged markup is based on HTML, which uses hexadecimal representations for color values in tags such as <font color="#ff0000"> and <BODY BGCOLOR="#ff6600">. Computers store data in binary, which is more easily expressed in a "power of two" numbering system like octal or hexadecimal than a base-ten system like decimal.

Anyway, what exactly do you suggest? Can you provide an example of what a tag would look like with decimal values? Would it be something like <cmyk(255,0,0,0)">? Would it be based on a range of 0 to 100, or 0 to 255?
Quote:
Originally Posted by esmith View Post
Until my feature request is implemented, I wrote a function that converts a CMYK color build to its 8-character hex format to appease the FP gods. This way I can enter my values in an OnJobStart callback rule and convert to the proper format when generating my tagged text. I can add/edit colors much easier in JavaScript than by accessing the Colors dialog, especially since I have a single, common JavaScript file that I load for every template -- I can now make the changes in one place for everything.

Code:
var color = [0,83,54,16]; // [C,M,Y,K]

function cmyk2hex(cmykArr) {
    var hexBuild = [];
    for (var i=0; i<cmykArr.length; i++) {
        var thisColor = Math.round(cmykArr[i] * 2.55);
        hexBuild[i] = thisColor.toString(16);
        if (hexBuild[i].length == 1) hexBuild[i] = "0" + thisColor;
    }
    return hexBuild.join("");
}

return cmyk2hex(color);
That's a nice solution. However, in FusionPro 8.1, there's already a much easier, built-in way to do this:
Code:
var myColor = new FusionProColor("Your Custom Color Name", 100, 0, 0, 0);
return '<color name="Your Custom Color Name">Hi there!';
Here, you can directly specify the color values as percentages (0 to 100), which looks like what you already have in your data. You can use this for things like frame border and shade colors too, as well as text. More info here:
http://forums.pti.com/showthread.php?p=11580#post11580
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #3  
Old June 21st, 2013, 02:57 PM
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 869
Default Re: Adding custom CMYK builds

Quote:
Originally Posted by Dan Korn View Post
Well, I could quibble about whether decimal format is actually more "standard" than hexadecimal. FusionPro's tagged markup is based on HTML, which uses hexadecimal representations for color values in tags such as <font color="#ff0000"> and <BODY BGCOLOR="#ff6600">.
Hexadecimal is certainly standard on the web where RGB colors are the norm. But decimal values are used in printing which is the primary use for FusionPro, no? I have not found anywhere else where CMYK values are entered in hex format.

Quote:
Originally Posted by Dan Korn View Post
Anyway, what exactly do you suggest? Can you provide an example of what a tag would look like with decimal values? Would it be something like <cmyk(255,0,0,0)">? Would it be based on a range of 0 to 100, or 0 to 255?
If i get to pick, then yes <color cmyk="100,0,100,0">green</color> would be nice. Something in decimal notation; the same as is required in the Color dialog box.

Quote:
Originally Posted by Dan Korn View Post
Code:
var myColor = new FusionProColor("Your Custom Color Name", 100, 0, 0, 0);
return '<color name="Your Custom Color Name">Hi there!';
Here, you can directly specify the color values as percentages (0 to 100), which looks like what you already have in your data.
While we are on the topic of features -- have you ever seen Microsoft's Clippy who gives advice as you do things in Word? I would like to see FP implement Korny, who sits in the upper corner and suggests simple solutions BEFORE I invest the time figuring out how to do something the hard way.
Reply With Quote
  #4  
Old June 21st, 2013, 04:07 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,592
Default Re: Adding custom CMYK builds

Quote:
Originally Posted by esmith View Post
Hexadecimal is certainly standard on the web where RGB colors are the norm. But decimal values are used in printing which is the primary use for FusionPro, no?
When you say, "used in printing," that's a pretty broad statement. There are lots of applications and formats and types of markup used in the printing industry.

At any rate, values are values, and numbers are numbers, whereas decimal and hexadecimal are representations of numbers (values). There's no one representation which is more "correct" than any other, nor, I maintain, more "standard." Nor is there any technical reason why a range should necessarily be 0 to 100 instead of 0 to 255 (FF in hex).
Quote:
Originally Posted by esmith View Post
I have not found anywhere else where CMYK values are entered in hex format.
Well, except for HTML tagging, which is what our tagging is based upon. We are talking about tagging here, not a GUI or some other dialog. FusionPro's tagging might not match what you see in any dialog, even in FusionPro itself, but if you're looking for something to compare it to, HTML tagging is the best comparison I can think of. And HTML tagging does indeed use hexadecimal values.
Quote:
Originally Posted by esmith View Post
If i get to pick, then yes <color cmyk="100,0,100,0">green</color> would be nice.
That's a good suggestion, although I'm not sure it's obvious that it's a percentage. It's also very close to the current syntax. Maybe something like this would be better: <color max="100" value="cmyk(100,0,100,0)">.
Quote:
Originally Posted by esmith View Post
Something in decimal notation; the same as is required in the Color dialog box.
Again, tagging doesn't always match what's in the GUI; it's modeled after HTML tagging.

But that doesn't mean we can't add functionality, as long as the older functionality remains the same, and I do appreciate any suggestions to make the product better.

On the other hand, with JavaScript, you can massage just about any input data into the format that FusionPro's tagging requires. Even if we changed the format of the tag itself, building up tags isn't something that is easily done without JavaScript, so this is all getting into more advanced territory than simply specifying a color in the Colors dialog and selecting it in the Text Editor.
Quote:
Originally Posted by esmith View Post
While we are on the topic of features -- have you ever seen Microsoft's Clippy who gives advice as you do things in Word? I would like to see FP implement Korny, who sits in the upper corner and suggests simple solutions BEFORE I invest the time figuring out how to do something the hard way.
LOL, I'll see if I can add that for you!
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #5  
Old June 24th, 2013, 01:37 PM
ThomasLewis's Avatar
ThomasLewis ThomasLewis is offline
Senior Contributor
 
Join Date: Feb 2011
Posts: 216
Default Re: Adding custom CMYK builds

You have my vote for this feature as well. There is something similar in pitstop where you can choose between percentile based (like the max=100 attribute suggested) or 255 based.

Incidentally Eric, not sure if you remember this one from last year: http://forums.pti.com/showthread.php?t=2701
I based that on hyphens as that's whats used in InDesign when you build colors without naming them. Commas could easily be used instead.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:59 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.