-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
518 lines (467 loc) · 16.6 KB
/
Copy pathindex.html
File metadata and controls
518 lines (467 loc) · 16.6 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
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Processing for C++</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.0/p5.min.js"></script>
<style>
@font-face {
font-family: "ProcessingSans";
src: url("/assets/ProcessingSansPro-Regular.ttf") format("truetype");
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #111; background: #fff; }
a { color: #111; text-decoration: none; }
/* Nav: matches all other pages via nav.js injection */
#site-nav {
border-bottom: 1px solid #e0e0e0;
padding: 0 2rem;
display: flex; align-items: center; justify-content: space-between;
height: 60px; position: sticky; top: 0; background: #fff; z-index: 100;
}
.layout { display: flex; min-height: calc(100vh - 60px); }
/* Sidebar: matches other pages exactly */
.sidebar {
width: 220px;
min-width: 220px;
border-right: 1px solid #e0e0e0;
padding: 1.5rem 1.5rem 1rem;
display: flex;
flex-direction: column;
position: sticky;
top: 60px;
height: calc(100vh - 60px);
background: #fff;
}
.sidebar a {
font-size: 14px;
color: #555;
padding: 0.4rem 0;
display: block;
}
.sidebar a:hover { color: #111; }
.sidebar a.active { color: #111; font-weight: 500; }
.page-body { flex: 1; overflow-x: hidden; }
/* Hero */
.main {
height: calc(100vh - 60px);
min-height: 400px;
max-height: 560px;
display: flex;
align-items: center;
padding: 0 5rem;
gap: 4rem;
position: relative;
}
.left { flex: 1; }
.left h1 {
font-size: 2.6rem;
font-weight: 600;
letter-spacing: -0.02em;
line-height: 1.2;
margin-bottom: 1.5rem;
}
.left h1 .proc {
font-family: "ProcessingSans", sans-serif;
color: #003f6b;
font-weight: 400;
}
.left p { font-size: 1rem; color: #555; }
.left p a { color: #111; border-bottom: 1px solid #111; font-weight: 500; }
.right { flex: 1; display: flex; justify-content: flex-end; align-items: center; }
.right img { width: 340px; height: 340px; object-fit: contain; }
/* Arrow: positioned inside .main so it's always visible above the fold */
.scroll-hint {
position: absolute;
bottom: 1.5rem;
left: 50%;
transform: translateX(-50%);
color: #bbb;
font-size: 22px;
animation: bounce 1.8s infinite;
}
@keyframes bounce {
0%, 100% { transform: translateX(-50%) translateY(0); }
50% { transform: translateX(-50%) translateY(6px); }
}
/* Examples section */
.examples-section {
max-width: 960px;
margin: 0 auto;
padding: 5rem 3rem;
border-top: 1px solid #e0e0e0;
}
.examples-section h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 2.5rem; }
.examples-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 1px;
border: 1px solid #e0e0e0;
border-radius: 8px;
overflow: hidden;
}
.example-card { background: #fff; overflow: hidden; display: block; text-decoration: none; color: inherit; }
.example-card:hover .example-info h3 { color: #e8b400; }
.example-canvas { width: 100%; aspect-ratio: 16/9; background: #000; display: block; }
.example-info { padding: 1rem 1.25rem; border-top: 1px solid #e0e0e0; }
.example-info h3 { font-size: 14px; font-weight: 500; margin-bottom: 0.2rem; }
.example-info p { font-size: 12px; color: #888; }
.examples-footer { padding: 3rem; text-align: center; }
.examples-footer a { font-size: 14px; color: #555; border-bottom: 1px solid #ddd; padding-bottom: 2px; }
.examples-footer a:hover { color: #111; border-color: #111; }
.getting-started-section {
max-width: 960px;
margin: 0 auto;
padding: 1rem 3rem 5rem;
}
.getting-started-section h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 1.5rem; }
.gs-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; }
.gs-card { border: 1px solid #e0e0e0; border-radius: 10px; padding: 1.5rem; }
.gs-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; }
.gs-card p { font-size: 13px; color: #777; line-height: 1.6; margin-bottom: 1rem; }
.gs-card-link { font-size: 13px; font-weight: 600; color: #111; }
.gs-card-link:hover { color: #e8b400; }
/* Hero actions: Reference link + single Download button */
.hero-actions { display: flex; align-items: center; gap: 1.5rem; margin-top: 1.5rem; }
.hero-link { font-size: 14px; font-weight: 600; border-bottom: 1px solid #ccc; padding-bottom: 2px; }
.hero-link:hover { border-bottom-color: #111; }
.hero-btn-download {
display: inline-block;
background: #e8b400;
color: #111;
font-size: 14px;
font-weight: 700;
padding: 0.65rem 1.5rem;
border-radius: 8px;
box-shadow: 0 2px 0 rgba(0,0,0,0.08);
transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hero-btn-download:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(232,180,0,0.35); }
@media (max-width: 768px) {
.hero-actions { flex-direction: column; align-items: flex-start; gap: 0.85rem; }
}
footer { border-top: 1px solid #e0e0e0; padding: 2rem; text-align: center; font-size: 13px; color: #888; }
@media (max-width: 768px) {
.sidebar {
position: fixed; top: 60px; left: -240px;
width: 240px; height: calc(100vh - 60px);
z-index: 200; transition: left 0.25s ease;
box-shadow: 2px 0 12px rgba(0,0,0,0.08);
}
.sidebar.open { left: 0; }
.main { flex-direction: column; padding: 3rem 2rem; height: auto; gap: 2rem; }
.right img { width: 180px; height: 180px; }
.scroll-hint { position: static; transform: none; display: block; text-align: center; padding: 1rem 0; animation: none; }
}
</style>
</head>
<body>
<nav id="site-nav"></nav>
<div class="layout">
<div class="sidebar" id="sidebar"></div>
<div class="page-body">
<div class="main">
<div class="left">
<h1>C++ Mode for<br><span class="proc">Processing</span></h1>
<div class="hero-actions">
<a class="hero-link" href="/reference">Reference</a>
<a class="hero-btn-download" href="/downloads">Download</a>
</div>
<p style="margin-top:10rem;font-size:0.85rem;color:#aaa;">Independently developed by Jose Llamas</p>
</div>
<div class="right">
<img src="assets/cpp-logo.png" alt="Processing for C++">
</div>
<div class="scroll-hint">↓</div>
</div>
<div class="examples-section">
<h2>Examples</h2>
<div class="examples-grid">
<a class="example-card" href="/examples/mandelbrot.html" id="card1">
<iframe class="example-canvas" id="c1" width="300" height="300" style="width:100%;aspect-ratio:1;border:none;display:block;background:#000;" scrolling="no"></iframe><script>(function(){const iframe=document.getElementById('c1');const doc=iframe.contentDocument||iframe.contentWindow.document;doc.open();doc.write(`<!DOCTYPE html><html><head><style>*{margin:0;padding:0;}body{overflow:hidden;}</style><script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.0/p5.min.js"><\/script></head><body><script>function setup() {
createCanvas(300,300);
pixelDensity(1);
noLoop();
background(255);
let w = 4;
let h = (w * height) / width;
let xmin = -w / 2;
let ymin = -h / 2;
loadPixels();
let maxiterations = 100;
let xmax = xmin + w;
let ymax = ymin + h;
let dx = (xmax - xmin) / width;
let dy = (ymax - ymin) / height;
let y = ymin;
for (let j = 0; j < height; j++) {
let x = xmin;
for (let i = 0; i < width; i++) {
let a = x;
let b = y;
let n = 0;
let maxAbs = 4.0;
let absOld = 0.0;
let convergeNumber = maxiterations;
while (n < maxiterations) {
let aa = a * a;
let bb = b * b;
let absVal = sqrt(aa + bb);
if (absVal > maxAbs) {
let diffToLast = absVal - absOld;
let diffToMax = maxAbs - absOld;
convergeNumber = n + diffToMax / diffToLast;
break;
}
let twoab = 2.0 * a * b;
a = aa - bb + x;
b = twoab + y;
n++;
absOld = absVal;
}
let idx = (i + j * width) * 4;
if (n == maxiterations) {
pixels[idx] = 0;
pixels[idx + 1] = 0;
pixels[idx + 2] = 0;
pixels[idx + 3] = 255;
} else {
let norm = map(convergeNumber, 0, maxiterations, 0, 1);
let bright = map(sqrt(norm), 0, 1, 0, 255);
pixels[idx] = bright;
pixels[idx + 1] = bright;
pixels[idx + 2] = bright;
pixels[idx + 3] = 255;
}
x += dx;
}
y += dy;
}
updatePixels();
}
function draw() {}<\/script></body></html>`);doc.close();})();</script>
<div class="example-info"><h3>Mandelbrot</h3><p>Fractals And L-Systems example</p></div>
</a>
<a class="example-card" href="/examples/rotate-push-pop.html" id="card2">
<iframe class="example-canvas" id="c2" width="300" height="300" style="width:100%;aspect-ratio:1;border:none;display:block;background:#000;" scrolling="no"></iframe><script>(function(){const iframe=document.getElementById('c2');const doc=iframe.contentDocument||iframe.contentWindow.document;doc.open();doc.write(`<!DOCTYPE html><html><head><style>*{margin:0;padding:0;}body{overflow:hidden;}</style><script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.0/p5.min.js"><\/script></head><body><script>let a = 0;
let offset;
let num = 12;
function setup() {
createCanvas(300,300, WEBGL);
noStroke();
offset = PI / 24.0;
}
function draw() {
background(0, 0, 26);
ambientLight(150);
directionalLight(255, 255, 255, 0, 0, -1);
directionalLight(100, 100, 100, 0, 0, 1);
// Move camera closer — default WEBGL camera is too far
translate(0, 0, 150);
for (let i = 0; i < num; i++) {
let gray = map(i, 0, num - 1, 0, 255);
push();
fill(gray);
rotateY(a + offset * i);
rotateX(a / 2 + offset * i);
box(150);
pop();
}
a += 0.01;
}<\/script></body></html>`);doc.close();})();</script>
<div class="example-info"><h3>Rotate Push Pop</h3><p>Transform example</p></div>
</a>
<a class="example-card" href="/examples/flocking.html" id="card3">
<iframe class="example-canvas" id="c3" width="300" height="300" style="width:100%;aspect-ratio:1;border:none;display:block;background:#000;" scrolling="no"></iframe><script>(function(){const iframe=document.getElementById('c3');const doc=iframe.contentDocument||iframe.contentWindow.document;doc.open();doc.write(`<!DOCTYPE html><html><head><style>*{margin:0;padding:0;}body{overflow:hidden;}</style><script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.0/p5.min.js"><\/script></head><body><script>// Flock class
class Flock {
constructor() {
this.boids = [];
}
run() {
for (let b of this.boids) {
b.run(this.boids);
}
}
addBoid(b) {
this.boids.push(b);
}
}
// Boid class
class Boid {
constructor(x, y) {
this.acceleration = createVector(0, 0);
let angle = random(TWO_PI);
this.velocity = createVector(cos(angle), sin(angle));
this.position = createVector(x, y);
this.r = 2.0;
this.maxspeed = 2;
this.maxforce = 0.03;
}
run(boids) {
this.flock(boids);
this.update();
this.borders();
this.render();
}
applyForce(force) {
this.acceleration.add(force);
}
flock(boids) {
let sep = this.separate(boids);
let ali = this.align(boids);
let coh = this.cohesion(boids);
sep.mult(1.5);
ali.mult(1.0);
coh.mult(1.0);
this.applyForce(sep);
this.applyForce(ali);
this.applyForce(coh);
}
update() {
this.velocity.add(this.acceleration);
this.velocity.limit(this.maxspeed);
this.position.add(this.velocity);
this.acceleration.mult(0);
}
seek(target) {
let desired = p5.Vector.sub(target, this.position);
desired.normalize();
desired.mult(this.maxspeed);
let steer = p5.Vector.sub(desired, this.velocity);
steer.limit(this.maxforce);
return steer;
}
render() {
let theta = this.velocity.heading() + radians(90);
fill(200, 100);
stroke(255);
push();
translate(this.position.x, this.position.y);
rotate(theta);
beginShape(TRIANGLES);
vertex(0, -this.r * 2);
vertex(-this.r, this.r * 2);
vertex(this.r, this.r * 2);
endShape();
pop();
}
borders() {
if (this.position.x < -this.r) this.position.x = width + this.r;
if (this.position.y < -this.r) this.position.y = height + this.r;
if (this.position.x > width + this.r) this.position.x = -this.r;
if (this.position.y > height + this.r) this.position.y = -this.r;
}
separate(boids) {
let desiredseparation = 25.0;
let steer = createVector(0, 0);
let count = 0;
for (let other of boids) {
let d = p5.Vector.dist(this.position, other.position);
if ((d > 0) && (d < desiredseparation)) {
let diff = p5.Vector.sub(this.position, other.position);
diff.normalize();
diff.div(d);
steer.add(diff);
count++;
}
}
if (count > 0) steer.div(count);
if (steer.mag() > 0) {
steer.normalize();
steer.mult(this.maxspeed);
steer.sub(this.velocity);
steer.limit(this.maxforce);
}
return steer;
}
align(boids) {
let neighbordist = 50;
let sum = createVector(0, 0);
let count = 0;
for (let other of boids) {
let d = p5.Vector.dist(this.position, other.position);
if ((d > 0) && (d < neighbordist)) {
sum.add(other.velocity);
count++;
}
}
if (count > 0) {
sum.div(count);
sum.normalize();
sum.mult(this.maxspeed);
let steer = p5.Vector.sub(sum, this.velocity);
steer.limit(this.maxforce);
return steer;
}
return createVector(0, 0);
}
cohesion(boids) {
let neighbordist = 50;
let sum = createVector(0, 0);
let count = 0;
for (let other of boids) {
let d = p5.Vector.dist(this.position, other.position);
if ((d > 0) && (d < neighbordist)) {
sum.add(other.position);
count++;
}
}
if (count > 0) {
sum.div(count);
return this.seek(sum);
}
return createVector(0, 0);
}
}
let flock;
function setup() {
createCanvas(300,300);
flock = new Flock();
for (let i = 0; i < 150; i++) {
flock.addBoid(new Boid(width / 2, height / 2));
}
}
function draw() {
background(50);
flock.run();
}
function mousePressed() {
flock.addBoid(new Boid(mouseX, mouseY));
}<\/script></body></html>`);doc.close();})();</script>
<div class="example-info"><h3>Flocking</h3><p>Simulate example</p></div>
</a>
</div>
<div class="examples-footer">
<a href="/examples">View all examples →</a>
</div>
</div>
<div class="getting-started-section">
<h2>Getting Started</h2>
<div class="gs-cards">
<div class="gs-card">
<h3>Looking for the C++ Mode?</h3>
<p>Install C++ Mode straight from the Processing IDE's Contribution Manager. No separate download needed.</p>
<a class="gs-card-link" href="/downloads#cpp-mode">See how →</a>
</div>
<div class="gs-card">
<h3>Download the headers</h3>
<p>Using your own editor and build system? Drop the engine into your project as a drag-and-drop folder or a CMake target.</p>
<a class="gs-card-link" href="/downloads">Go to downloads →</a>
</div>
<div class="gs-card">
<h3>New to C++ Mode?</h3>
<p>Walk through creating your first sketch, from opening Processing to seeing something on screen.</p>
<a class="gs-card-link" href="/gettingstarted">Getting started tutorial →</a>
</div>
</div>
</div>
</div>
</div>
<footer>
<p>C++ Mode for Processing</p>
<p class="footer-contact"><a href="mailto:pep84c@gmail.com">pep84c@gmail.com</a> · <a href="https://discord.gg/vShSrPegJT">Discord</a></p>
</footer>
<script src="./assets/nav.js"></script>
</body>
</html>