Skip to content

Commit f3b3817

Browse files
committed
Processing Geometry Suite
1 parent 5fc8d84 commit f3b3817

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Processing Geometry Suite
2+
---
3+
Processing Geometry Suite is a software project that provides easy access to 2D geometric algorithms in the form of a Processing library. Written by Michael Carleton aka Micycle.
4+
5+
See [repository](https://github.com/micycle1/PGS/tree/master).
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
require_relative './vector_list'
2+
load_library :pgs
3+
java_import 'micycle.pgs.PGS_Contour'
4+
5+
attr_reader :polygon, :heights, :max, :min
6+
MAX = -1
7+
MIN = 9999
8+
9+
def setup
10+
sketch_title 'Contour Map'
11+
@max = MAX
12+
@min = MIN
13+
end
14+
15+
def draw
16+
background(0, 0, 40)
17+
populate_height_map
18+
isolines = PGS_Contour.isolines(heights.array_list, 0.08, min, max)
19+
isolines.to_hash.each do |isoline, value|
20+
isoline.set_stroke(
21+
color(
22+
map1d(value, min..max, 50..255),
23+
map1d(isoline.get_vertex(0).x, 0..width, 50..255),
24+
map1d(isoline.get_vertex(0).y, 0..height, 50..255)
25+
)
26+
)
27+
shape(isoline)
28+
end
29+
end
30+
31+
def populate_height_map
32+
@heights = VectorList.new
33+
34+
res = 16
35+
anim_speed = 0.005
36+
37+
grid(width + res, height + res, res, res) do |x, y|
38+
z = norm(noise(x*0.01 + frame_count*anim_speed, y*0.01 + frame_count*anim_speed), -1.0, 1.0)
39+
h = Vec3D.new(x, y, 0)
40+
z += h.dist(Vec3D.new(mouse_x, mouse_y, 0))*0.005
41+
h.z = z
42+
heights << h
43+
@max = [max, z].max
44+
@min = [min, z].min
45+
end
46+
end
47+
48+
def settings
49+
size(800, 800)
50+
smooth
51+
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
java_import 'java.util.ArrayList'
2+
java_import 'processing.core.PVector'
3+
4+
class VectorList
5+
attr_reader :array_list
6+
def initialize
7+
@array_list = ArrayList.new
8+
end
9+
10+
def <<(val)
11+
array_list.add(PVector.new(val.x, val.y, val.z))
12+
end
13+
end

0 commit comments

Comments
 (0)