Skip to content

Commit

Permalink
Finish square limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ju Liu committed Mar 9, 2019
1 parent 9b6cda4 commit 5746e58
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 15 deletions.
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use Mix.Config
# Configure the main viewport for the Scenic application
config :scenic_escher, :viewport, %{
name: :main_viewport,
size: {700, 600},
size: {700, 650},
default_scene: {ScenicEscher.Scene.Home, nil},
drivers: [
%{
Expand Down
2 changes: 1 addition & 1 deletion lib/fitting.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Fitting do

def get_stroke_width(%Box{b: b, c: c}) do
ratio = max(Vector.length(b), Vector.length(c)) / 100.0
max(ratio, 1.0)
max(ratio, 0.5)
end

def create_picture(shapes, options \\ []) do
Expand Down
69 changes: 69 additions & 0 deletions lib/picture.ex
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,73 @@ defmodule Picture do
]).(box)
end
end

def nonet(p1, p2, p3, p4, p5, p6, p7, p8, p9) do
above_ratio(
1,
2,
beside_ratio(1, 2, p1, beside(p2, p3)),
above(
beside_ratio(1, 2, p4, beside(p5, p6)),
beside_ratio(1, 2, p7, beside(p8, p9))
)
)
end

def side(0, _fish), do: fn _ -> [] end

def side(n, fish) when n > 0 do
fn box ->
quartet(
side(n - 1, fish),
side(n - 1, fish),
turn(ttile(fish)),
ttile(fish)
).(box)
end
end

def corner(0, _fish), do: fn _ -> [] end

def corner(n, fish) when n > 0 do
fn box ->
quartet(
corner(n - 1, fish),
side(n - 1, fish),
side(n - 1, fish) |> turn,
utile(fish)
).(box)
end
end

def square_limit(0, _fish), do: fn _ -> [] end

def square_limit(n, fish) when n > 0 do
fn box ->
corner = corner(n - 1, fish)
side = side(n - 1, fish)

nw = corner
nc = side
ne = corner |> turn |> turn |> turn
mw = side |> turn
mc = utile(fish)
me = side |> turn |> turn |> turn
sw = corner |> turn
sc = side |> turn |> turn
se = corner |> turn |> turn

nonet(
nw,
nc,
ne,
mw,
mc,
me,
sw,
sc,
se
).(box)
end
end
end
16 changes: 3 additions & 13 deletions lib/scenes/home.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,10 @@ defmodule ScenicEscher.Scene.Home do
# debug: true
)

atom =
Picture.quartet(
Picture.ttile(fish),
Picture.ttile(fish) |> Picture.turn(),
Picture.ttile(fish) |> Picture.turn() |> Picture.turn() |> Picture.turn(),
Picture.ttile(fish) |> Picture.turn() |> Picture.turn()
)

picture =
Picture.quartet(
atom,
atom,
atom,
atom
Picture.square_limit(
5,
fish
)

paths =
Expand Down

0 comments on commit 5746e58

Please sign in to comment.