{"action":"closed","issue":{"url":"https://api.github.com/repos/processing/p5.js/issues/601","labels_url":"https://api.github.com/repos/processing/p5.js/issues/601/labels{/name}","comments_url":"https://api.github.com/repos/processing/p5.js/issues/601/comments","events_url":"https://api.github.com/repos/processing/p5.js/issues/601/events","html_url":"https://github.com/processing/p5.js/issues/601","id":67990885,"number":601,"title":"rounded rect support (with proposed patch)","user":{"login":"russomf","id":11917158,"avatar_url":"https://avatars.githubusercontent.com/u/11917158?v=3","gravatar_id":"","url":"https://api.github.com/users/russomf","html_url":"https://github.com/russomf","followers_url":"https://api.github.com/users/russomf/followers","following_url":"https://api.github.com/users/russomf/following{/other_user}","gists_url":"https://api.github.com/users/russomf/gists{/gist_id}","starred_url":"https://api.github.com/users/russomf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/russomf/subscriptions","organizations_url":"https://api.github.com/users/russomf/orgs","repos_url":"https://api.github.com/users/russomf/repos","events_url":"https://api.github.com/users/russomf/events{/privacy}","received_events_url":"https://api.github.com/users/russomf/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-13T02:40:51Z","updated_at":"2015-04-15T11:59:43Z","closed_at":"2015-04-15T11:59:43Z","body":"Are there plans to support the extended rect() syntax for drawing rounded rectangles? How about this drop-in replacement for p5.prototype.rect in 2d_primitives.js?\r\n\r\n```javascript\r\n  p5.prototype.rect = function (a, b, c, d, tl, tr, br, bl) {\r\n    if (!this._doStroke && !this._doFill) {\r\n      return;\r\n    }\r\n    var vals = canvas.modeAdjust(a, b, c, d, this._rectMode);\r\n    var ctx = this.drawingContext;\r\n    if (this._doStroke && ctx.lineWidth % 2 === 1) {\r\n      ctx.translate(0.5, 0.5);\r\n    }\r\n    ctx.beginPath();\r\n    \r\n    if (typeof tl === 'undefined') {\r\n        // No rounded corners\r\n        ctx.rect(vals.x, vals.y, vals.w, vals.h);\r\n    } else {\r\n        // At least one rounded corner\r\n        // One radius - set them all equal\r\n        if (typeof tr === 'undefined') tr = br = bl = tl;\r\n        \r\n        var x = vals.x;\r\n        var y = vals.y;\r\n        var w = vals.w;\r\n        var h = vals.h;\r\n        var hw = w / 2;\r\n        var hh = h / 2;\r\n        \r\n        // Clip radii\r\n        if (w < 2 * tl) tl = hw;\r\n        if (h < 2 * tl) tl = hh;\r\n        if (w < 2 * tr) tr = hw;\r\n        if (h < 2 * tr) tr = hh;\r\n        if (w < 2 * br) br = hw;\r\n        if (h < 2 * br) br = hh;\r\n        if (w < 2 * bl) bl = hw;\r\n        if (h < 2 * bl) bl = hh;\r\n        \r\n        // Draw shape\r\n        ctx.beginPath();\r\n        ctx.moveTo(x+tl, y);\r\n        ctx.arcTo(x+w, y, x+w, y+h, tr);\r\n        ctx.arcTo(x+w, y+h, x, y+h, br);\r\n        ctx.arcTo(x, y+h, x, y, bl);\r\n        ctx.arcTo(x, y, x+w, y, tl);\r\n        ctx.closePath();\r\n    }\r\n    if (this._doFill) {\r\n      ctx.fill();\r\n    }\r\n    if (this._doStroke) {\r\n      ctx.stroke();\r\n    }\r\n    if (this._doStroke && ctx.lineWidth % 2 === 1) {\r\n      ctx.translate(-0.5, -0.5);\r\n    }\r\n    return this;\r\n  };\r\n```\r\n"}}