Last active
September 7, 2022 11:28
-
-
Save GoSubRoutine/0e87585b329421c24451cb42260ec311 to your computer and use it in GitHub Desktop.
Trig Pixel Colors
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
height: 600 | |
scrolling: no | |
border: yes | |
license: cc-by-4.0 |
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
/** | |
* Trig Pixel Colors (v1.0.5) [JS/p5js] (Char Code Challenge) | |
* by Sunt (2022/Sep/03) | |
* mod GoToLoop (2022/Sep/04) | |
* | |
* https://Bl.ocks.org/GoSubRoutine/0e87585b329421c24451cb42260ec311 | |
* | |
* https://Discourse.Processing.org/t/pixels-array-p5-js-vs-java/38623/8 | |
* https://OpenProcessing.org/sketch/1637961 | |
*/ | |
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
<script async src=https://cdn.JsDelivr.net/npm/p5></script> | |
<script defer src=sketch.js></script> |
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
R=42,G=84,B=128,V=600,S=32 | |
I=Int32Array,A=new I(V*V),K=new I(B),f=0 | |
setup=_=>{createCanvas(V,V) | |
pixelDensity(1).loadPixels(s=sin) | |
p=new I(pixels.buffer) | |
for(y=0;y<V;++y)for(x=0;x<V;)A[V*y+x]=B/4*(s(x/S)+cos(y/S)+s(sqrt(x*x+++y*y)/S)) | |
for(i=0;i<B;)u=B*s(.12*i), | |
K[i]=color(R+u,G+B*s(PI/50*i+++.79),B+u).levels.reduce((a,v,i)=>v<<i*8|a,0)} | |
draw=_=>{++f | |
for(i=0;i<V*V;)p[i]=K[f+A[i++]&B-1] | |
updatePixels()} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment