Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


  <div class="svg-floater">
<svg width="400px" height="350px" id="svg">
  <circle id="cursor-tracker" cx="0", cy="0" r="10"/>
   <polygon id="pointer" points="180,350 200,300 220,350" style="fill:red;stroke-width:1" />
  <div class="labels"><strong>Angle</strong>(degrees, offset): <span id="angle-txt">0</span>


                html {
  width: 100%;
  position: relative;
  font-family: sans-serif;

.svg-floater, .labels {
  width: 400px;
  margin: 0px auto;
  touch-action: none;

.labels div {
  display: inline;
  width: 50%;
  float: right;

line {
  stroke-dasharray: 1 5;
  stroke-width: 3;
  stroke-linecap: round;
  stroke: black;

polygon {
  transform-origin: bottom


                // Collect all our items that we need
var circle = document.getElementById('cursor-tracker');
var pointer = document.getElementById('pointer');
var svg = document.getElementById('svg');
var acTxt = document.getElementById('ac-txt');
var angleTxt = document.getElementById('angle-txt');

// Define some variables
var arrowLoc = {
  x: 200,
  y: 350

svg.addEventListener('mousemove', function(event) {
  //console.log(event.clientX, event.clientY);
  updateComponents(event.clientX, event.clientY);

svg.addEventListener('touchmove', function(event) {
  updateComponents(event.changedTouches[0].clientX, event.changedTouches[0].clientY);

function updateComponents(x, y) {
  // First, we need to do a coordinate change because the x and y origin of the SVG is offset from that of the page.
  x -= 5 + svg.getBoundingClientRect().x;
  y -= 5 + svg.getBoundingClientRect().y;
  // Now we move the circle as well as the lines so they demonstrate the triangle.
  circle.setAttribute("cx", x);
  circle.setAttribute("cy", y);
  var dx = x - arrowLoc.x;
  var dy = y - arrowLoc.y;
  var angle = Math.atan2(dy,dx) * 180 / Math.PI + 90;
  console.log(angle); = `Rotate(${angle}deg)`;
  // Now round the values and display them
  //acTxt.innerHTML = angle;
  angleTxt.innerHTML = angle ;