-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
104 lines (93 loc) · 3.86 KB
/
index.html
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0, user-scalable=no">
<title>Demo</title>
<script src="lib/jquery-3.1.1.min.js"></script>
<style type="text/css">
button:hover,
input[type=button]:hover {
background: rgb(9, 147, 240);
}
button:active,
input[type=button]:active {
background: rgb(10, 118, 190);
}
button[disabled],
input[type=button][disabled] {
background: none;
border: 1px solid rgb(187, 181, 181);
color: gray;
text-shadow: none;
}
body {
background-image: url("/img");
}
</style>
</head>
<body>
<div style="height:760px;" class="crysyan-designer">
<a id="download-png" download="my-file-name.png" style="color: #ff0206" class="btn btn-github">download png</a>
<button type="button" id="start-record">start-record</button>
<button id="stop-record">stop-record</button>
</div>
<div id="videoTag" style="height:500px;"></div>
</body>
</html>
<script src="js/crysyan-designer.js"></script>
<script>
$(".crysyan-designer").CrysyanDesigner({
projectPath: "",
isRecord: true,
canvas: {
// px
width: 1000,
height: 600
},
toolbar: {
// widgets: ["CursorWidget", "PencilWidget","ShapeWidget", "EraserWidget", "TextWidget", "UndoWidget", "IndoGoWidget", "ClearWidget"],
}
}, function (designer) {
$("#download-png").click(function () {
var canvas = designer.getView().crysyanCanvas;
document.getElementById("download-png").href = canvas.toDataURL();
});
console.dir(designer);
var image = new Image();
image.src = "http://dream.com:9977/img/pencil.png";
console.log(image instanceof Image);
var dataurl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAADFBMVEVYWFhVVVUAAABUVFTqqlXjAAAAA3RSTlMxdACUjPeLAAAATElEQVR42u3SQQrAMAwDQSn7/z+XFExTcOxroN3zgC4STecApy1gpP2gBgZXQMwKwJ23QITYACLlQBC9gAFNwJMXoJhVc7lBA/gsuAArEgqPcT12VgAAAABJRU5ErkJggg=="
designer.drawBackgroupWithImage("../img/crysyan-love.png");
var videoTag = document.getElementById("videoTag");
var videoEle;
var recorder = designer.getCanvasRecorder();
$("#start-record").click(function () {
document.getElementById('start-record').disabled = true;
document.getElementById('stop-record').disabled = false;
document.getElementById('start-record').innerHTML = "Recording";
console.log("recording");
if (videoEle instanceof HTMLVideoElement) videoTag.removeChild(videoEle);
recorder.initRecorder();
recorder.startRecording();
});
$("#stop-record").click(function () {
document.getElementById('start-record').disabled = false;
document.getElementById('stop-record').disabled = true;
document.getElementById('start-record').innerHTML = "start-record";
console.log("stop");
recorder.stopRecording(function () {
var blob = recorder.getBlob();
videoEle = document.createElement('video');
videoEle.src = URL.createObjectURL(blob);
// videoEle.setAttribute('style', 'height: 100%; position: absolute; top:0; left:0;z-index:9999;width:100%;');
videoTag.appendChild(videoEle);
videoEle.controls = true;
videoEle.play();
});
});
});
</script>