Skip to content

Commit b4ecaae

Browse files
committed
bump
1 parent 6f02a48 commit b4ecaae

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# propane-examples
2-
Example Sketches for propane-2.6.0+ features replacement of `$app` with `Propane.app`, and additional hemesh examples.
2+
Example Sketches for propane-2.6.4+ features replacement of `$app` with `Propane.app`, and additional hemesh examples.
33
See also [Example-Sketches][examples] for JRubyArt (many of with only need to be class wrapped to run with propane).
44

55
WIP to complete translation from JRubyArt to propane using [this conversion tool][conversion], and by replacing `Processing::Proxy` with `Propane::Proxy`, and unnest some classes as required.

contributed/Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ end
2222

2323
def run_sample(sample_name)
2424
puts "Running #{sample_name}...quit to run next sample"
25-
open("|jruby #{sample_name}", 'r') do |io|
25+
open("|jruby --dev #{sample_name}", 'r') do |io|
2626
while l = io.gets
2727
puts(l.chop)
2828
end

contributed/chladni.rb

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env jruby
2+
# frozen_string_literal: true
3+
require 'propane'
4+
5+
# Chladni plate interference surfaces
6+
# —
7+
# Based on :
8+
# http://paulbourke.net/geometry/chladni/
9+
#
10+
# —
11+
# Developed on:
12+
# - Processing 2.1.1 on MacOSX (10.9.2)
13+
# Julien Gachadoat aka v3ga
14+
# www.v3ga.net
15+
# www.2roqs.com
16+
#
17+
# Translated and tested on:
18+
# - propane
19+
# Martin Prout
20+
21+
class Chladni <Propane::App
22+
23+
attr_reader :m, :n, :epsilon, :recompute
24+
25+
def settings
26+
size(500, 500, P2D)
27+
end
28+
29+
def setup
30+
sketch_title 'Chladni'
31+
@epsilon = 0.05
32+
@recompute = true
33+
@m = 10
34+
@n = 2
35+
end
36+
37+
def draw
38+
return unless recompute
39+
@recompute = false
40+
background(255)
41+
load_pixels
42+
grid(width, height) do |x, y|
43+
chladni = cos(n * PI * x / width) * cos(m * PI * y / width) - cos(m * PI * x / width) * cos(n * PI * y / width)
44+
pixels[x + y * width] = 0 if chladni.abs <= epsilon
45+
end
46+
update_pixels
47+
format_string = "m= %d n = %d \nepsilon= %0.3f"
48+
infos = format(format_string, m, n, epsilon)
49+
fill(255, 0, 0)
50+
text(infos, 4, 16)
51+
end
52+
53+
def key_pressed
54+
case key
55+
when '+'
56+
@epsilon += 0.01
57+
when '-'
58+
@epsilon -= 0.01
59+
when CODED
60+
case key_code
61+
when UP
62+
@m += 1
63+
when DOWN
64+
@m -= 1
65+
when LEFT
66+
@n -= 1
67+
when RIGHT
68+
@n += 1
69+
end
70+
end
71+
@recompute = true
72+
@m = constrain(m, 1, 20)
73+
@n = constrain(n, 1, 20)
74+
end
75+
end
76+
77+
Chladni.new

0 commit comments

Comments
 (0)