1. Home
  2. /
  3. P5js
  4. /
  5. Colorful Rectangles

Colorful Rectangles - P5js Typing CST Test

Loading…

Colorful Rectangles — P5js Code

Draws a series of colored rectangles.

function setup() {
	createCanvas(400, 200);
	noLoop();
}
function draw() {
	for(let i=0; i<10; i++) {
		fill(random(255), random(255), random(255));
		rect(i*40, 50, 30, 100);
	}
}

P5js Language Guide

p5.js is a JavaScript library designed to make coding accessible for artists, designers, and beginners. It provides an intuitive way to create graphics, animations, and interactive content on the web using a friendly API inspired by Processing.

Primary Use Cases

  • ▸Educational projects for teaching programming
  • ▸Interactive art installations
  • ▸Web-based animations and visualizations
  • ▸Prototyping games and interactive experiences
  • ▸Creative coding experiments

Notable Features

  • ▸Simplifies HTML5 Canvas and WebGL interactions
  • ▸High-level functions for drawing and animation
  • ▸Event handling for mouse, keyboard, and touch
  • ▸Supports multimedia like sound and video
  • ▸Open-source and community-driven

Origin & Creator

p5.js was created by Lauren McCarthy in 2014 as a JavaScript adaptation of Processing to make creative coding more web-friendly and accessible.

Industrial Note

Primarily used in education, art, and creative coding communities rather than enterprise software. Its focus is on learning, prototyping, and interactive visualization.

More P5js Typing Exercises

Hello World in p5.jsMoving CircleBouncing BallMouse Follow CircleRandom StarsGrowing CircleRotating LineRandom WalkInteractive Rectangle

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher