{"ScriptPreparationCode":"var master = document.getElementById(\u0027master\u0027);\r\nvar masterctx = master.getContext(\u00272d\u0027);\r\n\r\nvar cached = document.getElementById(\u0027cached\u0027);\r\nvar cachedctx = master.getContext(\u00272d\u0027);\r\n\r\nvar drawRoundRect = (\r\n ctx,\r\n x,\r\n y,\r\n width,\r\n height,\r\n stroke,\r\n radius\r\n) =\u003E {\r\n let cornerRadius = { upperLeft: 0, upperRight: 0, lowerLeft: 0, lowerRight: 0 };\r\n if (typeof radius === \u0027object\u0027) {\r\n const radiusKeys = Object.keys(radius);\r\n for (const side of radiusKeys) {\r\n cornerRadius[side] = radius[side];\r\n }\r\n } else {\r\n cornerRadius = { upperLeft: radius, upperRight: radius, lowerLeft: radius, lowerRight: radius };\r\n }\r\n\r\n ctx.save();\r\n\r\n if (stroke) {\r\n radiusPath(ctx, x, cornerRadius, y, width, height);\r\n ctx.clip();\r\n ctx.lineWidth *= 2;\r\n }\r\n\r\n radiusPath(ctx, x, cornerRadius, y, width, height);\r\n if (stroke) {\r\n ctx.stroke();\r\n } else {\r\n ctx.fill();\r\n }\r\n\r\n ctx.restore();\r\n};\r\n\r\nfunction radiusPath(\r\n ctx,\r\n x,\r\n cornerRadius,\r\n y,\r\n width,\r\n height\r\n) {\r\n ctx.beginPath();\r\n ctx.moveTo(x \u002B cornerRadius.upperLeft, y);\r\n ctx.lineTo(x \u002B width - cornerRadius.upperRight, y);\r\n ctx.quadraticCurveTo(x \u002B width, y, x \u002B width, y \u002B cornerRadius.upperRight);\r\n ctx.lineTo(x \u002B width, y \u002B height - cornerRadius.lowerRight);\r\n ctx.quadraticCurveTo(x \u002B width, y \u002B height, x \u002B width - cornerRadius.lowerRight, y \u002B height);\r\n ctx.lineTo(x \u002B cornerRadius.lowerLeft, y \u002B height);\r\n ctx.quadraticCurveTo(x, y \u002B height, x, y \u002B height - cornerRadius.lowerLeft);\r\n ctx.lineTo(x, y \u002B cornerRadius.upperLeft);\r\n ctx.quadraticCurveTo(x, y, x \u002B cornerRadius.upperLeft, y);\r\n ctx.closePath();\r\n}\r\ndrawRoundRect(cachedctx, 0, 0, 100, 100, 5)","TestCases":[{"Name":"Cached","Code":"masterctx.drawImage(cached,0,0);","IsDeferred":false},{"Name":"draw rect round border","Code":"drawRoundRect(masterctx, 0, 0, 100, 100, 5)","IsDeferred":false},{"Name":"draw rect","Code":"masterctx.strokeRect(0, 0, 100, 100);","IsDeferred":false}]}