You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* <a href="#/p5/endShape">endShape()</a> functions. The curved segment uses
1251
-
* the previous vertex as the first anchor point, so there must be at least
1252
-
* one call to <a href="#/p5/vertex">vertex()</a> before `quadraticVertex()` can
1253
-
* be used.
1254
-
*
1255
-
* The first two parameters, `cx` and `cy`, set the curve’s control point.
1256
-
* The control point "pulls" the curve towards its.
1257
-
*
1258
-
* The last two parameters, `x3`, and `y3`, set the last anchor point. The
1259
-
* last anchor point is where the curve ends.
1260
-
*
1261
-
* Bézier curves can also be drawn in 3D using WebGL mode. The 3D version of
1262
-
* `bezierVertex()` has eight arguments because each point has x-, y-, and
1263
-
* z-coordinates.
1264
-
*
1265
-
* Note: `quadraticVertex()` won’t work when an argument is passed to
1266
-
* <a href="#/p5/beginShape">beginShape()</a>.
1267
-
*
1268
-
* @method quadraticVertex
1269
-
* @param {Number} cx x-coordinate of the control point.
1270
-
* @param {Number} cy y-coordinate of the control point.
1271
-
* @param {Number} x3 x-coordinate of the anchor point.
1272
-
* @param {Number} y3 y-coordinate of the anchor point.
1273
-
* @chainable
1274
-
*
1275
-
* @example
1276
-
* <div>
1277
-
* <code>
1278
-
* function setup() {
1279
-
* createCanvas(100, 100);
1280
-
*
1281
-
* background(200);
1282
-
*
1283
-
* // Style the curve.
1284
-
* noFill();
1285
-
*
1286
-
* // Draw the curve.
1287
-
* beginShape();
1288
-
* vertex(20, 20);
1289
-
* quadraticVertex(80, 20, 50, 50);
1290
-
* endShape();
1291
-
*
1292
-
* describe('A black curve drawn on a gray square. The curve starts at the top-left corner and ends at the center.');
1293
-
* }
1294
-
* </code>
1295
-
* </div>
1296
-
*
1297
-
* <div>
1298
-
* <code>
1299
-
* function setup() {
1300
-
* createCanvas(100, 100);
1301
-
*
1302
-
* background(200);
1303
-
*
1304
-
* // Draw the curve.
1305
-
* noFill();
1306
-
* beginShape();
1307
-
* vertex(20, 20);
1308
-
* quadraticVertex(80, 20, 50, 50);
1309
-
* endShape();
1310
-
*
1311
-
* // Draw red lines from the anchor points to the control point.
1312
-
* stroke(255, 0, 0);
1313
-
* line(20, 20, 80, 20);
1314
-
* line(50, 50, 80, 20);
1315
-
*
1316
-
* // Draw the anchor points in black.
1317
-
* strokeWeight(5);
1318
-
* stroke(0);
1319
-
* point(20, 20);
1320
-
* point(50, 50);
1321
-
*
1322
-
* // Draw the control point in red.
1323
-
* stroke(255, 0, 0);
1324
-
* point(80, 20);
1325
-
*
1326
-
* describe('A black curve that starts at the top-left corner and ends at the center. Its anchor and control points are marked with dots. Red lines connect both anchor points to the control point.');
1327
-
* }
1328
-
* </code>
1329
-
* </div>
1330
-
*
1331
-
* <div>
1332
-
* <code>
1333
-
* // Click the mouse near the red dot in the top-right corner
1334
-
* // and drag to change the curve's shape.
1335
-
*
1336
-
* let x2 = 80;
1337
-
* let y2 = 20;
1338
-
* let isChanging = false;
1339
-
*
1340
-
* function setup() {
1341
-
* createCanvas(100, 100);
1342
-
*
1343
-
* describe('A black curve that starts at the top-left corner and ends at the center. Its anchor and control points are marked with dots. Red lines connect both anchor points to the control point.');
1344
-
* }
1345
-
*
1346
-
* function draw() {
1347
-
* background(200);
1348
-
*
1349
-
* // Style the curve.
1350
-
* noFill();
1351
-
* strokeWeight(1);
1352
-
* stroke(0);
1353
-
*
1354
-
* // Draw the curve.
1355
-
* beginShape();
1356
-
* vertex(20, 20);
1357
-
* quadraticVertex(x2, y2, 50, 50);
1358
-
* endShape();
1359
-
*
1360
-
* // Draw red lines from the anchor points to the control point.
1361
-
* stroke(255, 0, 0);
1362
-
* line(20, 20, x2, y2);
1363
-
* line(50, 50, x2, y2);
1364
-
*
1365
-
* // Draw the anchor points in black.
1366
-
* strokeWeight(5);
1367
-
* stroke(0);
1368
-
* point(20, 20);
1369
-
* point(50, 50);
1370
-
*
1371
-
* // Draw the control point in red.
1372
-
* stroke(255, 0, 0);
1373
-
* point(x2, y2);
1374
-
* }
1375
-
*
1376
-
* // Start changing the first control point if the user clicks near it.
1377
-
* function mousePressed() {
1378
-
* if (dist(mouseX, mouseY, x2, y2) < 20) {
1379
-
* isChanging = true;
1380
-
* }
1381
-
* }
1382
-
*
1383
-
* // Stop changing the first control point when the user releases the mouse.
1384
-
* function mouseReleased() {
1385
-
* isChanging = false;
1386
-
* }
1387
-
*
1388
-
* // Update the first control point while the user drags the mouse.
1389
-
* function mouseDragged() {
1390
-
* if (isChanging === true) {
1391
-
* x2 = mouseX;
1392
-
* y2 = mouseY;
1393
-
* }
1394
-
* }
1395
-
* </code>
1396
-
* </div>
1397
-
*
1398
-
* <div>
1399
-
* <code>
1400
-
* function setup() {
1401
-
* createCanvas(100, 100);
1402
-
*
1403
-
* background(200);
1404
-
*
1405
-
* // Start drawing the shape.
1406
-
* beginShape();
1407
-
*
1408
-
* // Add the curved segments.
1409
-
* vertex(20, 20);
1410
-
* quadraticVertex(80, 20, 50, 50);
1411
-
* quadraticVertex(20, 80, 80, 80);
1412
-
*
1413
-
* // Add the straight segments.
1414
-
* vertex(80, 10);
1415
-
* vertex(20, 10);
1416
-
* vertex(20, 20);
1417
-
*
1418
-
* // Stop drawing the shape.
1419
-
* endShape();
1420
-
*
1421
-
* describe('A white puzzle piece drawn on a gray background.');
1422
-
* }
1423
-
* </code>
1424
-
* </div>
1425
-
*
1426
-
* <div>
1427
-
* <code>
1428
-
* // Click the and drag the mouse to view the scene from a different angle.
1429
-
*
1430
-
* function setup() {
1431
-
* createCanvas(100, 100, WEBGL);
1432
-
*
1433
-
* describe('A white puzzle piece on a dark gray background. When the user clicks and drags the scene, the outline of a second puzzle piece is revealed.');
1434
-
* }
1435
-
*
1436
-
* function draw() {
1437
-
* background(50);
1438
-
*
1439
-
* // Enable orbiting with the mouse.
1440
-
* orbitControl();
1441
-
*
1442
-
* // Style the first puzzle piece.
1443
-
* noStroke();
1444
-
* fill(255);
1445
-
*
1446
-
* // Draw the first puzzle piece.
1447
-
* beginShape();
1448
-
* vertex(-30, -30, 0);
1449
-
* quadraticVertex(30, -30, 0, 0, 0, 0);
1450
-
* quadraticVertex(-30, 30, 0, 30, 30, 0);
1451
-
* vertex(30, -40, 0);
1452
-
* vertex(-30, -40, 0);
1453
-
* vertex(-30, -30, 0);
1454
-
* endShape();
1455
-
*
1456
-
* // Style the second puzzle piece.
1457
-
* stroke(255);
1458
-
* noFill();
1459
-
*
1460
-
* // Draw the second puzzle piece.
1461
-
* beginShape();
1462
-
* vertex(-30, -30, -20);
1463
-
* quadraticVertex(30, -30, -20, 0, 0, -20);
1464
-
* quadraticVertex(-30, 30, -20, 30, 30, -20);
1465
-
* vertex(30, -40, -20);
1466
-
* vertex(-30, -40, -20);
1467
-
* vertex(-30, -30, -20);
1468
-
* endShape();
1469
-
* }
1470
-
* </code>
1471
-
* </div>
1472
-
*/
1473
-
1474
-
/**
1475
-
* @method quadraticVertex
1476
-
* @param {Number} cx
1477
-
* @param {Number} cy
1478
-
* @param {Number} cz z-coordinate of the control point.
1479
-
* @param {Number} x3
1480
-
* @param {Number} y3
1481
-
* @param {Number} z3 z-coordinate of the anchor point.
0 commit comments