Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Thank you Steven Mills.</p> <p>And here is another way to do it, the code I came up with which uses HSL.</p> <p>Here is the answer. Please use this as you see fit, freely, as I am glad to post a working class that will create a Color Picker for anyone using C# and SFML.net- but also providing the logic for anyone who wishes to create a Color Picker for C# only.</p> <p>The solution is simple: <a href="http://richnewman.wordpress.com/about/code-listings-and-diagrams/hslcolor-class/" rel="nofollow noreferrer">http://richnewman.wordpress.com/about/code-listings-and-diagrams/hslcolor-class/</a></p> <p>1) Add the HSLColor class from the above link.</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using SFML; using SFML.Graphics; using SFML.Window; namespace Source { class ColorWheel : IGameObject { Image image = new Image(240, 220); HSLColor hslColor = new HSLColor(); System.Drawing.Color systemColor = new System.Drawing.Color(); Color pixelcolor = new Color(); public Sprite sprite = new Sprite(); public ColorWheel() { pixelcolor = Color.Red; hslColor.SetRGB(pixelcolor.R, pixelcolor.G, pixelcolor.B); for (int y = 0; y &lt; 220; y++) { //pixelcolor = Color.Red; //hslColor.SetRGB(pixelcolor.R, pixelcolor.G, pixelcolor.B); hslColor.Hue = 0; for (int x = 0; x &lt; 240; x++) { systemColor = hslColor; pixelcolor.R = systemColor.R; pixelcolor.G = systemColor.G; pixelcolor.B = systemColor.B; image.SetPixel((uint)x, (uint)y, pixelcolor); hslColor.Hue += 1; } hslColor.Saturation -= (y * 0.01); } Texture texture = new Texture(image); sprite.Texture = texture; } public void Update(double dt) { } public void Render(RenderWindow rWindow) { rWindow.Draw(sprite); } } } </code></pre> <p>And here is the resulting image, which you are freely allowed to use for anything you want. You do not even need to use the ColorWheel class, but simply use this image and get the pixel at the mouse position to dye your gameobjects as you see fit.</p> <p><img src="https://i.stack.imgur.com/uQ5RH.png" alt="enter image description here"></p> <p>To change the brightness (which would be on the slider) use hslColor.Luminosity in the equation, and it would probably be best to use the ColorWheel class instead of the image, unless you feel confident adjusting the image brightness based on a double integer attached to the slider. A good Color Picker GUI which includes both the image, mouse cursor, and slider with just a few lines of code would be TGUI. Obviously you would want to replace the default image with the ColorWheel class if you were using it, or the ColorWheel image I just provided.</p> <p>All free to be used by anyone as they see fit.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload