Skip to content

Commit be8223e

Browse files
committed
modified: contributed/library/curve/curve.rb
deleted: processing_app/library/vecmath/vec2d/README.txt modified: processing_app/library/vecmath/vec2d/wiggle_pshape.rb deleted: processing_app/topics/advanced_data/README modified: processing_app/topics/advanced_data/counting_words.rb modified: processing_app/topics/advanced_data/library/word/word.rb modified: processing_app/topics/advanced_data/word_frequency.rb modified: processing_app/topics/advanced_shader/blue_marble.rb
1 parent d72f1b3 commit be8223e

File tree

8 files changed

+17
-70
lines changed

8 files changed

+17
-70
lines changed

contributed/library/curve/curve.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
1+
# frozen_string_literal: true
22
module Olap
33
def self.overlaps(x, y, point_x, point_y)
44
Math.hypot(x - point_x, y - point_y) < RADIUS
55
end
66
end
77

8-
98
class Curve
109
include Propane::Proxy
1110
include Olap

processing_app/library/vecmath/vec2d/README.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
require 'propane'
2-
java_import 'monkstone.vecmath.ShapeRender'
3-
#
42
# WigglePShape. Demonstrates initialization and use of ShapeRender,
5-
# that allows us to send Vec2D to PShape vertex
3+
# that allows us to send Vec2D to PShape vertex see wiggler.rb
64
#
75
# How to move the individual vertices of a PShape
86
#
97
class Wiggling < Propane::App
8+
load_library :wiggler
109
attr_reader :wiggler
1110

1211
def setup
@@ -23,54 +22,5 @@ def settings
2322
size(640, 360, P2D)
2423
end
2524
end
26-
Wiggling.new
27-
28-
# An object that wraps the PShape
29-
class Wiggler
30-
include Propane::Proxy, Math
31-
attr_reader :original, :x, :y, :s, :yoff, :xoff
32-
33-
def initialize width, height
34-
@x = width/2
35-
@y = height/2
36-
@yoff = 0
37-
38-
# The "original" locations of the vertices make up a circle
39-
40-
@original = (0...16).map{ |a| Vec2D.from_angle(PI * a / 8) * 100 }
41-
42-
# Now make the PShape with those vertices
43-
@s = create_shape
44-
renderer = ShapeRender.new(s) # Prefix with Sketch classname
45-
s.begin_shape
46-
s.fill(127)
47-
s.stroke(0)
48-
s.stroke_weight(2)
49-
original.map{ |v| v.to_vertex(renderer) }
50-
s.end_shape(CLOSE)
51-
end
52-
53-
def wiggle
54-
@xoff = 0
55-
# Apply an offset to each vertex
56-
rad = ->(pos){ (Vec2D.from_angle(2 * PI * noise(xoff, yoff)) * 4) + pos }
57-
58-
original.each_with_index do |pos, i|
59-
# Calculate a new vertex location based on noise around "original" location
60-
r = rad.call(pos)
61-
# Set the location of each vertex to the new one
62-
s.set_vertex(i, r.x, r.y)
63-
# increment perlin noise x value
64-
@xoff += 0.5
65-
end
66-
# Increment perlin noise y value
67-
@yoff += 0.02
68-
end
6925

70-
def display
71-
push_matrix
72-
translate(x, y)
73-
shape(s)
74-
pop_matrix
75-
end
76-
end
26+
Wiggling.new

processing_app/topics/advanced_data/README

Lines changed: 0 additions & 1 deletion
This file was deleted.

processing_app/topics/advanced_data/counting_words.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ def setup
3838
def draw
3939
background 51
4040
fill 255
41-
s = (tokens[counter] == 'I') ? tokens[counter] : tokens[counter].downcase
41+
s = tokens[counter] == 'I' ? tokens[counter] : tokens[counter].downcase
4242
@counter = (counter + 1) % tokens.length
4343
if concordance.key? s
4444
# Get the word object and increase the count
4545
# We access objects from a Hash via its key, the String
46-
concordance[s].increment # increment word count
46+
concordance[s].increment # increment word count
4747
else
4848
# Otherwise make a new Word instance and add it to
4949
# the Hash using the word String as the key
@@ -55,7 +55,7 @@ def draw
5555
# Look at each word
5656
concordance.values.each do |w|
5757
# Only display words that appear 3 times
58-
if w.count > 3 # access word count
58+
if w.count > 3 # access word count
5959
# The size is the count
6060
fsize = constrain(w.count, 0, 100)
6161
text_size(fsize)
@@ -65,10 +65,10 @@ def draw
6565
end
6666
# If x gets to the end, move y
6767
# If y == 0 we are done
68-
no_loop if y == 0
68+
no_loop if y.zero?
6969
next unless x >= width
7070
x = 0
71-
y = (y < 0) ? 0 : y - 100
71+
y = y < 0 ? 0 : y - 100
7272
end
7373
end
7474

processing_app/topics/advanced_data/library/word/word.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
#######
23
# word.rb
34
# the word class stores data about words (text, source, frequency)

processing_app/topics/advanced_data/word_frequency.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
class WordFrequency < Propane::App
2020
load_library 'word'
2121

22-
DRACULA = 'data/dracula.txt'
23-
FRANKENSTEIN = 'data/frankenstein.txt'
22+
DRACULA = 'data/dracula.txt'.freeze
23+
FRANKENSTEIN = 'data/frankenstein.txt'.freeze
2424
DRAC = Regexp.new(DRACULA)
2525
FRANK = Regexp.new(FRANKENSTEIN)
2626

processing_app/topics/advanced_shader/blue_marble.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require 'propane'
33
# Earth model with bump mapping, specular texture and dynamic cloud layer.
44
# Adapted from the THREE.js tutorial to processing by Andres Colubri,
5-
# translated to JRubyArt by Martin Prout:
5+
# translated to propane by Martin Prout:
66
# http://learningthreejs.com/blog/2013/09/16/how-to-make-the-earth-in-webgl/
77
class BlueMarble < Propane::App
88
attr_reader :earth, :clouds, :earth_shader, :cloud_shader, :earth_rotation
@@ -30,11 +30,11 @@ def setup
3030
cloud_shader.set('texMap', textures[:cloud_tex])
3131
cloud_shader.set('alphaMap', textures[:alpha_tex])
3232
@earth = create_shape(SPHERE, 200)
33-
earth.setStroke(false)
34-
earth.setSpecular(color(125))
35-
earth.setShininess(10)
33+
earth.set_stroke(false)
34+
earth.set_specular(color(125))
35+
earth.set_shininess(10)
3636
@clouds = create_shape(SPHERE, 201)
37-
clouds.setStroke(false)
37+
clouds.set_stroke(false)
3838
end
3939

4040
def draw

0 commit comments

Comments
 (0)