Sha256: 2ea1948fd4dbbe6eb376d534e3c6b5c4903f19a1ebd26ad4993763f670f5e188
Contents?: true
Size: 1.46 KB
Versions: 7
Compression:
Stored size: 1.46 KB
Contents
/* --- script: Rectangle.js description: Rectangles with rounded corners license: Public domain (http://unlicense.org). authors: Yaroslaff Fedin requires: - ART/ART.Shape provides: [ART.Shape.Rectangle] ... */ ART.Shape.Rectangle = new Class({ Extends: ART.Shape, draw: function(width, height, radius) { var path = new ART.Path; if (!radius){ path.move(0, 0).line(width, 0).line(0, height).line(-width, 0).line(0, -height); } else { if (typeof radius == 'number') radius = [radius, radius, radius, radius]; var tl = radius[0], tr = radius[1], br = radius[2], bl = radius[3]; if (tl < 0) tl = 0; if (tr < 0) tr = 0; if (bl < 0) bl = 0; if (br < 0) br = 0; path.move(0, tl); if (width < 0) path.move(width, 0); if (height < 0) path.move(0, height); if (tl > 0) path.arc(tl, -tl); path.line(Math.abs(width) - (tr + tl), 0); if (tr > 0) path.arc(tr, tr); path.line(0, Math.abs(height) - (tr + br)); if (br > 0) path.arc(-br, br); path.line(- Math.abs(width) + (br + bl), 0); if (bl > 0) path.arc(-bl, -bl); path.line(0, - Math.abs(height) + (bl + tl)); } return this.parent(path); }, render: function(context) { var radius = context.radius; if (radius && radius.length == 4) radius = [radius[0], radius[2], radius[3], radius[1]] return this.draw(context.size.width, context.size.height, radius) } });
Version data entries
7 entries across 7 versions & 1 rubygems