Skip to content

Purpzl patch 1 rotation test #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions ASCII.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ var obj = {
randomness: 15,
invert: false,
animationType: 'Random Text',
rotationAngle: 0 // Default rotation angle (0 degrees)
};

var videoType = "Default";
Expand Down Expand Up @@ -172,6 +173,7 @@ gui.add(obj, "randomness").min(0).max(100).step(1).name('Randomness').onChange(r

gui.add(obj, 'animationType', [ 'Random Text', 'User Text'] ).name('Text Type').onChange(refresh);
gui.add(obj, "textInput").onFinishChange(refresh);
gui.add(obj, "rotationAngle").min(0).max(360).step(1).name('Rotation').onChange(refresh);

obj['pausePlay'] = function () {
togglePausePlay();
Expand Down Expand Up @@ -348,10 +350,32 @@ function renderText(){
if(invertToggle == false){
if(currentGrayValue/255 > adjustedThreshold){

ctx.fillStyle = interpolateHex(fontColor,fontColor2,(currentGrayValue/255-adjustedThreshold) / (1-adjustedThreshold))
ctx.fillText(char, col*pixelSize, row*(pixelSize) + pixelSize);
//ctx.strokeStyle = fontColor;
//ctx.strokeText(char, col*pixelSize + pixelSize/4, row*(pixelSize) + pixelSize/2);
if (currentGrayValue / 255 < (1 - adjustedThreshold)) {
// Save the context before rotating
ctx.save();

// Translate the context to the center of each character
ctx.translate(col * pixelSize + pixelSize / 2, row * pixelSize + pixelSize / 2);

// Rotate the context based on the rotation angle from the slider
ctx.rotate(obj.rotationAngle * Math.PI / 180); // Convert degrees to radians

// Set the fill style based on the gray value
ctx.fillStyle = interpolateHex(fontColor2, fontColor, (currentGrayValue / 255) / (1 - adjustedThreshold));

// Draw the rotated text
ctx.fillText(char, -pixelSize / 2, pixelSize / 2);

// Restore the context to its original state
ctx.restore();
} else {
// Set the fill style based on the other condition
ctx.fillStyle = interpolateHex(fontColor, fontColor2, (currentGrayValue / 255 - adjustedThreshold) / (1 - adjustedThreshold));

// Draw the text without rotation
ctx.fillText(char, col * pixelSize, row * pixelSize + pixelSize);
}

}
} else {
if(currentGrayValue/255 < (1-adjustedThreshold)){
Expand Down Expand Up @@ -981,4 +1005,4 @@ setTimeout(function(){

//MAIN METHOD
refresh();
startDefaultVideo();
startDefaultVideo();