p5实现一个点线网络结构效果代码
代码语言:html
所属分类:其他
代码描述:p5实现一个点线网络结构效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> body { margin: 0; background: white; } main { width: 100vw; height: 100vh; display: flex; } canvas { margin: auto; } </style> </head> <body> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/p5.1.4.0.js"></script> <script> let points = [] let n = 50 function getVizinhos(point, points, radius) { let vizinhos = [] for (let i = 0; i < points.length; i++) { let p = points[i] let d = dist(p.x, p.y, point.x, point.y) if (d < radius) { vizinhos.push(i) } } return vizinhos } function setup() { createCanvas( min(500, windowWidth), min(500, windowWidth) ) for (let i = 0; i < n; i++) { points.push( createVector( random(width*0.45, width*0.55), random(height*0.45, he.........完整代码请登录后点击上方下载按钮下载查看
网友评论0