一个用Canvas做的“计时器”

Plux posted @ 2009年12月08日 20:55 in Default with tags canvas javascript , 2066 阅读

很久没有发代码了。发一个用HTML 5 Canvas做的简单计时器……

<html>
<head>
<title>A clock</title>
<script type="text/javascript">
var clock = 0;
window.onload = function () {
    setInterval(drawClock, 1000);
}
function drawClock() {
    var canvas = document.getElementById('drawing');
    if (canvas.getContext){
        ctx = canvas.getContext('2d');
        ctx.lineWidth = 5;
        // clear the drawing place.
        ctx.strokeStyle = "rgba(0, 0, 0, 1)";
        ctx.beginPath();
        ctx.arc(200, 50, 50, 0, Math.PI * 2, true);
        ctx.stroke();
        // start another drawing.
        ctx.lineCap = 'round';
        ctx.strokeStyle = "rgba(0, 250, 0, 0.8)";
        ctx.beginPath();
        ctx.arc(200, 50, 50, 0, Math.PI * clock, false);
        ctx.stroke();
    }
    if (clock >= 2) {
        clock = 0;
    } else {
        clock += 1 / 6;
    }
}
</script>
</head>
<body>
<canvas id="drawing" width="800" height="200"></canvas>
</body>
</html>

发现Canvas还是很强大的。

carpet cleaning duba 说:
Sep 10, 2019 08:24:07 PM

Currently you the ideal part occasion maid that you can be seeking. Someone that's trustworthy and that can keep the house sparkling clean up. You can discover them which has a simple visit our site. All each of our maids are generally well-trained, seasoned, and reputable professionals, just to help you relax as you move the work has done with the best property maids throughout Dubai. Our prior customers get shared and carry on and share testimonails from others and reviews that are positive for each of our maids. Consequently, leave your worry for you to us and target what’s most crucial to anyone while many of us clean the house and manage the duties.

house maid services 说:
Jan 25, 2021 07:48:55 PM

There are several services that will claim they have got the nearly all dependable maids in the marketplace. There are countless fly-by-night cleanup businesses sprouting up overnight, that it must be impossible to enable them to have effectively screened along with checked a bunch of their employees' references and qualification. You never want only anyone wandering into your own home and holding your issues. You desire only bondable, experienced along with trusted employees to keep up the cleaning duties at your residence.

painting company in 说:
Jun 21, 2021 05:51:56 PM

Year after year, I've lasted a point to reach know your competition. Basically, they're really efficient at painting like a professional. Not so competent at running a business. They does a considerable amount of volume except for make a lot of profit. Here's a perfect situation. One night my partner and i met some semi-competitor from a dinner. He volunteered the quantity of business he had done the last year. It's the comparable amount there was done. Then i asked him the total number of painters functioned for your man. Twice as many as worked right now! That's best suited. We did an identical amount from business and yet his workcrews costs are double mine.

maid agency dubai 说:
Sep 18, 2021 06:28:22 PM

Thus, start with all the windows’ casings and clear cloth. Don’t overlook an inch with the frames and you may use a vacuum cleaner at the same time to reduce all people nasty soil. Furthermore, work with a dedicated windowpane cleaner regarding experiencing any smudge-free, along with streak-free house windows. And, don’t find yourself using h2o; or different, you’ll must repeat the complete process to remove water staining. Let dozens of cleaners run dry independently. Additionally, clean the particular shutters and also curtains or perhaps other drapes and window treatments.

babysitting services 说:
Nov 30, 2022 06:15:09 PM

Everyone like uncluttered homes. Everyone know cleanness is near to Godliness! And everyone also know on occasion this can be a cumbersome undertaking, in the best way this can be a project, and keep the property tidy. This can be a luxury and keep the home because of this; given any time limitations along with factors. Nevertheless most of us cannot shirk the duty in clean-up and maintaining each of our house. You don’t get the perfect time to clean the property or you sense this can be a herculean undertaking; so on and the like. So, the best way to go in relation to?


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter