processing / p5.js

p5.js is a client-side JS platform that empowers artists, designers, students, and anyone to learn to code and express themselves creatively on the web. It is based on the core principles of Processing. http://twitter.com/p5xjs —
http://p5js.org/
GNU Lesser General Public License v2.1
21.1k stars 3.22k forks source link

How to change color of all circles?? #7035

Closed yealicjswo closed 1 month ago

yealicjswo commented 1 month ago

Topic

I would like to add color(any color I want) of whole dot while I test with 'for' loops example. so, Is there an any solution for applying color of all circles??

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

function draw() { background(240); let space = 10; strokeWeight(4);

for (let x = space; x < 600; x += space) { // Loop from the top to the bottom. for (let y = space; y < 600; y += space) { point(x, y); } } }

Screen Shot 2024-05-13 at 5 16 28 PM
limzykenneth commented 1 month ago

Hi @yealicjswo you can use the stroke() function like the below:

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

function draw() {
  background(240);
  let space = 10;
  strokeWeight(4);
  stroke(255, 0, 0);

  for (let x = space; x < 600; x += space) {
    // Loop from the top to the bottom.
    for (let y = space; y < 600; y += space) {
      point(x, y);
    }
  }
}

If you need help with your own code, please direct your questions to the forum or Discord. We use GitHub issues mainly for bug reports and feature requests only. Thanks!

yealicjswo commented 1 month ago

@limzykenneth thanks! I will make sure to ask an question(for my own code) in the forum and Discord.