Skip to content

Commit

Permalink
More shaded areas fixes: improve fill and stroke colors, close polygo…
Browse files Browse the repository at this point in the history
…ns properly
  • Loading branch information
osnr committed Jul 11, 2012
1 parent c173b5b commit bcd94c7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions exercises/shaded_areas.html
Expand Up @@ -79,21 +79,22 @@

triangle: function(x, y, size) {
var s = 2*size,
v = [[x, y], [x + s, y], [x + s/2, y + sqrt(3)*s/2], [x, y]],
v = [[x, y], [x + s, y], [x + s/2, y + sqrt(3)*s/2]],
centroid = [(v[0][0] + v[1][0] + v[2][0]) / 3,
(v[0][1] + v[1][1] + v[2][1]) / 3];

// recenter the triangle
v = _.map(v, function(vertex) {
return [vertex[0] - centroid[0], vertex[1] - centroid[1]];
});
v.push(true);

var sign = function(p1, p2, p3) {
return (p1[0] - p3[0]) * (p2[1] - p3[1]) - (p2[0] - p3[0]) * (p1[1] - p3[1]);
};

return {
vertices: v,
vertices: _.initial(v),
contains: function(point) {
var b1, b2, b3;

Expand Down Expand Up @@ -148,8 +149,8 @@
<div class="graphie" id="shapes">
var g = init({ range: [[-14, 14], [-14, 14]], scale: [11, 11] });

graph.outerShape = OUTER.drawShape(g, { fill: GRAY, stroke: "black" });
graph.innerShape = INNER.drawShape(g, { fill: "white", stroke: "black" });
graph.outerShape = OUTER.drawShape(g, { fill: BLUE, stroke: BLUE, "fill-opacity": 0.5 });
graph.innerShape = INNER.drawShape(g, { fill: "#f8f8f8", stroke: BLUE });

graph.outerSize = OUTER.drawSize(g, { stroke: BLUE, opacity: 1 });
graph.innerSize = INNER.drawSize(g, { stroke: ORANGE, opacity: 1 }, true);
Expand Down

0 comments on commit bcd94c7

Please sign in to comment.