processing / processing/p5.js

Feature Suggestion : Custom Viewport Coordinate Mapping

Open
#7,959 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area:Accessibility Area:Core Area:Math Area:Utilities Feature Request
Dominant language
JavaScript
Stars
24k
Forks
3.8k
Avg merge
3d 16h
Merged PRs (30d)
25

Description

Increasing access

This feature would increase access to p5.js by making it easier to create resolution-independent sketches.

Most appropriate sub-area of p5.js?
  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)
Feature request details

The current p5.js coordinate system is pixel-based, which makes sketches dependent on canvas size and screen resolution.
This presents challenges for Building responsive visuals that work well on different screen sizes

Maybe we can implement function like this : setViewport(xmin, xmax, ymin, ymax) that allow users to remap the canvas from : (0, 0, WIDTH, HEIGHT) to (xmin, ymin, xmax, ymx)

In this case, drawing becomes resolution-independent and semantically clearer.
A call like :

setViewport(-10, -10, 10, 10);
line(-10, 0, 10, 0);

would always draw a horizontal line across the middle of the canvas, regardless of canvas resolution

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing p5.js core/environment/rendering and utilities APIs to understand how canvas coordinates are currently handled. Compare the proposed setViewport signature with existing API conventions and determine the required behavior across canvas sizes. Done means an agreed coordinate-mapping design that supports resolution-independent sketches.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.