導航:首頁 > 編程語言 > 數字點陣js

數字點陣js

發布時間:2023-08-20 14:28:20

Ⅰ 給定一個漢字如何得到它的點陣

我知道你的意思,是想在數字顯示時用到字的點陣數據吧,
我有一個方法,將該字以你想要的字體,大小,用textout輸出,然後再
用CDC 的getpiexl讀取顯示字元的區域,根據像素值就可以得到點陣了,
這樣子,你可以得到各種字體,各大小的字元點陣,甚至是任意字元集

js顯示剩下的時間

<html>
<head>
<title></title>
<scripttype="text/javascript"language="javascript">
functiongetTime(){//js函數,定期執行的函數主體
vardateTime=newDate();//新建系統時間的對象
varhour=formatTime(dateTime.getHours());//獲取小時並格式化,格式化函數formatTime(),下同
varminute=formatTime(dateTime.getMinutes());//獲取分
varsecond=formatTime(dateTime.getSeconds());//獲取秒
//varmillisecond=dateTime.getMilliseconds();//獲取毫秒
varcode="當前時間是:"+hour+":"+minute+":"+second;//+""+millisecond;//第一個div的內容(數字時鍾)
varcodeChinese="當前時間是:"+formatChinese(hour)+"時"+formatChinese(minute)+"分"+formatChinese(second)+"秒";//第二個div的內容(中文時鍾)
document.getElementById("divTime").innerHTML=code;//第一個div內容填充
document.getElementById("divTimeChinese").innerHTML=codeChinese;//第二個div內容填充
document.getElementById("monDigitalClock").innerHTML=makeMonCode(hour.toString()+":"+minute.toString()+":"+second.toString())+blockEmpty();//+makeMonCode(millisecond.toString());
updateLatestTime();//更新剩餘時間
}
functionformatTime(num){//格式化數字,小於10時在數字前添加0
if(num<10){
return"0"+num;
}
else{
returnnum;
}
}
functionformatChinese(num){//中文格式處理
varstr=String(num);
if(str.length==1){//一位數的情況,直接返回中文
returnformatSingleNumber(str);
}
else{//兩位數的情況
varmid="十";
vartop=str.substr(0,1);//第一位
varbtn=str.substr(1,2);//第二位
return(formatSingleNumber(top)+mid+formatSingleNumber(btn)).replace("零十","零").replace("十零","十").replace("零零","零").replace("一十","十");//使用formatSingleNumber函數轉換成中文並將不符合中文數字表示方法的替換一下
}

}

functionformatSingleNumber(num){//單個數字轉化成中文
returnnum.replace("1","一").replace("2","二").replace("3","三").replace("4","四").replace("5","五").replace("6","六").replace("7","七").replace("8","八").replace("9","九").replace("0","零");
}
setInterval("getTime();",1000);//定時刷新,每毫秒刷新一次//模擬時鍾代碼
functionbuidlPointArea(num){//將數字對應的點陣拼接成圖案
varcode="<divclass='singleNumber'>";
for(vari=1;i<6;i++){
for(varj=1;j<5;j++){
code+=createSinglePoint(i+"_"+j,num);
}
}
code+="</div>";
returncode;
}


functioncreateSinglePoint(id,num){//數字對應的黑點
vararray0=newArray("1_1","1_2","1_3","2_1","2_3","3_1","3_3","4_1","4_3","5_1","5_2","5_3");//數字0的點陣,下同
vararray1=newArray("1_3","2_3","3_3","4_3","5_3");
vararray2=newArray("1_1","1_2","1_3","2_3","3_1","3_2","3_3","4_1","5_1","5_2","5_3");
vararray3=newArray("1_1","1_2","1_3","2_3","3_1","3_2","3_3","4_3","5_1","5_2","5_3");
vararray4=newArray("1_1","1_3","2_1","2_3","3_1","3_2","3_3","4_3","5_3");
vararray5=newArray("1_1","1_2","1_3","2_1","3_1","3_2","3_3","4_3","5_1","5_2","5_3");
vararray6=newArray("1_1","1_2","1_3","2_1","3_1","3_2","3_3","4_1","4_3","5_1","5_2","5_3");
vararray7=newArray("1_1","1_2","1_3","2_3","3_3","4_3","5_3");
vararray8=newArray("1_1","1_2","1_3","2_1","2_3","3_1","3_2","3_3","4_1","4_3","5_1","5_2","5_3");
vararray9=newArray("1_1","1_2","1_3","2_1","2_3","3_1","3_2","3_3","4_3","5_1","5_2","5_3");
varnumArr=newArray();
numArr[0]=array0;
numArr[1]=array1;
numArr[2]=array2;
numArr[3]=array3;
numArr[4]=array4;
numArr[5]=array5;
numArr[6]=array6;
numArr[7]=array7;
numArr[8]=array8;
numArr[9]=array9;
varcls="whitePoint";
for(vari=0;i<numArr[num].length;i++){
if(id==numArr[num][i]){
cls="blackPoint";
}
}
return"<divid='"+id+"'class='"+cls+"'></div>";
}

functionblockEmpty(){//空格代碼
return"<divclass='singleNumber'></div>";
}


functionblockM(){//冒號的代碼
varcode="";
code+="<divclass='singleNumber'><divclass='whitePoint'></div>";
code+="<divclass='whitePoint'></div>";
code+="<divclass='whitePoint'></div>";
code+="<divclass='whitePoint'></div>";
code+="<divclass='whitePoint'></div>";
code+="<divclass='blackPoint'></div>";
code+="<divclass='whitePoint'></div>";
code+="<divclass='whitePoint'></div>";
code+="<divclass='whitePoint'></div>";
code+="<divclass='whitePoint'></div>";
code+="<divclass='whitePoint'></div>";
code+="<divclass='whitePoint'></div>";
code+="<divclass='whitePoint'></div>";
code+="<divclass='blackPoint'></div>";
code+="<divclass='whitePoint'></div>";
code+="<divclass='whitePoint'></div>";
code+="<divclass='whitePoint'></div>";
code+="<divclass='whitePoint'></div>";
code+="<divclass='whitePoint'></div>";
code+="<divclass='whitePoint'></div></div>";
returncode;
}


