An interactive browser-based graphics experiment built with JavaScript and p5.js. The sketch captures a live webcam feed and represents it as a grid of squares whose sizes vary according to each sampled pixel's brightness.
- Live webcam capture in the browser
- Pixel-level RGB sampling
- Average-brightness calculation
- Brightness-to-size mapping
- Dynamic rendering with p5.js
- Original source preserved separately for comparison
- Download or clone this repository.
- Open the project folder in a code editor.
- Start a local web server (for example, the Live Server extension in Visual Studio Code).
- Open the local URL and allow webcam access.
Camera access generally requires a secure context such as https:// or localhost; opening index.html directly as a file:// URL may not allow camera access in every browser.
createCapture(VIDEO)requests a webcam stream.- The video is reduced to a small sampling grid.
loadPixels()makes the current frame's pixel data available.- The sketch reads each pixel's red, green, and blue values and calculates their average.
map()converts brightness from the 0–255 range to a square size from 0 tovScale.- p5.js draws the resulting grid every frame.
index.html— browser entry pointsrc/sketch.js— runnable version, with row-major pixel indexing and a centered gridsrc/sketch.original.js— original source, preserved without editssrc/style.css— page stylingdocs/ARCHITECTURE.md— implementation notes
JavaScript · p5.js · HTML5 · Web APIs · RGB pixel sampling · Real-time visualization
The sketch requests webcam permission and processes the video locally in the browser. This repository contains no video upload or recording functionality. Review any future changes before publishing or deploying.
This is an educational graphics prototype, not a complete computer-vision or machine-learning system. Results depend on browser support, camera availability, lighting, and the device's processing performance.
Released under the MIT License. See LICENSE.