Skip to content

Commit e54d4f0

Browse files
committed
for fixed load local library
1 parent 2e19e0c commit e54d4f0

File tree

26 files changed

+680
-241
lines changed

26 files changed

+680
-241
lines changed

contributed/bezier_playground.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env jruby
22
require 'propane'
3-
require_relative 'library/curve/curve'
43

54
X1, Y1, X2, Y2 = 50.0, 50.0, 250.0, 250.0
65
REDDISH = [250, 100, 100]
@@ -10,9 +9,8 @@
109
# Arrows toggle between curves, delete removes them.
1110
# You can print out the parametric equations for t = 0..1
1211
class BezierPlayground < Propane::App
12+
load_libraries :control_panel, :curve
1313
include Olap
14-
load_library :control_panel
15-
1614
attr_accessor :curves, :c1x, :c1y, :c2x, :c2y
1715
attr_reader :panel, :hide
1816

contributed/fire.rb

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
require 'propane'
2+
3+
# After original by Alex Young https://github.com/alexyoung/fire-p5r
4+
5+
# Algorithm:
6+
# 1. Create an indexed palette of red, orange and yellows
7+
# 2. Loop:
8+
# 3. Draw a random set of colours from the palette at the bottom of the screen
9+
# 4. Loop through each pixel and average the colour index value around it
10+
# 5. Reduce the average by a fire intensity factor
11+
12+
# jruby fire.rb
13+
class Fire < Propane::App
14+
load_library :palette
15+
16+
def settings
17+
size 320, 240
18+
end
19+
20+
def setup
21+
sketch_title 'Fire'
22+
frame_rate 30
23+
@palette = Palette.create_palette
24+
@fire = []
25+
@scale = 8
26+
@width = width / @scale
27+
@height = height / @scale
28+
@intensity = 2
29+
end
30+
31+
def draw
32+
background 0
33+
update_fire
34+
end
35+
36+
def update_fire
37+
random_line @height - 1
38+
(0..@height - 2).each do |y|
39+
(0..@width).each do |x|
40+
# Wrap
41+
left = x.zero? ? fire_data(@width - 1, y) : fire_data(x - 1, y)
42+
right = (x == @width - 1) ? fire_data(0, y) : fire_data(x + 1, y)
43+
below = fire_data(x, y + 1)
44+
# Get the average pixel value
45+
average = (left.to_i + right.to_i + (below.to_i * 2)) / 4
46+
# Fade the flames
47+
average -= @intensity if average > @intensity
48+
set_fire_data x, y, average
49+
fill @palette[average]
50+
stroke @palette[average]
51+
rect x * @scale, (y + 1) * @scale, @scale, @scale
52+
end
53+
end
54+
end
55+
56+
def fire_data(x, y)
57+
@fire[offset(x, y)]
58+
end
59+
60+
def set_fire_data(x, y, value)
61+
@fire[offset(x, y)] = value.to_i
62+
end
63+
64+
def random_offset
65+
rand(0..@palette.size)
66+
end
67+
68+
def random_line(y)
69+
(0...@width).each do |x|
70+
@fire[offset(x, y)] = random_offset
71+
end
72+
end
73+
74+
def offset(x, y)
75+
(y * @width) + x
76+
end
77+
end
78+
79+
Fire.new
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class Palette
2+
include Propane::Proxy # needed to access 'color' and 'map1d'
3+
attr_reader :palette
4+
5+
def initialize
6+
@palette = make_palette
7+
end
8+
9+
def make_palette
10+
(0..256).map do |i|
11+
# Create the bands of colour for the palette (256 is the maximum colour))
12+
case i
13+
when 0..64 # Range of reds
14+
color(*[map1d(i, 0..64, 1..255), 0, 0])
15+
when 64..128 # Range of orange
16+
color(*[255, map1d(i, 64..128, 1..255), 0])
17+
when 128..172 # range of yellow
18+
color(*[255, 255, map1d(i, 128..172, 1..255)])
19+
else
20+
color(*[180, 0, 0])
21+
end
22+
end
23+
end
24+
25+
def self.create_palette
26+
Palette.new.palette
27+
end
28+
end

contributed/library/particles/lib/attractor.rb

Lines changed: 0 additions & 40 deletions
This file was deleted.

contributed/library/particles/lib/particle.rb

Lines changed: 0 additions & 64 deletions
This file was deleted.

contributed/library/particles/particles.rb

Lines changed: 0 additions & 3 deletions
This file was deleted.

contributed/library/rain_drops/rain_drops.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def fill_up(weight)
3131

3232
# Encapsulates drop behaviour, and include Proxy to access PApplet methods
3333
class Drop
34-
include Processing::Proxy
34+
include Propane::Proxy
3535
attr_reader :weight, :x, :y
3636

3737
def initialize(x, y, weight = nil)

contributed/raining.rb

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
#!/usr/bin/env jruby -v -W2
22
require 'propane'
3-
require_relative 'lib/rain_drops'
4-
3+
# raining after Rain1 by Thomas R. 'TomK32' Koll
4+
#
5+
# draws raindrops as bezier shapes and moves them downwards
6+
#
7+
# available key commands:
8+
# + make raindrops heavier/bigger
9+
# - make raindrops smaller
10+
# a more raindrops
11+
# s less raindrops
12+
# <SPACE>
13+
#
14+
# License: Same as processing
15+
#
516
class Raining < Propane::App
6-
# raining after Rain1 by Thomas R. 'TomK32' Koll
7-
#
8-
# draws raindrops as bezier shapes and moves them downwards
9-
#
10-
# available key commands:
11-
# + make raindrops heavier/bigger
12-
# - make raindrops smaller
13-
# a more raindrops
14-
# s less raindrops
15-
# <SPACE>
16-
#
17-
# License: Same as processing
18-
#
19-
17+
load_library :rain_drops
2018
attr_reader :drops, :weight, :drops_size, :paused
21-
22-
def setup
19+
20+
def settings
2321
size 640, 480
2422
end
2523

external_library/gem/pbox2d/lib/particle.rb

Lines changed: 0 additions & 77 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)