-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_wcbv.js
69 lines (60 loc) · 1.76 KB
/
test_wcbv.js
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
wc = new WordcloudJS();
$(document).ready(function () {
$("#scene").css("background-color", "#ffffff");
$("#canvasWrapper").css("margin-top", "100px");
$("#btn_back").click(function () {
window.location = "index.html";
});
// Controller
$("#value_minsize").html($("#input_minsize").val());
$("#input_minsize").mousemove(function () {
build();
$("#value_minsize").html($("#input_minsize").val());
});
$("#input_option").mousemove(function () {
build();
var val = parseInt($("#input_option").val());
if (val == 0) {
$("#value_option").html("all");
} else if (val == 1) {
$("#value_option").html("empty");
} else if (val == 2) {
$("#value_option").html("filled");
}
});
$("#input_fill").change(function () {
build();
});
build();
});
function build() {
$("#canvasWrapper canvas").remove();
var text = "WordCloud";
var fontSize = 200;
var boundingVolumeMinSize = parseInt($("#input_minsize").val());
var bvColor = "#ff0000";
var bvFill = $("#input_fill").prop("checked");
var bvDrawOption = "all";
var val = parseInt($("#input_option").val());
if (val == 0) {
bvDrawOption = "all";
} else if (val == 1) {
bvDrawOption = "empty";
} else if (val == 2) {
bvDrawOption = "filled";
}
var word = new wc.createWord({
text: text,
boundingVolumeMinSize: boundingVolumeMinSize,
style: {
fontSize: fontSize,
fontFamily: "Arial"
}
});
var canvas = word.drawWordOnCanvas({
color: bvColor,
fill: bvFill,
drawOption: bvDrawOption
});
$("#canvasWrapper").append(canvas);
}