Hi Everyone,
I'm a newbie to Graphics.I'm drawing a rectangle which will change its color after one second.
- (void)drawRect:(CGRect)rect {
[self setWidthHeightOfRectangle];
[self changeColorOfNumbers];
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextClearRect(ctx, rect);
// Draw a solid square
CGContextSetRGBFillColor(ctx, 255, 255, 255, 1);
CGContextFillRect(ctx, CGRectMake(0.0, 24.0, 380.0, 2.0));
CGContextSetRGBFillColor(ctx, redNumber, greenNumber, blueNumber, 1);
CGContextFillRect(ctx, frameToDraw);
}
I'm changing the color of the rectangle using the changeColorOfNumbers method. Here is the method
- (void)changeColorOfNumbers {
iHit++;
if (iHit==100) {
redNumber=249;
greenNumber=252;
blueNumber=0;
} else if (iHit==200) {
redNumber=0;
greenNumber=168;
blueNumber=245;
} else if (iHit==300) {
redNumber=255;
greenNumber=0;
blueNumber=140;
} else if (iHit==400) {
redNumber=255;
greenNumber=125;
blueNumber=0;
} else if (iHit==500) {
redNumber=0;
greenNumber=176;
blueNumber=72;
} else if (iHit==600) {
redNumber=128;
greenNumber=0;
blueNumber=148;
} else if (iHit==700) {
redNumber=8;
greenNumber=79;
blueNumber=168;
} else if (iHit==800) {
redNumber=127;
greenNumber=212;
blueNumber=20;
} else if (iHit==900) {
redNumber=255;
greenNumber=0;
blueNumber=0;
} else if (iHit==1) {
redNumber=0;
greenNumber=0;
blueNumber=0;
frameToDraw=CGRectMake(0.0, 0.0, 0.0, 50.0);
} else if (iHit==2) {
redNumber=255;
greenNumber=255;
blueNumber=255;
}
}
Problem is that some of the RGB colors that I'm applying aren't showing up. What am I doing wrong here?.....
Thanks...