-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.html
196 lines (147 loc) · 4.68 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Noise flow field painter</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
<link rel="icon" href="image/1.ico" type="image/x-icon">
<link rel="shortcut icon" href="image/1.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="fonts.css">
<script type="text/javascript" src="js/dat.gui.min.js"></script>
<script type="text/javascript" src="js/p5.min.js"></script>
<script type="text/javascript" src="js/p5.dom.js"></script>
<script type="text/javascript" src="js/p5.dom.min.js"></script>
<input id="img-path" type="file" />
<style type="text/css">
*{
margin:0;
padding:0;
}
#credits {
font-size: 12px;
position: absolute;
bottom: 25px;
right: 15px;
color: #303030;
max-width: 70%;
text-align: right;
line-height: 20px;
}
.logo {
font-size: 12px;
position: absolute;
bottom: 80px;
left: 25px;
color: #ffffff;
max-width: 70%;
line-height: 20px;
opacity: 0.7;
}
.social{
opacity: 0.7;
}
.iconlink{
bottom: 50px;
margin-right: 0px;
}
#img-path {
display: none;
}
</style>
</head>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?44f8fa2f0b239ea3093628142486b48a";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<body>
<div id="credits">
<div class = "social" style="margin-right:10px">This tool is based on <a href ='https://www.openprocessing.org/sketch/472966' target='_blank'><strong>Jason Labbe's fantasitc project</strong></a></div>
</div>
<div class = "logo" style="margin-left:10px; margin-bottom: -40px; "><a href = "https://wangyasai.github.io/designtools.html"><img src="logo.png" style ="width: 40px"></a></div>
<script type="text/javascript">
var type;
var options ={
drawTimes: 280,
strokeLength: 40,
strokeWeight: 25,
noiseScale: 0.002,
Image_DataURL :'',
'Upload Image': function(){
// you need to create an input element in HTML, explained later
var input = document.getElementById('img-path');
input.addEventListener('change', function() {
var file = input.files[0];
r = new FileReader();
r.onload = function (){
gui['Image_DataURL'] = r.result;
console.log(r.result)
p5LoadImage(r.result);
type ='image';
}
r.readAsDataURL(file);
for (var i in gui.__controllers) {
gui.__controllers[i].updateDisplay();
}
});
input.click();
},
Random: function () {
options.strokeLength = random(30,60);
options.noiseScale= random(0.001,0.008);
options.drawTimes = random(250,600);
options.strokeWeight = random(10,40);
},
Save: function(){
saveFrames("image", "png", 1, 1);
},
}
//upload image
var GuiConfig = function() {
this['Image Path'] = 'image/a.png'; // default image path
this['UploadImage'] = function() {
};
};
var gui, config,LengthControl, strokeWeightControltimesControl,RandomControl,UploadImg,strokeLengthControl,noiseScaleControl,DistanceControl, pngControl;
window.onload = function() {
gui = new dat.GUI();
//folder1
var folder1 = gui.addFolder('Controls');
UploadImg = folder1.add(options, 'Upload Image');
strokeLengthControl = folder1.add(options, 'strokeLength',25,60);
strokeLengthControl.onChange(setup);
strokeLengthControl.listen();
strokeWeightControl = folder1.add(options, 'strokeWeight',20,40);
strokeWeightControl.onChange(setup);
strokeWeightControl.listen();
noiseScaleControl = folder1.add(options, 'noiseScale',0.001,0.008);
noiseScaleControl.onChange(setup);
noiseScaleControl.listen();
timesControl = folder1.add(options, 'drawTimes',250,600);
timesControl.onChange(setup);
timesControl.listen();
RandomControl = folder1.add(options, 'Random');
RandomControl.onChange(setup);
var SaveControl = folder1.add(options, 'Save');
SaveControl.onChange(save);
folder1.open();
};
//rgb to hex颜色转换
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
function rgbToHex(r, g, b) {
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
</script>
<script type="text/javascript" src="js/sketch.js"></script>
</body>
</html>