-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewflower.js
86 lines (78 loc) · 2.05 KB
/
newflower.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const t = new bt.Turtle();
const width = 125;
const height = 125;
setDocDimensions(width, height);
function drawTinyFlower(t, centerX, centerY, size, color) {
const halfWidth = size / 2;
const halfHeight = size * 0.75;
const tailLength = size * 0.5;
// Create a single path for the entire flower
const flowerPath = [
[centerX, centerY - halfHeight],
[centerX - halfWidth, centerY],
[centerX, centerY + halfHeight],
[centerX + halfWidth, centerY],
[centerX, centerY - halfHeight],
[centerX, Math.max(0, centerY - halfHeight - tailLength)]
];
// Draw and fill the flower in one step
drawLines([flowerPath], { fill: color, stroke: color });
}
function drawRandomColorFlowers(count) {
const tinyFlowerSize = 3.2;
const colors = ['red', 'blue', 'pink', 'purple', 'white'];
for (let i = 0; i < count; i++) {
const randomX = bt.randInRange(10, 115); // Adjusted x-coordinate range
const randomY = bt.randInRange(10, 63); // Adjusted y-coordinate range
const randomColor = colors[Math.floor(bt.randInRange(0, colors.length))];
drawTinyFlower(t, randomX, randomY, tinyFlowerSize, randomColor);
}
}
// Draw the background layers
const ground = [
[
[0, 3 * 0],
[125, 3 * 0],
[125, height],
[0, height]
]
];
const top = [
[
[0, 3 * height / 4],
[125, 3 * height / 4],
[125, height],
[0, height]
]
];
const middle2 = [
[
[0, 4.25 * height / 6],
[125, 4.25 * height / 6],
[125, height],
[0, height]
]
];
const middle1 = [
[
[0, 4 * height / 6],
[125, 4 * height / 6],
[125, height],
[0, height]
]
];
const down = [
[
[0, 3 * height / 6],
[125, 3 * height / 6],
[125, height],
[0, height]
]
];
drawLines(ground, { fill: "#32a467", stroke: "#29636A" });
drawLines(down, { fill: "#dfecf6", stroke: "#F4CA90" });
drawLines(middle1, { fill: "#72aee0", stroke: "#C7B087" });
drawLines(middle2, { fill: "#5693dc", stroke: "#99977E" });
drawLines(top, { fill: "#0149aa", stroke: "#83c0ea" });
// Draw the flowers
drawRandomColorFlowers(125);