1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-21 21:57:01 +00:00

avoid some unnecessary calculations when drawing the progress bar gradients by flipping it

This commit is contained in:
Mitchell Livingston 2008-06-24 04:16:46 +00:00
parent ecab0ddc15
commit 6450f36349
2 changed files with 23 additions and 25 deletions

View file

@ -28,35 +28,33 @@
+ (CTGradient *) progressGradientForColor: (NSColor *) color
{
float redComponent = [color redComponent],
greenComponent = [color greenComponent],
blueComponent = [color blueComponent];
float redComponent = [color redComponent], greenComponent = [color greenComponent], blueComponent = [color blueComponent];
CTGradientElement color1;
color1.red = redComponent;
color1.green = greenComponent;
color1.blue = blueComponent;
color1.red = redComponent * 0.9684;
color1.green = greenComponent * 0.9684;
color1.blue = blueComponent * 0.9684;
color1.alpha = 1.0;
color1.position = 0.0;
CTGradientElement color2;
color2.red = redComponent * 0.8736;
color2.green = greenComponent * 0.8736;
color2.blue = blueComponent * 0.8736;
color2.red = redComponent;
color2.green = greenComponent;
color2.blue = blueComponent;
color2.alpha = 1.0;
color2.position = 0.5;
CTGradientElement color3;
color3.red = redComponent;
color3.green = greenComponent;
color3.blue = blueComponent;
color3.red = redComponent * 0.8736;
color3.green = greenComponent * 0.8736;
color3.blue = blueComponent * 0.8736;
color3.alpha = 1.0;
color3.position = 0.5;
CTGradientElement color4;
color4.red = redComponent * 0.9684;
color4.green = greenComponent * 0.9684;
color4.blue = blueComponent * 0.9684;
color4.red = redComponent;
color4.green = greenComponent;
color4.blue = blueComponent;
color4.alpha = 1.0;
color4.position = 1.0;

View file

@ -622,7 +622,7 @@
if (!fLightGrayGradient)
fLightGrayGradient = [[CTGradient progressLightGrayGradient] retain];
[fLightGrayGradient fillRect: noIncludeRect angle: -90];
[fLightGrayGradient fillRect: noIncludeRect angle: 90];
}
if (rightWidth > 0)
@ -641,7 +641,7 @@
if (!fRedGradient)
fRedGradient = [[CTGradient progressRedGradient] retain];
[fRedGradient fillRect: notAvailableRect angle: -90];
[fRedGradient fillRect: notAvailableRect angle: 90];
}
}
@ -653,7 +653,7 @@
if (!fWhiteGradient)
fWhiteGradient = [[CTGradient progressWhiteGradient] retain];
[fWhiteGradient fillRect: includeRect angle: -90];
[fWhiteGradient fillRect: includeRect angle: 90];
}
}
}
@ -669,7 +669,7 @@
{
if (!fYellowGradient)
fYellowGradient = [[CTGradient progressYellowGradient] retain];
[fYellowGradient fillRect: completeRect angle: -90];
[fYellowGradient fillRect: completeRect angle: 90];
}
else if ([torrent isSeeding])
{
@ -684,7 +684,7 @@
if (!fLightGreenGradient)
fLightGreenGradient = [[CTGradient progressLightGreenGradient] retain];
[fLightGreenGradient fillRect: ratioLeftRect angle: -90];
[fLightGreenGradient fillRect: ratioLeftRect angle: 90];
}
if (leftWidth > 0)
@ -693,14 +693,14 @@
if (!fGreenGradient)
fGreenGradient = [[CTGradient progressGreenGradient] retain];
[fGreenGradient fillRect: completeRect angle: -90];
[fGreenGradient fillRect: completeRect angle: 90];
}
}
else
{
if (!fBlueGradient)
fBlueGradient = [[CTGradient progressBlueGradient] retain];
[fBlueGradient fillRect: completeRect angle: -90];
[fBlueGradient fillRect: completeRect angle: 90];
}
}
else
@ -711,20 +711,20 @@
{
if (!fDarkGreenGradient)
fDarkGreenGradient = [[CTGradient progressDarkGreenGradient] retain];
[fDarkGreenGradient fillRect: completeRect angle: -90];
[fDarkGreenGradient fillRect: completeRect angle: 90];
}
else
{
if (!fDarkBlueGradient)
fDarkBlueGradient = [[CTGradient progressDarkBlueGradient] retain];
[fDarkBlueGradient fillRect: completeRect angle: -90];
[fDarkBlueGradient fillRect: completeRect angle: 90];
}
}
else
{
if (!fGrayGradient)
fGrayGradient = [[CTGradient progressGrayGradient] retain];
[fGrayGradient fillRect: completeRect angle: -90];
[fGrayGradient fillRect: completeRect angle: 90];
}
}
}