Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

103
Vistas
Creating An Abstract Calendar in P5JS

how do i use nested for loops to create a calendar for 2021 where theres 12 columns of black circles, where the number of circles for each column corresponds to the number of days in that month.

For example, the first column of circles will represent January and will have 31 circles. Each circle should be 10 pixels wide, and the canvas should be 140 X 330 which will allow a space of 10 pixels around the entire set of circles. i also need to indicate what day it is currently with a green circle and im not sure how to write a function for that either

this is all i have:

    var numDays; 

function setup() {
    createCanvas(140, 330);
    background(220);

}

function draw () { 
    fill(0);
    for (let m = 1; m <= 12; m +=1 ) {
        //set the variable numDays here 


    for (let d = 1; d <= numDays; d += 1) {
            //black circles
        }
    }
    fill (0, 255, 0);  
    //green circle

    noLoop();

}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

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

function drawCircleRow(quantity, diameter, space, xOffset, yOffset, dayColoredOtherwise) {
  for(let i = 0; i < quantity; i++) {
    if (dayColoredOtherwise - 1 === i) {
      fill(127);
    } else {
      fill(0);
    }
    circle(xOffset + (diameter + space) * i, yOffset, diameter);
  }
}

function draw() {
  background(255);
  const daysPerMonth = [31, 28, 31, 30];
  const monthIndex = 2;
  const day = 5;
  
  for (let i = 0; i < daysPerMonth.length; i++) {
    const days = daysPerMonth[i];
    drawCircleRow(days, 5, 5, 5, 10 * (i + 1), monthIndex === i ? day : -1);
  }
  
  noLoop();
}

This is not the full solution, but it should be good enough to twist it to your own needs.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda