Skip to content

Commit

Permalink
Massive hack for VML gradients in 280 Slides.
Browse files Browse the repository at this point in the history
Conflicts:

	AppKit/CoreGraphics/CGContextVML.j
  • Loading branch information
Ross Boucher committed May 7, 2009
1 parent 854d1c0 commit 06e3221
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions AppKit/CoreGraphics/CGContextVML.j
Original file line number Diff line number Diff line change
Expand Up @@ -273,17 +273,44 @@ function CGContextDrawLinearGradient(aContext, aGradient, aStartPoint, anEndPoin
if (!aContext || !aGradient)
return;

var colors = aGradient.colors,
count = colors.length,
var vml = nil;

// MASSIVE hack for 280 Slides
if (aGradient.vml_gradient)
{
var stops = [[aGradient.vml_gradient stops] sortedArrayUsingSelector:@selector(comparePosition:)],
count = [stops count];

vml = ["<cg_vml_:fill type=\"gradient\" method=\"linear sigma\" "];
vml.push("angle=\"" + ([aGradient.vml_gradient angle] + 90) +"\" ");

vml.push("colors=\"");

for (var i = 0; i < count; i++)
{
vml.push(([stops[i] position]*100).toFixed(0)+"% ");
vml.push([[[stops[i] color] colorForSlideBase:nil] cssString]);

if (i < count-1)
vml.push(",");
}

vml.push("\" />");
}
else
{
var colors = aGradient.colors,
count = colors.length;

vml = ["<cg_vml_:fill type=\"gradient\" "];

vml.push("colors=\"");
console.log(aGradient.locations);
for (var i = 0; i < count; i++)
vml.push((aGradient.locations[i]*100).toFixed(0)+"% "+to_string(colors[i])+(i<count-1 ? "," : ""));

vml.push("\" />");
vml.push("colors=\"");

for (var i = 0; i < count; i++)
vml.push((aGradient.locations[i]*100).toFixed(0)+"% "+to_string(colors[i])+(i<count-1 ? "," : ""));

vml.push("\" />");
}

aContext.gState.gradient = vml.join("");
console.log(vml.join(""));
Expand Down

0 comments on commit 06e3221

Please sign in to comment.