0

I created a library of custom colours in Objective-C that I now want to use in JavaScript. Each custom colour is defined like so

+ (UIColor *)darkYellow
{
    return [UIColor colorWithRed:(235.0/255.0) green:(235.0/255.0) blue:(0.0/255.0) alpha:1.0];
}

Rather than rewrite the library, is it possible to read the above RGBA tuplet from a file named UIColor+CustomColors.m and return a value that can be used in JavaScript?

e.g.

var view = document.getElementById("myCanvas");
var context = view.getContext("2d");
context.beginPath();
var colour =                // values returned from RGBA tuplet
context.fillStyle = colour;
context.rect(20, 20, 150, 100);
context.fill();
Cœur
  • 37,241
  • 25
  • 195
  • 267
Greg
  • 1,750
  • 2
  • 29
  • 56
  • Does this answer your question? [How can I get a hex string from UIColor or from rgb](https://stackoverflow.com/questions/14051807/how-can-i-get-a-hex-string-from-uicolor-or-from-rgb) – DonMag Jan 27 '20 at 13:25
  • DonMag, I'm not sure yet if it answers my question but at first glance a couple of answers look pretty promising particularly the one in Swift. It will take me some time to work through the five answers and hopefully answer my own question. Thanks. Watch this space. – Greg Jan 28 '20 at 03:28

0 Answers0