functionmakeMonCode(totalCode){//生成模擬的數字時鍾代碼
varfinalCode="";
for(vari=0;i<totalCode.length;i++){//每個字元分別轉換
if(isNaN(totalCode[i])){//非數字字元,例子中只有冒號
if(totalCode[i]==":"){
finalCode+=blockM();//冒號的代碼,用blockM()函數生成
}
}
else{
finalCode+=buidlPointArea(totalCode[i]);//數字的代碼,用buildPointArea()函數生成
}
}
returnfinalCode;
}
functionupdateLatestTime(){//更新剩餘時間
varsetHour=document.getElementById("sltHour").value;//獲取選擇的小時值
varsetMin=document.getElementById("sltMin").value;//獲取選擇的分值
varsetSecond=document.getElementById("sltSecond").value;//獲取選擇的秒值
vartime=newDate();//獲取系統時間
varnowHour=time.getHours();//當前時間小時值
varnowMin=time.getMinutes();//當前時間分值
varnowSecond=time.getSeconds();//當前時間秒值
varviewHour=setHour-nowHour;//剩餘小時
varviewMin=setMin-nowMin;//剩餘分鍾
varviewSecond=setSecond-nowSecond;//剩餘秒
if(viewSecond<0){//剩餘秒小於0時,借位
viewSecond+=60;
viewMin-=1;
}
if(viewMin<0){//剩餘分小於0時,借位
viewMin+=60;
viewHour-=1;
}
if(viewHour<0){//剩餘小時小於0時,借位
viewHour+=24;
}

document.getElementById("divLatestTime").innerHTML="剩餘時間為:"+viewHour+"時"+viewMin+"分"+viewSecond+"秒";//填充
if(viewHour==0&&viewMin==0&&viewSecond==0){//到點提示
alert("到點了!");
}
}
functioncreateSelect(){//生成選擇框代碼
varcode="";
code+="請選擇鬧鍾時間:<selectid='sltHour'onchange='updateLatestTime()'>";
for(vari=1;i<25;i++){
code+="<optionvalue='"+i+"'>"+i+"</option>";
}
code+="</select>時";
code+="<selectid='sltMin'onchange='updateLatestTime()'>";
for(vark=1;k<61;k++){
code+="<optionvalue='"+k+"'>"+k+"</option>";
}
code+="</select>分";
code+="<selectid='sltSecond'onchange='updateLatestTime()'>";
for(varj=1;j<61;j++){
code+="<optionvalue='"+j+"'>"+j+"</option>";
}
code+="</select>秒";
document.getElementById("divAlert").innerHTML=code;
}

</script>
<styletype="text/css">
body{
background-color:#FFFFFF;
}

.clsTime{
width:600px;
height:50px;
font-size:30px;
margin-left:auto;
margin-right:auto;
margin-top:100px;
}

.whitePoint{
width:10px;
height:10px;
background-color:#FFFFFF;
margin:0px;
padding:0px;
float:left;
}

.blackPoint{
width:10px;
height:10px;
background-color:#000000;
margin:0px;
padding:0px;
float:left;
}

.clsMonDigitalClock{
margin-left:auto;
margin-right:auto;
width:480px;
height:50px;
background-color:#FFFFFF;
}

.singleNumber{
width:40px;
height:50px;
float:left;
font-size:8px;
}

.clsAlert{
width:400px;
margin-top:50px;
margin-left:auto;
margin-right:auto;
}

.clsLatestTime{
width:400px;
margin-top:50px;
margin-left:auto;
margin-right:auto;
}
</style>
</head>
<bodyonload="createSelect();">
<divid="divTime"class="clsTime">loading....</div>
<divid="divTimeChinese"class="clsTime">loading....</div>
<divid="monDigitalClock"class="clsMonDigitalClock"></div>
<divid="divAlert"class="clsAlert"></div>
<divid="divLatestTime"class="clsLatestTime"></div>

</body>
</html>

之前做著玩的,有你說到的功能,有興趣看看。代碼存為html即可。

Ⅲ 按鍵精靈點陣識別數字的問題

存兩個數組,搞二維數組不好處理,按鍵精靈不支持結構體的,你這樣做反而給自己添麻煩,你分兩個數組寫,還用得著這樣折騰嗎?

閱讀全文

與數字點陣js相關的資料

熱點內容
驅動程序順序安裝腳本 瀏覽:665
word文件里怎樣查重 瀏覽:219
mx5系統基帶版本 瀏覽:184
ntlea全域通win10 瀏覽:171
qq怎麼查看別人的收藏 瀏覽:135
地震三參數matlab程序 瀏覽:57
怎樣給優盤文件加密軟體 瀏覽:7
收拾文件有哪些小妙招 瀏覽:431
pdf文件去底網 瀏覽:253
win10重裝系統需要格式化c盤嗎 瀏覽:424
路由器trx文件 瀏覽:655
淘寶店鋪數據包怎麼做 瀏覽:195
win10鍵盤黏連 瀏覽:332
json如何生成表格 瀏覽:323
怎麼修復sql資料庫表 瀏覽:40
微信微博差別 瀏覽:163
簽到積分換禮品app 瀏覽:812
mfc最近打開文件 瀏覽:672
app埋點平台都有哪些app 瀏覽:314
瑞斯康達網路管理界面 瀏覽:254

友情鏈接