<html> <head> <title>CoffeScript Canvas</title> <script src="coffee-script.js"></script> <script type="text/coffeescript"> draw = () -> canvas = document.getElementById('coffee') if canvas.getContext ctx = canvas.getContext('2d') ctx.fillStyle = "rgb(200,0,0)" ctx.fillRect(10, 10, 55, 50) ctx.fillStyle = "rgba(0, 0, 200, 0.5)" ctx.fillRect(30, 30, 55, 50) draw() </script> <style type="text/css"> canvas { border: 1px solid black; } </style> </head> <body> <canvas id="coffee" width="150" height="150"></canvas> </body> </html>
Well, it's basically the same as with JavaScript.
No hay comentarios:
Publicar un comentario