setIgnoresAlpha (Newbye)
setIgnoresAlpha (Newbye)
- Subject: setIgnoresAlpha (Newbye)
- From: Michèle Garoche <email@hidden>
- Date: Fri, 28 Dec 2001 10:00:10 +0100
In a very simple application, I have three text fields, three sliders
and a color well.
The text fields are populated with the number corresponding to the color
chosen in the color will, as well as the sliders and vice-versa.
For text fields and sliders, I have four IBAction (blue, red, green,
alpha) as follows:
- (IBAction)setBlue:(id)sender
{
blueValue = [sender floatValue];
[blueField setFloatValue: blueValue];
[blueSlider setFloatValue: blueValue];
[self updateColor];
}
and two other methods: one for updating the color well from the text
fields or sliders
- (void) updateColor
{
NSColor *aColor = [NSColor colorWithCalibratedRed:
redValue
green: greenValue
blue: blueValue
alpha: alphaValue];
[colorWell setColor: aColor];
}
another for updating the text fields and sliders from the color well:
- (IBAction)getColor:(id)sender
{
NSColor *aColor = [[sender color]
colorUsingColorSpaceName:@"NSCalibratedRGBColorSpace"];
[self setRed: [NSNumber numberWithFloat:[aColor redComponent]]];
[self setGreen: [NSNumber numberWithFloat:[aColor greenComponent]]];
[self setBlue: [NSNumber numberWithFloat:[aColor blueComponent]]];
[self setAlpha: [NSNumber numberWithFloat:[aColor alphaComponent]]];
}
It works fine except that the alpha channel is always endowed with 1.0
when I change the color from the color well.
Is there a way to give a different value to the alpha channel? I've
tried to use setIgnoresAlpha, but I don't understand how to use it.
Could somebody help me?
Thanks in advance,
Michhle