{"action":"created","issue":{"url":"https://api.github.com/repos/paperjs/paper.js/issues/621","labels_url":"https://api.github.com/repos/paperjs/paper.js/issues/621/labels{/name}","comments_url":"https://api.github.com/repos/paperjs/paper.js/issues/621/comments","events_url":"https://api.github.com/repos/paperjs/paper.js/issues/621/events","html_url":"https://github.com/paperjs/paper.js/issues/621","id":54575586,"number":621,"title":"Support for SVG device color [Feature Request]","user":{"login":"ontic","id":609973,"avatar_url":"https://avatars.githubusercontent.com/u/609973?v=3","gravatar_id":"","url":"https://api.github.com/users/ontic","html_url":"https://github.com/ontic","followers_url":"https://api.github.com/users/ontic/followers","following_url":"https://api.github.com/users/ontic/following{/other_user}","gists_url":"https://api.github.com/users/ontic/gists{/gist_id}","starred_url":"https://api.github.com/users/ontic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ontic/subscriptions","organizations_url":"https://api.github.com/users/ontic/orgs","repos_url":"https://api.github.com/users/ontic/repos","events_url":"https://api.github.com/users/ontic/events{/privacy}","received_events_url":"https://api.github.com/users/ontic/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-01-16T13:32:58Z","updated_at":"2015-01-19T09:21:22Z","closed_at":null,"body":"I've been reading about the different ways you can specify colors in SVG documents found in this [specification](http://www.w3.org/TR/SVGColor12/#Color_syntax). What caught my attention was that SVG supports both CMYK and ICC named colors (A.K.A Spot Colors). I realise SVG is predominately used on display devices (RGB) and serves no purpose for graphics generated on a Canvas, but I'm working on a prototype application where I need to convert an SVG file to a PDF with CMYK and Spot Color support, which will eventually make its way to a printer.\r\n\r\nWould this be something you'd consider implementing?\r\n\r\nI'm not a JavaScript developer by trade, but I believe adding this feature should be quite trivial without breaking backwards compatibility. The only files I see needing to be modified are:\r\n\r\n[Color.js](https://github.com/paperjs/paper.js/blob/master/src/style/Color.js)\r\n[SVGImport.js](https://github.com/paperjs/paper.js/blob/master/src/svg/SVGImport.js)\r\n[SVGExport.js](https://github.com/paperjs/paper.js/blob/master/src/svg/SVGExport.js)\r\n\r\nLet me know what you think? P.S I should finally get some spare time to work on that Font API.\r\n\r\nCheers,\r\nAdam "},"comment":{"url":"https://api.github.com/repos/paperjs/paper.js/issues/comments/70464855","html_url":"https://github.com/paperjs/paper.js/issues/621#issuecomment-70464855","issue_url":"https://api.github.com/repos/paperjs/paper.js/issues/621","id":70464855,"user":{"login":"ontic","id":609973,"avatar_url":"https://avatars.githubusercontent.com/u/609973?v=3","gravatar_id":"","url":"https://api.github.com/users/ontic","html_url":"https://github.com/ontic","followers_url":"https://api.github.com/users/ontic/followers","following_url":"https://api.github.com/users/ontic/following{/other_user}","gists_url":"https://api.github.com/users/ontic/gists{/gist_id}","starred_url":"https://api.github.com/users/ontic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ontic/subscriptions","organizations_url":"https://api.github.com/users/ontic/orgs","repos_url":"https://api.github.com/users/ontic/repos","events_url":"https://api.github.com/users/ontic/events{/privacy}","received_events_url":"https://api.github.com/users/ontic/received_events","type":"User","site_admin":false},"created_at":"2015-01-19T09:21:21Z","updated_at":"2015-01-19T09:21:21Z","body":"@lehni \r\n\r\n> But it looks like SVG 2.0 will also implement device color, so I guess it's OK to implement it already:\r\nhttp://www.w3.org/TR/SVG2/color.html\r\n\r\nI think it's safe to say the next version of SVG will support device colors. It's just a matter of whether you want to support it before the specification is finalized.\r\n\r\n> Right now we're exporting SVG version 1.1, which should not contain such device color definitions. I guess we'll add a `version` property in the option parameter of `exportSVG()` and if it's >= 1.2 then device-colors can be added to the definitions.\r\n\r\nYes that's definitely an idea. However see my answer to the next question.\r\n\r\n> The other issue is how to convert RGB to CMYK in a decent way... The simple algorithm (e.g. http://www.javascripter.net/faq/rgb2cmyk.htm) doesn't produce very good results, and anything beyond that requires full support of ICC as far as I know.\r\n\r\nYes you're right, I've tried allot of different methods (in various programming languages) to convert RGB to CMYK, using pure Math and it's just not possible to get accurate results. There are a few techniques I use in PHP which are 100% accurate (which I can share).\r\n\r\nI don't think converting from RGB to CMYK should be part of the library, instead just allow the developer to specify print colors in their SVG when importing and also let them define a print color on paper objects which can then be exported to SVG.\r\n\r\nAny paper object (supporting print colors) could receive a new property or public setter method. For example:\r\n\r\n`object.printColor = \"device-cmyk(0, 0, 0.2, 0.4)\"`\r\n`object.printBorderColor = \"device-cmyk(0, 0, 0.2, 0.8)\"`\r\n\r\nI'm conflicted about this implementation and would much prefer a more object-oriented approach, but it does have it's positives.\r\n\r\n* Setting the print color on a paper object is easy since its just a string.\r\n* Passing the print color when importing is relatively easy, check for white space on any color attribute (regex, split, substring etc.) and set the print color value on the paper object.\r\n* Outputting the print color when exporting is dead simple, if a print color is defined on the paper object, append it after the RGB color.\r\n* It allows the developer to specify a print color which doesn't adhere to the SVG specification. This is a big plus in my mind because the software a developer uses to convert from SVG to PDF may require the print color value to be specified in a different way. For example, the normal way of defining a CMYK color looks like this.\r\n\r\n`<rect y=\"120\" width=\"40\" height=\"40\" fill=\"#FF0000 device-cmyk(0.0,0.0,0.2,0.4)\" />`\r\n\r\nHowever some SVG to PDF processors may require CMYK colors to look like this.\r\n\r\n`<rect y=\"120\" width=\"40\" height=\"40\" fill=\"#FF0000 cmyk(0.0,0.0,0.2,0.4)\" />`\r\n\r\nor like this.\r\n\r\n`<rect y=\"120\" width=\"40\" height=\"40\" fill=\"#FF0000 spot-color('FancyColor', 0.0,0.0,0.2,0.4)\" />`\r\n\r\nIf a developer chose to use Apache Batik they would benefit allot from this flexibility and having very little constraints. I came across [Pseudo Color Profiles](http://xmlgraphics.apache.org/fop/trunk/extensions.html#pseudo-color-profiles) which I think is a perfect use case.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n "}}