
<img src="img/num.gif" style="clip:rect(0px,60px,60px,0px);position:absolute;left:0px;top:0px;"> <img src="img/num.gif" style="clip:rect(0px,120px,60px,60px);position:absolute;left:0px;top:0px;"> <img src="img/num.gif" style="clip:rect(0px,180px,60px,120px);position:absolute;left:0px;top:0px;"> |
| 数字 | 画像内のX座標 | 描画されるX座標 | 描画される Y座標 |
|---|---|---|---|
| 数字0 | 0 | 0 | 0 |
| 数字1 | 60 | 60 | 0 |
| 数字2 | 120 | 120 | 0 |
<img src="img/num.gif" style="clip:rect(0px,60px,60px,0px);position:absolute;left:0px;top:0px;"> <img src="img/num.gif" style="clip:rect(0px,360px,60px,300px);position:absolute;left:-240px;top:0px;"> |
// 数字 num を座標 0,0 に描画
function View_Zero(num)
{ var pos = num*60;
var s1= 'style="clip:rect(0px,' + (pos+60) + 'px,60px,' + pos + 'px);';
var s2 = 'position:absolute;left:' + (0-pos) + 'px;top:0px;';
var s = '<img src="img/num.gif"' + s1 + s2 + '">';
document.write(s);
}
|
<script type="text/javascript">
View_Zero(0);
View_Zero(3);
View_Zero(8);
</script>
|
//「上, 右, 下, 左」の順
function View_Num(num, x, y)
{ var pos = num*60;
var s1= 'style="clip:rect(0px,' + (pos+60) + 'px,60px,' + pos + 'px);';
var s2 = 'position:absolute;left:' + (x-pos) + 'px;top:' + y + 'px;';
var s = '<img src="img/num.gif"' + s1 + s2 + '">';
//window.alert(s);
document.write(s);
}
|
<script type="text/javascript">
View_Num(3,100,100);
View_Num(2,160,100);
View_Num(1,220,100);
</script>
|
![]()
// 6桁でカウンターを描画
function View_Count(cnt)
{ var i,w,c;
w= cnt;
for(i=0; i<6; i++)
{ c= w%10; //下位の桁から取り出す
w= parseInt(w/10);
View_Num(c, 360-i*60,100);
}
}
|
<script type="text/javascript">
View_Count(14375);
</script>
|
![]()