js实现随机圆形迷宫生成器代码
代码语言:html
所属分类:其他
代码描述:js实现随机圆形迷宫生成器代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { margin: 0; overflow: hidden; } p { font-family: sans-serif; position: absolute; bottom: 0; width: 100%; text-align: center; } svg { width: 100vw; height: 100vh; } line, circle { fill: none; stroke: #000; stroke-width: 4; stroke-linecap: square; } path { fill: none; stroke: #080; stroke-width: 4; stroke-linejoin: round; stroke-linecap: round; display: none; pointer-events: none; } #center { pointer-events: all; cursor: pointer; } #center:hover ~ path { display: inline; } </style> </head> <body> <svg></svg> <p>Touch/hover the center to see how to reach it. <a href="javascript:init()">Reload</a> to get a new maze.</p> <script> // rings at which to half the width of a // field, counting outwards. // ring 1 is the first pathway outside the center // and allways has 8 fields const keys = [1,2,4,8]; // counting the innermost wall as 2, // radius of the outermost wall const maxC = 15; const root = document.querySelector('svg'); const size = maxC * 20 + 50; root.setAttribute('viewBox', [-size, -size, 2*size, 2*size].join(' .........完整代码请登录后点击上方下载按钮下载查看
网友评论0