Advertisement
AJordanInLimbo

Processing project

Jul 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* global draw ellipse rect p processing width height size */
  2. var sketch = function(processing) {
  3.     with(processing) {
  4.         size(screen.availWidth, screen.availHeight);
  5.         // °º¤ø,¸¸,ø¤º°`°º¤ø Create Project Below This Line ø¤º°`°º¤ø,¸,ø¤°//
  6.         background(200);
  7.         var sunHeight = 0;
  8.  
  9.         /**
  10.          * Creates the text at the beginning
  11.          */
  12.         intro = function() {
  13.             var y = screen.height;
  14.             strokeWeight(6);
  15.             noFill();
  16.  
  17.             /**Creates the arrow at the beginning*/
  18.             line(300, y / 2, 300, y / 2 + 100);
  19.             line(300, y / 2, 270, y / 2 + 30);
  20.             line(300, y / 2, 330, y / 2 + 30);
  21.  
  22.  
  23.             /**Creates the letter t*/
  24.             line(375, y / 2 + 10, 375, y / 2 + 90);
  25.             line(355, y / 2 + 30, 395, y / 2 + 30);
  26.  
  27.  
  28.             /**Creates the letter o*/
  29.             ellipse(420, y / 2 + 65, 55, 55);
  30.  
  31.  
  32.             /**Creates the letter b*/
  33.             ellipse(508, y / 2 + 65, 55, 55);
  34.             line(480, y / 2 + 10, 480, y / 2 + 90);
  35.             line(490, y / 2 + 10, 490, y / 2 + 90);
  36.  
  37.  
  38.             /**Creates the letter e*/
  39.             line(550, y / 2 + 40, 550, y / 2 + 90);
  40.             line(560, y / 2 + 40, 560, y / 2 + 90);
  41.             line(550, y / 2 + 38, 580, y / 2 + 38);
  42.             line(550, y / 2 + 92, 580, y / 2 + 92);
  43.             line(550, y / 2 + 65, 580, y / 2 + 65);
  44.  
  45.  
  46.             /**Creates the letter g*/
  47.             ellipse(620, y / 2 + 65, 55, 55);
  48.             line(647, y / 2 + 60, 647, y / 2 + 120);
  49.             arc(622, 500, 50, 50, 0, 4 * PI / 5);
  50.  
  51.  
  52.             /**Creates the letter i*/
  53.             line(680, y / 2 + 40, 680, y / 2 + 90);
  54.             line(658, y / 2 + 38, 678, y / 2 + 38);
  55.             line(670, y / 2 + 40, 670, y / 2 + 90);
  56.             ellipse(672.5, y / 2 + 20, 15, 15);
  57.  
  58.  
  59.             /**Creates the letter n*/
  60.             line(700, y / 2 + 40, 700, y / 2 + 90);
  61.             line(700, y / 2 + 40, 730, y / 2 + 90);
  62.             line(730, y / 2 + 40, 730, y / 2 + 90);
  63.  
  64.         };
  65.  
  66.         /**
  67.          * Creates the base starting image
  68.          */
  69.         base = function() {
  70.             /** Creates a seesaw */
  71.             seesaw = function() {
  72.                 stroke(43, 15, 198);
  73.                 strokeWeight(10);
  74.  
  75.                 //Main body
  76.                 line(300, 630, 500, 530);
  77.  
  78.                 //Handle A
  79.                 line(325, 610, 315, 590);
  80.  
  81.                 //Handle B
  82.                 line(470, 530 + 7, 460, 510 + 7);
  83.                 noStroke();
  84.  
  85.                 //Base
  86.                 fill(76, 47, 0);
  87.                 triangle(405, 580, 380, 630, 430, 630);
  88.             };
  89.  
  90.             /** Creates a gradient for the sky */
  91.             sky = function() {
  92.  
  93.                 /**Color Variables for the sky*/
  94.                 var r = 30;
  95.                 var g = 50;
  96.                 var b = 110;
  97.  
  98.                 /**Creates the gradient for the sky*/
  99.                 for (var y = 0; y < screen.height * 2; y += 5) {
  100.                     noStroke();
  101.                     fill(r, g, b);
  102.                     rect(0, y, screen.width, 25);
  103.                     g--;
  104.                     b--;
  105.                 }
  106.             };
  107.  
  108.             /** Creates the sun */
  109.             sun = function() {
  110.                 var colorA = color(20, 19, 71);
  111.                 var colorB = color(255, 195, 0);
  112.                 var aura = lerpColor(colorA, colorB, .66);
  113.                 stroke(aura);
  114.                 fill(255, 195, 0);
  115.  
  116.                 /**
  117.                  * Sun height is a variable that is later manipulated
  118.                  * to raise and lower the sun.
  119.                  */
  120.                 ellipse(screen.width / 2, 670 - sunHeight, 200, 200);
  121.             };
  122.  
  123.             /** Makes the ground */
  124.             ground = function() {
  125.                 /**
  126.                  * Draws small circles that repeat for the ground.
  127.                  */
  128.                 for (var i = 0; i < screen.width; i += 50) {
  129.                     noStroke();
  130.                     fill(38, 34, 30);
  131.                     ellipse(i, screen.height - 80, 150, 200);
  132.                 }
  133.             };
  134.  
  135.             /** Combines the parts of the tree to draw full trees */
  136.             trees = function() {
  137.                 /** Draws all of the tree trunks */
  138.                 trunks = function() {
  139.                     tree = function(move) {
  140.                         stroke(84, 56, 34);
  141.                         strokeWeight(20);
  142.                         noFill();
  143.                         curve(5 + move, screen.height - 300, 73 + move, 400, 73 + move, 680, 15 + move, 680);
  144.                         fill(84, 56, 34);
  145.                         triangle(80 + move, screen.height - 200, 30 + move, 800, 130 + move, 750);
  146.  
  147.                     };
  148.                     tree(0);
  149.                     tree(100);
  150.                     tree(screen.width - 100);
  151.                     tree(screen.width - 220);
  152.                     tree(screen.width - 380);
  153.                     tree(screen.width - 300);
  154.                     tree(screen.width - 500);
  155.                 };
  156.  
  157.                 /** Draws thicker main branches and thinner branches */
  158.                 branches = function() {
  159.                     tree = function(move) {
  160.                         //Main Branches
  161.                         strokeWeight(6);
  162.                         stroke(84, 56, 34);
  163.                         triangle(67 + move, 430, 67 + move, 432, 25 + move, 428);
  164.                         triangle(70 + move, 400, 70 + move, 402, 130 + move, 390);
  165.                         triangle(30 + move, 330, 30 + move, 330, 70 + move, 400);
  166.  
  167.                         //Smaller Branches
  168.                         strokeWeight(4);
  169.                         triangle(128 + move, 390, 140 + move, 370, 140 + move, 370);
  170.                         triangle(128 + move, 390, 150 + move, 410, 150 + move, 410);
  171.                         line(60 + move, 320, 54 + move, 370);
  172.                     };
  173.                     tree(0);
  174.                     tree(100);
  175.                     tree(screen.width - 100);
  176.                     tree(screen.width - 220);
  177.                     tree(screen.width - 380);
  178.                     tree(screen.width - 300);
  179.                     tree(screen.width - 500);
  180.  
  181.                 };
  182.  
  183.                 /** Creates the leaves for the trees */
  184.                 leaves = function() {
  185.                     noStroke();
  186.                     tree = function(move) {
  187.                         //Main Leaves,
  188.                         fill(10, 71, 23, 400);
  189.                         ellipse(80 + move, 400, 220, 130);
  190.                         fill(10, 71, 23, 300);
  191.                         ellipse(120 + move, 350, 100, 80);
  192.  
  193.                         //Little leaves,
  194.                         fill(0, 75, 25, 250);
  195.                         ellipse(30 + move, 445, 70, 40);
  196.  
  197.                         //Med. Leaves,
  198.                         fill(11, 68, 21, 240);
  199.                         ellipse(45 + move, 330, 90, 80);
  200.  
  201.                         //Long Leaves,
  202.                         fill(0, 70, 9, 250);
  203.                         ellipse(140 + move, 383, 120, 80);
  204.                     };
  205.                     tree(0);
  206.                     tree(20);
  207.                     tree(70);
  208.                     tree(screen.width - 100);
  209.                     tree(screen.width - 370);
  210.                     tree(screen.width - 220);
  211.                     tree(screen.width - 300);
  212.                     tree(screen.width - 500);
  213.                 };
  214.  
  215.                 /** Calling all of the functions */
  216.                 leaves(); //draws the leaves
  217.                 trunks(); //draws the tree trunks
  218.                 branches(); //draws the branches
  219.             };
  220.  
  221.             sky();
  222.             trees(); //draws the trees
  223.             sun(); //draws the sun
  224.             ground(); //draws the ground
  225.             seesaw(); //Makes a seesaw!
  226.         };
  227.  
  228.         keyPressed = function() {
  229.             /**
  230.              * Makes the sun move up when the up key is pressed
  231.              * Moves the sun down when the down key is pressed.
  232.              */
  233.             if (key == CODED) {
  234.                 if (keyCode == UP) {
  235.                     base();
  236.                     sunHeight += 7.5;
  237.                 }
  238.                 else if (keyCode == DOWN) {
  239.                     base();
  240.                     sunHeight -= 7.5;
  241.                 }
  242.             }
  243.         };
  244.  
  245.         /**Prints the intro with no fill*/
  246.         draw = function() {
  247.             noFill();
  248.             intro();
  249.         };
  250.  
  251.         // °º¤ø,¸¸,ø¤º°`°º¤ø Create Project Above This Line ø¤º°`°º¤ø,¸,ø¤°//  
  252.     }
  253. };
  254. var p = new Processing(document.getElementById("output-canvas"), sketch);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement