Skip to content

Commit 100f35e

Browse files
author
monkstone
committed
downgrade sketch to work with ruby-processing
1 parent 5d23d62 commit 100f35e

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

samples/processing_app/basics/modules/euler_ball.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ class EulerBall
1414
include Processing::Proxy, Runner
1515
attr_reader :pos, :spd, :radius, :bounds_x, :bounds_y
1616

17-
def initialize(position:, speed:, radius:)
17+
def initialize(position, speed, radius)
1818
@pos = position
1919
@spd = speed
2020
@radius = radius
21-
@bounds_x = Bounds.new(lower: radius, upper: width - radius)
22-
@bounds_y = Bounds.new(lower: radius, upper: height - radius)
21+
@bounds_x = Bounds.new(radius, $app.width - radius)
22+
@bounds_y = Bounds.new(radius, $app.height - radius)
2323
end
2424

2525
def move
@@ -42,7 +42,7 @@ def bounds_collision
4242
class Bounds
4343
include Processing::MathTool
4444
attr_reader :low, :high, :inside
45-
def initialize(lower:, upper:)
45+
def initialize(lower, upper)
4646
@low = lower
4747
@high = upper
4848
@inside = true

samples/processing_app/basics/modules/euler_integration.rb

+7-10
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@
22
# Euler Integration (v01)
33
# pos += spd
44
# sketch after Ira Greenwood
5-
# Features first class keyword arguments, and use of modules
5+
# Features use of modules
66
#
7+
load_library :vecmath
78
require_relative 'euler_ball'
89

910
attr_reader :ball
1011

1112
def setup
12-
sketch_title 'Euler Integration'
13+
size(400, 400)
14+
smooth 4
1315
@ball = EulerBall.new(
14-
position: Vec2D.new(width / 2, height / 2),
16+
Vec2D.new(width / 2, height / 2),
1517
# create a random direction vector, scaled by 3
16-
speed: Vec2D.random * 3,
17-
radius: 10
18+
Vec2D.random * 3,
19+
10
1820
)
1921
end
2022

@@ -25,8 +27,3 @@ def draw
2527
fill(0)
2628
ball.run
2729
end
28-
29-
def settings
30-
size(400, 400)
31-
smooth 4
32-
end

0 commit comments

Comments
 (0)