В основном я хочу, чтобы круг менял цвет, когда ползунок перемещает его по флагу: зеленый на белом фоне, белый на зеленом прямоугольнике.
function move() {
let slider = document.querySelector("#slider");
let circle = document.querySelector("#player");
circle.setAttribute("cx", slider.value);
}
<h1>Flag</h1>
<svg width="375" height="375">
<g id="flag">
<rect x="0" y="0" width="125" height="375" fill="green"/>
<rect x="250" y="0" width="125" height="375" fill="green"/>
</g>
<circle id="player" cx="187.5" cy="187.5" r="10" fill="green" />
</svg><br>
<input id="slider" type="range" min="0" max="375" value="150" style="width:370px" oninput="move()">
Свободный перевод вопроса how to change circle fill based on background color with javascript? от участника @thegoldmolar.