Skip to content

Commit dc733d3

Browse files
committed
fix PVector version of wiggle
1 parent 552c882 commit dc733d3

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

processing_app/topics/create_shapes/library/wiggler/wiggler.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ class Wiggler
66

77
def initialize width, height
88
@x = width/2
9-
@y = height/2
9+
@y = height/2
1010
@yoff = 0
1111
# The 'original' locations of the vertices make up a circle
1212
@original = []
13-
(0 ... TAU).step(0.2) do |a|
14-
v = PVector.from_angle(a)
13+
(0...TAU).step(0.2) do |a|
14+
v = Java::ProcessingCore::PVector.from_angle(a)
1515
v.mult(100)
1616
original << v
1717
end
18-
18+
1919
# Now make the PShape with those vertices
2020
@s = create_shape
2121
s.begin_shape
@@ -31,11 +31,11 @@ def initialize width, height
3131
def wiggle
3232
@xoff = 0
3333
# Apply an offset to each vertex
34-
(0 ... s.get_vertex_count).each do |i|
34+
(0...s.get_vertex_count).each do |i|
3535
# Calculate a new vertex location based on noise around 'original' location
3636
pos = original[i]
3737
a = TAU*noise(xoff,yoff)
38-
r = PVector.from_angle(a)
38+
r = Java::ProcessingCore::PVector.from_angle(a)
3939
r.mult(4)
4040
r.add(pos)
4141
# Set the location of each vertex to the new one
@@ -54,4 +54,3 @@ def display
5454
pop_matrix
5555
end
5656
end
57-
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#
2-
# WigglePShape.
2+
# WigglePShape.
33
# wiggler library uses PVector, see vecmath library
44
# examples to see alternative using Vec2D
55
# How to move the individual vertices of a PShape
66
#
77

8-
load_library 'wiggler'
8+
load_library :wiggler
99

1010
attr_reader :wiggler
1111

1212
def setup
13-
sketch_title 'Wiggle Pshape'
13+
sketch_title 'Wiggle PShape'
1414
@wiggler = Wiggler.new width, height
1515
end
1616

@@ -20,9 +20,6 @@ def draw
2020
wiggler.wiggle
2121
end
2222

23-
24-
2523
def settings
2624
size(640, 360, P2D)
2725
end
28-

0 commit comments

Comments
 (0)