JSFiddle - React, Tailwind, and code Playground
by insane36
HTML
<div id="holder"></div>
CSS
#holder {
height: 100%;
left: 100%;
margin: -100% 0 0 -100%;
position: absolute;
top: 100%;
width: 100%;
}
JavaScript
var r = Raphael("holder", window.innerWidth, window.innerHeight)
function curve(x, y, ax, ay, bx, by, zx, zy, color) {
var path = [["M", x, y], ["C", ax, ay, bx, by, zx, zy]],
path2 = [["M", x, y], ["L", ax, ay], ["M", bx, by], ["L", zx, zy]],
curve = r.path(path).attr({stroke: color || Raphael.getColor(), "stroke-width": 4, "stroke-linecap": "round"}),
controls = r.set(
r.path(path2).attr({stroke: "#ccc", "stroke-dasharray": ". ","stroke-width":2}),
r.circle(x, y, 5).attr({fill: "#9F2200", stroke: "none"}),
r.circle(ax, ay, 5).attr({fill: "#9F2200", stroke: "none"}),
r.circle(bx, by, 5).attr({fill: "#9F2200", stroke: "none"}),
r.circle(zx, zy, 5).attr({fill: "#9F2200", stroke: "none"})
);
controls[1].update = function (x, y) {
var X = this.attr("cx") + x,
Y = this.attr("cy") + y;
this.attr({cx: X, cy: Y});
path[0][1] = X;
path[0][2] = Y;
path2[0][1] = X;
path2[0][2] = Y;
controls[2].update(x, y);
};
controls[2].update = function (x, y) {
var X = this.attr("cx") + x,
Y = this.attr("cy") + y;
this.attr({cx: X, cy: Y});
path[1][1] = X;
path[1][2] = Y;
path2[1][1] = X;
path2[1][2] = Y;
curve.attr({path: path});
controls[0].attr({path: path2});
};
controls[3].update = function (x, y) {
...