# Border between two colours

**URL:** <https://discourse.processing.org/t/border-between-two-colours/46399>\
**Category:** Beginners\
**Created:** [May 16, 2025, 7:29am UTC](https://discourse.processing.org/t/border-between-two-colours/46399 "2025-05-16T07:29:07Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![paulstgeorge](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Post date:** [May 16, 2025, 4:55pm UTC](https://discourse.processing.org/t/border-between-two-colours/46399/3 "2025-05-16T16:55:58Z")

</div>

That’s good, but it boils down to this:

> [@scudly](#):
>
> find its nearest neighbor color in the palette

And that is my question. How do you find the nearest colour? I thought of using approximate equality but often the Red value of a colour will send you one way and the Blue value the other way…

> [@Approximate equality for Rosetta](https://discourse.processing.org/t/approximate-equality-for-rosetta/42196):
>
> I noticed that Processing is missing from [https://rosettacode.org/wiki/Approximate\_equality](https://rosettacode.org/wiki/Approximate_equality). Sure this can be improved, but here is a start… I have used ‘big’ not in a vain attempt to avoid floating point errors, but to give expected results. int big = 1000000000; void setup() { noLoop(); } void draw() { isClose(1.2, 1.1, 0.10000001); // first number, second number, how close is close } void isClose(float num1, float num2, float prox) { int intnum1 = int(num1\*big); int intnum2 …

---

_[View the full topic](https://discourse.processing.org/t/border-between-two-colours/46399)._
