Skip to content

Commit c5d8185

Browse files
committed
extract vanilla library info to yaml
1 parent ef574e3 commit c5d8185

File tree

6 files changed

+62
-35
lines changed

6 files changed

+62
-35
lines changed

contributed/arc_tesselation.rb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# use `c` key to toggle colored / greyscale
88
# use 's' to save
99
class ArcTesselation < Propane::App
10+
load_library :color_group
1011
attr_reader :cols, :coloured
1112

1213
PALETTE = %w[#152A3B #158ca7 #F5C03E #D63826 #0F4155 #7ec873 #4B3331].freeze
@@ -19,7 +20,7 @@ def setup
1920
background 0
2021
sketch_title 'Arc Tesselation'
2122
# create a java primitive array of signed int
22-
@cols = web_to_color_array(PALETTE)
23+
@cols = ColorGroup.from_web_array(PALETTE)
2324
stroke_weight 1.5
2425
stroke_cap SQUARE
2526
stroke(0, 200)
@@ -35,7 +36,7 @@ def sep_index(idx, length)
3536
end
3637

3738
def sep_color(idx, number)
38-
cols[sep_index(idx - 1, number + 1)]
39+
cols.colors[sep_index(idx - 1, number + 1)]
3940
end
4041

4142
def arc_pattern
@@ -63,7 +64,7 @@ def arc_pattern
6364
end
6465

6566
def mouse_pressed
66-
@cols = shuffle_array(cols) if coloured
67+
cols.shuffle!
6768
loop
6869
end
6970

@@ -75,13 +76,6 @@ def key_typed
7576
save(data_path('arc_pattern.png'))
7677
end
7778
end
78-
79-
# do a ruby shuffle! on a primitive java array
80-
def shuffle_array(arr)
81-
cols = arr.to_a
82-
cols.shuffle!
83-
cols.to_java(Java::int)
84-
end
8579
end
8680

8781
ArcTesselation.new

external_library/gem/ruby_wordcram/render_to_buffer.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ def draw_progress_bar(progress)
4444
rect(100, (height / 2) - 30, (width - 200), 60)
4545
# Fill in the portion that's done:
4646
fill(gray)
47-
rect(100, (height/2)-30, (width-200) * progress, 60)
47+
rect(100, (height / 2) - 30, (width - 200) * progress, 60)
4848
end
4949

50-
def draw_progress_text(progress)
51-
text(format('%d%', (progress * 100).round), width / 2, (height / 2) + 50)
50+
def draw_progress_text(progress = 0)
51+
text "#{(progress * 100).round}%", width / 2, (height / 2) + 50
5252
end
5353

5454
def settings

external_library/java/library_list.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# frozen_string_literal: true
2+
3+
require 'open-uri'
4+
require 'yaml'
5+
6+
my_list = []
7+
# Source of libary data
8+
VANILLA = 'http://download.processing.org/contribs'
9+
# Struct to store library data
10+
ALib = Struct.new(:name, :description, :url)
11+
lib = nil
12+
13+
def extract(line, name)
14+
line.sub(name, '').strip
15+
end
16+
17+
open(VANILLA) do |lib_list|
18+
loop do
19+
lin = lib_list.readline
20+
lib = ALib.new('dummy', 'dummy') if lin.start_with?('library')
21+
lib = nil if lin =~ /examples|mode|tool/
22+
lib.name = extract(lin, 'name=') if lib && lin.start_with?('name=')
23+
lib.url = extract(lin, 'download=') if lib && lin.start_with?('download=')
24+
lib.description = extract(lin, 'sentence=') if lib && lin.start_with?('sentence=')
25+
my_list << lib if lib && lin.start_with?('type=library') if lib
26+
27+
break if lib_list.eof?
28+
end
29+
end
30+
31+
File.write('libraries.yml', my_list.to_yaml)

processing_app/basics/color/colors_two.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ class CreatingColors < Propane::App
1111
def settings
1212
size 640, 360
1313
end
14-
14+
1515
def setup
1616
sketch_title 'Homage to Albers'
17-
# palette = web_to_color_array(['#CC6600', '#CC9900', '#993300'].to_java(:string))
18-
palette = web_to_color_array(['#CC6600', '#CC9900', '#993300'])
17+
palette = web_to_color_array(%w[#CC6600 #CC9900 #993300])
1918
# @redder = color 204, 102, 0
2019
# @yellower = color 204, 153, 0
2120
# @orangish = color 153, 51, 0

processing_app/library/dxf/simple_export.rb

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,51 @@
11
#!/usr/bin/env jruby -v -W2
22
# frozen_string_literal: true
3+
34
require 'propane'
5+
require 'arcball'
46
# DXF DXF Export
5-
# by Simon Greenwold.
6-
#
7+
# original by Simon Greenwold.
8+
# Translated to propane by Martin Prout
9+
# Rotate by dragging mouse, wheel to zoom.
710
# Press the 'R' key to export a DXF file.
811
class DXFExport < Propane::App
912
load_library :dxf
1013
attr_reader :recording
1114

1215
def setup
1316
sketch_title 'DXF Export'
14-
noStroke
15-
sphereDetail(12)
17+
Processing::ArcBall.init(self)
18+
no_stroke
19+
sphere_detail(15)
1620
@recording = false
1721
end
1822

1923
def draw
20-
begin_raw(DXF, data_path('output.dxf')) if recording # Start recording to the file
24+
# Start recording to the file
25+
begin_raw(DXF, data_path('output.dxf')) if recording
2126
lights
2227
background(0)
23-
translate(width / 3, height / 3, -200)
24-
rotate_z(map1d(mouse_y, (0..height), (0..PI)))
25-
rotateY(map1d(mouse_x, (0..width), (0..HALF_PI)))
26-
(-2..2).step do |y|
27-
(-2..2).step do |x|
28-
(-2..2).step do |z|
29-
push_matrix
30-
translate(120 * x, 120 * y, -120 * z)
31-
sphere(30)
32-
pop_matrix
33-
end
34-
end
28+
mesh_grid(400, 400, 400, 80, 80, 80) do |x, y, z|
29+
push_matrix
30+
translate(x - 200, y - 200, z - 200)
31+
sphere(25)
32+
pop_matrix
3533
end
3634
end_raw if recording
37-
@recording = false # Stop recording to the file
35+
# Stop recording to the file
36+
@recording = false
3837
end
3938

4039
def key_pressed
41-
return unless key == 'R' || key == 'r' # Press R to save the file
40+
# Press R to save the file
41+
return unless key == 'R' || key == 'r'
42+
4243
@recording = true
4344
end
4445

4546
def settings
4647
size(400, 400, P3D)
48+
smooth(16)
4749
end
4850
end
4951

processing_app/library/vecmath/vec3d/frame_of_reference.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env jruby -v -W2
22
# frozen_string_literal: true
3+
34
require 'propane'
45
require 'arcball'
56

0 commit comments

Comments
 (0)