<div class="box">
  <div class="circle">
    <div class="dot"></div>
    <div class="ray">
      <div class="dot"></div>
    </div>
    <div class="ray-box"></div>
  </div>
</div>

<div class="control">
  <div class="item">
    <input type="checkbox" id="ray" />
    <label for="ray">Toggle ray()</label>
  </div>
  <div class="item">
    <label for="rayAngle">Angle:</label>
    <input type = "range" min="-360" max="360" value="0" onchange="rangevalue.value=value" id="rayAngle" />
	  <output id="rangevalue">0</output>deg
  </div>
</div>
* {
  box-sizing: border-box;
}
:root {
  --rayAngle: 0deg;
}
body {
  width: 100vw;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10vh;
}

.box {
  width: 60vh;
  height: 60vh;
  border: 1px dashed #666;
  position: relative;
  margin: 1vh;
}

.circle {
  width: 60vh;
  height: 60vh;
  border: 1px dashed #f36;
  border-radius: 50%;
}

.dot {
  width: 1vh;
  height: 1vh;
  background-color: #000;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ray {
  width: 10vh;
  height: 10vh;
  background-color: #89f;
  border: 2vh solid;
  border-color: #F44336 #9C27B0 #2196F3 #009688;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  
  .dot {
    background-color: red;
  }
  
  &.add-ray {
    offset-path: ray(var(--rayAngle) closest-side);
  }
}
.ray-box{
  width: 10vh;
  height: 10vh;
  border: 1px dashed #666;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.control {
  padding-top: 4vh;
  display: flex;
  align-items: center;
  justify-content: center;
  
  .item {
    margin: 0 1vh;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
View Compiled
const toggleEle = document.getElementById('ray')
const rayEle = document.querySelector('.ray')
const rayAngle = document.getElementById('rayAngle')

toggleEle.addEventListener('click', (e) => {
  console.log(e.target.checked)
 if(e.target.checked ) {
   rayEle.classList.add('add-ray')
 } else {
   rayEle.classList.remove('add-ray')
 } 
})

rayAngle.addEventListener('click', (e) => {
  console.log(e.target.value)
  rayEle.style.setProperty('--rayAngle', `${e.target.value}deg`)
})
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.