Dynamic HTML 5 Canvas title component with horisontal skewing and masking.
ACHTUNG! Current version does not support WebFonts.
bower install rectitle
| IE | Safari | Google Chrome | Firefox | Opera |
|---|---|---|---|---|
| 9+ | 7+ | 31+ | 26+ | 19+ |
The following code achieves the image included above:
<h1>Headline</h1>
<script src="scripts/rectitle.js"></script>
<script>
var heading = document.querySelectorAll('h1')[0];
var config = {
backgroundColor: '#000',
mask: true,
horizontalSkew: -0.05,
backgroundPadding: {
left: 10,
top: 10,
bottom: 10,
right: 10
},
opacity: 0.8
};
var rectitle = new RecTitle(config);
rectitle.render(heading);
</script>| Option | Description |
|---|---|
backgrounColor |
String. Colour of the rectangle background (hex) |
backgroundOpacity |
Number. Opacity of the rectangle (0-1) |
backgroundPadding |
Object. Padding of the content in rectangle on all edges (top, right, bottom, left; see Example) |
opacity
|
Number. Overall opacity of all grapihcs, incl. text (0-1) |
mask
|
Boolean. Whether or not text masks the rectangle |
horizontalSkew
|
Number. Skew amount for transformation matrix |
fontFamily
|
String. Font family, same as CSS font-family
|
fontSize |
Number. Font size |
fontColor |
String. Hex colour code |
className |
Element class name attribute appended to canvas element |
id |
Element ID attribute appended to canvas element |
See release tags.
Contributions are regulated as regular, fork, create a contribution-specific branch and send a Pull Request.
-
npm ito install Node.js dependencies -
grunt serverto run server which runs tests automatically wheneversrc/rectitle.jsis changed.



