Is it possible to pick the color of a pixel on a gradient element?

Asked

Viewed 640 times

2

Imagine I have an element div with the following CSS:

.minha-div{
    width:100px;height:100px;
    background:linear-grandient(45deg, orange, red);
}

It’s possible that when I hover over that div, it tells me which pixel color the mouse is on top of, using Javascript / jQuery?

I’ve managed to define the mouse position in the colored block, but I can’t imagine a way to get the color in that exact position.

Example of what has already been done: FIDDLE

  • 1

    It is worth using a separate equation (doing a manual linear interpolation to find the color)?

  • What kind of content do you have in this div? If it’s just an image, you can use a canvas. Then it’s easier to get the color.

  • The idea is to create a kind of color-Picker own, but with CSS, so the content of this div would be the same, but colors may change.

1 answer

1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.