GithubHelp home page GithubHelp logo

Comments (2)

wojtek-viirtue avatar wojtek-viirtue commented on August 11, 2024 3

Again...know you guys aren't accepting pull requests but here's a working version with minimal changes:

/**
 * @param argb ARGB representation of a color.
 * @return Hex string representing color, ex. #ff0000 for red.
 */
export const hexFromArgb = (argb: number) => {
  const a = colorUtils.alphaFromArgb(argb);
  const r = colorUtils.redFromArgb(argb);
  const g = colorUtils.greenFromArgb(argb);
  const b = colorUtils.blueFromArgb(argb);
  const outParts = [r.toString(16), g.toString(16), b.toString(16), a.toString(16)];

  // Pad single-digit output values
  for (const [i, part] of outParts.entries()) {
    if (part.length === 1) {
      outParts[i] = '0' + part;
    }
  }

  return '#' + outParts.join('');
};

from material-color-utilities.

WillsterJohnson avatar WillsterJohnson commented on August 11, 2024

Going to see about implementing this.
My idea is to have no effect on the current operation of any fromArgb functions, but to provide an optional final argument alpha: boolean = false, which when set to true will include the alpha value in the returned data.
I also intend to track the movement of color data through the library's various functions and classes and ensure that alpha data is preserved such that you can abuse and mangle data to your hearts content and expect the alpha value which went in to also come out the other end.
Above all though, existing code will perform exactly as it currently does.

from material-color-utilities.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.