Facebook
From Adjowa Asamoah, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 141
  1. int canvasWidth = 400; // Width of the canvas
  2. int canvasHeight = 400; // Height of the canvas
  3.  
  4. int sunX = 100; // X-coordinate of the sun
  5. int sunY = 100; // Y-coordinate of the sun
  6. int sunSize = 80; // Size of the sun
  7.  
  8. int grassHeight = 100; // Height of the grass
  9.  
  10. int houseX = 200; // X-coordinate of the house
  11. int houseY = 200; // Y-coordinate of the house
  12. int houseWidth = 150; // Width of the house
  13. int houseHeight = 150; // Height of the house
  14.  
  15. int roofHeight = 100; // Height of the roof
  16.  
  17. int doorWidth = 40; // Width of the door
  18. int doorHeight = 100; // Height of the door
  19. int doorX = houseX + houseWidth / 2 - 20; // X-coordinate of the door
  20. int doorY = houseY + houseHeight - doorHeight; // Y-coordinate of the door (adjusted)
  21.  
  22. // setup function
  23. void settings() {
  24.   size(canvasWidth, canvasHeight); // Set the canvas size
  25. }
  26.  
  27. // setup function
  28. void setup() {
  29.   // empty setup function as everything is already initialized
  30. }
  31.  
  32. // draw function
  33. void draw() {
  34.   background(220); // Set the background color
  35.  
  36.   // Sun
  37.   fill(255, 255, 0); // Yellow color
  38.   ellipse(sunX, sunY, sunSize, sunSize); // Draw the sun
  39.  
  40.   // Grass
  41.   fill(0, 255, 0); // Green color
  42.   rect(0, canvasHeight - grassHeight, canvasWidth, grassHeight); // Draw the grass
  43.  
  44.   // House
  45.   fill(255); // White color
  46.   rect(houseX, houseY, houseWidth, houseHeight); // Draw the main body of the house
  47.  
  48.   // Roof
  49.   fill(255, 0, 0); // Red color
  50.   triangle(houseX - roofHeight / 2, houseY, houseX + houseWidth / 2, houseY - roofHeight, houseX + houseWidth + roofHeight / 2, houseY); // Draw the roof
  51.  
  52.   // Door
  53.   fill(150, 75, 0); // Brown color
  54.   rect(doorX, doorY, doorWidth, doorHeight); // Draw the door
  55. }
  56.