|
1 | | -/*! p5.js v0.4.4 April 16, 2015 */ |
| 1 | +/*! p5.js v0.4.4 April 24, 2015 */ |
2 | 2 | (function (root, factory) { |
3 | 3 | if (typeof define === 'function' && define.amd) |
4 | 4 | define('p5', [], function () { return (root.returnExportsGlobal = factory());}); |
@@ -4966,17 +4966,66 @@ amdclean['shape2d_primitives'] = function (require, core, canvas, constants) { |
4966 | 4966 | } |
4967 | 4967 | return this; |
4968 | 4968 | }; |
4969 | | - p5.prototype.rect = function (a, b, c, d) { |
| 4969 | + p5.prototype.rect = function (x, y, w, h, tl, tr, br, bl) { |
4970 | 4970 | if (!this._doStroke && !this._doFill) { |
4971 | 4971 | return; |
4972 | 4972 | } |
4973 | | - var vals = canvas.modeAdjust(a, b, c, d, this._rectMode); |
| 4973 | + var vals = canvas.modeAdjust(x, y, w, h, this._rectMode); |
4974 | 4974 | var ctx = this.drawingContext; |
4975 | 4975 | if (this._doStroke && ctx.lineWidth % 2 === 1) { |
4976 | 4976 | ctx.translate(0.5, 0.5); |
4977 | 4977 | } |
4978 | 4978 | ctx.beginPath(); |
4979 | | - ctx.rect(vals.x, vals.y, vals.w, vals.h); |
| 4979 | + if (typeof tl === 'undefined') { |
| 4980 | + ctx.rect(vals.x, vals.y, vals.w, vals.h); |
| 4981 | + } else { |
| 4982 | + if (typeof tr === 'undefined') { |
| 4983 | + tr = tl; |
| 4984 | + } |
| 4985 | + if (typeof br === 'undefined') { |
| 4986 | + br = tr; |
| 4987 | + } |
| 4988 | + if (typeof bl === 'undefined') { |
| 4989 | + bl = br; |
| 4990 | + } |
| 4991 | + var _x = vals.x; |
| 4992 | + var _y = vals.y; |
| 4993 | + var _w = vals.w; |
| 4994 | + var _h = vals.h; |
| 4995 | + var hw = _w / 2; |
| 4996 | + var hh = _h / 2; |
| 4997 | + if (_w < 2 * tl) { |
| 4998 | + tl = hw; |
| 4999 | + } |
| 5000 | + if (_h < 2 * tl) { |
| 5001 | + tl = hh; |
| 5002 | + } |
| 5003 | + if (_w < 2 * tr) { |
| 5004 | + tr = hw; |
| 5005 | + } |
| 5006 | + if (_h < 2 * tr) { |
| 5007 | + tr = hh; |
| 5008 | + } |
| 5009 | + if (_w < 2 * br) { |
| 5010 | + br = hw; |
| 5011 | + } |
| 5012 | + if (_h < 2 * br) { |
| 5013 | + br = hh; |
| 5014 | + } |
| 5015 | + if (_w < 2 * bl) { |
| 5016 | + bl = hw; |
| 5017 | + } |
| 5018 | + if (_h < 2 * bl) { |
| 5019 | + bl = hh; |
| 5020 | + } |
| 5021 | + ctx.beginPath(); |
| 5022 | + ctx.moveTo(_x + tl, _y); |
| 5023 | + ctx.arcTo(_x + _w, _y, _x + _w, _y + _h, tr); |
| 5024 | + ctx.arcTo(_x + _w, _y + _h, _x, _y + _h, br); |
| 5025 | + ctx.arcTo(_x, _y + _h, _x, _y, bl); |
| 5026 | + ctx.arcTo(_x, _y, _x + _w, _y, tl); |
| 5027 | + ctx.closePath(); |
| 5028 | + } |
4980 | 5029 | if (this._doFill) { |
4981 | 5030 | ctx.fill(); |
4982 | 5031 | } |
|
0 commit comments