Skip to content

Commit 0ebef24

Browse files
committed
remove some fix some update some
1 parent 53aff9c commit 0ebef24

File tree

8 files changed

+129
-259
lines changed

8 files changed

+129
-259
lines changed

demo/arc_tesselation.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def setup
2121
sketch_title 'Arc Tesselation'
2222
# create a java primitive array of signed int
2323
# @cols = web_to_color_array(PALETTE)
24-
@group = ColorGroup.web_to_color_array(PALETTE)
24+
@group = ColorGroup.from_web_array(PALETTE)
2525
@cols = group.colors
2626
stroke_weight 1.5
2727
stroke_cap SQUARE

demo/blend_mode.rb

+9-6
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ class BlendModeSketch < Processing::App
88
java_import 'com.jogamp.opengl.GL3'
99
java_import 'com.jogamp.opengl.GLContext'
1010

11+
HALF = 300
12+
1113
attr_reader :gl
1214
def setup
1315
sketch_title 'Blend Mode Difference P2D'
1416
noStroke
1517
fill(255)
1618
# DIFFERENCE is not supported in P2D / P3D
1719
# blendMode(DIFFERENCE)
18-
@gl = GLContext.getCurrentGL.getGL2
20+
# @gl = GLContext.getCurrentGL.getGL3 # x86_64
21+
@gl = GLContext.getCurrentGL.getGL2 # RaspberryPi aarch64
1922
end
2023

2124
def draw
@@ -25,15 +28,15 @@ def draw
2528
gl.glBlendFunc(GL3::GL_ONE_MINUS_DST_COLOR, GL3::GL_ZERO)
2629
20.times do |i|
2730
sz = 50 + (i % 4) * 50
28-
x = width * noise(i * 0.527 + millis * 0.0003)
29-
y = height * noise(i * 0.729 + millis * 0.0001)
30-
circle(x, y, sz)
31+
x = HALF * noise(i * 0.527 + millis * 0.0003)
32+
y = HALF * noise(i * 0.729 + millis * 0.0001)
33+
circle(x + HALF, y + HALF, sz)
3134
end
3235
end
3336

3437
def settings
35-
size 600, 600, P3D
36-
smooth 8
38+
size(2 * HALF, 2 * HALF, P2D)
39+
smooth(8)
3740
end
3841
end
3942

demo/elegant_ball.rb

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
java_import 'monkstone.vecmath.GfxRender'
88

99
class ElegantBall < Processing::App
10-
1110
def settings
1211
size(750, 750, P3D)
1312
end

demo/reflection.rb

-28
This file was deleted.

demo/ribbon_doodle.rb

+12-10
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
# Use Face Struct triangle 'mesh'.
77
Face = Struct.new(:a, :b, :c) # triangle mesh face
88

9-
# Monkey patch the Vec3D class to support rotations
10-
Vec3D.class_eval do # re-open the Vec3D class to add the rotate methods
11-
def rotate_y!(theta)
9+
Vec3D.class_eval do # re-open the Vec3D class to add rotation functionality
10+
def rotate_y(theta)
1211
co = Math.cos(theta)
1312
si = Math.sin(theta)
1413
xx = co * x - si * z
@@ -17,7 +16,7 @@ def rotate_y!(theta)
1716
self
1817
end
1918

20-
def rotate_x!(theta)
19+
def rotate_x(theta)
2120
co = Math.cos(theta)
2221
si = Math.sin(theta)
2322
zz = co * z - si * y
@@ -27,8 +26,12 @@ def rotate_x!(theta)
2726
end
2827
end
2928

30-
# After a toxiclibs "MeshDoodle" sketch by Karsten Schmidt
3129
class Doodle < Processing::App
30+
# After a toxiclibs "MeshDoodle" sketch by Karsten Schmidt
31+
# Adapted to use JRubyArt Vec2D and Vec3D classes by Martin Prout
32+
# Note: The extension of Vec3D class to support rotations, and the ruby Struct
33+
# Face for triangle 'mesh'. Also an example of AppRenderer for Vec3D => vertex
34+
3235
attr_reader :prev, :p, :q, :rotation, :faces, :pos, :weight
3336

3437
def settings
@@ -68,8 +71,8 @@ def draw
6871
def mouse_moved
6972
# get 3D rotated mouse position
7073
@pos = Vec3D.new(mouse_x - width / 2, mouse_y - height / 2, 0)
71-
pos.rotate_x!(rotation.x)
72-
pos.rotate_y!(rotation.y)
74+
pos.rotate_x(rotation.x)
75+
pos.rotate_y(rotation.y)
7376
# use distance to previous point as target stroke weight
7477
@weight += (sqrt(pos.dist(prev)) * 2 - weight) * 0.1
7578
# define offset points for the triangle strip
@@ -84,10 +87,9 @@ def mouse_moved
8487
@q = b
8588
end
8689

87-
# An example of GfxRenderer usage for Vec3D => vertex conversion
8890
def renderer
89-
@renderer ||= Processing::Render::GfxRender.new(self.g)
90-
end
91+
@renderer ||= GfxRender.new(self.g)
92+
end
9193
end
9294

9395
Doodle.new

library/vecmath/vec2d/aabb_test.rb

-107
This file was deleted.

0 commit comments

Comments
 (0)