-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
343 lines (305 loc) · 8.47 KB
/
test.html
File metadata and controls
343 lines (305 loc) · 8.47 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
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<!DOCTYPE html>
<head>
<title>LU MING-BIN</title>
<script src="/myscripts.js"></script>
</head>
<html>
<body>
<h1>hello world</h1>
<h2>Konva's Circle</h2>
<script src="https://unpkg.com/konva@3.4.1/konva.min.js"></script>
<div id="123456"></div>
<h1></h1>
<div id="container2"></div>
<h1></h1>
<div id="container3"></div>
<h1></h1>
<div id="container4"></div>
<h1></h1>
<div id="container5"></div>
<h1></h1>
<div id="container6"></div>
<h1></h1>
<div id="my container"></div>
<script src="myscripts.js"></script>
<script>
var stage = new Konva.Stage({
container:'my container',
width:800,
height:800
});
var layer = new Konva.Layer();
var rect1 = new Konva.Rect({
x: 0,
y: 0,
width: 400,
height: 400,
fill: 'green',
});
var rect2 = new Konva.Rect({
x: 200,
y: 200,
width: 200,
height: 200,
fill: 'blue',
stroke: 'white',
strokeWidth: 4
});
var rect3 = new Konva.Rect({
x: 200,
y: 0,
width: 200,
height: 200,
fill: 'yellow',
stroke: 'white',
strokeWidth: 4
});
var circle = new Konva.Circle({
x: stage.width() / 4, // x position of the center
y: stage.height() / 4, // y position of the center
radius: 70, // circle radius
fill: 'red', // color to fill the area
stroke: 'black', // color to draw the line
strokeWidth: 4 // line width
});
layer.add(rect1);
layer.add(rect2);
layer.add(rect3);
layer.add(circle);
stage.add(layer);
layer.draw();
</script>
<script>//Draw a house
var stage = new Konva.Stage({
container:'container6',
width:500,
height:300
});
var layer = new Konva.Layer();
var triangle_1 = new Konva.RegularPolygon({
x:100,
y:100,
sides:3,
radius:80,
fill:'red'
});
var rect_1 = new Konva.Rect({
x:48,
y:140,
width:100,
height:90,
fill:'gray'
});
var rect_2 = new Konva.Rect({
x:60,
y:160,
width:30,
height:70,
fill:'black'
});
var rect_3 = new Konva.Rect({
x:105,
y:160,
width:30,
height:30,
fill:'blue'
});
layer.add(triangle_1);
layer.add(rect_1);
layer.add(rect_2);
layer.add(rect_3);
stage.add(layer);
layer.draw();
</script>
<script>//Draw a tree
var stage = new Konva.Stage({
container:'container5',
width:500,
height:300
});
var layer = new Konva.Layer();
var triangle_1 = new Konva.RegularPolygon({
x:50,
y:50,
sides:3,
radius:30,
fill:'blue'
});
var triangle_2 = new Konva.RegularPolygon({
x:50,
y:80,
sides:3,
radius:40,
fill:'black'
});
var triangle_3 = new Konva.RegularPolygon({
x:50,
y:110,
sides:3,
radius:50,
fill:'green'
});
var rect = new Konva.Rect({
x:40,
y:135,
width:20,
height:80,
fill:'brown'
});
layer.add(triangle_1);
layer.add(triangle_2);
layer.add(triangle_3);
layer.add(rect);
stage.add(layer);
layer.draw();
</script>
<script>
var stage = new Konva.Stage({
container: 'container4',
width: 340,
height: 220
});
var layer = new Konva.Layer();
var simpleText = new Konva.Text({
x: stage.width() / 2,
y: 5,
text: 'Simple Text',
fontSize: 30,
fontFamily: 'Calibri',
fill: 'green'
});
// to align text in the middle of the screen, we can set the
// shape offset to the center of the text shape after instantiating it
simpleText.offsetX(simpleText.width() / 2);
// since this text is inside of a defined area, we can center it using
// align: 'center'
var complexText = new Konva.Text({
x: 20,
y: 50,
text:
"COMPLEX TEXT\n\nAll the world's a stage, and all the men and women merely players. They have their exits and their entrances.",
fontSize: 18,
fontFamily: 'Calibri',
fill: '#555',
width: 300,
padding: 20,
align: 'center'
});
var rect = new Konva.Rect({
x: 20,
y: 50,
stroke: '#555',
strokeWidth: 5,
fill: '#ddd',
width: 300,
height: complexText.height(),
shadowColor: 'black',
shadowBlur: 10,
shadowOffset: [10, 10],
shadowOpacity: 0.2,
cornerRadius: 10
});
// add the shapes to the layer
layer.add(simpleText);
layer.add(rect);
layer.add(complexText);
// add the layer to the stage
stage.add(layer);</script>
<script>
var stage = new Konva.Stage({
container: 'container3',
width: 340,
height: 200
});
var layer = new Konva.Layer();
var redLine = new Konva.Line({
points: [15, 120, 140, 71, 200, 110, 300, 70],
stroke: 'red',
strokeWidth: 15,
lineCap: 'round',
lineJoin: 'round'
});
var greenLine = new Konva.Line({
points: [15, 70, 140, 23, 250, 60, 300, 20],
stroke: 'blue',
strokeWidth: 2,
lineJoin: 'round',
/*
* line segments with a length of 33px
* with a gap of 10px
*/
dash: [33, 10]
});
// add the shapes to the layer
layer.add(greenLine);
layer.add(redLine);
// add the layer to the stage
stage.add(layer);</script>
<script>
// first we need to create a stage
var stage = new Konva.Stage({
container: 'container2', // id of container <div>
width: 500,
height: 160
});
var layer = new Konva.Layer();
var rect1 = new Konva.Rect({
x: 20,
y: 20,
width: 100,
height: 50,
fill: 'green',
stroke: 'black',
strokeWidth: 4
});
var rect2 = new Konva.Rect({
x: 170,
y: 20,
width: 100,
height: 50,
fill: 'red',
shadowBlur: 10,
cornerRadius: 10
});
var rect3 = new Konva.Rect({
x: 320,
y: 20,
width: 100,
height: 100,
fill: 'blue',
cornerRadius: [0, 10, 20, 30]
});
// add the shapes to the layer
layer.add(rect1);
layer.add(rect2);
layer.add(rect3);
stage.add(layer);
layer.draw();
</script>
<script>
// first we need to create a stage
var stage = new Konva.Stage({
container: '123456', // id of container <div>
width: 160,
height: 160
});
// then create a layer
var layer = new Konva.Layer();
// create our shape
var circle = new Konva.Circle({
x: stage.width() / 2, // x position of the center
y: stage.height() / 2, // y position of the center
radius: 70, // circle radius
fill: 'red', // color to fill the area
stroke: 'black', // color to draw the line
strokeWidth: 4 // line width
});
// add the shape to the layer
layer.add(circle);
// add the layer to the stage
stage.add(layer);
// draw the image
layer.draw();
</script>
</body>
</html>