Skip to main content
AmigoFish

Coding Challenge 181: Weighted Voronoi Stippling

From The Coding Train Β· Β· 28 min

The player loads from YouTube only when you click. It uses YouTube's privacy-enhanced mode.

If the video does not play, the owner may have turned off embedding. Watch it on YouTube instead.

Watch on YouTube

Not rated yet

Description

Stippling is an artistic technique that uses numerous dots to craft an image. In this coding challenge I attempt to implement a weighted Voronoi stippling algorithm with p5.js along with the Delaunay triangulation package from d3.js. Code: https://thecodingtrain.com/challenges/181-image-stippling

πŸš€ Watch this video ad-free on Nebula https://nebula.tv/videos/codingtrain-coding-challenge-181-weighted-voronoi-stippling

p5.js Web Editor Sketches: πŸ•ΉοΈ Weighted Voronoi Stippling: https://editor.p5js.org/codingtrain/sketches/Z_YV25_4G πŸ•ΉοΈ Circumcircle: https://editor.p5js.org/codingtrain/sketches/eJnSI84Tw πŸ•ΉοΈ Delaunay Triangulation: https://editor.p5js.org/codingtrain/sketches/fuQz_-FnA πŸ•ΉοΈ Voronoi Diagram: https://editor.p5js.org/codingtrain/sketches/GpeT1W8X1 πŸ•ΉοΈ Voronoi Phyllotaxis: https://editor.p5js.org/codingtrain/sketches/ydiZeUK8R πŸ•ΉοΈ Voronoi Diagram colored by area: https://editor.p5js.org/codingtrain/sketches/opmU_UQqg πŸ•ΉοΈ Lloyd's relaxation: https://editor.p5js.org/codingtrain/sketches/04sgsAcNu πŸ•ΉοΈ Weighted Stippling - Size and Color: https://editor.p5js.org/codingtrain/sketches/_HTZUBPld πŸ•ΉοΈ Weighted Stippling - Abstract Pattern: https://editor.p5js.org/codingtrain/sketches/9ntWWLXqA πŸ•ΉοΈ Weighted Stippling - Video: https://editor.p5js.org/codingtrain/sketches/7TKSgi16z

πŸŽ₯ Previous: https://youtu.be/L4u7Zy_b868?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH πŸŽ₯ All: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH

References: πŸ”— d3-delaunay: https://d3js.org/d3-delaunay πŸ”— Weighted Voronoi Stippling: https://www.cs.ubc.ca/labs/imager/tr/2002/secord2002b/secord.2002b.pdf πŸ”— Sweep Line Algorithm: https://en.wikipedia.org/wiki/Sweep_line_algorithm πŸ”— Lloyd's algorithm: https://en.wikipedia.org/wiki/Lloyd%27s_algorithm πŸ”— Polygons and meshes by Paul Bourke: https://paulbourke.net/geometry/polygonmesh/ 🎨 Pablo Jurado Ruiz: https://www.instagram.com/pablojuradoruiz/ πŸ”— Stippling: https://en.wikipedia.org/wiki/Stippling πŸ”— Voronoi Diagram: https://en.wikipedia.org/wiki/Voronoi_diagram πŸ”— Delaunay Triangulation: https://en.wikipedia.org/wiki/Delaunay_triangulation πŸ”— Mike Bostock's Voronoi Stippling: https://observablehq.com/@mbostock/voronoi-stippling

Videos: πŸš‚ Pixel Array: https://youtu.be/nMUMZ5YRxHI

Related Coding Challenges: πŸš‚ C4 Worley Noise: https://youtu.be/4066MndcyCk πŸš‚ 33 Poisson-disc Sampling: https://youtu.be/flQgnCUxHlw

Timestamps: 0:00 Hello! 0:37 What is a Delaunay triangulation? 2:31 d3-delaunay package 2:49 Coding the delaunay triangulation. 6:38 What is a Voronoi diagram? 9:17 voronoi function on the delaunay object 10:25 Things you could try with the Voronoi diagram 10:56 Lloyd's "relaxation" algorithm 12:07 Calculate the average of a polygon's vertices 15:30 Calculate the area of a polygon 16:45 Calculate the proper centroid of a polygon 18:47 What is stippling? 19:45 Draw dots based on brightness value of pixel 21:50 Calculate a weighted centroid 24:51 Using delaunay.find() 27:52 Ideas for you to try! 28:47 Goodbye!

Editing by Mathieu Blanchette Animations by Jason Heglund Music from Epidemic Sound

πŸš‚ Website: https://thecodingtrain.com/ πŸ‘Ύ Share Your Creation! https://thecodingtrain.com/guides/passenger-showcase-guide 🚩 Suggest Topics: https://github.com/CodingTrain/Suggestion-Box πŸ’‘ GitHub: https://github.com/CodingTrain πŸ’¬ Discord: https://thecodingtrain.com/discord πŸ’– Membership: http://youtube.com/thecodingtrain/join πŸ›’ Store: https://standard.tv/codingtrain πŸ–‹οΈ Twitter: https://twitter.com/thecodingtrain πŸ“Έ Instagram: https://www.instagram.com/the.coding.train/

πŸŽ₯ Coding Challenges: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH πŸŽ₯ Intro to Programming: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA

πŸ”— p5.js: https://p5js.org πŸ”— p5.js Web Editor: https://editor.p5js.org/ πŸ”— Processing: https://processing.org

πŸ“„ Code of Conduct: https://github.com/CodingTrain/Code-of-Conduct

This description was auto-generated. If…

Back to The Coding Train Β· Report a problem