jQ - 刮刮卡

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		img {
			display: block;
			width: 100%;
		}
		div {
			width: 200px;
			height: 200px;
			background: red;
		}
	</style>
</head>
<body>
	<div>
		<img src="i/1.jpg" id="test_eraser">
	</div>

	<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
	<script src="jquery.eraser.js"></script>
	<script>
		$('img').eraser({
			size: 10, // 橡皮擦直徑, 越小擦拭進度越精準
			opacity: 1, // 擦拭力度 (0, 1], 默認1
			width: 0, // 刮刮圖層大小, !1默認填充畫布
			height: 0,
			completeRatio: .5, // 擦拭完成比例 (0, 1], 默認1
			completeFunction: function () { // 擦拭完成
				// $(test_eraser).eraser('clear'); // 需要用對象id
				$(test_eraser).eraser('reset');
			},
			progressFunction: function (e) { // 擦拭進度 (0 ,1)
				console.log(e);
			}
		});
	</script>
</body>
</html>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章