Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This calls the drawTree function, the major function of it all
- drawTree();
- //
- function drawTree() {
- // Draws the stump of the tree
- drawStump();
- drawStump2();
- // This adds detail to the stump of the tree (bumps)
- drawBump();
- drawBump2();
- // Draws the multiple branches of the tree
- drawLeftBranch();
- drawRightBranch();
- // Draws the cherryblossom leaves
- drawLeftLeaves();
- drawRightLeaves();
- // Drawing stump command
- }
- // Stump of the left tree
- function drawStump() {
- penUp();
- moveTo(-10, 455);
- penColor("#3F250B");
- penWidth(80);
- penDown();
- moveForward(175);
- turnRight(90);
- penWidth(30);
- turnTo(45);
- arcLeft(90, 25);
- turnTo(0);
- penUp();
- }
- // Stump of the right tree
- function drawStump2() {
- penUp();
- moveTo(330, 465);
- penColor("#3F250B");
- penWidth(80);
- penDown();
- moveForward(175);
- turnRight(90);
- penWidth(30);
- turnTo(45);
- arcLeft(90, 25);
- turnTo(0);
- penUp();
- }
- // Bump of the left tree
- function drawBump() {
- penUp();
- turnTo(0);
- moveTo(15, 450);
- dot(25);
- for (var i = 0; i < 10; i++) {
- moveForward(20);
- penDown();
- dot(20);
- }
- penUp();
- }
- // Bump of the right tree
- function drawBump2() {
- penUp();
- turnTo(0);
- moveTo(305, 450);
- dot(25);
- for (var i = 0; i < 10; i++) {
- moveForward(20);
- penDown();
- dot(20);
- }
- penUp();
- }
- // All four branches of the tree
- function drawLeftBranch() {
- drawLeftBranch1();
- drawLeftBranch2();
- drawLeftBranch3();
- drawLeftBranch4();
- }
- function drawRightBranch() {
- drawRightBranch1();
- drawRightBranch2();
- drawRightBranch3();
- }
- // First branch of left tree
- function drawLeftBranch1(){
- var branchWidth = 20;
- penUp();
- penColor("#3F250B");
- moveTo(25, 230);
- penWidth(branchWidth);
- turnTo(20);
- penDown();
- moveForward(70);
- turnRight(45);
- penWidth(branchWidth-3);
- moveForward(60);
- turnRight(-10);
- penWidth(branchWidth-5);
- moveForward(40);
- penUp();
- }
- // First branch of the right tree
- function drawRightBranch1(){
- var branchWidth = 20;
- penUp();
- penColor("#3F250B");
- moveTo(300, 228);
- penWidth(branchWidth);
- turnTo(-20);
- penDown();
- moveForward(70);
- turnRight(-45);
- penWidth(branchWidth-3);
- moveForward(60);
- turnRight(-10);
- penWidth(branchWidth-5);
- moveForward(40);
- penUp();
- }
- // Second branch of the left tree
- function drawLeftBranch2() {
- var branchWidth = 20;
- penUp();
- penColor("#3F250B");
- moveTo(15, 240);
- penWidth(branchWidth);
- turnTo(40);
- penDown();
- moveForward(70);
- turnRight(45);
- penWidth(branchWidth-3);
- moveForward(60);
- turnRight(-10);
- penWidth(branchWidth-5);
- moveForward(35);
- penUp();
- }
- // Second branch of the right tree
- function drawRightBranch2() {
- var branchWidth = 20;
- penUp();
- penColor("#3F250B");
- moveTo(285, 235);
- penWidth(branchWidth);
- turnTo(-40);
- penDown();
- moveForward(70);
- turnRight(45);
- penWidth(branchWidth-3);
- moveForward(60);
- turnRight(-10);
- penWidth(branchWidth-5);
- moveForward(35);
- penUp();
- }
- // Third branch of the left tree
- function drawLeftBranch3() {
- var branchWidth = 20;
- penUp();
- penColor("#3F250B");
- moveTo(12, 230);
- penWidth(branchWidth);
- turnTo(10);
- penDown();
- moveForward(70);
- turnRight(45);
- penWidth(branchWidth-3);
- moveForward(60);
- turnRight(-10);
- penWidth(branchWidth-5);
- moveForward(40);
- penUp();
- }
- // Third branch of the right tree
- function drawRightBranch3() {
- var branchWidth = 20;
- penUp();
- penColor("#3F250B");
- moveTo(313, 235);
- penWidth(branchWidth);
- turnTo(10);
- penDown();
- moveForward(70);
- turnRight(45);
- penWidth(branchWidth-3);
- moveForward(60);
- turnRight(-10);
- penWidth(branchWidth-5);
- moveForward(40);
- penUp();
- }
- // Fourth branch of the left tree ONLY
- function drawLeftBranch4() {
- var branchWidth = 20;
- penUp();
- penColor("#3F250B");
- moveTo(8, 230);
- penWidth(branchWidth);
- turnTo(0);
- penDown();
- moveForward(70);
- turnRight(45);
- penWidth(branchWidth-3);
- moveForward(60);
- turnRight(-10);
- penWidth(branchWidth-5);
- moveForward(40);
- penUp();
- }
- // The cherry blossom leaves of left tree!!
- function drawLeftLeaves() {
- penUp();
- moveTo(25, 244);
- penWidth(23);
- penDown();
- for (var i = 0; i < 125; i++) {
- drawColor1();
- drawColor2();
- drawColor3();
- penUp();
- turnTo(randomNumber(5, 179));
- moveTo(randomNumber(-10, 135), randomNumber(67, 230));
- penDown();
- }
- penUp();
- }
- // The cherry blossom trees of the right tree!!
- function drawRightLeaves() {
- penUp();
- moveTo(299, 255);
- penWidth(23);
- penDown();
- for (var i = 0; i < 100; i++) {
- drawColor1();
- drawColor2();
- drawColor3();
- penUp();
- turnTo(randomNumber(5, 179));
- moveTo(randomNumber(195, 320), randomNumber(65, 240));
- penDown();
- }
- penUp();
- }
- // First cherry blossom leaf color
- function drawColor1() {
- penColor("#ba808b");
- arcRight(90, 20);
- turnRight(90);
- arcRight(90, 20);
- }
- // Second cherry blossom leaf color
- function drawColor2() {
- penColor("d498a3");
- arcRight(90, 20);
- turnRight(90);
- arcRight(90, 20);
- }
- // Third cherry blossom leaf color
- function drawColor3() {
- penColor("#f2b9c4");
- arcRight(90, 20);
- turnRight(90);
- arcRight(90, 20);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement