<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">
  <input type="checkbox" id="ray" />
  <label for="ray">Toggle ray()</label>
</div>
* {
  box-sizing: border-box;
}
body {
  width: 100vw;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  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(0deg closest-side);
  }
}
.ray-box{
  width: 10vh;
  height: 10vh;
  border: 1px dashed #666;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
View Compiled
const toggleEle = document.getElementById('ray')
const rayEle = document.querySelector('.ray')

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

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.