-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathph.html
More file actions
169 lines (145 loc) · 4.35 KB
/
Copy pathph.html
File metadata and controls
169 lines (145 loc) · 4.35 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Pornhub Logo Creator</title>
</head>
<body>
<div id="logo-container">
<div contenteditable="true" id="porn" class="logo">Type</div>
<div contenteditable="true" id="hub" class="logo">Here</div>
</div>
<button id="save" onclick="draw()">download</button>
<canvas width="500" height="115"></canvas>
<style>
body {
text-align: center;
background-color: rgb(0, 0, 0);
}
#logo-container {
margin-top: 15%;
}
#save {
margin-top: 20px;
background-color: orange;
color: black;
font-family: Arial;
font-weight: bold;
font-size: 50px;
border-radius: 10px;
border: none;
}
#porn {
color: white;
}
#hub {
background-color: orange;
padding: 0px 10px;
border-radius: 10px;
}
.logo {
font-family: Arial;
font-weight: bold;
font-size: 100px;
display: inline-block;
min-width: 25px;
outline: none;
}
canvas {
display: none;
}
</style>
<script>
// When the "Porn" div is empty give it a border
document.getElementById("porn").addEventListener("input", () => {
let porn = document.getElementById("porn");
if (porn.innerHTML == "")
porn.setAttribute("style", "border: 3px dashed red;");
else porn.setAttribute("style", "");
});
var mp = (multiplier = 10); // Number to mulitply all variables used in creating the image with for a higher res
var iM = (imageMargin = 30);
function draw(
porn = document.getElementById("porn").innerHTML,
hub = document.getElementById("hub").innerHTML
) {
const canvas = document.getElementsByTagName("canvas")[0];
const pornDiv = document.getElementById("porn");
const hubDiv = document.getElementById("hub");
canvas.width =
(iM * 2 + pornDiv.offsetWidth + hubDiv.offsetWidth) * mp;
canvas.height = (iM * 2 + pornDiv.offsetHeight) * mp;
const { width, height } = canvas;
const ctx = canvas.getContext("2d");
ctx.font = `bold ${100 * mp}px Arial`;
const pornWidth = ctx.measureText(porn).width;
const hubWidth = ctx.measureText(hub).width;
//Black background
ctx.fillStyle = "black";
ctx.fillRect(0, 0, canvas.width, canvas.height);
//Draw "porn"
ctx.fillStyle = "white";
ctx.fillText(porn, iM * mp, iM * mp + 92 * mp); //92 is the magic number
//draw orange
let borderRadius = 20;
ctx.strokeStyle = "orange";
ctx.fillStyle = "orange";
ctx.lineJoin = "round";
ctx.lineWidth = borderRadius * mp;
ctx.strokeRect(
iM * mp + pornWidth + (borderRadius / 2) * mp + 5 * mp,
iM * mp + (borderRadius / 2) * mp,
hubWidth,
-iM * 2 * mp + height - borderRadius * mp
);
ctx.fillRect(
iM * mp + pornWidth + borderRadius * mp + 5 * mp - 1 * mp,
iM * mp + borderRadius * mp,
hubWidth + 2 * mp - borderRadius * mp,
-iM * 2 * mp + height - borderRadius * 2 * mp
);
//The -1 (x) and +2 (width) are to make the inner-square a bit bigger to avoid creating a visible edge between the stroke outline and the inner-square
//draw "hub"
ctx.fillStyle = "black";
ctx.fillText(
hub,
iM * mp + pornWidth + 10 * mp,
iM * mp + 92 * mp
); //92 is the magic number
save();
}
function save() {
porn = document.getElementById("porn").innerHTML;
hub = document.getElementById("hub").innerHTML;
let link = document.createElement("a");
let canvas = document.getElementsByTagName("canvas")[0];
link.setAttribute("download", porn + hub + ".png");
link.setAttribute("href", canvas.toDataURL("image/png;base64"));
if (document.createEvent) {
e = document.createEvent("MouseEvents");
e.initMouseEvent(
"click",
true,
true,
window,
0,
0,
0,
0,
0,
false,
false,
false,
false,
0,
null
);
link.dispatchEvent(e);
} else if (link.fireEvent) {
link.fireEvent("onclick");
}
}
</script>
<!-- By Rein Fernhout (reinfernhout.xyz). Fixed by ZJUGuoShuai. -->
</body>
</html>