processing / processing/p5.js

Drawn pixel using pencil on canvas is not centred

Open
#6,645 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Discussion
Dominant language
JavaScript
Stars
24k
Forks
3.8k
Avg merge
3d 16h
Merged PRs (30d)
25

Description

Topic

I am drawing pixels using a pencil on canvas using p5.js. The issue is that when the pencil size is 1 and canvas is Zoomed IN in that scenario, its position is not centered. It's coming left sometime right not centered.
I've noticed an interesting observation in our code. It appears that when the mouse's x and y positions are close to .5, the drawn pixel appears centered,
So I have query that I want to know how image.set() method work internally ,
like did it accept Floating value too?

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 reproducing the issue with p5.js using a zoomed canvas, a pencil size of 1, and coordinates near and away from .5. Then inspect how image.set() handles floating-point positions. Done means the pixel is consistently centered and the behavior is covered by a documented reproduction or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.