Last active
November 26, 2020 15:29
-
-
Save rbricheno/c5fe54bda78498f8d7deb9650bad2df0 to your computer and use it in GitHub Desktop.
bbc-graphics-processing.js
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
let x; | |
let y; | |
let XM=640.1; | |
let ZM=800; | |
let YM=700; | |
let tilt=20; | |
let ST; | |
let CT; | |
let maxY; | |
let minY; | |
let KR; | |
let screenY; | |
let line_thickness = 3; | |
function setup() { | |
createCanvas(1280, 1280); | |
colorMode(HSB,512); | |
ST=sin(radians(tilt)); | |
CT=cos(radians(tilt)); | |
background(0); | |
for (x = -XM; x < 0; x = x+1) { | |
for (y = -ZM; y < ZM; y = y+8) { | |
screenY = y * ST + CT * YM * fnsin(x,y); | |
if (y == -1 * ZM) { | |
minY = screenY; | |
maxY = screenY; | |
} | |
stroke(((ZM/(y+ZM))) * 255,512,512); | |
if (screenY > maxY) { | |
maxY = screenY; | |
procplot(x,y); | |
} | |
if (screenY < minY) { | |
minY = screenY; | |
procplot(x,y); | |
} | |
} | |
} | |
} | |
function draw() { | |
} | |
function fnsin(x,y) { | |
KR = 0.02 * sqrt(x*x+y*y); | |
return sin(KR)/KR; | |
} | |
function procplot(x,y) { | |
line(XM + x, YM - screenY, XM + x, YM - screenY + line_thickness); | |
line(XM + -1 * x, YM - screenY, XM + -1 * x, YM - screenY + line_thickness); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment