processing / processing/p5.js

`p5.Color.equals` method

Open
#7,949 19 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area:Color Area:Data Area:Utilities Enhancement
Dominant language
JavaScript
Stars
24k
Forks
3.8k
Avg merge
3d 16h
Merged PRs (30d)
25

Description

Increasing access

Sometimes it's useful to be able to be able to compare colors against stored colours, for example, when sampling an image with a constrained palette. It would be great if you could compare p5.Color objects with eachother, which is kind of a hassle now.

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 enhancement details

I suggest creating a equals() method like in string objects. I could be a piecewise comparison of either of the p5.Color.levels or p5.Color._array arrays, but I don't quite understand what their difference is in practice (which one is the master).

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 with the p5.Color API and compare the roles of the p5.Color.levels and p5.Color._array values mentioned in the issue. Decide which representation defines equality, then add equals() behavior that lets p5.Color objects be compared and verify that comparisons against stored colors work as intended.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics, frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.