Skip to content

Commit

Permalink
remove FX2D examples
Browse files Browse the repository at this point in the history
  • Loading branch information
monkstone committed Feb 16, 2019
1 parent 97799c7 commit 2a98d1f
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 13 deletions.
89 changes: 89 additions & 0 deletions contributed/recursive_pentagon.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env jruby
require 'propane'# After an openprocessing sketch by C.Andrews
class RecursivePentagons < Propane::App
attr_reader :strut_factor, :renderer

def setup
sketch_title 'Recursive Pentagons'
@strut_factor = 0.2
@renderer = AppRender.new self # so we can send Vec2D :to_vertex
background 0
end

def draw
translate(width / 2, height / 2)
angle = TWO_PI / 5
radius = width * 0.7
points = (0...5).map do |i|
x = radius * cos(angle * i)
y = radius * sin(angle * i)
Vec2D.new(x, y)
end
fractal = PentagonFractal.new(points, 5)
fractal.draw
end

def settings
size(800, 800)
end
end

RecursivePentagons.new

# Here we include Processing::Proxy to mimic vanilla processing inner class
# access.
class PentagonFractal
include Propane::Proxy
attr_reader :points ,:branches, :level, :midpoints, :innerpoints
COLOURS = %w[#ff0000 #00ff00 #00ffff #0000ff #0000ff #ffffff]

def initialize(points, levels)
@points = points
@level = levels
return if level.zero? # so called guard clause in ruby simplifies code

@midpoints = (0...5).map do |i| # build an array of midpoints
midpoint(points[i], points[(i + 1) % 5])
end
@innerpoints = (0...5).map do |i| # build an array of inner points
opposite = points[(i + 3) % 5]
x = midpoints[i].x + (opposite.x - midpoints[i].x) * strut_factor
y = midpoints[i].y + (opposite.y - midpoints[i].y) * strut_factor
Vec2D.new(x, y)
end
# Create the PentagonFractal objects representing the six inner
# pentagons
# the shape is very regular, so we can build the ring of five
@branches = (0...5).map do |i|
p = [
midpoints[i],
innerpoints[i],
innerpoints[(i + 1) % 5],
midpoints[(i + 1) % 5],
points[(i + 1) % 5]
]
PentagonFractal.new(p, level - 1)
end
# add the final innermost pentagon
branches << PentagonFractal.new(innerpoints, level - 1)
end
# This is a simple helper function that takes in two points (as Vec2D) and
# returns the midpoint between them as Vec2D.
def midpoint(point1, point2)
(point2 + point1) * 0.5
end

def draw
stroke 255
no_fill
begin_shape
stroke_weight 0.5 + 0.75 * level
stroke color(COLOURS[level]), 100
points.each do |point|
point.to_vertex(renderer)
end
end_shape CLOSE
return if level.zero?
branches.each(&:draw)
end
end
2 changes: 1 addition & 1 deletion external_library/java/handy/preset_style_demo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def settings
# Should work with all Processing 3 renderers.
# size(1200, 800, P2D)
# size(1200, 800, P3D)
# size(1200, 800, FX2D)
# size(1200, 800)
pixelDensity(displayDensity) # Use platform's maximum display density.
end

Expand Down
2 changes: 1 addition & 1 deletion processing_app/basics/arrays/array_objects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def draw
end

def settings
size 640, 360, FX2D
size 640, 360
end

module Runnable
Expand Down
2 changes: 1 addition & 1 deletion processing_app/basics/arrays/custom_array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def draw
end

def settings
size 640, 360, FX2D
size 640, 360
end

# The Particle object
Expand Down
2 changes: 1 addition & 1 deletion processing_app/basics/color/blend_color.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def draw
end

def settings
size 100, 100, FX2D
size 100, 100
end
end

Expand Down
2 changes: 1 addition & 1 deletion processing_app/basics/color/color_wheel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def mouse_pressed
end

def settings
size 640, 360, FX2D
size 640, 360
end
end

Expand Down
2 changes: 1 addition & 1 deletion processing_app/basics/color/saturation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def draw
end

def settings
size 640, 360, FX2D
size 640, 360
end
end

Expand Down
2 changes: 1 addition & 1 deletion processing_app/demos/performance/text_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def draw
end

def settings
size(800, 600, FX2D)
size(800, 600)
end
end

Expand Down
2 changes: 1 addition & 1 deletion processing_app/demos/tests/no_background_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def draw
end

def settings
size(400, 400, FX2D)
size(400, 400)
end
end

Expand Down
2 changes: 1 addition & 1 deletion processing_app/demos/tests/redraw_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def key_pressed
end

def settings
size(400, 400, FX2D)
size(400, 400)
end
end

Expand Down
2 changes: 1 addition & 1 deletion processing_app/demos/tests/resize_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def draw
end

def settings
size(400, 400, FX2D)
size(400, 400)
end
end

Expand Down
2 changes: 1 addition & 1 deletion processing_app/topics/advanced_data/load_save_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def draw
end

def settings
size 640, 360, FX2D
size 640, 360
end

def mouse_pressed
Expand Down
2 changes: 1 addition & 1 deletion processing_app/topics/gui/rollover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def over_circle?(x, y, diameter)
end

def settings
size 640, 360, FX2D
size 640, 360
smooth(4)
end
end
Expand Down
2 changes: 1 addition & 1 deletion processing_app/topics/lsystems/cstest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def draw
end

def settings
size 125, 250, FX2D
size 125, 250
end
end

Expand Down

0 comments on commit 2a98d1f

Please sign in to comment.