TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: JavaScript Fractal implementation in a single tweet

6 点作者 asyncanup大约 6 年前

2 条评论

rsiqueira大约 6 年前
Here is a collection of fractals in 140 characters (or less!) of JavaScript: <a href="https:&#x2F;&#x2F;www.dwitter.net&#x2F;h&#x2F;fractal" rel="nofollow">https:&#x2F;&#x2F;www.dwitter.net&#x2F;h&#x2F;fractal</a> It includes Mandelbrot, Fern, Iterated Function System (IFS), Cantor Set, Dragon Curves, fractal animations and other recursive functions and iterated geometric transformations. Dwitter is a great place to find clever code tricks and very short algorithm implementations.
asyncanup大约 6 年前
Hi, author here.<p>Here&#x27;s the code:<p>F=()=&gt;{ c=v.getContext(&#x27;2d&#x27;) c.lineWidth=.03 C=[1,-.5,-.5] S=[0,.87,-.87] P=[[X=300,Y=300],[X,Y],[X,Y]] R=()=&gt;{d=parseInt(Math.random()<i>3) P=<a href="http:&#x2F;&#x2F;P.map" rel="nofollow">http:&#x2F;&#x2F;P.map</a> (([x,y],i)=&gt;(c.moveTo(x,y),c.lineTo(X=x+3</i>C[I=(d+i)%3],Y=y+3*S[I]),[X,Y])) c.stroke() setTimeout(R,17) } R()}<p>Assumes no existing dependencies or dwitter-like shortcuts available. Needs this HTML to be on the page:<p>&lt;canvas width=400 height=400 id=&quot;v&quot;&gt;&lt;&#x2F;canvas&gt;&lt;script&gt;F()&lt;&#x2F;script&gt;<p>Demo here: <a href="https:&#x2F;&#x2F;runkit.com&#x2F;asyncanup&#x2F;5cd629840a18bf001b4860e9" rel="nofollow">https:&#x2F;&#x2F;runkit.com&#x2F;asyncanup&#x2F;5cd629840a18bf001b4860e9</a>
评论 #19927421 未加载
评论 #19928398 未加载