Created
August 2, 2022 18:52
-
-
Save thetanil/b4a6baceebf57978f5050a3834aa70df to your computer and use it in GitHub Desktop.
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
local top = [[ | |
<!DOCTYPE html> | |
<html lang=en> | |
<head> | |
<link rel="icon" href="data:;base64,iVBORw0KGgo="> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<meta name="description" content="description"> | |
<style> | |
* { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
body { | |
height: 100vh; | |
display: grid; | |
place-items: center; | |
background: hsl(0, 0%, 96%); | |
} | |
.canvas { | |
width: 75vmin; | |
height: 75vmin; | |
background: hsl(350, 70%, 80%); | |
} | |
.shadow { | |
filter: drop-shadow( 1px 1px 0.5px rgba(0, 0, 0, .25)); | |
} | |
</style> | |
</head> | |
<body> | |
]] | |
local bottom = [[ | |
</body> | |
</html> | |
]] | |
local nrows = 10 | |
local ncols = 10 | |
local sqsize = 20 | |
local function rect(x, y, w, h, rx) | |
local jit = math.random(-10,10) | |
return string.format( | |
'<rect class="shadow" fill="hsla(%s, 80%%, 65%%, 0.8)" x="%s" y="%s" width="%s" height="%s" rx="%s">', | |
math.random(1, 100) + 140, x+jit, y+jit, w+jit, h+jit, rx+jit) | |
end | |
local function writeBlock(x, y) | |
Write('<g class="draw-block">') | |
Write(rect(x * sqsize - sqsize, y * sqsize - sqsize, sqsize, sqsize, | |
math.random(1, 10))) | |
Write('</g>') | |
end | |
local function render() | |
local xsize = nrows * sqsize | |
local ysize = ncols * sqsize | |
Write('<svg class="canvas" viewBox="0 0 ' .. xsize .. ' ' .. ysize .. '">') | |
for i = 1, nrows, 1 do for j = 1, ncols, 1 do writeBlock(i, j) end end | |
Write('</svg>') | |
return 'grass/index' | |
end | |
Write(top) | |
Write(render()) | |
Write(bottom) |
shmup
commented
Aug 2, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment