書き逃げアンドロイド。

副交感神経が優位になるような写真が好き。

startUp01

2021年01月26日 12時02分20秒 | 日記

startUp01

<canvas width="450" height="350" id="startUp01" style="background-color:rgba(255, 255, 255, 1.0);"></canvas>

<script>
var canvas = document.getElementById('startUp01');
var context = canvas.getContext('2d');
var x = canvas.width / 2;
var y = canvas.height / 2;
var size = 5;
var vect_x = 1;
var vect_y = 1;

function draw(){
    context.globalCompositeOperation = "source-over";
    context.fillStyle = "black";
    context.globalAlpha = 1.0;
    context.fillRect(0, 0, canvas.width, canvas.height);

    context.beginPath();
    context.globalCompositeOperation = "lighter";
    context.fillStyle = "white";
    context.globalAlpha = 0.5;
    context.arc(x, y, size, 0, Math.PI*2, false);
    context.fill();

    x += vect_x;
    y += vect_y;

    if(x < 0 || x > canvas.width){
         vect_x *= -1;
    }
    if(y < 0 || y > canvas.height){
         vect_y *= -1;
    }
}
setInterval(draw,32);
</script>

 

実行サンプル -Seesaaブログ

Ende;