ScratchData LogoScratchData
Back to kriblo_test's profile

Cohen–Sutherland Algorithm for line clipping

KRkriblo_test•Created September 21, 2021
Cohen–Sutherland Algorithm for line clipping
20
12
112 views
View on Scratch

Instructions

Arrow keys to pan the map. Slider to zoom. "Lines drawn" shows how many lines are drawn. There are a total of 6 lines in this example. If you scroll or zoom in such a way that lines completely disappear off screen, they will not be drawn. Lines are clipped to only be drawn to the "screen" edge. This makes it simple to have long lines in your map. For my project The Village (see below) I came up with my own way to clip the streets to only draw what was visible on the screen. I recently shared a simplified version of that to illustrate (see below). When I shared that example @RobFarley74 pointed out that someone else had pondered this before me ;) @RobFarley74 suggested the Cohen–Sutherland Algorithm for line clipping. Thus, I have googled, and implemented said algorithm. Thanks @RobFarley74, this was much easier and more versatile than my solution! All Scratch code by me (@kriblo), looking at this example: https://www.geeksforgeeks.org/line-clipping-set-1-cohen-sutherland-algorithm/ The Village: https://scratch.mit.edu/projects/417540041/ Previously shared example: Simple street map using the Pen: https://scratch.mit.edu/projects/572494948/

Project Details

Project ID573209280
CreatedSeptember 21, 2021
Last ModifiedOctober 6, 2021
SharedSeptember 22, 2021
Visibilityvisible
CommentsAllowed