Created
August 7, 2019 16:00
-
-
Save jamesmichiemo/9491b0dfb09a1b1bebea52be73b4e9b9 to your computer and use it in GitHub Desktop.
processing + propane sketch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env jruby | |
| # frozen_string_literal: false | |
| require 'propane' | |
| # smooth lines with easing | |
| # propane graffiti by 8mana | |
| # based on code by Casey Reas and Ben Fry | |
| class SmoothLines < Propane::App | |
| def settings | |
| size 480, 120 | |
| end | |
| def setup | |
| sketch_title 'smooth lines with easing' | |
| $x = 0 | |
| $y = 0 | |
| $px = 0 | |
| $py = 0 | |
| $easing = 0.05 | |
| stroke 0, 102 | |
| end | |
| def draw | |
| targetX = mouseX | |
| $x += (targetX - $x) * $easing | |
| targetY = mouseY | |
| $y += (targetY - $y) * $easing | |
| weight = dist $x, $y, $px, $py | |
| strokeWeight weight | |
| line $x, $y, $px, $py | |
| $py = $y | |
| $px = $x | |
| end | |
| end | |
| SmoothLines.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment