Skip to content

Commit

Permalink
added triangle primitive. good?
Browse files Browse the repository at this point in the history
  • Loading branch information
electronicwhisper committed Apr 25, 2012
1 parent dfc5a59 commit 1f6d7da
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
13 changes: 11 additions & 2 deletions compiled/app.js
Expand Up @@ -49,7 +49,7 @@
}
return this.require.define;
}).call(this)({"app": function(exports, require, module) {(function() {
var arrayEquals, canvasTopLevelTransform, circle, clearCanvas, combineComponents, definitions, domCompensate, drawFurther, init, koState, localCoords, model, movedCircle, regenerateRenderers, render, setSize, sizeCanvas, square, startsWith, ui, workspaceCoords, workspaceView;
var arrayEquals, canvasTopLevelTransform, circle, clearCanvas, combineComponents, definitions, domCompensate, drawFurther, init, koState, localCoords, model, movedCircle, regenerateRenderers, render, setSize, sizeCanvas, square, startsWith, triangle, ui, workspaceCoords, workspaceView;

arrayEquals = function(a1, a2) {
return a1.length === a2.length && a1.every(function(x, i) {
Expand All @@ -73,9 +73,18 @@
return ctx.rect(-1 * require("config").normalizeConstant, -1 * require("config").normalizeConstant, 2 * require("config").normalizeConstant, 2 * require("config").normalizeConstant);
});

triangle = model.makePrimitiveDefinition(function(ctx) {
var n;
n = require("config").normalizeConstant;
ctx.moveTo(0, -n * 2 * Math.sqrt(3) / 3);
ctx.lineTo(n, n / Math.sqrt(3));
ctx.lineTo(-n, n / Math.sqrt(3));
return ctx.lineTo(0, -n * 2 * Math.sqrt(3) / 3);
});

window.movedCircle = movedCircle = model.makeCompoundDefinition();

definitions = ko.observableArray([circle, square, movedCircle]);
definitions = ko.observableArray([circle, square, triangle, movedCircle]);

ui = {
view: model.makeTransform([1, 0, 0, 1, 400, 300]),
Expand Down
1 change: 1 addition & 0 deletions compiled/css/style.css
Expand Up @@ -142,6 +142,7 @@ button:active {
top: 50%;
margin-top: -8px;
color: #666;
cursor: default;
}
#sidebarRight .component .disclosure.expanded:after {
content: "▼";
Expand Down
8 changes: 7 additions & 1 deletion src/app.coffee
Expand Up @@ -14,11 +14,17 @@ model = require("model")

circle = model.makePrimitiveDefinition (ctx) -> ctx.arc(0, 0, 1*require("config").normalizeConstant, 0, Math.PI*2)
square = model.makePrimitiveDefinition (ctx) -> ctx.rect(-1*require("config").normalizeConstant, -1*require("config").normalizeConstant, 2*require("config").normalizeConstant, 2*require("config").normalizeConstant)
triangle = model.makePrimitiveDefinition (ctx) ->
n = require("config").normalizeConstant
ctx.moveTo(0, -n*2*Math.sqrt(3)/3)
ctx.lineTo(n, n/Math.sqrt(3))
ctx.lineTo(-n, n/Math.sqrt(3))
ctx.lineTo(0, -n*2*Math.sqrt(3)/3)

window.movedCircle = movedCircle = model.makeCompoundDefinition()


definitions = ko.observableArray([circle, square, movedCircle])
definitions = ko.observableArray([circle, square, triangle, movedCircle])


ui = {
Expand Down
1 change: 1 addition & 0 deletions src/style.styl
Expand Up @@ -161,6 +161,7 @@ button
margin-top: -8px

color: #666
cursor: default
&.expanded:after
content: "▼"
&.collapsed:after
Expand Down

0 comments on commit 1f6d7da

Please sign in to comment.