howard-lee-generative

This is an old revision of the document!



function setup() {

createCanvas(2000, 1200);
noLoop();

}

class BackgroundPattern {

constructor (xposition, yposition, size, pColor )
{ this.xposition = xposition;
  this.yposition = yposition;
  this.size = size;
  this.patternColor = pColor;

}

draw () {
fill(this.patternColor);
rect(this.xposition, this.yposition, this.size, this.size);
fill(227, 94, 84);
rect(this.xposition + 10, this.yposition + 10, this.size/2, this.size/2);
}

}

function patternRow (n, xposition, yposition) {

  let outputArray = [];
  for (let i = 0; i < n ; i++) {
      outputArray.push(new BackgroundPattern (xposition + (i*105), yposition, 100,"brown"))
  }
  return outputArray

}

class Dog {

constructor (xposition,yposition, fColor, eColor)
{ this.xposition = xposition;
  this.yposition = yposition;
  this.furColor = fColor;
  this.eyeColor = eColor
}
draw () {
  fill(this.furColor);
  let leftEarPosition = [this.xposition+180,

this.yposition+140];

let rightEarPosition = [this.xposition+300,this.yposition+140];
triangle(30 + leftEarPosition[0], 75 + leftEarPosition[1], 58 + leftEarPosition[0], 20 + leftEarPosition[1], 86 + leftEarPosition[0], 75 + leftEarPosition[1]);
triangle(30 + rightEarPosition[0], 75 + rightEarPosition[1], 58 + rightEarPosition[0], 20 + rightEarPosition[1], 86 + rightEarPosition[0], 75 + rightEarPosition[1]);
circle(this.xposition+300,this.yposition+300, 244);

fill(this.eyeColor);

rect(this.xposition+250,this.yposition+ 270, 15, 85);
rect(this.xposition+335,this.yposition+ 270, 15, 85);
}

}

function dogArray (n, xposition, yposition) {

  let outputArray = [];
  for (let i = 0; i < n ; i++) {
      outputArray.push(new Dog ( xposition+ (i*200), yposition+(i*200),"yellow","pink"))
  }
  return outputArray

}

function fullPattern (startingX, startingY, numberOfRows, rowLength){

for(let i = 0; i < numberOfRows ; i++){
  let mypattern = patternRow(rowLength, startingX, startingY+(i*105));
  for(let i = 0; i < mypattern.length ; i++){
    mypattern[i].draw()
};
}

}

function fulldogs (startingX, startingY, numberOfRows, rowLength){

for(let i = 0; i < numberOfRows ; i++){
  let mydogs = dogArray(rowLength, startingX, startingY+(i*105));
  for(let i = 0; i < mydogs.length ; i++){
    mydogs[i].draw()
};
}

} let myDogs = dogArray(20); function draw() { background(229, 195, 230); fullPattern(5,5,10,30) fulldogs(5,5,10,30) for(let i = 0; i < myDogs.length ; i++){

  //myDogs[i].draw()
//let dog2 = new Dog (400,100, "yellow", "red");
//dog2.draw();
//}

}

  • howard-lee-generative.1624257506.txt.gz
  • Last modified: 2021/06/20 23:38
  • by renick