あるボックスを別のボックスの上に描画する際の問題に気づきました。要求に応じて、ここにコードがありますが、より詳細に
function draw(x,y,w,h,c){
ctx.fillStyle=c;
ctx.strokeStyle=c;
ctx.lineWidth=1;
ctx.globalAlpha=1.0;
ctx.fillRect(x,y,w,h);
}
function Rectangle(x,y,w,h,c){
this.x=x;
this.y=y;
this.w=w;
this.h=h;
this.c=c;
this.draw=draw;
this.onMouseEnter=function(){
this.c='rgb(0,0,0)'; //black
this.draw();
}
this.onMouseLeave=function(){
this.c='rgb(255,255,255)'; //white
this.draw();
}
}
box=new Rectangle(10,10,110,110,'rgb(255,255,255)'); //black box at
静止しているボックスは白ですが、ホバーすると黒に変わります。ただし、まだ白い境界線があります。寸法ではなく色を変更しているので、これは私の側の計算エラーではないと確信しています。また、他のほとんどのonHover関数でこの問題が発生していることに気づきました。
HTMLで他のオブジェクトを描画する際にこれらの問題が発生するのはなぜですか。
ありがとう