Skip to content

Instantly share code, notes, and snippets.

View Mtillmann's full-sized avatar
👻
bouncing

Martin Tillmann Mtillmann

👻
bouncing
View GitHub Profile
@dcousineau
dcousineau / raphael.centroid.js
Created November 15, 2011 17:16
RaphaëlJs approximate centroid extension, should work with arbitrary paths.
Raphael.el.getCentroid = function() {
var centroid = { x: 0, y: 0 }
, area = 0
, length = this.getTotalLength()
, lengthSegment = length / 100.00;
for (var i = 0; i < length; i += lengthSegment) {
var curr = this.getPointAtLength(i)
, next = this.getPointAtLength(i + lengthSegment);