JSFiddle - React, Tailwind, and code Playground

by chriswilsondc

JavaScript

var paper = Raphael(0, 0, 100, 100);

Raphael.fn.star = function(x, y, r) {
    var theta = Math.PI / 5,
        path = "M" + x + "," + (y - r);// + "v-" + r;
       
    path += "L" + (x + Math.sin(theta) * r) + "," + (y + Math.cos(theta) * r); 
    path += "L" + (x - Math.cos(theta / 2) * r) + "," + (y - Math.sin(theta / 2) * r); 
    path += "L" + (x + Math.cos(theta / 2) * r) + "," + (y - Math.sin(theta / 2) * r); 
    path += "L" + (x - Math.sin(theta) * r) + "," + (y + Math.cos(theta) * r); 
    path += "L" + x + "," + (y - r); 

    return this.path(path);

}

paper.star(50, 50, 40).attr("fill", "red").attr("stroke-width", 0);