<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JS1K | 酷 壳 - CoolShell</title>
	<atom:link href="https://coolshell.cn/tag/js1k/feed" rel="self" type="application/rss+xml" />
	<link>https://coolshell.cn</link>
	<description>享受编程和技术所带来的快乐 - Coding Your Ambition</description>
	<lastBuildDate>Sun, 26 Dec 2010 04:33:47 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.2</generator>
	<item>
		<title>程序员的圣诞节</title>
		<link>https://coolshell.cn/articles/3429.html</link>
					<comments>https://coolshell.cn/articles/3429.html#comments</comments>
		
		<dc:creator><![CDATA[陈皓]]></dc:creator>
		<pubDate>Mon, 27 Dec 2010 00:43:32 +0000</pubDate>
				<category><![CDATA[Web开发]]></category>
		<category><![CDATA[杂项资源]]></category>
		<category><![CDATA[Christmas]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JS1K]]></category>
		<guid isPermaLink="false">http://coolshell.cn/?p=3429</guid>

					<description><![CDATA[<p>程序员Román Cortés用1021个字节写了一个3D 的圣诞树，很强大。（请使用Chrome浏览器查看），还记得本站介绍的那个叫js1k.com的网站吗？...</p>
<p class="read-more"><a class="btn btn-default" href="https://coolshell.cn/articles/3429.html"> Read More<span class="screen-reader-text">  Read More</span></a></p>
The post <a href="https://coolshell.cn/articles/3429.html">程序员的圣诞节</a> first appeared on <a href="https://coolshell.cn">酷 壳 - CoolShell</a>.]]></description>
										<content:encoded><![CDATA[<p><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-3415450859608158"
     crossorigin="anonymous"></script>程序员Román Cortés用1021个字节写了一个<a style="font-weight: bold;" href="http://js1k.com/2010-xmas/demo/856" target="_blank">3D 的圣诞树</a>，很强大。（请使用Chrome浏览器查看），还记得<a href="https://coolshell.cn/articles/2785.html" target="_blank">本站介绍的那个叫js1k.com的网站</a>吗？</p>
<p style="text-align: center;"><a title=" 3D Christmas tree" href="http://js1k.com/2010-xmas/demo/856" target="_blank"><img decoding="async" loading="lazy" src="http://www.romancortes.com/ficheros/arbol_0.jpg" alt="Christmas Tree" hspace="38" vspace="30" width="434" height="339" /></a></p>
<p style="text-align: left;">其原理如下所示：</p>
<p style="text-align: left;"><span id="more-3429"></span></p>
<p style="text-align: left;"><a href="http://www.romancortes.com/blog/how-i-did-the-1kb-christmas-tree/" target="_blank">http://www.romancortes.com/blog/how-i-did-the-1kb-christmas-tree/</a></p>
<p style="text-align: center;"><img decoding="async" loading="lazy" src="http://www.romancortes.com/ficheros/arbol_1.gif" alt="-" hspace="68" vspace="30" width="374" height="168" /></p>
<p style="text-align: center;"><img decoding="async" loading="lazy" src="http://www.romancortes.com/ficheros/arbol_2.gif" alt="-" hspace="68" vspace="30" width="374" height="168" /></p>
<p style="text-align: center;"><img decoding="async" loading="lazy" src="http://www.romancortes.com/ficheros/arbol_3.gif" alt="-" hspace="96" vspace="30" width="318" height="162" /></p>
<p style="text-align: center;"><img decoding="async" loading="lazy" src="http://www.romancortes.com/ficheros/arbol_4.gif" alt="-" hspace="15" vspace="30" width="480" height="276" /></p>
<p style="text-align: center;"><img decoding="async" loading="lazy" src="http://www.romancortes.com/ficheros/arbol_5.gif" alt="-" hspace="114" vspace="30" width="282" height="368" /></p>
<p style="text-align: center;"><img decoding="async" loading="lazy" src="http://www.romancortes.com/ficheros/arbol_6.gif" alt="-" hspace="79" vspace="30" width="351" height="171" /></p>
<p style="text-align: left;">——————————————</p>
<p style="text-align: left;">还有另外一个叫Dustin DeWeese程序员，也做了一个贺卡给大家（请点下面的链接）。这个贺卡需要向下滚动网页才能看得出效果来，no Javascript。</p>
<p style="text-align: center;"><a href="http://www.hackerfoo.com.nyud.net/christmas/christmas.html" target="_blank">http://www.hackerfoo.com.nyud.net/christmas/christmas.html</a></p>
<p style="text-align: left;">这种使用遮罩而产生的动画的东西确实很有意思：<a href="http://blogoscoped.com/files/stripes.html" target="_blank">http://blogoscoped.com/files/stripes.html</a>，有一个小工具可以用来创建这样的东西：<a href="http://dl.dropbox.com/u/15095913/Scanimation_Creation_v1.1.zip" target="_blank">http://dl.dropbox.com/u/15095913/Scanimation_Creation_v1.1.zip</a></p>
<p style="text-align: left;">呵呵。挺有意思的吧。</p>
<p><!--



<p align="center"><a href= target=_blank><img decoding="async" src=""></a></p>





<p align="center"><img decoding="async" src="https://coolshell.cn/wp-content/uploads/2020/03/coolshell.weixin.jpg"> <img decoding="async" loading="lazy" src="https://coolshell.cn/wp-content/uploads/2020/03/coolshell.mini_.jpg" width="300" height="300"> <br />关注CoolShell微信公众账号和微信小程序</p>

 

--></p>
<div style="margin-top: 15px; font-size: 16px;color: #cc0000;">
<p align="center"><strong>（转载本站文章请注明作者和出处 <a href="https://coolshell.cn/">酷 壳 &#8211; CoolShell</a> ，请勿用于任何商业用途）</strong></p>
</div>

<div class="wp_rp_wrap  wp_rp_vertical_m" id="wp_rp_first"><div class="wp_rp_content"><h3 class="related_post_title">相关文章</h3><ul class="related_post wp_rp"><li ><a href="https://coolshell.cn/articles/2785.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/plugins/wordpress-23-related-posts-plugin/static/thumbs/5.jpg" alt="JS1K 演示" width="150" height="150" /></a><a href="https://coolshell.cn/articles/2785.html" class="wp_rp_title">JS1K 演示</a></li><li ><a href="https://coolshell.cn/articles/18360.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/uploads/2018/05/300x262-150x150.jpg" alt="程序员练级攻略（2018)  与我的专栏" width="150" height="150" /></a><a href="https://coolshell.cn/articles/18360.html" class="wp_rp_title">程序员练级攻略（2018)  与我的专栏</a></li><li ><a href="https://coolshell.cn/articles/17634.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/uploads/2017/01/pretty-code-150x150.gif" alt="Chrome开发者工具的小技巧" width="150" height="150" /></a><a href="https://coolshell.cn/articles/17634.html" class="wp_rp_title">Chrome开发者工具的小技巧</a></li><li ><a href="https://coolshell.cn/articles/17524.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/uploads/2016/10/drawing-recursive-150x150.jpg" alt="如何读懂并写出装逼的函数式代码" width="150" height="150" /></a><a href="https://coolshell.cn/articles/17524.html" class="wp_rp_title">如何读懂并写出装逼的函数式代码</a></li><li ><a href="https://coolshell.cn/articles/10822.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/uploads/2013/12/yoda-lambda-150x150.png" alt="函数式编程" width="150" height="150" /></a><a href="https://coolshell.cn/articles/10822.html" class="wp_rp_title">函数式编程</a></li><li ><a href="https://coolshell.cn/articles/10739.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/uploads/2013/12/lua-150x150.gif" alt="Lua简明教程" width="150" height="150" /></a><a href="https://coolshell.cn/articles/10739.html" class="wp_rp_title">Lua简明教程</a></li></ul></div></div>The post <a href="https://coolshell.cn/articles/3429.html">程序员的圣诞节</a> first appeared on <a href="https://coolshell.cn">酷 壳 - CoolShell</a>.]]></content:encoded>
					
					<wfw:commentRss>https://coolshell.cn/articles/3429.html/feed</wfw:commentRss>
			<slash:comments>13</slash:comments>
		
		
			</item>
		<item>
		<title>JS1K 演示</title>
		<link>https://coolshell.cn/articles/2785.html</link>
					<comments>https://coolshell.cn/articles/2785.html#comments</comments>
		
		<dc:creator><![CDATA[陈皓]]></dc:creator>
		<pubDate>Mon, 09 Aug 2010 05:51:37 +0000</pubDate>
				<category><![CDATA[Web开发]]></category>
		<category><![CDATA[杂项资源]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JS1K]]></category>
		<guid isPermaLink="false">http://coolshell.cn/?p=2785</guid>

					<description><![CDATA[<p>以前本站发布过很多和Javascript相关的东西，如：《又一个Javascript试验田》、《一个Windows 3.1的Web网站》、《哥是玩程序的》。今天...</p>
<p class="read-more"><a class="btn btn-default" href="https://coolshell.cn/articles/2785.html"> Read More<span class="screen-reader-text">  Read More</span></a></p>
The post <a href="https://coolshell.cn/articles/2785.html">JS1K 演示</a> first appeared on <a href="https://coolshell.cn">酷 壳 - CoolShell</a>.]]></description>
										<content:encoded><![CDATA[<p><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-3415450859608158"
     crossorigin="anonymous"></script>以前本站发布过很多和Javascript相关的东西，如：《<a rel="bookmark" href="https://coolshell.cn/articles/2276.html">又一个Javascript试验田</a>》、《<a rel="bookmark" href="https://coolshell.cn/articles/2065.html">一个Windows 3.1的Web网站</a>》、《<a rel="bookmark" href="https://coolshell.cn/articles/1932.html">哥是玩程序的</a>》。今天要介绍另外一组，先看下面的这个Javascript特效（在IE下无法正常工作），你可以用Chrome查看，很炫。不过最炫的是其源码，非常的简单，不超过1K。如果你要知道这个效果的原理，这里有一个<a href="http://acko.net/blog/js1k-demo-the-making-of" target="_blank">教程</a>。这里有个网站：<a href="http://js1k.com/" target="_blank">JS1K Demo</a>， 这个站上主要收集一些Javascript不大于1K的程序。</p>
<p align=center><iframe loading="lazy" id="1kjs" frameborder="0" style="background:#000;border:0" width="510" height="320" src="http://acko.net/files/1022b.html"></iframe><br /> <br />
<button id="1kjs-stop" onclick="document.getElementById('1kjs').src='about:blank';document.getElementById('1kjs-stop').style.display='none';document.getElementById('1kjs-start').style.display='block';">停止演示</button><button style="display: none" id="1kjs-start" onclick="document.getElementById('1kjs').src='http://acko.net/files/1022b.html';document.getElementById('1kjs-start').style.display='none';document.getElementById('1kjs-stop').style.display='block';">开始演示</button></p>
<p>下面是其源码：<br />
<span id="more-2785"></span></p>
<p>[javascript]<br />
f=Math; _=document.body; _.style.background=&quot;#000&quot;; e=_.children[0]; e.width=w=innerWidth-10; e.height=h=innerHeight-25; g=e.getContext(&quot;2d&quot;); t=w/h; with(g){scale(w*0.5/t,h*0.5); translate(1*t,1); globalCompositeOperation=&quot;lighter&quot;; lw=45/h; $=p=m=q=r=d=0; g=u=-8; setInterval(function(){if(&#8211;d&lt; 0){h=f.random; e=h()*18-9; r2=h()*18-9; u2=h()*18-9; d=70}function A(C,B){return C+(B-C)*0.04}p=A(p,e); m=A(m,r2); g=A(g,u2); q=A(q,p); r=A(r,m); u=A(u,g); a=f.atan2(q,-u*2); b=f.atan2(r*2,f.sqrt(u*u+q*q)); $+=0.05; clearRect(-t,-1,2*t,2); for(i=12; i; &#8211;i){v=0; for(j=45; j; ){c=f.cos; s=f.sin; j&#8211;; w=$-j*0.03-i*3; A=f.sqrt(j+0.2); n=c(w+s(w*0.31))*2+s(w*0.83)*3+w*0.02; o=s(w*0.7)-c(3+w*0.23)*3; x=c(n)*c(o)*A-q; y=s(n)*c(o)*A-r; z=s(o)*A-u; n=c(a); o=s(a); k=x*n+z*o; h=z*n-x*o; n=c(b); o=s(b); l=y*n+h*o; z=h*n-y*o; lineTo(k/z,l/z); lineWidth=lw*(2+!j)/z; h=f.round; w=h(60-j)*(1+!j+f.max(0,s($*6-j/8)-0.95)*70); strokeStyle=&quot;rgb(&quot;+h(w*(!j+s(i+$*0.15)+1))+&quot;,&quot;+h(!j+w*(s(i-1)+1))+&quot;,&quot;+h(!j+w*(s(i-1.3)+1))+&quot;)&quot;; if(z&gt; 0.1){v++&amp;&amp;stroke()}else{v=0}beginPath(); moveTo(k/z,l/z)}}},33)}<br />
[/javascript]</p>
<p>下面，让我们再看一个只有1023字节的3D演示，同样，只有在Chrome中才能看到最佳效果。</p>
<p align=center><iframe loading="lazy" id="1kjs1" frameborder="0" style="background:#000;border:0" width="510" height="320" src="http://js1k.com/pleaseDontHotlinkMe/15"></iframe><br /> <br />
<button id="1kjs-stop1" onclick="document.getElementById('1kjs1').src='about:blank';document.getElementById('1kjs-stop1').style.display='none';document.getElementById('1kjs-start1').style.display='block';">停止演示</button><button style="display: none" id="1kjs-start1" onclick="document.getElementById('1kjs1').src='http://js1k.com/pleaseDontHotlinkMe/15';document.getElementById('1kjs-start1').style.display='none';document.getElementById('1kjs-stop1').style.display='block';">开始演示</button></p>
<p>其源代码如下：</p>
<p>[javascript]<br />
with(document.body.style){margin=&quot;0px&quot;;overflow=&quot;hidden&quot;;}var w=window.innerWidth;var h=window.innerHeight;var ca=document.getElementById(&quot;c&quot;);ca.width=w;ca.height=h;var c=ca.getContext(&quot;2d&quot;);m=Math;fs=m.sin;fc=m.cos;fm=m.max;setInterval(d,30);function p(x,y,z){return{x:x,y:y,z:z};}function s(a,z){r=w/10;R=w/3;b=-20*fc(a*5+t);return p(w/2+(R*fc(a)+r*fs(z+2*t))/z+fc(a)*b,h/2+(R*fs(a))/z+fs(a)*b);}function q(a,da,z,dz){var v=[s(a,z),s(a+da,z),s(a+da,z+dz),s(a,z+dz)];c.beginPath();c.moveTo(v[0].x,v[0].y);for(i in v)c.lineTo(v[i].x,v[i].y);c.fill();}var Z=-0.20;var t=0;function d(){t+=1/30.0;c.fillStyle=&quot;#000&quot;;c.fillRect(0,0,w,h);c.fillStyle=&quot;#f00&quot;;var n=30;var a=0;var da=2*Math.PI/n;var dz=0.25;for(var z=Z+8;z&gt;Z;z-=dz){for(var i=0;i&lt;n;i++){fog=1/(fm((z+0.7)-3,1));if(z&lt;=2){fog=fm(0,z/2*z/2);}var k=(205*(fog*Math.abs(fs(i/n*2*3.14+t))))&gt;&gt;0;k*=(0.55+0.45*fc((i/n+0.25)*Math.PI*5));k=k&gt;&gt;0;c.fillStyle=&quot;rgb(&quot;+k+&quot;,&quot;+k+&quot;,&quot;+k+&quot;)&quot;;q(a,da,z,dz);if(i%3==0){c.fillStyle=&quot;#000&quot;;q(a,da/10,z,dz);}a+=da;}}Z-=0.05;if(Z&lt;=dz)Z+=dz;}<br />
[/javascript]</p>
<p>你可以前往一看更多的<a href="http://js1k.com/demos" target="_blank">演示</a>。<!--



<p align="center"><a href= target=_blank><img decoding="async" src=""></a></p>





<p align="center"><img decoding="async" src="https://coolshell.cn/wp-content/uploads/2020/03/coolshell.weixin.jpg"> <img decoding="async" loading="lazy" src="https://coolshell.cn/wp-content/uploads/2020/03/coolshell.mini_.jpg" width="300" height="300"> <br />关注CoolShell微信公众账号和微信小程序</p>

 

--></p>
<div style="margin-top: 15px; font-size: 16px;color: #cc0000;">
<p align="center"><strong>（转载本站文章请注明作者和出处 <a href="https://coolshell.cn/">酷 壳 &#8211; CoolShell</a> ，请勿用于任何商业用途）</strong></p>
</div>

<div class="wp_rp_wrap  wp_rp_vertical_m" ><div class="wp_rp_content"><h3 class="related_post_title">相关文章</h3><ul class="related_post wp_rp"><li ><a href="https://coolshell.cn/articles/3429.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/uploads/2010/12/arbol_0-150x150.jpg" alt="程序员的圣诞节" width="150" height="150" /></a><a href="https://coolshell.cn/articles/3429.html" class="wp_rp_title">程序员的圣诞节</a></li><li ><a href="https://coolshell.cn/articles/18360.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/uploads/2018/05/300x262-150x150.jpg" alt="程序员练级攻略（2018)  与我的专栏" width="150" height="150" /></a><a href="https://coolshell.cn/articles/18360.html" class="wp_rp_title">程序员练级攻略（2018)  与我的专栏</a></li><li ><a href="https://coolshell.cn/articles/17634.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/uploads/2017/01/pretty-code-150x150.gif" alt="Chrome开发者工具的小技巧" width="150" height="150" /></a><a href="https://coolshell.cn/articles/17634.html" class="wp_rp_title">Chrome开发者工具的小技巧</a></li><li ><a href="https://coolshell.cn/articles/17524.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/uploads/2016/10/drawing-recursive-150x150.jpg" alt="如何读懂并写出装逼的函数式代码" width="150" height="150" /></a><a href="https://coolshell.cn/articles/17524.html" class="wp_rp_title">如何读懂并写出装逼的函数式代码</a></li><li ><a href="https://coolshell.cn/articles/10822.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/uploads/2013/12/yoda-lambda-150x150.png" alt="函数式编程" width="150" height="150" /></a><a href="https://coolshell.cn/articles/10822.html" class="wp_rp_title">函数式编程</a></li><li ><a href="https://coolshell.cn/articles/10739.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/uploads/2013/12/lua-150x150.gif" alt="Lua简明教程" width="150" height="150" /></a><a href="https://coolshell.cn/articles/10739.html" class="wp_rp_title">Lua简明教程</a></li></ul></div></div>The post <a href="https://coolshell.cn/articles/2785.html">JS1K 演示</a> first appeared on <a href="https://coolshell.cn">酷 壳 - CoolShell</a>.]]></content:encoded>
					
					<wfw:commentRss>https://coolshell.cn/articles/2785.html/feed</wfw:commentRss>
			<slash:comments>15</slash:comments>
		
		
			</item>
	</channel>
</rss>
