-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevfest.html
More file actions
193 lines (166 loc) · 5.78 KB
/
Copy pathdevfest.html
File metadata and controls
193 lines (166 loc) · 5.78 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
<!DOCTYPE html>
<html>
<head>
<script src="lib/p5.min.js"></script>
<script src="sketch.js"></script>
<!-- add extra scripts below -->
<script src="toolbox.js"></script>
<script src="colourPalette.js"></script>
<script src="helperFunctions.js"></script>
<script src="canvasImage.js"></script>
<script src="freehandTool.js"></script>
<script src="lineToTool.js"></script>
<script src="mirrorDrawTool.js"></script>
<script src="sprayCanTool.js"></script>
<script src="eraserTool.js"></script>
<script src="rectangleTool.js"></script>
<script src="editableShapeTool.js"></script>
<script src="polygonTool.js"></script>
<script src="bucketFillTool.js"></script>
<script src="zoomTool.js"></script>
<script src="textTool.js"></script>
<script src="algorithms.js"></script>
<script src="stampTool.js"></script>
<script src="scissorsTool.js"></script>
<script src="noneTool.js"></script>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body style="background-color: #444">
<div class="wrapper" style="background-color: #444;">
<div id="AppOpt" style="color: rgb(255, 255, 255);">
<p>GDG OGBOMOSO DEVFEST</p>
<p>
<label>Pick Image</label><input type="file" id="file" accept="image/*" /><br><br>
<button id="name">Click To Enter Your Name</button>
<small>A small input box will appear below after clicking, enter your name there. You can select color, change
font and increase font size</small><br><br>
<button id="preview">Preview Image</button><small>Preview the image before downloding, if need be hide and
edit</small><br><br>
<button id="saveApp">Download Image</button><br>
</p>
</div>
<div class="box header" style="visibility: hidden;">
TFL Birthday App
<button id="Reload">Clear</button>
<button id="saveImageButton">Save Image</button>
<button id="undoButton">Undo</button>
<button id="redoButton">Redo</button>
<button id="History">Layer History</button>
<span id="stateMes"></span>
</div>
<div class="box" id="sidebar" style="visibility: hidden;">
</div>
<div id="content" class="canvas-area" style="position: absolute;
top: -9999px;
left: -9999px;"></div>
<div class="box component-area" id="initOpt">
<label for="color">Select Fill Color: </label>
<input type="color" name="color" id="color" value="#9EFFF4" />
<label for="color">Select Stroke Color: </label>
<input type="color" name="SC" id="SC" value="#7B7342" />
<label for="color"> Stroke Weight: </label>
<input type="number" name="SW" id="SW" value="1" min="1" max="50" />
</div>
<div class="box options" style="visibility: hidden;">
<div id="options"></div>
<div id="message" style="color: red"></div>
<div id="info" disabled style="color: paleturquoise"></div>
</div>
<a href="https://github.com/olawalejuwonm/picgen"><img src="./assets/os.jpg"/></a>
</div>
<script>
function getBase64(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = (error) => reject(error);
});
}
const appPic = "assets/devfest.jpg"
const imgsizepx = [66, 246, 419, 422]
const preview = new p5.Element(document.getElementById("preview"))
const dC = new p5.Element(document.getElementById("content"))
const btn2 = new p5.Element(document.getElementById("name"))
let imgAlert = "Please Upload An Image",
name = "Please Enter Name"
ImgTextBg = "#2177DE"
c = "#9EFFF4"
let runCheck = () => {
console.log(imgAlert)
if (imgAlert) {
alert(imgAlert)
return true
}
else if (name) {
alert(name)
return true
}
}
const actions = {
preview: () => {
if (preview.html() == "Hide Image") {
// AppMode.removeAttribute("style")
dC.attribute(
"style",
`position: absolute;
top: -9999px;
left: -9999px;`
);
preview.html("Preview Image");
} else {
// let app = document.getElementById("AppBtn").
// AppMode.attribute("style", "background-color: #444;color:white")
if (runCheck()) {
return;
}
else {
dC.removeAttribute("style");
preview.html("Hide Image");
}
}
},
name: () => {
if (!toolbox.selectedTool.textMode) {
toolbox.selectTool("TextTool");
let namePixel = { x: 531, y: 230, w: 391, h: 61 };
toolbox.selectedTool.selectScale = namePixel;
toolbox.selectedTool.mouseReleased();
name = false
}
},
saveApp: () => {
if (runCheck()) {
return;
}
saveCanvas(window.location.pathname.split('/')[1].split('.')[0] + ".png")
},
file: (f) => {
getBase64(f.target.files[0])
.then((d) => {
loadImage(d, (img) => {
let shape = createGraphics(img.width, img.height);
// img.resize(width, height)
// shape.ellipse(535, 540,615,596)
shape.ellipse(
img.width / 2,
img.height / 2,
img.width,
img.height
);
img.resize(imgsizepx[2], imgsizepx[3])
// img.mask(shape);
// image(img, 535, 540,615,596)
image(img, ...imgsizepx);
imgAlert = false
// console.log(img)
});
})
.catch((e) => {
alert(e.message);
});
}
}
</script>
</body>
</html>