Canvas moduleCanvas module is for image manipulation purposes. You can generate image for your styles on fly. It gives you unlimited possibilities to create graphics that matches your theme colors or styles. And it is all inside you *.tea file. teacss.Canvas is javascript api for image creation and adjustment. It has no dependecies with teacss.core, but is inteded to be used inside tea files. Under the hood
| Simple examplevar canvas = new Canvas('foo.jpg') .brightnessContrast(10,20) .multiplyColor('red') .draw2D(function(ctx,c2d) { ctx.strokeWidth = 5; ctx.moveTo(0,0); ctx.lineTo(c2d.width,c2d.height); }) canvas.background('foo_bg.png'); Code is pretty self-explanatory. First, we load 'foo.jpg' adjust brightness and contrast, then colorize it with red and later add some drawings on top. Then we use it as element background and point that we want to save that image as 'foo_bg.png' if we are in production. |
Live sample (simple background generator), FF & Chrome only
Use colorpickers on the right to generate background image. You can review the full code behind the link (with teacss.ui code):canvas_demo.tea And here is all the tea code needed for this sample. body { @{ // pretty clear here, huh? var canvas = new Canvas("src.png"); canvas.replaceColors( { '#ffae00':picker1.value, '#f7e7ba':lighten(picker1.value,30), '#705551':picker2.value }); // display canvas.background('bg.png'); } } | Sorry, no Opera and no IE for this sample. WebGL has to be enabled. |