favoritos
Version:
Favoritos is a JavaScript plugin that adds some HTML5 canvas magic to your favicon. With just a wee bit of code, we can make some really cool effects.
27 lines (24 loc) • 753 B
JavaScript
/**
*
* favoritos
*
* @version 1.1.0
* @author Alexey Istomin
* @email: webistomin@gmail.com
* @license: MIT
*
**/
var roundedRect = function roundedRect(context, x, y, width, height, radius) {
var rectX = x;
var rectY = y;
var rectWidth = width;
var rectHeight = height;
var cornerRadius = Math.min(Math.max(width - 1, 1), Math.max(height - 1, 1), radius);
context.lineJoin = 'round';
context.lineWidth = cornerRadius;
context.strokeRect(rectX + cornerRadius / 2, rectY + cornerRadius / 2, rectWidth - cornerRadius, rectHeight - cornerRadius);
context.fillRect(rectX + cornerRadius / 2, rectY + cornerRadius / 2, rectWidth - cornerRadius, rectHeight - cornerRadius);
context.stroke();
context.fill();
};
export { roundedRect };