-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathccc.html
More file actions
67 lines (50 loc) · 1.61 KB
/
ccc.html
File metadata and controls
67 lines (50 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
#gg2 { background:no-repeat;
}
</style>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
<canvas id="myCanvas" width="578" height="200"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
// draw cloud
context.beginPath();
context.moveTo(170, 80);
context.bezierCurveTo(130, 100, 130, 150, 230, 150);
context.bezierCurveTo(250, 180, 320, 180, 340, 150);
context.bezierCurveTo(420, 150, 420, 120, 390, 100);
context.bezierCurveTo(430, 40, 370, 30, 340, 50);
context.bezierCurveTo(320, 5, 250, 20, 250, 50);
context.bezierCurveTo(200, 5, 150, 20, 170, 80);
context.closePath();
context.lineWidth = 5;
context.fillStyle = '#8ED6FF';
context.fill();
context.strokeStyle = '#0000ff';
context.stroke();
// save canvas image as data url (png format by default)
var dataURL = canvas.toDataURL();
</script>
<script >
$(document).ready(function(e) {
$("#gg").click(function(e) {
// alert (dataURL);
$("#jj").attr("src",dataURL );
var temp_url ="url(" +dataURL + ")" ;
$("#gg2").css("background-image",temp_url );
});
});
</script>
</body>
<div id="gg"> asdfsadf<img id="jj" src="" /> </div>
<div id="gg2" style="width:500px; height:200px; overflow:hidden"> gggg </div>
</html>