Created
November 15, 2016 03:18
-
-
Save angelaperrone/6d42b6a891b469ed82fec33d5468aea1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Sources: | |
//http://printingcode.runemadsen.com/examples/randomization/pintori_1/index.html | |
//Rune Madsen | |
// | |
// | |
var r = new Rune({ | |
container: "#canvas", | |
width: 800, | |
height: 1000, | |
debug: false | |
}); | |
var width = r.width; | |
var height = r.height; | |
var x=-300; | |
var y= 0; | |
var colorNumber = 60; | |
var oneSixth = 1/6; | |
var fiveSixths = 5/6; | |
var twoSixths = 2/6 | |
var random = _.random(0,width); | |
var ranDist1 = _.random((fiveSixths*width)-30,(fiveSixths*width)+30) | |
var ranDist2 = _.random((fiveSixths*width)-30,(fiveSixths*width)+30) | |
console.log(random); | |
//-----Background - fill has to be v between 30-60------ | |
// for (var j=height; j<height; j--) { | |
// r.rect (x, j, width, 5).stroke(false).fill('hsv', 71, 63, 59) | |
// } | |
for (var i = width; i > -10; i -= 3) { | |
r.rect(i, y, 5, height).stroke(false).fill('hsv', 40, 35, colorNumber*=1.0015) | |
} | |
//-----Ground Base | |
var noise = new Rune.Noise().noiseDetail(1.5, .65); | |
var groundPoints = []; | |
//noise.noiseSeed(2); | |
while(x<801) { | |
//increment x with random amt | |
//how tall and wide the shapes will be between each other | |
x += _.random((width*twoSixths), (width*oneSixth)+- 50) | |
//use noise to find y value | |
y = (height*fiveSixths) +- (noise.get(x/150) *100); | |
groundPoints.push(new Rune.Vector(x,y)); | |
} | |
//draw TREE lines based on points... | |
//--------- | |
//loop thru each point but the last one | |
for (var k = 0; k<groundPoints.length - 1; k++) { | |
//Tree Trunk Height | |
var treeHeight = 0; | |
console.log("k is " + k); | |
//find all bottom points needed for the line | |
var bottomPoint1 = groundPoints[k]; | |
var bottomPoint2 = groundPoints[k+1] | |
//calculate top points from this | |
var topPoint1 = bottomPoint1.sub(new Rune.Vector (ranDist1, treeHeight)); | |
//TREE TRUNKS | |
var tree = r.path(bottomPoint1.x, 0).fill(false).strokeWidth(_.random(3,8)) | |
var noiseStep = 0; | |
for(var i = 0; i <= bottomPoint1.y + 5; i += 5) { | |
var j = noise.get(noiseStep) * -10; | |
tree.lineTo(j, i) | |
noiseStep += 0.1; | |
} | |
console.log("noise is" + noise) | |
var e = groundPoints[3].x; | |
var f =groundPoints[3].y+160; | |
var circW =200; | |
var circH = 60; | |
//---__LANDSCAPE -- bottom line | |
var landscapeGroup = r.group(bottomPoint1.x, bottomPoint1.y) | |
var landscapePath = r.path (0,0) | |
//.lineTo (bottomPoint1.x, bottomPoint1.y) | |
//-5 is to move the path over a bit so it does not leave a small white line gap between the paths in the shape | |
.moveTo(bottomPoint1.x-5, bottomPoint1.y) | |
.lineTo(bottomPoint2.x-5, bottomPoint2.y) | |
.lineTo(bottomPoint2.x-5, height) | |
.lineTo (bottomPoint1.x-5, height) | |
.lineTo(bottomPoint1.x-5, 0).fill('hsv', 113,36,52) | |
.stroke (false) | |
//.closePath | |
var waterPath = r.path (0,0) | |
//.lineTo (bottomPoint1.x, bottomPoint1.y) | |
//-5 is to move the path over a bit so it does not leave a small white line gap between the paths in the shape | |
.moveTo(bottomPoint1.x-5, bottomPoint1.y+115) | |
.lineTo(bottomPoint2.x-5, bottomPoint2.y+115) | |
.lineTo(bottomPoint2.x+5, height) | |
.lineTo (bottomPoint1.x-5, height) | |
.lineTo(bottomPoint1.x-5, 0).fill('hsv', 194,63,69) | |
.stroke (false) | |
//line to make sure that the paths are correct | |
r.line (bottomPoint1.x, bottomPoint1.y, bottomPoint2.x, bottomPoint2.y).stroke(false) | |
} | |
for (var c =0; c<2; c++) { | |
r.ellipse (e, f, circW, circH).strokeWidth(8).stroke(255).fill(false) | |
e = e+5; | |
f = f+5; | |
circW = circW*.6; | |
circH=circH*.4; | |
} | |
//-----DEER----- | |
var deerBackLeg = r.path (e-circW*.50, f-30) | |
.moveTo(53,-110) | |
.curveTo (55, -80, 65, -75) | |
.lineTo(70,-45) | |
.curveTo(72,-40,73,-45) | |
.lineTo(70,-110) | |
.closePath() | |
.stroke(false) | |
.fill('hsv', 24, 35, 55) | |
var deerLeg = r.path (e-circW*.50, f-30) | |
.moveTo(25, -55) | |
.lineTo(15,-5) | |
.curveTo(15, 5,20, -5) | |
.lineTo(30, -55) | |
.fill('hsv', 24, 35, 55) | |
.stroke(false) | |
var deerBody = r.path (e-circW*.50, f-30) | |
.moveTo(-10, -25) | |
.lineTo (0, -70) | |
.curveTo(40, -120, 5, -125, 70, -125) | |
.curveTo(85, -100, 78,-75) | |
.lineTo(82,-45) | |
.curveTo(80, -42,79, -46) | |
.lineTo(74,-75) | |
//back leg meat part | |
.curveTo(60, -90, 60, -100) | |
///curve top back leg | |
.curveTo(57, -110, 55, -95) | |
.curveTo(55, -70,42,-55) | |
//right leg | |
.curveTo(45,-40 ,42, -30) | |
.lineTo(37,0) | |
//front foot | |
.curveTo(34,3, 34, -3) | |
.lineTo(35,-45) | |
.curveTo(30,-47,28, -43) | |
.lineTo(0,-25) | |
.fill('hsv', 24, 49, 50) | |
.stroke(false) | |
var deerHead = r.path(e-circW*.50, f-30) | |
//nose | |
.curveTo(-3, 10, -10, 0) | |
//snout | |
.lineTo(-13, -15) | |
//side face of eye | |
.curveTo (-20, -15,-19,-35) | |
//left view ear | |
.curveTo (-30, -45,-25, -50) | |
//bottom inner ear | |
.curveTo(-15,-50,-15,-38) | |
//top of head | |
.curveTo(0,-45,8,-37) | |
//ear right view | |
.curveTo (7, -50, 15,-51) | |
.curveTo(20, -47, 13,-35) | |
.curveTo(15, -18,9,-15) | |
//neck to back | |
.lineTo(0,0) | |
.fill('hsv', 24, 49, 45) | |
.stroke(false) | |
.strokeWidth(.5) | |
//.closePath(); | |
var deerNose = r.path(e-circW*.50, f-30) | |
.curveTo(-3, 10, -10, 0).fill(0,0,0) | |
// console.log (ranThick); | |
// console.log(groundPoints); | |
r.draw(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment