Skip to content

Commit 41a9c42

Browse files
committed
Fix stack overload
1 parent 6b1afcc commit 41a9c42

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

graphics_test.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,15 @@ def key_pressed
8888
@corner = @mesh.before(@corner)
8989
when 'o'
9090
@corner = @mesh.opposite(@corner)
91+
when 'q', 'Q'
92+
Processing.app.exit
93+
end
9194
end
92-
end
9395

9496
def mouse_pressed
9597
mouse_point = Point.new(mouse_x, mouse_y)
9698
@point = polygon.closest_point(mouse_point, 4)
97-
if key_pressed? and key == ?d and @point.nil?
99+
if key_pressed? and key == 'd' and @point.nil?
98100
closest = polygon.closest(mouse_point)
99101
index = polygon.vertices.index(closest)
100102
polygon.vertices.insert(index + 1, mouse_point)
@@ -132,7 +134,7 @@ def actions
132134
def show_help
133135
@line = 1
134136
fill(color(0, 0, 128))
135-
scribe('Project 5 (Bulge) by Brandon Whitehead')
137+
scribe('Press q or Q to quit')
136138
scribe('')
137139
scribe('To insert a point hold d and click in/on the polygon')
138140
scribe('To modify vertex count press < or >')
@@ -296,6 +298,7 @@ def draw_mesh
296298
maxn = normals.max * 1.2
297299
end
298300
@mesh.triangles.each do |triangle|
301+
java_signature 'int color(float, float, float)'
299302
fill(color(0, 25, 255 - 255 * triangle.normal.abs / maxn)) if @color
300303
begin_shape(POLYGON)
301304
triangle.each do |point|

library/geometry/lib/draw.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# draw module
22
module Draw
3-
include Processing::Proxy
3+
include_package 'processing.core'
44
def draw_point(point, thick = 2)
55
ellipse(point.x, point.y, thick, thick)
66
end
@@ -25,7 +25,7 @@ def draw_polygon(polygon, hash = {})
2525
polygon.each do |point|
2626
vertex(point.x, point.y)
2727
end
28-
hash.key?(:close) ? end_shape(hash[close]) : end_shape(CLOSE)
28+
hash.key?(:close) ? end_shape(hash[close]) : end_shape(PConstants::CLOSE)
2929
end
3030

3131
def draw_smooth_polygon(polygon, refine = 5, hash = {})

0 commit comments

Comments
 (0)