Skip to content

Cut bread and see how good you are at cutting even slices with this website

Notifications You must be signed in to change notification settings

StoneT2000/Cut-Bread

Repository files navigation

Cut Bread

That's literally it, see how good you are at cutting bread with a friendly passive-aggresive chef cheering you on

Online demo of this web app at https://stonet2000.github.io/Cut-Bread/

As featured in a popular tiktok:

As featured in random news:

Technical

Uses HTML, Javascript, CSS, and p5.js library

How It Works

Finding the area of a bread cut is done by calculating the number of pixels that are colored and not white/transparent. All colored pixels are assumed to be a part of the bread.

Figuring out which bread slice the area is a part of is done by a function that assigns whether a pixel is on the 'left' or 'right' side of each slice (theres no real left or right, but more of a assignment of a relative direction). Then, the area for which a pixel corresponds to depends on its unique sequence of 'left' and 'right' assignments for each slice. Pixels with the same sequence of assignments, meaning they are on the same side of all slices, then must be part of the same bread slice.

Displaying the slices is done by drawing the slices as white lines onto a seperate canvas element. Then by changing the globalCompositeOperation of the canvas to source-atop, and then drawing the background behind the bread piece onto the canvas, the slices are displayed.

About

Cut bread and see how good you are at cutting even slices with this website

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published