require("pequod")
math.randomseed(os.clock() * 9999999999)
local margin = 8
local shape_size = 60
local shape_offset = 6
local number_of_lines = 5
local rows = 5
local columns = 5
local paper = Paper(
shape_size * columns + shape_offset * (number_of_lines - 1) + margin * 2,
shape_size * rows + shape_offset * (number_of_lines - 1) + margin * 2
)
local black_pen = Pen(paper, 2, 'black')
local function draw_shape (point)
return Path({
point:clone(),
point:clone():move(0, shape_size),
point:clone():move(shape_size / 2, shape_size),
point:clone():move(shape_size / 2, 0),
point:clone():move(shape_size, 0),
point:clone():move(shape_size, shape_size),
}):draw_with(black_pen)
end
local function draw_cell (point, flip, rotate)
for i = 0, number_of_lines - 1 do
local shape = draw_shape(
point:clone():move(i * shape_offset, i * shape_offset)
)
shape:scale(1, flip)
shape:rotate(rotate)
end
end
for c = 0, columns - 1 do
for r = 0, rows - 1 do
local flip = {-1, 1}
flip = flip[math.random(1, 2)]
local rotate = math.random(0, 1) * 90
draw_cell(
Point(margin + shape_size * c, margin + shape_size * r), flip, rotate
)
end
end
paper:save_svg('output/alex_makarovitsch.svg')