“text mode 360 test” by Paul Wheeler
https://openprocessing.org/sketch/1503978
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 text mode 360 by Morgan Brackish Meadows
CC Attribution NonCommercial ShareAlike
text mode 360 test
Wheeler
xxxxxxxxxx
//these values are used by the forked sketch
let h = 0,
v = 0;
let tex;
let canv;
let glBuff;
let smallBuff;
const small = 120; //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 = 30;
const textModeRowH = 400 / textModeRows;
let smallfont;
//evaluated in setup()
let textModeCols;
let textModeColW;
let sampleW;
let sampleH;
//evaluated in obtainTextModeSamples()
let textModeSamples = [];
const textModeDensity = "█▓▒░+:.";
//"00000OOOoo^.. "
const hueDepth = 2
const satDepth = 2
const briDepth = 2
const alpDepth = 2
function preload() {
smallFont = loadFont('712_serif.ttf');
tex = loadImage('360.png');
}
function setup() {
canv = createCanvas(windowWidth, windowHeight);
pixelDensity(1);
glBuff = createGraphics(windowWidth, windowHeight, WEBGL);
glBuff.pixelDensity(1);
glBuff.noStroke();
glBuff.noSmooth();
smallBuff = createGraphics(small, small);
smallBuff.pixelDensity(1);
// colorMode(HSB, hueDepth, satDepth, briDepth, alpDepth)
// smallBuff.colorMode(HSB, hueDepth, satDepth, briDepth, alpDepth)
textSize(textModeRowH);
textFont(smallFont);
textModeColW = textWidth('@');
textModeCols = 400 / textModeColW;
sampleW = floor(small / textModeCols);
sampleH = floor(small / textModeRows);
console.log({
textModeColW,
textModeRowH,
textModeCols,
textModeRows,
sampleW,
sampleH
})
}
function draw() {
{ //this recreates the output from the forked sketch
glBuff.clear();
glBuff.push();
// glBuff.background(0)
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();
}
/* smallBuff.copy(canv,
0, 0, width, height,
0, 0, smallBuff.width, smallBuff.height) */
smallBuff.image(glBuff, 0, 0, smallBuff.width, smallBuff.height, 0, 0, glBuff.width, glBuff.height);
background(255);
imageMode(CENTER);
let w = textModeCols * textModeColW;
image(smallBuff, width / 2 + smallBuff.width * 2, height / 2, w, w);
//show the small buffer contents
//image(smallBuff,-300,-200,smallBuff.width,smallBuff.height)
obtainTextModeSamples();
drawTextMode();
{ //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;
v = min(90, max(-90, v + (mouseY - height / 2) / height));
}
}
}
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 * small) * 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, 0, 100, 0, len - 1));
let chr = (textModeDensity.charAt(charIndex));
textModeSamples[y].push([chr, r, g, b, a]);
}
}
}
let debugLog = false;
function doubleClicked() {
debugLog = true;
}
function drawTextMode() {
//background
//fill(0);
//rect(-200, -200, 400, 400);
push();
let w = textModeCols * textModeColW;
translate(width / 2 - w / 2, height / 2);
for (let y = 0; y < textModeRows; y++) {
for (let x = 0; x < textModeCols; x++) {
let [chr, r, g, b, a] = textModeSamples[y][x];
fill(`rgba(${r},${g},${b},${a})`);
text(chr, (x) * textModeColW - w / 2, (y + 0.75) * textModeRowH - 200);
}
}
pop();
}
See More Shortcuts