hsl

RGB to HSL and back, calculation problems

蓝咒 提交于 2019-12-17 19:22:17
问题 I'm trying to convert RGB to HSL and I also want to convert from HSL to RGB, I have written a class for it but if I do RGB->HSL->RGB to try if it works I get a different value. Example case: if you create a HSLColor object by doing HSLColor MyTestConversion = HSLColor.FromRGB(Colors.Green); and then do Color ExpectedGreenHere = MyTestConversion.ToRGB() you get a different color than Colors.Green while it was the original input so something goes wrong.. This is the code i'm using: public class

how generate only darken random colors in javascript?

笑着哭i 提交于 2019-12-11 19:24:38
问题 I've been reading the questions here about how to generate random colors in JS/JQuery. But I want to generate only darken colors avoiding the black, yellow and gray range colors, in order to be able to draw areas in google maps with different colors. Thanks 回答1: var hue = Math.floor(Math.random() * 360), saturation = Math.floor(Math.random() * 100), lightness = Math.floor(Math.random() * 50), color = "hsl(" + hue + ", " + saturation + "%, " + lightness + "%)"; That was to generate a random

How to modify color brightness in C#?

夙愿已清 提交于 2019-12-11 16:44:01
问题 In c#, you can get the HSL brightness of a color by doing Color.GetBrightness(). If I want to increase the brightness of a color by a certain percentage, I cannot simply multiply the individual RGB values by that amount. It seems HSL doesn't work like that. How would I do it? 回答1: I think this article can help you with this and all other color related questions. It has C# source for all conversions and modifications. RGB and HSL Colour Space Conversions 来源: https://stackoverflow.com/questions

Convert RGB bytes to HSL and back?

a 夏天 提交于 2019-12-11 06:41:16
问题 Is there an algorithm for converting a RGB byte array to an HSL float array and back again? I have tried the one found here but it seems to have bugs. 回答1: I use the following class which converts from HSL to RGB and vice-versa. You can construct a ColorRGB instance from a Color , or simply cast one. It exposes H , S , L properties also. I found it on the internet. Apologies to the original author, I cannot find a reference: public class ColorRGB { public byte R; public byte G; public byte B;

C# setHue (or alternatively, convert HSL to RGB and set RGB)

我们两清 提交于 2019-12-11 01:55:40
问题 C# has a very convenient getHue method, but I can't find a set Hue method. Is there one? If not, I think the best way to define a color after changing the hue would be to convert the HSL value to RGB, and then set the RGB value. I know there are formulas on the internet for doing this, but how would I best go about performing this conversion from HSL to RGB using C#? Thank You 回答1: To set the Hue you create a new Color , maybe from a given one by using GetHue and GetSaturation . See below for

HSL Interpolation

*爱你&永不变心* 提交于 2019-12-10 19:42:57
问题 If the hue component of my HSL color is in degrees, how can I correctly interpolate between two hues? Using (h1 + h2) / 2 does not seem to produce desirable results in all cases. Here are two examples that illustrate why: Let: red = 0° yellow = 60° blue = 240° (red + yellow) / 2 = 30° (orange) (yellow + blue) / 2 = 150° (blue green) (red + blue) / 2 = 120° (green) As you can see, averaging red and blue produces green instead purple/magenta! However, if we let: red = 360° yellow = 60° blue =

Convert YUV into HSL or HSV bypassing the RGB step

纵然是瞬间 提交于 2019-12-10 16:17:57
问题 Wikipedia and plethora of online resources provide detailed and abundant help with various color space conversions from/to RGB. What I need is a straight YUV->HSL/HSV conversion . In fact what I need is just the Hue (don't care much for the Saturation or the brightness Lightness/Value). In other words I just need to calculate the "color angle" for a given YUV color. Code in any language would suffice, though my preference is C-style syntax. Note that by YUV I mean specifically Y′UV, a.k.a.

PHP function to convert HSL to RGB or Hex

感情迁移 提交于 2019-12-10 10:16:54
问题 Does anyone know a PHP function (for >5.3) which can convert an HSL color to either RGB or Hex? I've tried a dozen Google searches and none of the functions I have found work as expected. It doesn't matter whether the function converts to RGB or hex because converting between those two is trivial. The inputs are HSL values for CSS (Hue: 0–360, Saturation: 0–100, Lightness: 0–100). Edit: Specifying the input and output format would be a bonus :) 回答1: Taking the code from one of the answers in

How to apply HSB color filters to UIImage

霸气de小男生 提交于 2019-12-08 02:27:23
问题 I've been struggling for a few days for a project on UIImage colorization. The idea is that the app will embark a set of images that I will have to colorize with values retrieved from a webservice. Some sort of themes if you wish. The designer I work with gave me a background image on all of his Photoshop values. The first problem is that Photoshop uses HSL and iOS uses HSB. So the first challenge was to translate the values from Photoshop. Photoshop HSL: -28 (range -180 => +180), 100 (range

How to colorize via HSL colors?

坚强是说给别人听的谎言 提交于 2019-12-07 15:07:03
问题 I have an complex problem, but it could be solved via this little problem. I would like to make a colorizer, which works per pixel. I have a defined base color for the picture (the picture has some pixels with this color and a lot of other pixels, which are near to this color): Hex: #188DD9 HSL: 204° 80% 47% RGB: 24 141 217 I know my target base color : Hex: #23752E HSL: 128° 54% 30% RGB: 35 117 46 So, I would like to colorize an image. My assumption is that if I find the correlation in this