[ ] GraphicsJS JavaScript |
, SVG DOM.
//
var stage = acgraph.create('stage-container');
//
var stage.rect(25, 50, 350, 300);
//
var stage = acgraph.create('stage-container');
//
var frame = stage.rect(25, 50, 350, 300);
//
var walls = stage.rect(50, 250, 200, 100);
var roof = stage.path()
.moveTo(50, 250)
.lineTo(150, 180)
.lineTo(250, 250)
.close();
//
var head = stage.circle(330, 280, 10);
var neck = stage.path().moveTo(330, 290).lineTo(330, 300);
var kilt = stage.triangleUp(330, 320, 20);
var rightLeg = stage.path().moveTo(320, 330).lineTo(320, 340);
var leftLeg = stage.path().moveTo(340, 330).lineTo(340, 340);
stage.path().moveTo(320, 330).lineTo(320, 340);
), . , .//
//
frame.stroke(["red", "green", "blue"], 2, "2 2 2");
//
walls.fill(acgraph.hatchFill('horizontalbrick'));
//
roof.fill("#e4d96f");
//
kilt.fill(acgraph.hatchFill('plaid'));
// 169 -
var text = acgraph.text().text(String.fromCharCode(169)).opacity(0.2);
var pattern_font = stage.pattern(text.getBounds());
pattern_font.addChild(text);
//
frame.fill(pattern_font);
//
var stage = acgraph.create("stage-container");
//
var palette_fill = ['#5f8c3f', '#cb9226', '#515523', '#f2ad33', '#8b0f01'];
var palette_stroke = ['#43622c', '#8e661b', '#393b19', '#a97924', '#610b01'];
//
var leavesCounter = 0;
stage.layer
zIndex
, .//
var counterLabel = stage.text(10,10, "Swiped: 0", {fontSize: 20});
//
var gameLayer = stage.layer().zIndex(counterLabel.zIndex()-1);
function drawLeaf(x, y) {
//
var index = Math.floor(Math.random() * 5);
var fill = palette_fill[index];
var stroke = palette_stroke[index];
//
var scale = Math.round(Math.random() * 30) / 10 + 1;
var angle = Math.round(Math.random() * 360 * 100) / 100;
// ()
var path = acgraph.path();
//
path.fill(fill).stroke(stroke, 1, 'none', 'round', 'round');
var size = 18;
path.moveTo(x, y)
.curveTo(x + size / 2, y - size / 2, x + 3 * size / 4, y + size / 4, x + size, y)
.curveTo(x + 3 * size / 4, y + size / 3, x + size / 3, y + size / 3, x, y);
//
path.scale(scale, scale, x, y).rotate(angle, x, y);
return path;
};
drawLeaf
, return
:path.listen("mouseover", function(){
path.remove();
counterLabel.text("Swiped: " + leavesCounter++);
if (gameLayer.numChildren() < 200) shakeTree(300);
});
if (gameLayer.numChildren() < 200) shakeTree(300);
function shakeTree(n){
stage.suspend(); //
for (var i = 0; i < n; i++) {
var x = Math.random() * stage.width()/2 + 50;
var y = Math.random() * stage.height()/2 + 50;
gameLayer.addChild(drawLeaf(x, y)); //
}
stage.resume(); //
}
//
shakeTree(500);
shakeTree()
.