Skip to content

Commit

Permalink
Updated accurate conversion test
Browse files Browse the repository at this point in the history
  • Loading branch information
humanbydefinition committed Nov 18, 2024
1 parent ab93ef0 commit c121dd0
Showing 1 changed file with 16 additions and 27 deletions.
43 changes: 16 additions & 27 deletions tests/accurate_conversion/sketch.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/**
* This test checks if all the effects can be applied and modified without causing any errors.
*/

let sketchFramebuffer;

let img;

let fontSizes = [8, 16]; // accurate renderer drops fps if the font size is too large currently
let currentFontSize = 8;
const renderModes = ['accurate', 'brightness'];
let currentModeIndex = 0;
let renderMode = renderModes[currentModeIndex];

function preload() {
img = loadImage('brutalist-high-rise-building.jpeg'); // forgot where it's from, but definitely CC0
Expand All @@ -17,45 +14,37 @@ function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
sketchFramebuffer = createFramebuffer({ format: FLOAT });

setAsciiOptions({
setAsciiOptions({
common: {
fontSize: currentFontSize,
fontSize: 8,
},
ascii: {
enabled: true,
// All characters available in the default font `UrsaFont` provided by the library
characters: ` .‼╨\`',-_ú:░+;╘╙╤╥!"/=\^i~±âñ◘─├┬┴()*<>l|ÖÜèë←↑→↓♪?fr{}°²¶ÄÅÆÉíüƒΘΦφⁿ₧∙∞┌┘╒╓╪╫■□♀LT[]cjptvxzÑ∟7qyä│┤║╕╖╡╢╣Feo«»½απ↨≤≥╗☼1au•↔4CIYZks┼╔╚╞╟╩▄█▌▐$3gn£à▬◙%2EJSmw¡ª¼↕≈╜╝▲►◄♂59hå♠♦PVXbd¥6@GKç♣8ADOUÇáéó▀▒♫ê⌂#0HR§ºBQ═╠╦╬¢¬µ¿ï÷⌐&MNW♥ìîτ└▼ε∩╧▓☺☻ÿùûòöæô≡ßΓΣσ⌠⌡┐╛○·Ωδ√`,
renderMode: 'accurate',
renderMode: renderMode,
characterColorMode: 0,
backgroundColorMode: 0,
},
});
}

function draw() {
sketchFramebuffer.begin();

background(0);

push();
translate(100, 0, 0);
fill(255);
rotateX(radians(frameCount * 3));
rotateZ(radians(frameCount));
directionalLight(255, 255, 255, 0, 0, -1);
box(600, 80, 80);
pop();

image(img, -windowWidth / 2, -windowHeight / 2);
sketchFramebuffer.end();

image(sketchFramebuffer, -windowWidth / 2, -windowHeight / 2);

if (frameCount % 120 === 0) {
// Cycle to the next font size
currentFontSize = fontSizes[(fontSizes.indexOf(currentFontSize) + 1) % fontSizes.length];
setAsciiOptions({ common: { fontSize: currentFontSize } });
console.log("Changing font size to", currentFontSize);
currentModeIndex = (currentModeIndex + 1) % renderModes.length;
renderMode = renderModes[currentModeIndex];
setAsciiOptions({ ascii: { renderMode } });

// If renderMode is 'brightness', set backgroundColorMode to 1
if (renderMode === 'brightness') {
setAsciiOptions({ ascii: { backgroundColorMode: 1 } });
} else {
setAsciiOptions({ ascii: { backgroundColorMode: 0 } });
}
}
}

Expand Down

0 comments on commit c121dd0

Please sign in to comment.