currently I am working on a painting game, i'm wondering how i could make a colour picker (something were if you silect it, then click a colour it will change the pen to that colour)
here is my game if you need it: http://scratch.mit.edu/projects/godbisset/2095671
Offline
Godbisset,
I made a color picker for your project. The color picker is a 100*100 square. As long as you don't change its position, it will work well. There are 200 shades of color and 100 shades of brightness. When your mouse is touching the color picker and is down, the color picker will set the color and shade based on the mouse x and y coordinates. I hope the color picker helps!
~~ HD123 ~~
Offline
HD123 wrote:
Godbisset,
I made a color picker for your project. The color picker is a 100*100 square. As long as you don't change its position, it will work well. There are 200 shades of color and 100 shades of brightness. When your mouse is touching the color picker and is down, the color picker will set the color and shade based on the mouse x and y coordinates. I hope the color picker helps!
~~ HD123 ~~
I'm terribly sorry, but that's not quite what i men't.
It's like the syrige thing you get when you get the <set pen color to( block.
Offline
There is no color picker block, unfortunately.
One VERY complicated way to do it is have a list that has the colors of every single pixel on the screen, and take the x and y position to find that color, and switch to it.
It's very time-consuming though.
Offline
What you want, godbisset, is very difficult to handle. I do not recommend using it for many reasons:
•you are still a new Scratcher
•is very difficult to handle and could cause lag and glitches
•would take many, many scripts
•too time consuming for your paint project
I wish you luck in your paint project if you are persisting in further development. :D
~~ HD123 ~~
Offline
I just made a color picker! Check my latest project! 1s1s1c1p!
Offline
SUMMARY
Although most developers and APIs use the RGB system when working with colors, is not the only way available to represent or select colors. For example, the Windows standard color selection dialog box lets you work with the HSL color scheme in an indirect way. In this article the author describes several color selection schemes, and uses GDI + (via the System.Drawing namespace) to create a component that enables its own applications to provide a simple color picker, friendly. Along the way, get tips to help you use GDI + in your own applications.
Color spaces
The investigation of the sample application
The color conversion
Illustration of the color wheel
Finish the drawing
Painting on demand
Repainting is expensive
Cleaning
The research shows
Conclusion
Because Windows ® provides a common standard dialog for selecting colors (see Figure 1) is easy to assume that this is the only method for selecting colors. That's not true, however, and in this article I will provide an easy to use replacement for standard dialog box for selecting color. Sample design and appearance are easy to modify. Indicators can design almost any shape you want, and the sample application includes two different designs for the dialog box. This article focuses on two specific areas: the investigation of different techniques for color selection and explain to the members of the System.Drawing namespace that make the work of sample application.
Color spaces
The color standard Windows dialog box for selecting colors represent just two of the many ways you can represent colors in the code. This representation of color choices is often called a "color space" because color representations normally allow you to reference the colors of a set of coordinates in three dimensional space. Figure 1 shows the dialog box with the standard Windows Define Custom Colors button selected, so the right panel appears, allowing you to define your own colors. Ignoring the left side of the dialog box, which simply allows you to select from a palette of preselected colors, the right pane lets you drag the color selector with your mouse, or introduce the use of two different color spaces color, red / green / blue (RGB) or Hue / Saturation / Lightness (HSL). In this dialog box, the individual RGB values contain 8-bit values and the range of 0 to a maximum of 255. HSL values range from 0 to 240.
The color conversion
Throughout the class color wheel and the sample project, the code must convert color values between RGB and HSV format. Generally, the code uses the VHS format for most internal uses maps closely to the way colors are represented on the screen, but uses RGB values in the interaction with the user or when displaying the selected color in the screen. Although he made a valiant attempt to develop conversion formulas for a cross-country flight, once you reconnect and do a quick search, I found several sites list more or less the same algorithm in several languages, but not in C # or Visual Basic. NET. I have converted the code to C # and Visual Basic. NET, and the kind ColorHandler in the sample project provides shared / static methods that handle the conversion between RGB and HSV. The class also contains HSV and RGB structures used in the application. They are simple and provide an easy way to cart around RGB and HSV values.
Specifically, the class offers HSVToRGB ColorHandler, RGBToHSV and HSVToColor methods to perform the color conversions. The color in the structure. NET Framework provides methods and FromArgb ToArgb, so no need to create those methods here. If you are interested in the details of carrying out conversions to and from the HSV color scheme, see the code in the class ColorHandler. Have not focused on the code here, since it is unlikely to have to modify the code for use in other projects, simply import the code or package in any way you want to reuse.
It is important to note, however, that the two methods HSVToRGB RGBToHSV and wait for the color of the individual components, R, G, B and H, S, V-containing integer values between 0 and 255. Although there is no reason why these exact values to use, I have chosen to maintain consistency between the two color spaces, using the same range for both. To control the color values in a different way, you have to modify the code ColorHandler class.
Illustration of the color wheel
To be honest, I started on this project especially because he had seen an application that uses an HSV color selection and was convinced it was possible to create a circular gradient used for selecting colors without writing much code using GDI +. As I suspected, it is very simple to create the gradient. PathGradientBrush work with an object, provides an array of points that define the edge of the slope, indicating the color of the center and the center, providing a range of colors on an assignment for one to one, and that's it. GDI + does all the work, filling in the prescribed area with the gradient you have requested. (Both the class and class PathGradientBrush LinearGradientBrush discussed later inherit from the Brush class, and are one of several means of filling a region).
CreateGradient procedure handles all these tasks, but in a way that might not expect. As I originally wrote it, the procedure generates the gradient each time it was called, and this procedure can be called every time you move the mouse. Of course, this inefficiency made it impossible to follow the mouse effectively even sturdier hardware, and the current solution born of necessity, ie, instead of constantly redrawing the gradient CreateGradient procedure (see Figure 8) indicates the gradient of a turn, creates an image of the slope, and then displays the image each time the host needs to be repainted.
Offline
OK. Here's how:
Make one color-sprite.
Put this code in it:
[blocks]
<when[ sprite]clicked>
<set pen color to( color of sprite)>
[/blocks]
Duplicate this sprite, and in every sprite change the color of the sprite and the pen color to be set.
After you have made the palette, make a small hidden sprite that follows the mouse. The sprite should have this code:
[blocks]
<when green flag clicked>
<forever>
<if><mouse down?>
<pen down>
<end>
<end>
Offline