-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrazyMain.js
More file actions
148 lines (146 loc) · 2.67 KB
/
crazyMain.js
File metadata and controls
148 lines (146 loc) · 2.67 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
let xCoord = 0 //x coordinate
let yCoord = 0 //y coordinate
let x = Math.round(Math.random()*1000) //x dimension
let y = Math.round(Math.random()*1000) //y dimension
let xSentinel = 0
xFill = Math.round(Math.random()*100) //pixel length and width
yFill = Math.round(Math.random()*100)
let xRand = 10
let yRand = 10
const imgName = Math.round(Math.random()*100000)
const { createCanvas, loadImage } = require('canvas')
const { Console } = require('console')
const pixelCount = x*y
const canvas = createCanvas(x, y)
const ctx = canvas.getContext('2d')
const fs = require('fs')
let color = ['AliceBlue',
'Aqua',
'Aquamarine',
'Blue',
'BlueViolet',
'Brown',
'CadetBlue',
'Chartreuse',
'Chocolate',
'Coral',
'CornflowerBlue',
'Crimson',
'Cyan',
'DarkBlue',
'DarkCyan',
'DarkGoldenRod',
'DarkGreen',
'DarkMagenta',
'DarkOliveGreen',
'DarkOrange',
'DarkOrchid',
'DarkRed',
'DarkSalmon',
'DarkSeaGreen',
'DarkSlateBlue',
'DarkSlateGray',
'DarkSlateGrey',
'DarkTurquoise',
'DarkViolet',
'DeepPink',
'DeepSkyBlue',
'DodgerBlue',
'FireBrick',
'ForestGreen',
'Fuchsia',
'Gold',
'GoldenRod',
'Green',
'GreenYellow',
'HotPink',
'IndianRed',
'Indigo',
'Lavender',
'LavenderBlush',
'LawnGreen',
'LightBlue',
'LightCoral',
'LightCyan',
'LightGoldenRodYellow',
'LightGreen',
'LightPink',
'LightSalmon',
'LightSeaGreen',
'LightSkyBlue',
'Lime',
'LimeGreen',
'Linen',
'Magenta',
'Maroon',
'MediumAquaMarine',
'MediumBlue',
'MediumOrchid',
'MediumPurple',
'MediumSeaGreen',
'MediumSlateBlue',
'MediumSpringGreen',
'MediumTurquoise',
'MediumVioletRed',
'MidnightBlue',
'MintCream',
'MistyRose',
'Navy',
'Olive',
'OliveDrab',
'Orange',
'OrangeRed',
'Orchid',
'PaleGoldenRod',
'PaleGreen',
'PaleTurquoise',
'PaleVioletRed',
'PapayaWhip',
'PeachPuff',
'Peru',
'Pink',
'Plum',
'PowderBlue',
'Purple',
'RebeccaPurple',
'Red',
'RosyBrown',
'RoyalBlue',
'SaddleBrown',
'Salmon',
'SandyBrown',
'SeaGreen',
'Sienna',
'Silver',
'SkyBlue',
'SlateBlue',
'SpringGreen',
'SteelBlue',
'Teal',
'Thistle',
'Tomato',
'Turquoise',
'Violet',
'YellowGreen']
ctx.fillStyle = color[Math.round(Math.random()*color.length)]
ctx.fillRect(0,0,x,y)
ctx.fill()
imageGen = async() =>{
for (xCoord; yCoord<=x; xCoord++){
xFill = Math.round(Math.random()*50) //pixel length and width
yFill = Math.round(Math.random()*50)
ctx.fillStyle = await color[Math.round(Math.random()*color.length)]
//console.log(await ctx.fillStyle," ",xCoord," ",yCoord," ",xSentinel)
await ctx.fillRect(xCoord,yCoord,xFill,yFill)
if (xSentinel%x === 0){
xCoord=0
yCoord+=yFill
//console.log(yCoord," ",xCoord)
}
xSentinel++
}
const buffer = canvas.toBuffer("image/png");
fs.writeFileSync('./insane/'+imgName+'.png',buffer);
console.log(imgName+".png saved")
}
imageGen()