-
Notifications
You must be signed in to change notification settings - Fork 1
/
seal.html
281 lines (261 loc) · 9.66 KB
/
seal.html
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>pp_round_logo</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.3.15/p5.min.js"></script>
<script type="text/javascript" src="jquery.cookie.js"></script>
<script type="text/javascript">
/* @pjs preload="pp_established.png"; */
var logo;
var r = 250;
function setup()
{
var canvas = createCanvas(640, 640).parent('logoCanvas');
logo = loadImage("pp_established.png");
}
function drawTextOnCurve(message, angleStart, angleSpread)
{
var ratio;
var arcLength = 0;
var totalWidth = 0;
// Determine actual anglular "length" of the message.
for (var i = 0; i < message.length; i++)
{
totalWidth += textWidth(message.charAt(i));
}
arcLength = totalWidth / r;
//println("arcLength is " + arcLength);
//println("Desired arcLength is " + angleSpread);
// Calculate ratio between actual and desired angle.
ratio = angleSpread / arcLength;
//println("Ratio is " + ratio);
// Print the message
arcLength = 0;
for (var i = 0; i < message.length; i++)
{
// Instead of a constant width, we check the width of each character.
var currentChar = message.charAt(i);
var w = textWidth(currentChar);
w *= ratio;
// Each box is centered so we move half the width
arcLength += w/2;
// Angle in radians is the arclength divided by the radius
// Starting on the left side of the circle by adding PI
var theta = PI + angleStart + arcLength / r;
push();
// Polar to cartesian coordinate conversion
translate(r * cos(theta), r * sin(theta));
// Rotate the box
rotate(theta + PI/2); // rotation is offset by 90 degrees
// Display the character
//fill(0);
text(currentChar, 0, 0);
pop();
// Move halfway again
arcLength += w/2;
}
}
function drawLogo(newWidth)
{
var newHeight = newWidth * logo.height / logo.width;
image(logo, (width - newWidth) / 2, (height - newHeight) / 2, newWidth, newHeight);
}
function dashedCircle(radius, steps, dashWidth, dashSpacing)
{
var dashPeriod = dashWidth + dashSpacing;
var lastDashed = false;
for (var i = 0; i < steps; i++)
{
var curDashed = (i % dashPeriod) < dashWidth;
if (curDashed && !lastDashed)
{
beginShape();
}
if (!curDashed && lastDashed)
{
endShape();
}
if (curDashed) {
var theta = map(i, 0, steps, 0, TWO_PI);
vertex(cos(theta) * radius, sin(theta) * radius);
}
lastDashed = curDashed;
}
if (lastDashed)
{
endShape();
}
}
function draw()
{
var cityList;
var fontSize = $('#fontSize').val();
var sloganAngle = parseInt($('#angle').val(), 10) * PI / 180;
var circles = $('#circles').prop('checked');
background(255);
drawLogo(640 - 250);
// Start in the center and draw the circle
translate(width / 2, height / 2);
noFill();
if ('1' == circles)
{
stroke(192);
//ellipse(0, 0, r*2, r*2);
dashedCircle(r - 10, 700, 2, 2);
stroke(0);
ellipse(0, 0, (r + fontSize * 1.4) * 2, (r + fontSize * 1.4) * 2);
}
stroke(0);
// Slogan
textFont("Helvetica");
textSize(fontSize);
textStyle(BOLD);
textAlign(CENTER);
smooth();
fill(0);
noStroke();
drawTextOnCurve("Beer, friends, puzzles", 0, sloganAngle);
// City list
cities = $('#cityListInput').val().split(',');
cityList = " \u2605 ";
for (var i = 0; i < cities.length; i++)
{
cityList += cities[i].trim();
cityList += " \u2605 ";
}
if ($('#uppercase').prop('checked'))
cityList = cityList.toUpperCase();
textFont("Helvetica");
textSize(fontSize);
textStyle(NORMAL);
textAlign(CENTER);
smooth();
fill(128);
noStroke();
drawTextOnCurve(cityList, sloganAngle, 2 * PI - sloganAngle);
}
/* ===============================================================
===== LOAD / SAVE STATE
=============================================================== */
function getParameterByName(name)
{
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
function preloadTextbox()
{
var value = getParameterByName('cities')
if (0 == value.length)
value = $.cookie('cities');
if (undefined != value && value.length > 0)
$('#cityListInput').val(value)
value = getParameterByName('size')
if (0 == value.length)
value = $.cookie('fontSize');
if (undefined != value && value.length > 0)
{
$("#fontSize option").each(function()
{
if ($(this).val() == value)
$(this).prop('selected', true);
});
}
value = getParameterByName('angle')
if (0 == value.length)
value = $.cookie('angle');
if (undefined != value && value.length > 0)
{
$("#angle option").each(function()
{
if ($(this).val() == value)
$(this).prop('selected', true);
});
}
value = getParameterByName('uppercase');
if (0 == value.length)
value = $.cookie('uppercase');
if (undefined != value && '1' == value)
$('#uppercase').prop('checked', true);
value = getParameterByName('circles');
if (0 == value.length)
value = $.cookie('circles');
if (undefined != value && '1' == value)
$('#circles').prop('checked', true);
}
function saveCookies()
{
$.cookie('cities', $('#cityListInput').val());
$.cookie('fontSize', $('#fontSize').val());
$.cookie('angle', $('#angle').val());
$.cookie('uppercase', $('#uppercase').prop('checked') ? '1' : '0');
$.cookie('circles', $('#circles').prop('checked') ? '1' : '0');
}
</script>
<style type="text/css" media="screen">
form {margin:0; padding:0;}
#cityListInput {width:40em;}
#return {position:fixed; top:5px; right:5px; font-size:8pt;}
</style>
</head>
<body id="pp_round_logo" onload="preloadTextbox();">
<div id="logoCanvas"></div>
<!--
Portland, 2010-07
Seattle, 2011-11
London, 2013-11
Chicago, 2014-03
Phoenix, 2014-06
Bay Area, 2014-07
Washington DC, 2014-09
Boston, 2014-09
Austin, 2014-09
Pittsburgh, 2014-10
Montreal, 2014-11
-->
<form onsubmit="return false;">
<p>City List: <input type="text" id="cityListInput" value="Portland, Seattle, London, Chicago, Phoenix" onchange="saveCookies();" onblur="saveCookies();"></p>
<p>Font Size: <select id="fontSize" onchange="saveCookies();">
<option value="10">10pt</option>
<option value="12">12pt</option>
<option value="14">14pt</option>
<option value="16">16pt</option>
<option value="18">18pt</option>
<option value="20">20pt</option>
<option value="22">22pt</option>
<option value="24">24pt</option>
<option value="26">26pt</option>
<option value="28">28pt</option>
<option value="30">30pt</option>
<option value="32" selected>32pt</option>
</select>
Bold Angle: <select id="angle" onchange="saveCookies();">
<option value="45">45°</option>
<option value="50">50°</option>
<option value="55">55°</option>
<option value="60">60°</option>
<option value="65">65°</option>
<option value="70">70°</option>
<option value="75">75°</option>
<option value="80">80°</option>
<option value="85">85°</option>
<option value="90" selected>90°</option>
</select>
<label><input type="checkbox" id="uppercase" value="1" onchange="saveCookies();"/> Force-Uppercase?</label>
<label><input type="checkbox" id="circles" value="1" onchange="saveCookies();"/> Circles?</label>
</p>
</form>
<p><small><em>
Notes: Cities are comma-delimited.
Pass in “<code>?cities=...</code>”, “<code>?size=...</code>”, “<code>?angle=...</code>”, or “<code>?uppercase=...</code>” query strings to prepopulate these fields.
</em></small></p>
<div id="return">
<a href="index.html">return to main menu</a>
</div>
</body>
</html>