mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-17 04:00:42 +00:00
CGContextDrawLinearGradient() now works in CGContextVML.
This commit is contained in:
1 parent
ae8fd0c2d4
commit
854d1c0afa
1 file changed
+34
-1
@@ -229,7 +229,10 @@ function CGContextDrawPath(aContext, aMode)
|
||||
|
||||
vml.push("\">");
|
||||
|
||||
if (fill)
|
||||
if (gState.gradient)
|
||||
vml.push(gState.gradient)
|
||||
|
||||
else if (fill)
|
||||
vml.push("<cg_vml_:fill color=\"", gState.fillStyle, "\" opacity=\"", opacity, "\" />");
|
||||
|
||||
if (stroke)
|
||||
@@ -260,3 +263,33 @@ function CGContextDrawPath(aContext, aMode)
|
||||
aContext.DOMElement.insertAdjacentHTML("BeforeEnd", vml.join(""));
|
||||
}
|
||||
|
||||
function to_string(aColor)
|
||||
{
|
||||
return "rgb(" + ROUND(aColor.components[0] * 255) + ", " + ROUND(aColor.components[1] * 255) + ", " + ROUND(255 * aColor.components[2]) + ")";
|
||||
}
|
||||
|
||||
function CGContextDrawLinearGradient(aContext, aGradient, aStartPoint, anEndPoint, options)
|
||||
{
|
||||
if (!aContext || !aGradient)
|
||||
return;
|
||||
|
||||
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("\" />");
|
||||
|
||||
aContext.gState.gradient = vml.join("");
|
||||
console.log(vml.join(""));
|
||||
|
||||
// if (aContext.buffer != nil)
|
||||
// aContext.buffer += vml.join("");
|
||||
// else
|
||||
// aContext.DOMElement.innerHTML = vml.join("");
|
||||
}
|
||||
Reference in new issue
Block a user