“text mode 360” by Morgan Brackish Meadows
https://openprocessing.org/sketch/1503819
License CreativeCommons Attribution NonCommercial ShareAlike
https://creativecommons.org/licenses/by-nc-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
Press arrow keys or tap
A fork of 360 by midorigoke
CC Attribution NonCommercial ShareAlike
text mode 360
Brackish Meadows
xxxxxxxxxx
//these values are used by the forked sketch by midorigoke
let h = 0, v = 0;
let tex;
//-------------------
let canv
let smallBuff
let glBuff
const small = 80 //this is the width and height of the smallBuff
//small needs to be a multiple of textModeRows
//i think ideally 2x textModeRows for maximum smallness
const textModeRows = 40
const textModeRowH = 400/textModeRows
let smallfont
//evaluated in setup()
let textModeCols
let textModeColW
let sampleW
let sampleH
let oneRow
//evaluated in obtainTextModeSamples()
let textModeSamples ={}
const textModeDensity = "███▓█▓▓▓▒▓▒▒▒░▒░░░+░+++:+:::.:... . "
function preload() {
smallFont = loadFont('712_serif.ttf')
}
function setup() {
canv = createCanvas(windowWidth, windowHeight)
tex = loadImage('360.png');
glBuff = createGraphics(windowWidth, windowHeight, WEBGL)
smallBuff = createGraphics(small,small)
smallBuff.pixelDensity(1)
glBuff.noStroke()
textSize(textModeRowH)
textFont(smallFont)
textModeColW = textWidth('@')
textModeCols = 400/textModeColW
sampleW = floor(small/textModeCols)
sampleH = floor(small/textModeRows)
oneRow = textModeCols*sampleW
}
function draw() {
{ //this recreates the output from the forked sketch
glBuff.clear();
glBuff.push();
glBuff.camera(0, 0, 0, 0, 0, 1, 0, 1, 0);
glBuff.scale(-1, 1, 1);
glBuff.rotateX(radians(v));
glBuff.rotateY(radians(h));
glBuff.texture(tex);
glBuff.sphere(1000);
glBuff.pop();
}
push()
translate(windowWidth/2,windowHeight/2)
// draw the glBuff to the whole screen
image(glBuff,-windowWidth/2, -windowHeight/2, windowWidth, windowHeight)
//copy the glBuff to the smallBuff
smallBuff.image(glBuff, 0, 0, smallBuff.width, smallBuff.height, 0, 0, glBuff.width, glBuff.height)
//show the small buffer contents
image(smallBuff,-300,-200,smallBuff.width,smallBuff.height)
obtainTextModeSamples()
drawTextMode()
image(canv, 0, 0, windowWidth, windowHeight, -200, -200, 400, 400)
// draw the glBuff to the whole screen
image(canv, 0, 0, windowWidth, windowHeight, -200, -200, 400, 400)
pop()
{ //this recreates the input functionality from the forked sketch
if (keyIsDown(39)) h-=5;
if (keyIsDown(37)) h+=5;
if (keyIsDown(38) && v > -90) v-=5;
if (keyIsDown(40) && v < 90) v+=5;
if (mouseIsPressed) {
h -= (mouseX - width / 2) / width*5;
v = min(90, max(-90, v + (mouseY - height / 2) / height*5));
}
}
}
function obtainTextModeSamples(){
textModeSamples = []
smallBuff.loadPixels()
for(let y = 0;y<textModeRows;y++) {
textModeSamples.push([])
for(let x = 0;x<textModeCols;x++) {
let xx = x*sampleW
let yy = y*sampleH
const pixelIndex = (xx + yy*oneRow)*4
const r = smallBuff.pixels[pixelIndex + 0]
const g = smallBuff.pixels[pixelIndex + 1]
const b = smallBuff.pixels[pixelIndex + 2]
const a = smallBuff.pixels[pixelIndex + 3]
const len = textModeDensity.length
const bri = brightness((`rgb(${r},${g},${b})`))
const charIndex = round(map(bri, 100, 20, 0, len-1))
let chr =(textModeDensity.charAt(charIndex))
textModeSamples[y].push([chr,r,g,b,a])
}
}
}
function drawTextMode() {
//background
fill(255/6)
rect(-200,-200,400,400)
for(let y = 0;y<textModeRows;y++) {
for(let x = 0; x<textModeCols; x++) {
let chr,r,g,b,a
[chr,r,g,b,a] = textModeSamples[y][x]
let rstep = 3
let gstep = 4
let bstep = 3
var rr = round(rstep * r / 255) * floor(255 / rstep)
var gg = round(gstep * g / 255) * floor(255 / gstep)
var bb = round(bstep * b / 255) * floor(255 / bstep)
let outcolor = color(`rgba(${rr},${gg},${bb},${a})`)
fill(outcolor)
text(chr,(x)*textModeColW-200,(y+0.75)*textModeRowH-200)
}}
}
See More Shortcuts