[NTG-context] Metapost and CMYK

Hans Hagen pragma at wxs.nl
Sun Feb 4 22:33:29 CET 2007

Mojca Miklavec wrote:
> On 2/4/07, Hans Hagen <pragma at wxs.nl> wrote:
>
>> Peter Rolf wrote:
>>
>>> But to my surprise ConTeXt automatically converts my RGB colors (even
>>> the MP defined ones), except that the final colors are in the CMY
>>> instead of CMYK color space. All I want is a true RGBtoCMYK conversion.
>>> I know about the calculating limitations in TeX, so I can wait for an
>>> implemetation of that macro in LuaTeX.
>>>
>>>
>> but even then ... we need a formula ...
>>
>
> Most pages on the internet list the following simple conversion formula:
>
> C' = 1 - (R/range)      C = (C' - K') / (1 - K')
> M' = 1 - (G/range)      M = (M' - K') / (1 - K')
> Y' = 1 - (B/range)      Y = (Y' - K') / (1 - K')
> K' = MIN(C',Y',M')      K = K'
>
> In the special case of K'=1, use (0,0,0,1)
>
> (I'm not a TeX guru, but I assume that conversion with current macros
> should not be much more difficult than conversion with luaTeX.)
>
>
this is what we have now

\def\doconvertRGBtoCMYK#1\to#2%
{\colordimen#1\points
\multiply\colordimen \plusthousand
\colorcount\colordimen
\divide\colorcount \maxcard
\colorcount-\colorcount
\edef#2{\realcolorvalue\colorcount}}

\def\convertRGBtoCMYK#1#2#3%
{\doconvertRGBtoCMYK#1\to\@@cl@@c
\doconvertRGBtoCMYK#2\to\@@cl@@m
\doconvertRGBtoCMYK#3\to\@@cl@@y
\let\@@cl@@k\@@cl@@z}

well, you can spent the rest of the evening writing an alternative

-----------------------------------------------------------------
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.9577172994613647, "perplexity": 6402.006589418276}, "config": {"markdown_headings": false, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 5, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2014-35/segments/1408500835822.36/warc/CC-MAIN-20140820021355-00419-ip-10-180-136-8.ec2.internal.warc.gz"}