↳ large number, or a cluster, of bright characters(index 9 - 14) indicate absence or void or low presence while dark characters(index 0 - 5) indicate presence or visual density
both past and present ascii character sets must have the same number of characters. also on the same alphabet, for pixel to character modulation and convenient merging logic
merge logic
use boolean statement
if currentIndex > or => or < or <= or === [index number] && pastIndex > or => or < or <= or === [index number] { mergedLine += '[resulting character with span styling tag]';
else if ------
else ------ }
baseline logic
Current
Past
Result
brightest
darkest
past
brightest
dark-ish
past
brightest
middle
past
brightest
bright-ish
past
brightest
brightest
anomaly
bright-ish
darkest
past
bright-ish
dark-ish
past
bright-ish
middle
past
bright-ish
bright-ish
anomaly
bright-ish
brightest
current
middle
darkest
past
middle
dark-ish
past
middle
middle
anomaly
middle
bright-ish
current
middle
brightest
current
dark-ish
darkest
past
dark-ish
dark-ish
anomaly
dark-ish
middle
current
dark-ish
bright-ish
current
dark-ish
brightest
current
darkest
darkest
anomaly
darkest
dark-ish
current
darkest
middle
current
darkest
bright-ish
current
darkest
brightest
current
→ this is too simple. I'm little bit worried that it would end up boring
↳ but the clear logic can ensure reabability
output rendering
code to work
declaration
what I need here
two different character set for current, past frames
functiondraw(){video.loadPixels();letcurrentAscii=convertToAscii(video);pastStrings.push(currentAscii);if(pastStrings.length>delayFrames){pastStrings.shift();}if(pastStrings.length===delayFrames){letpastAscii=pastStrings[0];letmergedAscii=mergeAscii(currentAscii,pastAscii);finalAsciiDiv.html(mergedAscii);}else{finalAsciiDiv.html(currentAscii);}//missed this one, same delay logic}
helper function
convert to ascii
what I need here
i'll be using three character sets, one for current density, another for past density, lastly a set of anomalies. first i need conversion between current and past density set at some point here (make sure the both density sets--past and present--has same amount of character for modulation later) ↳ ahhh no need, forgot it works with the index of the density spectrum. i only need to manipulate that in css (or not even)
functionconvertToAscii(img){// video, img, the name doesn;t matter hereletasciiString="";for(letj=0;j<img.height;j++){for(leti=0;i<img.width;i++){constpixelIndex=(i+j*img.width)*4;constr=img.pixels[pixelIndex+0];constg=img.pixels[pixelIndex+1];constb=img.pixels[pixelIndex+2];constavg=(r+g+b)/3;constlen=density.length;constcharIndex=floor(map(avg,0,255,0,len));constc=density.charAt(charIndex);if(c==" ")asciiString+=" ";elseasciiString+=c;}asciiString+="<br/>";}returnasciiString;}
compare two ascii frames (past and current. like we did on converToAscii function), using character by character comparison. both frames are splt into rows using the line break, and each row is procesesd one character at a time using the loop.
!!i for rows, j for collumns!! ↳ get the same index of the row first, then the column.
the conditional rule should outputs the resulting character
append(+=) the resulting character to line(a row by row) variable, add break line at the end of the loop
juxtaposition of two timestamps showing the time of the current frame and the time of the past frame
☀︎Fred gave me this idea i quite like it☀︎
basically it should look something like:
[13:42:10]———[13:41:20]
the current frame time written on the left-top corner, and the past frame time on the right-top corner
JavaScript Date objects represent a single moment in time in a platform-independent format. Date objects encapsulate an integral number that represents milliseconds since the midnight at the beginning of January 1, 1970, UTC (the epoch).