Page script no longer working

I made this page quite some time ago now, so I don’t really recall how I made the source code due to not leaving comments in it.

It was initially meant to serve as a calculator for changing RGB values to Animal Crossing: New Horizon’s HVB format used in their custom design maker.

It currently no longer does what it’s supposed to and I cannot figure out why.

You can find the project here: Acnhrgbtohvb

(Feel free to let me know if I’d made it unable to be remixed in the past and I can temporarily undo that setting upon request, and/or just send you the code necessary via DMs.)

hello!

the reason why the code wasn’t working was because of this error:

Uncaught TypeError: document.getElementById(...) is null
    getInputValue https://acnhrgbtohvb.glitch.me/:85
    onclick https://acnhrgbtohvb.glitch.me/:1
acnhrgbtohvb.glitch.me:85:30

i think you used the wrong element IDs to get the color values!

// line 85-89
var hu = (document.getElementById("hue").value / 360) * 30;
var sa = (document.getElementById("sat").value / 100) * 15;
var va = (document.getElementById("val").value / 100) * 15;

solution 1?

elements with IDs hue, sat, and val do not exist. perhaps you meant r, g, and b?

var hu = (document.getElementById("r").value / 360) * 30;
var sa = (document.getElementById("g").value / 100) * 15;
var va = (document.getElementById("b").value / 100) * 15;

alternatively

it looks like you’re trying to convert the input rgb into hsv/hsb, so why not use the conversion function you’ve already declared?

let r = document.getElementById("r").value;
let g = document.getElementById("g").value;
let b = document.getElementById("b").value;

let [h, s, v] = rgb2hsv(r, g, b);

document.getElementById("hu").innerHTML = h;
document.getElementById("sa").innerHTML = s;
document.getElementById("va").innerHTML = v;

the above code might be completely wrong for your intended purpose because i’m not aware of the conversion formula for RGB to animal crossing colors!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.