-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
153 additions
and
150 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
external_library/gem/toxiclibs/geometry/circle_resolution.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'toxiclibs' | ||
java_import 'toxi.geom.Circle' | ||
attr_reader :gfx | ||
|
||
def setup | ||
sketch_title 'Circle Resolution' | ||
@gfx = Gfx::ToxiclibsSupport.new(self) | ||
end | ||
|
||
def draw | ||
background(0) | ||
no_stroke | ||
fill(255) | ||
res = map1d(mouse_x, 0..width, 3..72) | ||
poly = Circle.new(TVec2D.new(width / 2, height / 2), 200).toPolygon2D(res) | ||
gfx.polygon2D(poly) | ||
fill(255, 0, 0) | ||
poly.each { |vertex| gfx.circle(vertex, 5) } | ||
text(res, 20, 20) | ||
end | ||
|
||
def settings | ||
size(600, 600) | ||
smooth 8 | ||
end |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
external_library/gem/toxiclibs/verlet_physics/soft_body/library/blanket.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require_relative 'blanket' | ||
require_relative 'connection' | ||
require_relative 'particle' |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# RULE 110 | ||
# 2 + 4 + 8 + 32 + 64 = 110 | ||
# using axiom in sense of an LSystem, starting condition | ||
# see https://en.wikipedia.org/wiki/Rule_110 | ||
attr_reader :row, :axiom, :black | ||
|
||
def setup | ||
sketch_title 'Wolfram CA Rule 110' | ||
@black = color(0) | ||
# one of most interesting starting points | ||
@axiom = [0, 1, 1, 1, 0, 1, 1, 0] | ||
initial | ||
end | ||
|
||
def draw | ||
reset if row > height | ||
display | ||
end | ||
|
||
def display | ||
(0..width).each_cons(3) do |triple| | ||
left, center, right = *triple | ||
a = get(left, row) | ||
b = get(center, row) | ||
c = get(right, row) | ||
idx = 0 | ||
idx += 1 if a == black | ||
idx += 2 if b == black | ||
idx += 4 if c == black | ||
set(center, row.succ, black) unless axiom[idx].zero? | ||
end | ||
@row += 1 | ||
end | ||
|
||
def settings | ||
size(400, 400) | ||
end | ||
|
||
def initial | ||
background(255) | ||
set(1, 0, black) | ||
@row = 0 | ||
end | ||
|
||
def reset | ||
# create some random starting conditions and re-start | ||
initial | ||
asum = 0 | ||
# filter out some of less interesting results | ||
while asum < 4 || asum > 5 | ||
@axiom = Array.new(8) { rand(0..1) } | ||
asum = axiom.inject(:+) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# RULE 30 | ||
# using axiom in sense of an LSystem, starting condition | ||
# see https://en.wikipedia.org/wiki/Rule_30 | ||
attr_reader :row, :axiom | ||
|
||
def setup | ||
sketch_title 'Wolfram CA Rule 30' | ||
# An interesting starting point | ||
@axiom = [0, 1, 0, 1, 1, 0, 1, 0] | ||
initial | ||
end | ||
|
||
def black | ||
color(0) | ||
end | ||
|
||
def white | ||
color(255) | ||
end | ||
|
||
def draw | ||
reset if row > height | ||
display | ||
end | ||
|
||
def display | ||
(0..width).each_cons(3) do |triple| | ||
left, center, right = *triple | ||
a = get(left, row) | ||
b = get(center, row) | ||
c = get(right, row) | ||
idx = 0 | ||
case a + b + c | ||
when 3 * white | ||
idx = 7 | ||
when 2 * black + white | ||
idx = (a == white)? 3 : (b == white)? 5 : 6 | ||
when 2 * white + black | ||
idx = (c == black)? 1 : (a == black)? 4 : 2 | ||
end | ||
set(center, row.succ, white) unless axiom[idx].zero? | ||
end | ||
@row += 1 | ||
end | ||
|
||
def settings | ||
size(400, 400) | ||
end | ||
|
||
def initial | ||
background(0) | ||
set(width / 2, 0, white) | ||
@row = 0 | ||
end | ||
|
||
def reset | ||
# create some random starting conditions and re-start | ||
initial | ||
@axiom = Array.new(8) {rand(0..1)} | ||
end |