GithubHelp home page GithubHelp logo

Brightening black in RGB about d3-color HOT 3 CLOSED

d3 avatar d3 commented on April 27, 2024
Brightening black in RGB

from d3-color.

Comments (3)

maltebaer avatar maltebaer commented on April 27, 2024 1

Thanks for your answers.

Converting to HCL color space will work as desired, in my scenario.

from d3-color.

Fil avatar Fil commented on April 27, 2024

Interesting question. https://github.com/d3/d3-color#color_brighter says β€œThe behavior of this method [brighter] is dependent on the implementing color space.”

and indeed d3.lch(d3.rgb("#000")).brighter().hex() // "#2c2c2c"

from d3-color.

danburzo avatar danburzo commented on April 27, 2024

There's no "official" definition of a brighten function, and as @Fil mentions, the behavior depends on the color space. In RGB, the effect on black follows the definiton: C' = C * Math.pow(1.42, k). This mostly corresponds to how the CSS brightness filter works (C' = slope * C + intercept); it, too, leaves black intact.

If you wanted more flexibility in applying transforms to colors (to obtain various brightness/contrast-type adjustments), the CSS Filter Effects Module may be a good start: In addition to a linear multiplier, you can also apply a gamma multiplier: C' = amplitude * Math.pow(C, exponent) + offset.

from d3-color.

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.