Skip to content

Gafgarian/Cut-Half

 
 

Repository files navigation

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 images in half and see how good you are at cutting even slices with this website

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 67.8%
  • CSS 23.2%
  • HTML 9.0%