Giter Site home page Giter Site logo

Comments (2)

kumarashish2405 avatar kumarashish2405 commented on June 10, 2024 1

@postspectacular i agree and see that in updated docs. Thanks

from umbrella.

postspectacular avatar postspectacular commented on June 10, 2024

This is actually expected and documented behavior: When the first argument is null, this function (and others) will mutate the 2nd arg, thus allowing the same functions to control where results should be written to and to be used for both in-place manipulation or immutable ops. Also see remarks in the mix() documentation.

This same convention also applies to (and stems from) most of the 900+ vector & matrix operations in the thi.ng/vectors & thi.ng/matrices packages. You can find more examples in those readme & docs too.

If you want to create a number of new, independent color objects for your mix results, then the following would work (use of transducers package is optional, but useful):

import { map, normRange } from "@thi.ng/transducers"

const gradient = [...map((t) => mix(hsv(), col1, col2, t), normRange(4))];

gradient.map((x) => css(x))
// [
//   'hsl(0.000,0.000%,100.000%)',
//   'hsl(36.000,100.000%,87.500%)',
//   'hsl(72.000,100.000%,75.000%)',
//   'hsl(108.000,100.000%,62.500%)',
//   'hsl(144.000,100.000%,50.000%)'
// ]

If you don't know the color type/space of the input colors, you can derive a new matching color object from one of the inputs, e.g. mix(col1.empty(), col1, col2, 0.5) or mix(col1.copy(), ...)

from umbrella.

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.