Drawing Factory Part 2



Unit Progress: Unit 2: Build your Creativity

 79%

Drawing Factory Part 2

 

 

Click here to load the code live in P5JS

 


Code you can copy/paste below

 

function setup() {
  createCanvas(600, 600);
  drawSetup();
}

function draw() {
  // Empty draw loop – p5.js will loop this continuously
}

function drawSetup() {
  console.log("I am in the drawSetup function!");

  background('#FFFFCD');
  strokeWeight(5);
  rectMode(CORNER);

  // Data
  let xPosition = 50;
  let yPosition = 50;
  let shapeWidth = 50;
  let shapeHeight = 50;
  let shapeColor = "8,129,249";
  let shapeOutline = "5,6,7";

  // Call the drawShape function
  drawShape(xPosition, yPosition, shapeWidth, shapeHeight, shapeColor, shapeOutline);
  drawShape(xPosition, yPosition, shapeWidth, shapeHeight, shapeColor, shapeOutline);
}

function drawShape(xPOS, yPOS, shapeWidth, shapeHeight, shapeColor, shapeOutline) {
  console.log("I am in the drawShape function and xPOS = " + xPOS);

  // Currently, shapeColor and shapeOutline are not used for drawing.
  // You can add code here to use these parameters if needed.

  rect(xPOS, yPOS, shapeWidth, shapeHeight);
}


Previous Next