howard-liao-generative

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
howard-liao-generative [2021/06/20 18:28] howard.liaohoward-liao-generative [2021/06/29 01:35] (current) renick
Line 1: Line 1:
 =====Howard Liao's crazyDog.js===== =====Howard Liao's crazyDog.js=====
 +by [[:howard-liao|Howard Liao]]
  
 <HTML> <HTML>
-<iframe src=https://editor.p5js.org/Howardliao/present/V1lr5K7Vl width=99% height=799px></iframe>+<iframe src=https://editor.p5js.org/renick/present/dgt185pBI width=99% height=799px></iframe>
 </HTML> </HTML>
 +
 +===== about my crazyDog.js =====
 +
 +This is my crazy dog.js, this is what I learned this semester, We try to make a lot of dogs and an animation background or a dog.  
 +
 +The animation code is released under the [[https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html|GNU Lesser General Public License v2.1]].
 +
 +===== the code for my crazyDog.js =====
 +
 <Code:js> <Code:js>
 function setup() { function setup() {
Line 23: Line 33:
   square(this.xposition + 90, this.yposition + 80, this.dogSize * 50);   square(this.xposition + 90, this.yposition + 80, this.dogSize * 50);
   square(this.xposition + 130, this.yposition + 130, this.dogSize * 140);   square(this.xposition + 130, this.yposition + 130, this.dogSize * 140);
-fill(Math.random() * 255, Math.random() * 255, Math.random() * 255)+  fill(Math.random() * 255, Math.random() * 255, Math.random() * 255)
   square(this.xposition + 98, this.yposition + 121, this.dogSize * 35);   square(this.xposition + 98, this.yposition + 121, this.dogSize * 35);
   square(this.xposition + 162, this.yposition + 122, this.dogSize * 35);   square(this.xposition + 162, this.yposition + 122, this.dogSize * 35);
- fill(Math.random() * 255, Math.random() * 255, Math.random() * 255)+  fill(Math.random() * 255, Math.random() * 255, Math.random() * 255)
   square(this.xposition + 99, this.yposition + 126, this.dogSize * 24);   square(this.xposition + 99, this.yposition + 126, this.dogSize * 24);
   square(this.xposition + 163, this.yposition + 126, this.dogSize * 24);   square(this.xposition + 163, this.yposition + 126, this.dogSize * 24);
Line 34: Line 44:
   fill(Math.random() * 255, Math.random() * 255, Math.random() * 255)   fill(Math.random() * 255, Math.random() * 255, Math.random() * 255)
   square(this.xposition + 100, this.yposition + 126,this.dogSize * 10);   square(this.xposition + 100, this.yposition + 126,this.dogSize * 10);
- fill(Math.random() * 255, Math.random() * 255, Math.random() * 255)+  fill(Math.random() * 255, Math.random() * 255, Math.random() * 255)
   square(this.xposition + 110, this.yposition + 196, this.dogSize * 200, 1, 50)   square(this.xposition + 110, this.yposition + 196, this.dogSize * 200, 1, 50)
   fill(Math.random() * 255, Math.random() * 255, Math.random() * 255)   fill(Math.random() * 255, Math.random() * 255, Math.random() * 255)
Line 48: Line 58:
    
    
-class BackgroundPattern {+  class BackgroundPattern {
   // dogSize is the number of times bigger   // dogSize is the number of times bigger
   constructor (xposition, yposition, patternSize, hColor, eColor)   constructor (xposition, yposition, patternSize, hColor, eColor)
Line 69: Line 79:
     noSmooth();     noSmooth();
     ellipse(this.xposition + 70, this.yposition + 50, this.patternSize * 36, this.patternSize * 36);     ellipse(this.xposition + 70, this.yposition + 50, this.patternSize * 36, this.patternSize * 36);
-+   
-}+   }
    
-function backgroundPatternArray (n, y) {+   function backgroundPatternArray (n, y) {
     let outputArray = [];     let outputArray = [];
     for (let i = 0; i < n ; i++) {     for (let i = 0; i < n ; i++) {
Line 78: Line 88:
     }     }
     return outputArray     return outputArray
-}+    }
    
-function dogArray (n, y) {+    function dogArray (n, y) {
     let outputArray = [];     let outputArray = [];
-  for(let k = 0; k < n ; k++){+   for(let k = 0; k < n ; k++){
     for (let i = 0; i < n ; i++) {     for (let i = 0; i < n ; i++) {
       outputArray.push(new Dog (0 + (200*i),y+(k*400), 0.5 + (1 * Math.random())))       outputArray.push(new Dog (0 + (200*i),y+(k*400), 0.5 + (1 * Math.random())))
-    }   +      }   
-  +    
-  return outputArray +    return outputArray 
-}+   }
    
    
-function draw() {+  function draw() {
   background(255,255,255)   background(255,255,255)
   //background(random(0,255),random(0,255),random(0,255));    //background(random(0,255),random(0,255),random(0,255)); 
Line 112: Line 122:
   for(let i = 0; i< howardsDogs.length; i++){   for(let i = 0; i< howardsDogs.length; i++){
     howardsDogs[i].draw();     howardsDogs[i].draw();
-  }+    }
      
   //let myDog = new Dog (0, 0, 1);   //let myDog = new Dog (0, 0, 1);
   //myDog.draw();   //myDog.draw();
 } }
- + </Code>
  
  • howard-liao-generative.1624238904.txt.gz
  • Last modified: 2021/06/20 18:28
  • by howard.liao