I've no idea to be honest....
I find the idea of masturbating over a cartoon somewhat strange... If the cartoon was based on a real person, then it probably would be a sin because it would be lusting after someone. But if it was an entirely fictional character? Interesting question. Most people probably haven't considered masturbating over a cartoon, so it probably wouldn't affect that many people anyway.
To be honest, you'd probably be more likely to get images of real people popping into your head, even if you were looking at a cartoon character.
I get the impression God would probably rather people didn't do it in case other images started popping into your head causing you to lust.