导航:首页 > 编程语言 > 数字点阵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相关的资料

热点内容
迅雷影音文件夹 浏览:109
makefile的文件路径 浏览:392
计算机程序文件名扩展名为 浏览:982
网络游戏推广策划案 浏览:609
替换所有文件内容的代码 浏览:960
不是常用数据模型有哪些 浏览:426
aspcms版本号 浏览:835
安卓怎么用数据流量下载软件 浏览:553
大众手动空调数据流通道号是多少 浏览:303
手机qq令牌 浏览:737
cg原画上色教程 浏览:993
婚介服务中心app怎么做 浏览:43
日本苹果66g多少钱 浏览:93
个性的文件夹名称 浏览:697
怎么设置文件打开密码 浏览:811
手机版qq客服代码怎么用 浏览:24
fme可以打开哪些文件 浏览:339
好看的qq密码 浏览:293
安卓唯一标识有哪些 浏览:243
win10ime 浏览:271

友情链接