# Existing p5.js code I should learn from?

**URL:** <https://discourse.processing.org/t/existing-p5-js-code-i-should-learn-from/43941>\
**Category:** Teaching\
**Created:** [February 19, 2024, 12:50am UTC](https://discourse.processing.org/t/existing-p5-js-code-i-should-learn-from/43941 "2024-02-19T00:50:08Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [February 19, 2024, 4:42am UTC](https://discourse.processing.org/t/existing-p5-js-code-i-should-learn-from/43941/2 "2024-02-19T04:42:09Z")

</div>

> [@bodomo](#):
>
> (I have extensive experience programming in other languages, not so much in JS),

So, which 1s do you already know?

> [@bodomo](#):
>
> Which code would you recommend I understand to improve my knowledge?

Maybe this “Ramer–Douglas–Peucker Algorithm” sketch from this topic below which I’ve converted to many versions in different Processing language flavors, including Java Mode, p5js, Python Mode and recently PyScript + p5js:

> [@Reducing points in polygon](https://discourse.processing.org/t/reducing-points-in-polygon/13590):
>
> I’ve been working with this example code over on the old forum, which reduces the number of points in a polygon using the [Ramer-Douglas-Peucker algorithm](https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm). It works great for my purposes, but for one weird thing: it creates duplicates of all the points frowning Here’s my demo code; simplification functions below with a few notes: int numPoints = 12; // reduce to this many points float[][] pointsArray = { { 1687, 1667 }, { 1684, 1708 }, { 1663, 1948 }, { 1662, 1955 }, { 1642, 2030 }, {…

This is my most recent post there, w/ links to both PyScript & p5js versions:

> [@Reducing points in polygon](https://discourse.processing.org/t/reducing-points-in-polygon/13590/7):
>
> For an additional completeness’ sake, here’s the [PyScript](https://pyscript.net) + p5\*js version: snake[https://PyScript.com/@gotoloop/ramer-douglas-peucker](https://PyScript.com/@gotoloop/ramer-douglas-peucker)[https://GoToloop.PyScriptApps.com/ramer-douglas-peucker](https://GoToloop.PyScriptApps.com/ramer-douglas-peucker)[https://GoToloop.PyScriptApps.com/ramer-douglas-peucker/latest/js.html](https://GoToloop.PyScriptApps.com/ramer-douglas-peucker/latest/js.html)

---

_[View the full topic](https://discourse.processing.org/t/existing-p5-js-code-i-should-learn-from/43941)._
