Skip to content

Instantly share code, notes, and snippets.

@yageek
Created March 15, 2014 12:24
Show Gist options
  • Save yageek/9566353 to your computer and use it in GitHub Desktop.
Save yageek/9566353 to your computer and use it in GitHub Desktop.
Undefined rapahel bug
//=require raphael
function inherits(p) {
if (p == null) throw TypeError();
if (Object.create)
return Object.create(p);
var t = typeof p;
if( t !== "object" && t !== "function") throw TypeError();
function f() {};
f.prototype = p;
return new f();
}
function RNPoint(x, y){
this.x = x;
this.y = y;
}
function RNRect(x, y, width, height){
this.topLeft = new Point(x,y);
this.width = width;
this.height = height;
}
function RNView(paper){
this.Rpaper = paper;
this.strokeColor = "#000";
this.fillColor = "#000";
this.strokeWidth = 5;
}
RNView.prototype = {
draw: function(robject){
robject.attr({
fill: this.fillColor,
stroke: this.strokeColor,
"stroke-width": this.strokeWidth
});
}
};
function RNLineView(paper, startPoint, endPoint){
RNView.apply(this,paper);
this.startPoint = startPoint;
this.endPoint = endPoint;
}
RNLineView.prototype = inherits(RNView.prototype);
RNLineView.prototype.constructor = RNLineView;
RNLineView.prototype.draw = function()
{
var d = "M " + this.startPoint.x + "," + this.startPoint.y + ' L' + this.endPoint.x + "," + this.endPoint.y;
var path = this.Rpaper.path(d);
RNView.prototype.draw(path);
}
$(document).ready(function (){
var paper = new Raphael('canvas', 640, 480);
var startPoint = new RNPoint(10,20),
endPoint = new RNPoint(40, 60);
var line = new RNLineView(paper, startPoint,endPoint);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment