Forum > General
Bright color
BubikolRamios:
Say this produces dark blue. Ideas how to convert it to light blue ?
Should work for any color randome generated.
Out of curiosity, what would pitch black then become ?
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---RGBToColor(Random(256),Random(256),Random(256))
Fibonacci:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function MulDiv(a, b, c: int64): int64;begin result := (a*b) div c;end; function lighten(color, pc: dword): dword;var r, g, b: byte;begin r := color; g := color shr 8; b := color shr 16; r := r+MulDiv(255-byte(color), pc, 100); g := g+MulDiv(255-byte(color shr 8), pc, 100); b := b+MulDiv(255-byte(color shr 16), pc, 100); result := r or (g shl 8) or (b shl 16);end; function RGBToColor(r, g, b: dword): dword;begin result := r; result := result or (g shl 8); result := result or (b shl 16);end; procedure TForm1.Button1Click(Sender: TObject);begin form1.Canvas.Brush.Color := lighten(RGBToColor(Random(256),Random(256),Random(256)), 50); form1.Canvas.FillRect(0, 0, 500, 500);end;
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function darken(color, pc: dword): dword;var r, g, b: byte;begin r := color; g := color shr 8; b := color shr 16; r := r-MulDiv(byte(color), pc, 100); g := g-MulDiv(byte(color shr 8), pc, 100); b := b-MulDiv(byte(color shr 16), pc, 100); result := r or (g shl 8) or (b shl 16);end;
wp:
In unit GraphUtil:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function GetHighLightColor(const Color: TColor; Luminance: Integer = 19): TColor;function GetShadowColor(const Color: TColor; Luminance: Integer = -50): TColor;
BubikolRamios:
--- Quote ---function GetHighLightColor(const Color: TColor; Luminance: Integer = 19): TColor;
--- End quote ---
Kind of works (doing FloodFill from current to luminated color on click), I assume the Luminance should be max 250, or ? How come it takes bigger numbers ? I assume 249 (source Luminance) results in 18, at default Luminance parameter 19 .
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- PaintBox1.Canvas.Brush.Color:= GetHighLightColor(PaintBox1.Canvas.Pixels[b.X,b.y]); PaintBox1.Canvas.FloodFill(b.X,b.y,PaintBox1.Canvas.Pixels[b.X,b.y],fsSurface);
wp:
--- Quote from: BubikolRamios on December 05, 2024, 07:42:07 am ---Kind of works (doing FloodFill from current to luminated color on click), I assume the Luminance should be max 250, or ? How come it takes bigger numbers ? I assume 249 (source Luminance) results in 18, at default Luminance parameter 19 .
--- End quote ---
I don't understand what you mean. The function converts the input color to the HLS color system and adds the provided Luminance parameter to the L value of the HLS input color. Since L in this function is a byte, the maximum L value is 255. The function does not check the byte range, however, and may lead to an ERange exception. (A bit careless, in my opinion...; and as I notriced, GetShadowColor does the same as GetHighlightColor). So, when you make too large luminance changes you may run into this issue.
Navigation
[0] Message Index
[#] Next page