Here's one that works in Sigil (and I assume iBooks)
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
//<![CDATA[
function draw_square() {
var c1 = document.getElementById("c1");
var c1_context = c1.getContext("2d");
c1_context.fillStyle = "#f00";
c1_context.fillRect(50, 50, 100, 100);
}
//]]>
</script>
</head>
<body>
<canvas id="c1" width="200" height="200" style="border:solid 1px #000000;"></canvas>
<div>
<button onclick="draw_square();return true;">Red Square</button>
</div>
</body>
</html>
This is taken directly from
http://www.html5tutorial.info/html5-canvas-rect.php where you can find many other examples...
-Bill