小编推荐的这篇文章介绍了canvas实现钟表效果的实例代码,实现后效果非常酷炫,有兴趣的快看看吧。
效果如下:
代码如下:
代码如下 复制代码
<!DOCTYPE html>
<html>
<head>
<metacharset="UTF-8">
<title>canvas画钟表</title>
<style>
body{
background: #fc0;
}
#canvas1{
background: #fff;
}
</style>
</head>
<body>
<canvasid="canvas1"width="400"height="400"></canvas>
<script>
var oC=document.getElementById('canvas1');
var oGC=oC.getContext('2d');
function toDraw(){
var x=200;
var y=200;
var r=150;
oGC.clearRect(0,0,oC.width,oC.height);
var oDate=new Date();
var oHour=oDate.getHours();
var oMinu=oDate.getMinutes();
var oSec=oDate.getSeconds();
var hVal=(-90+oHour*30+oMinu/2)*Math.PI/180;
var mVal=(-90+oMinu*6)*Math.PI/180;
var sVal=(-90+oSec*6)*Math.PI/180;
oGC.beginPath();
for(i=0;i<60;i++){
oGC.moveTo(x,y);
oGC.arc(x,y,r,6*i*Math.PI/180,6*(i+1)*Math.PI/180,false);
}
oGC.closePath();
oGC.stroke();
oGC.fillStyle='#fff';
oGC.beginPath();
oGC.moveTo(x,y);
oGC.arc(x,y,r*19/20,0,360*Math.PI/180,false);
oGC.closePath();
oGC.fill();
oGC.lineWidth=3;
oGC.beginPath();
for(i=0;i<12;i++){
oGC.moveTo(x,y);
oGC.arc(x,y,r,30*i*Math.PI/180,30*(i+1)*Math.PI/180,false);
}
oGC.closePath();
oGC.stroke();
oGC.fillStyle='#fff';
oGC.beginPath();
oGC.moveTo(x,y);
oGC.arc(x,y,r*18/20,0,360*Math.PI/180,false);
oGC.closePath();
oGC.fill();
oGC.lineWidth=5;
oGC.beginPath();
oGC.moveTo(x,y);
oGC.arc(x,y,r*10/20,hVal,hVal,false);
oGC.closePath();
oGC.stroke();
oGC.lineWidth=3;
oGC.beginPath();
oGC.moveTo(x,y);
oGC.arc(x,y,r*14/20,mVal,mVal,false);
oGC.closePath();
oGC.stroke();
oGC.lineWidth=1;
oGC.beginPath();
oGC.moveTo(x,y);
oGC.arc(x,y,r*17/20,sVal,sVal,false);
oGC.closePath();
oGC.stroke();
}
setInterval(toDraw,1000);
toDraw();
</script>
</body>
</html>
没有了
小编推荐的这篇文章介绍了Mybatis结果生成键值对的实例代码,非常实用,有兴趣的同学快来看看吧。
在实际应用中我们经常会遇到这样的情况,需要给下拉框赋值,这个时候就需要键值对了,具体使用方法如下
1,在maper.xml文件中定义结果类型(resultType)定义为hashmap,如下所示
代码如下 复制代码
<select id="selectSuperUnitInfo"resultType="hashmap">
SELECT unit_id ,unit_name from unit_info
</select>
2,在对应的mapper类中用List<Map<String,String>>来接受这个类型,如下所示
代码如下 复制代码
publicList<Map<String,String>> selectSuperUnitInfo();
其实最强大的莫过于resultMap类型了,这个可以在mapper.xml文件中自定义扩展类型,然后在包中添加这个类型即可,真是强大
下面给大家补充下MyBatis返回Map键值对数据
代码如下 复制代码
List<Map<String, String>> getMtypeList();
<select id="getMtypeList"resultType="java.util.HashMap">
select code,`name` from jk_control_measure
</select>
[DEBUG]2016-08-2917:50:09:==> Executing: select code,`name` from jk_control_measure
[DEBUG]2016-08-2917:50:09:==> Parameters:
[DEBUG]2016-08-2917:50:10:<== Columns: code, name
[DEBUG]2016-08-2917:50:10:<== Row: one, 地面冲洗
[DEBUG]2016-08-2917:50:10:<== Row: two, 边界围挡
[DEBUG]2016-08-2917:50:10:<== Row: three, 垃圾覆盖
[DEBUG]2016-08-2917:50:10:<== Row: four, 裸地覆盖
[DEBUG]2016-08-2917:50:10:<== Row: five, 洒水降尘
[DEBUG]2016-08-2917:50:10:<== Row: six, 车辆冲洗
[DEBUG]2016-08-2917:50:10:<== Row: seven, 建筑渣土
[DEBUG]2016-08-2917:50:10:<== Row: eight, 车辆冒装
[DEBUG]2016-08-2917:50:10:<== Row: nine, 扬尘覆盖
[DEBUG]2016-08-2917:50:10:<== Row: ten, 车辆撒漏
[DEBUG]2016-08-2917:50:10:<== Row: eleven, 车辆黑烟
[DEBUG]2016-08-2917:50:10:<== Row: twelve, 道路积尘<br>
[{"NAME":"地面冲洗","name":"地面冲洗","code":"one","CODE":"one"},
{"NAME":"边界围挡","name":"边界围挡","code":"two","CODE":"two"},
{"NAME":"垃圾覆盖","name":"垃圾覆盖","code":"three","CODE":"three"},
{"NAME":"裸地覆盖","name":"裸地覆盖","code":"four","CODE":"four"},
{"NAME":"洒水降尘","name":"洒水降尘","code":"five","CODE":"five"},
{"NAME":"车辆冲洗","name":"车辆冲洗","code":"six","CODE":"six"},
{"NAME":"建筑渣土","name":"建筑渣土","code":"seven","CODE":"seven"},
{"NAME":"车辆冒装","name":"车辆冒装","code":"eight","CODE":"eight"},
{"NAME":"扬尘覆盖","name":"扬尘覆盖","code":"nine","CODE":"nine"},
{"NAME":"车辆撒漏","name":"车辆撒漏","code":"ten","CODE":"ten"},
{"NAME":"车辆黑烟","name":"车辆黑烟","code":"eleven","CODE":"eleven"},
{"NAME":"道路积尘","name":"道路积尘","code":"twelve","CODE":"twelve"}
]
返回的结果带有大写与小写的key
没有了