p5 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/{src → dist}/accessibility/color_namer.js +48 -3
  2. package/{src → dist}/accessibility/describe.js +2 -2
  3. package/{src → dist}/accessibility/gridOutput.js +2 -2
  4. package/dist/accessibility/index.js +60 -0
  5. package/{src → dist}/accessibility/outputs.js +2 -2
  6. package/{src → dist}/accessibility/textOutput.js +2 -2
  7. package/dist/app.js +120 -0
  8. package/{src → dist}/color/color_conversion.js +48 -10
  9. package/{src → dist}/color/color_spaces/hsb.js +3 -1
  10. package/dist/color/creating_reading.js +3 -0
  11. package/dist/color/index.js +13 -0
  12. package/dist/color/p5.Color.culori.js +1 -0
  13. package/dist/color/p5.Color.js +3 -0
  14. package/{src → dist}/color/setting.js +9 -6
  15. package/{src/core/constants.js → dist/constants-C-g_eAdC.js} +266 -130
  16. package/{src → dist}/core/States.js +3 -1
  17. package/dist/core/constants.js +1 -0
  18. package/{src → dist}/core/environment.js +7 -6
  19. package/{src → dist}/core/friendly_errors/browser_errors.js +1 -1
  20. package/{src → dist}/core/friendly_errors/fes_core.js +14 -44
  21. package/{src → dist}/core/friendly_errors/file_errors.js +6 -3
  22. package/dist/core/friendly_errors/index.js +23 -0
  23. package/dist/core/friendly_errors/param_validator.js +5455 -0
  24. package/{src → dist}/core/friendly_errors/sketch_reader.js +50 -4
  25. package/{src → dist}/core/friendly_errors/sketch_verifier.js +6 -6
  26. package/{src → dist}/core/friendly_errors/stacktrace.js +3 -5
  27. package/{src → dist}/core/friendly_errors/validate_params.js +50 -41
  28. package/{src → dist}/core/helpers.js +9 -6
  29. package/dist/core/init.js +105 -0
  30. package/dist/core/internationalization.js +302 -0
  31. package/dist/core/legacy.js +73 -0
  32. package/dist/core/main.js +44 -0
  33. package/dist/core/noop.js +3 -0
  34. package/dist/core/p5.Graphics.js +40 -0
  35. package/dist/core/p5.Renderer.js +11 -0
  36. package/dist/core/p5.Renderer2D.js +44 -0
  37. package/dist/core/reference.js +1 -0
  38. package/dist/core/rendering.js +40 -0
  39. package/{src → dist}/core/structure.js +3 -3
  40. package/{src → dist}/core/transform.js +2 -2
  41. package/{src/color/creating_reading.js → dist/creating_reading-D4AAKRbx.js} +841 -13
  42. package/{src → dist}/data/index.js +3 -1
  43. package/{src → dist}/data/local_storage.js +2 -8
  44. package/{src → dist}/dom/dom.js +11 -5
  45. package/dist/dom/index.js +18 -0
  46. package/{src → dist}/dom/p5.Element.js +14 -12
  47. package/{src → dist}/dom/p5.File.js +4 -4
  48. package/{src → dist}/dom/p5.MediaElement.js +10 -4
  49. package/{src → dist}/events/acceleration.js +2 -2
  50. package/{src → dist}/events/index.js +3 -1
  51. package/{src → dist}/events/keyboard.js +14 -11
  52. package/{src → dist}/events/pointer.js +16 -17
  53. package/dist/image/const.js +9 -0
  54. package/{src → dist}/image/filterRenderer2D.js +57 -37
  55. package/{src → dist}/image/filters.js +1 -3
  56. package/dist/image/image.js +40 -0
  57. package/dist/image/index.js +51 -0
  58. package/dist/image/loading_displaying.js +40 -0
  59. package/dist/image/p5.Image.js +11 -0
  60. package/{src → dist}/image/pixels.js +4 -3
  61. package/{src → dist}/io/csv.js +72 -70
  62. package/dist/io/files.js +40 -0
  63. package/dist/io/index.js +51 -0
  64. package/{src → dist}/io/p5.Table.js +6 -6
  65. package/{src → dist}/io/p5.TableRow.js +3 -4
  66. package/{src → dist}/io/p5.XML.js +2 -5
  67. package/{src → dist}/io/utilities.js +1 -1
  68. package/{src/core/p5.Renderer2D.js → dist/main-s72KWcUy.js} +735 -57
  69. package/{src → dist}/math/Matrices/Matrix.js +10 -8
  70. package/{src → dist}/math/Matrices/MatrixInterface.js +5 -3
  71. package/{src → dist}/math/Matrices/MatrixNumjs.js +12 -26
  72. package/{src → dist}/math/calculation.js +2 -2
  73. package/{src → dist}/math/index.js +6 -3
  74. package/{src → dist}/math/math.js +2 -2
  75. package/{src → dist}/math/noise.js +2 -2
  76. package/{src → dist}/math/p5.Matrix.js +7 -4
  77. package/{src → dist}/math/p5.Vector.js +6 -6
  78. package/{src → dist}/math/random.js +2 -2
  79. package/{src → dist}/math/trigonometry.js +16 -15
  80. package/{src/image/p5.Image.js → dist/p5.Renderer-CwAYZOC2.js} +390 -19
  81. package/dist/rendering--aAe5aq3.js +24925 -0
  82. package/{src → dist}/shape/2d_primitives.js +18 -17
  83. package/{src → dist}/shape/attributes.js +18 -17
  84. package/{src → dist}/shape/curves.js +2 -2
  85. package/{src → dist}/shape/custom_shapes.js +44 -64
  86. package/{src → dist}/shape/index.js +10 -2
  87. package/{src → dist}/shape/vertex.js +2 -3
  88. package/dist/type/index.js +25 -0
  89. package/{src → dist}/type/lib/Typr.js +76 -94
  90. package/{src → dist}/type/p5.Font.js +37 -61
  91. package/{src → dist}/type/textCore.js +34 -57
  92. package/{src → dist}/type/unicodeRanges.js +3 -1
  93. package/{src → dist}/utilities/conversion.js +2 -2
  94. package/{src → dist}/utilities/index.js +3 -1
  95. package/{src → dist}/utilities/time_date.js +6 -7
  96. package/{src → dist}/utilities/utility_functions.js +2 -2
  97. package/dist/webgl/3d_primitives.js +40 -0
  98. package/{src → dist}/webgl/GeometryBufferCache.js +3 -1
  99. package/{src → dist}/webgl/GeometryBuilder.js +12 -8
  100. package/{src → dist}/webgl/ShaderGenerator.js +79 -82
  101. package/{src → dist}/webgl/ShapeBuilder.js +26 -23
  102. package/dist/webgl/index.js +76 -0
  103. package/{src → dist}/webgl/interaction.js +7 -6
  104. package/dist/webgl/light.js +40 -0
  105. package/{src → dist}/webgl/loading.js +45 -12
  106. package/dist/webgl/material.js +40 -0
  107. package/dist/webgl/p5.Camera.js +40 -0
  108. package/{src → dist}/webgl/p5.DataArray.js +3 -5
  109. package/dist/webgl/p5.Framebuffer.js +40 -0
  110. package/{src → dist}/webgl/p5.Geometry.js +12 -15
  111. package/{src → dist}/webgl/p5.Quat.js +5 -4
  112. package/{src → dist}/webgl/p5.RenderBuffer.js +2 -3
  113. package/dist/webgl/p5.RendererGL.js +40 -0
  114. package/dist/webgl/p5.Shader.js +40 -0
  115. package/dist/webgl/p5.Texture.js +40 -0
  116. package/{src → dist}/webgl/text.js +51 -9
  117. package/lib/p5.esm.js +102 -48
  118. package/lib/p5.js +102 -48
  119. package/lib/p5.min.js +1 -1
  120. package/package.json +17 -16
  121. package/translations/dev.js +6 -6
  122. package/translations/index.js +1 -1
  123. package/src/README.md +0 -27
  124. package/src/accessibility/index.js +0 -13
  125. package/src/app.js +0 -61
  126. package/src/color/index.js +0 -9
  127. package/src/color/p5.Color.culori.js +0 -66
  128. package/src/color/p5.Color.js +0 -851
  129. package/src/core/README.md +0 -91
  130. package/src/core/friendly_errors/index.js +0 -13
  131. package/src/core/friendly_errors/param_validator.js +0 -561
  132. package/src/core/init.js +0 -58
  133. package/src/core/internationalization.js +0 -195
  134. package/src/core/legacy.js +0 -29
  135. package/src/core/main.js +0 -689
  136. package/src/core/noop.js +0 -1
  137. package/src/core/p5.Graphics.js +0 -696
  138. package/src/core/p5.Renderer.js +0 -408
  139. package/src/core/reference.js +0 -2060
  140. package/src/core/rendering.js +0 -697
  141. package/src/dom/index.js +0 -11
  142. package/src/image/const.js +0 -6
  143. package/src/image/image.js +0 -731
  144. package/src/image/index.js +0 -15
  145. package/src/image/loading_displaying.js +0 -1431
  146. package/src/io/files.js +0 -2210
  147. package/src/io/index.js +0 -11
  148. package/src/math/README.md +0 -40
  149. package/src/type/index.js +0 -9
  150. package/src/webgl/3d_primitives.js +0 -2741
  151. package/src/webgl/index.js +0 -37
  152. package/src/webgl/light.js +0 -1851
  153. package/src/webgl/material.js +0 -3854
  154. package/src/webgl/p5.Camera.js +0 -4010
  155. package/src/webgl/p5.Framebuffer.js +0 -1865
  156. package/src/webgl/p5.RendererGL.js +0 -2867
  157. package/src/webgl/p5.Shader.js +0 -1505
  158. package/src/webgl/p5.Texture.js +0 -541
  159. package/src/webgl/shaders/basic.frag +0 -6
  160. package/src/webgl/shaders/filters/base.frag +0 -22
  161. package/src/webgl/shaders/filters/base.vert +0 -19
  162. package/src/webgl/shaders/filters/blur.frag +0 -60
  163. package/src/webgl/shaders/filters/default.vert +0 -18
  164. package/src/webgl/shaders/filters/dilate.frag +0 -39
  165. package/src/webgl/shaders/filters/erode.frag +0 -39
  166. package/src/webgl/shaders/filters/gray.frag +0 -16
  167. package/src/webgl/shaders/filters/invert.frag +0 -15
  168. package/src/webgl/shaders/filters/opaque.frag +0 -12
  169. package/src/webgl/shaders/filters/posterize.frag +0 -29
  170. package/src/webgl/shaders/filters/threshold.frag +0 -23
  171. package/src/webgl/shaders/font.frag +0 -216
  172. package/src/webgl/shaders/font.vert +0 -44
  173. package/src/webgl/shaders/imageLight.vert +0 -33
  174. package/src/webgl/shaders/imageLightDiffused.frag +0 -82
  175. package/src/webgl/shaders/imageLightSpecular.frag +0 -134
  176. package/src/webgl/shaders/light.vert +0 -37
  177. package/src/webgl/shaders/light_texture.frag +0 -26
  178. package/src/webgl/shaders/lighting.glsl +0 -227
  179. package/src/webgl/shaders/line.frag +0 -74
  180. package/src/webgl/shaders/line.vert +0 -294
  181. package/src/webgl/shaders/normal.frag +0 -6
  182. package/src/webgl/shaders/normal.vert +0 -72
  183. package/src/webgl/shaders/phong.frag +0 -84
  184. package/src/webgl/shaders/phong.vert +0 -87
  185. package/src/webgl/shaders/point.frag +0 -29
  186. package/src/webgl/shaders/point.vert +0 -19
  187. package/src/webgl/shaders/sphereMapping.frag +0 -26
  188. package/src/webgl/shaders/webgl2Compatibility.glsl +0 -34
@@ -1,3 +1,11 @@
1
+ import { C as Color } from './creating_reading-D4AAKRbx.js';
2
+ import { N as NORMAL, am as WORD, an as BASELINE, ao as LEFT, C as CENTER, e as CORNER, I as INCLUDE } from './constants-C-g_eAdC.js';
3
+ import Filters from './image/filters.js';
4
+ import { Vector } from './math/p5.Vector.js';
5
+ import { Shape } from './shape/custom_shapes.js';
6
+ import { States } from './core/States.js';
7
+ import { _checkFileExtension, downloadFile } from './io/utilities.js';
8
+
1
9
  /**
2
10
  * @module Image
3
11
  * @submodule Image
@@ -6,13 +14,6 @@
6
14
  * @requires filters
7
15
  */
8
16
 
9
- /**
10
- * This module defines the <a href="#/p5.Image">p5.Image</a> class and P5 methods for
11
- * drawing images to the main display canvas.
12
- */
13
- import Filters from './filters';
14
- import { Renderer } from '../core/p5.Renderer';
15
- import { downloadFile, _checkFileExtension } from '../io/utilities';
16
17
 
17
18
  class Image {
18
19
  constructor(width, height) {
@@ -48,11 +49,6 @@ class Image {
48
49
  if (typeof density !== 'undefined') {
49
50
  // Setter: set the density and handle resize
50
51
  if (density <= 0) {
51
- const errorObj = {
52
- type: 'INVALID_VALUE',
53
- format: { types: ['Number'] },
54
- position: 1
55
- };
56
52
 
57
53
  // p5._friendlyParamError(errorObj, 'pixelDensity');
58
54
 
@@ -1926,8 +1922,7 @@ class Image {
1926
1922
  }
1927
1923
  }
1928
1924
  }
1929
- };
1930
-
1925
+ }
1931
1926
  function encodeAndDownloadGif(pImg, filename) {
1932
1927
  const props = pImg.gifProperties;
1933
1928
 
@@ -2151,8 +2146,7 @@ function encodeAndDownloadGif(pImg, filename) {
2151
2146
  type: 'image/gif'
2152
2147
  });
2153
2148
  downloadFile(blob, filename, extension);
2154
- };
2155
-
2149
+ }
2156
2150
  function image(p5, fn){
2157
2151
  /**
2158
2152
  * A class to describe an image.
@@ -2415,9 +2409,386 @@ function image(p5, fn){
2415
2409
  */
2416
2410
  }
2417
2411
 
2418
- export default image;
2419
- export { Image };
2420
-
2421
2412
  if(typeof p5 !== 'undefined'){
2422
2413
  image(p5, p5.prototype);
2423
2414
  }
2415
+
2416
+ /**
2417
+ * @module Rendering
2418
+ * @submodule Rendering
2419
+ * @for p5
2420
+ */
2421
+
2422
+
2423
+ class ClonableObject {
2424
+ constructor(obj = {}) {
2425
+ for (const key in obj) {
2426
+ this[key] = obj[key];
2427
+ }
2428
+ }
2429
+
2430
+ clone() {
2431
+ return new ClonableObject(this);
2432
+ }
2433
+ }
2434
+ class Renderer {
2435
+ static states = {
2436
+ strokeColor: null,
2437
+ strokeSet: false,
2438
+ fillColor: null,
2439
+ fillSet: false,
2440
+ tint: null,
2441
+
2442
+ imageMode: CORNER,
2443
+ rectMode: CORNER,
2444
+ ellipseMode: CENTER,
2445
+ strokeWeight: 1,
2446
+
2447
+ textFont: { family: 'sans-serif' },
2448
+ textLeading: 15,
2449
+ leadingSet: false,
2450
+ textSize: 12,
2451
+ textAlign: LEFT,
2452
+ textBaseline: BASELINE,
2453
+ bezierOrder: 3,
2454
+ splineProperties: new ClonableObject({ ends: INCLUDE, tightness: 0 }),
2455
+ textWrap: WORD,
2456
+
2457
+ // added v2.0
2458
+ fontStyle: NORMAL, // v1: textStyle
2459
+ fontStretch: NORMAL,
2460
+ fontWeight: NORMAL,
2461
+ lineHeight: NORMAL,
2462
+ fontVariant: NORMAL,
2463
+ direction: 'inherit'
2464
+ }
2465
+
2466
+ constructor(pInst, w, h, isMainCanvas) {
2467
+ this._pInst = pInst;
2468
+ this._isMainCanvas = isMainCanvas;
2469
+ this.pixels = [];
2470
+ this._pixelDensity = Math.ceil(window.devicePixelRatio) || 1;
2471
+
2472
+ this.width = w;
2473
+ this.height = h;
2474
+
2475
+ this._events = {};
2476
+
2477
+ if (isMainCanvas) {
2478
+ this._isMainCanvas = true;
2479
+ }
2480
+
2481
+ // Renderer state machine
2482
+ this.states = new States(Renderer.states);
2483
+
2484
+ this.states.strokeColor = new Color([0, 0, 0]);
2485
+ this.states.fillColor = new Color([1, 1, 1]);
2486
+
2487
+ this._pushPopStack = [];
2488
+ // NOTE: can use the length of the push pop stack instead
2489
+ this._pushPopDepth = 0;
2490
+
2491
+ this._clipping = false;
2492
+ this._clipInvert = false;
2493
+
2494
+ this._currentShape = undefined; // Lazily generate current shape
2495
+ }
2496
+
2497
+ get currentShape() {
2498
+ if (!this._currentShape) {
2499
+ this._currentShape = new Shape(this.getCommonVertexProperties());
2500
+ }
2501
+ return this._currentShape;
2502
+ }
2503
+
2504
+ remove() {
2505
+
2506
+ }
2507
+
2508
+ pixelDensity(val){
2509
+ let returnValue;
2510
+ if (typeof val === 'number') {
2511
+ if (val !== this._pixelDensity) {
2512
+ this._pixelDensity = val;
2513
+ }
2514
+ returnValue = this;
2515
+ this.resize(this.width, this.height);
2516
+ } else {
2517
+ returnValue = this._pixelDensity;
2518
+ }
2519
+ return returnValue;
2520
+ }
2521
+
2522
+ // Makes a shallow copy of the current states
2523
+ // and push it into the push pop stack
2524
+ push() {
2525
+ this._pushPopDepth++;
2526
+ this._pushPopStack.push(this.states.getDiff());
2527
+ }
2528
+
2529
+ // Pop the previous states out of the push pop stack and
2530
+ // assign it back to the current state
2531
+ pop() {
2532
+ this._pushPopDepth--;
2533
+ const diff = this._pushPopStack.pop() || {};
2534
+ const modified = this.states.getModified();
2535
+ this.states.applyDiff(diff);
2536
+ this.updateShapeVertexProperties(modified);
2537
+ this.updateShapeProperties(modified);
2538
+ }
2539
+
2540
+ bezierOrder(order) {
2541
+ if (order === undefined) {
2542
+ return this.states.bezierOrder;
2543
+ } else {
2544
+ this.states.setValue('bezierOrder', order);
2545
+ this.updateShapeProperties();
2546
+ }
2547
+ }
2548
+
2549
+ bezierVertex(x, y, z = 0, u = 0, v = 0) {
2550
+ const position = new Vector(x, y, z);
2551
+ const textureCoordinates = this.getSupportedIndividualVertexProperties().textureCoordinates
2552
+ ? new Vector(u, v)
2553
+ : undefined;
2554
+ this.currentShape.bezierVertex(position, textureCoordinates);
2555
+ }
2556
+
2557
+ splineProperty(key, value) {
2558
+ if (value === undefined) {
2559
+ return this.states.splineProperties[key];
2560
+ } else {
2561
+ this.states.setValue('splineProperties', this.states.splineProperties.clone());
2562
+ this.states.splineProperties[key] = value;
2563
+ }
2564
+ this.updateShapeProperties();
2565
+ }
2566
+
2567
+ splineProperties(values) {
2568
+ if (values) {
2569
+ for (const key in values) {
2570
+ this.splineProperty(key, values[key]);
2571
+ }
2572
+ } else {
2573
+ return { ...this.states.splineProperties };
2574
+ }
2575
+ }
2576
+
2577
+ splineVertex(x, y, z = 0, u = 0, v = 0) {
2578
+ const position = new Vector(x, y, z);
2579
+ const textureCoordinates = this.getSupportedIndividualVertexProperties().textureCoordinates
2580
+ ? new Vector(u, v)
2581
+ : undefined;
2582
+ this.currentShape.splineVertex(position, textureCoordinates);
2583
+ }
2584
+
2585
+ curveDetail(d) {
2586
+ if (d === undefined) {
2587
+ return this.states.curveDetail;
2588
+ } else {
2589
+ this.states.setValue('curveDetail', d);
2590
+ }
2591
+ }
2592
+
2593
+ beginShape(...args) {
2594
+ this.currentShape.reset();
2595
+ this.updateShapeVertexProperties();
2596
+ this.currentShape.beginShape(...args);
2597
+ }
2598
+
2599
+ endShape(...args) {
2600
+ this.currentShape.endShape(...args);
2601
+ this.drawShape(this.currentShape);
2602
+ }
2603
+
2604
+ beginContour(shapeKind) {
2605
+ this.currentShape.beginContour(shapeKind);
2606
+ }
2607
+
2608
+ endContour(mode) {
2609
+ this.currentShape.endContour(mode);
2610
+ }
2611
+
2612
+ drawShape(shape, count) {
2613
+ throw new Error('Unimplemented')
2614
+ }
2615
+
2616
+ vertex(x, y, z = 0, u = 0, v = 0) {
2617
+ const position = new Vector(x, y, z);
2618
+ const textureCoordinates = this.getSupportedIndividualVertexProperties().textureCoordinates
2619
+ ? new Vector(u, v)
2620
+ : undefined;
2621
+ this.currentShape.vertex(position, textureCoordinates);
2622
+ }
2623
+
2624
+ bezier(x1, y1, x2, y2, x3, y3, x4, y4) {
2625
+ const oldOrder = this._pInst.bezierOrder();
2626
+ this._pInst.bezierOrder(oldOrder);
2627
+ this._pInst.beginShape();
2628
+ this._pInst.bezierVertex(x1, y1);
2629
+ this._pInst.bezierVertex(x2, y2);
2630
+ this._pInst.bezierVertex(x3, y3);
2631
+ this._pInst.bezierVertex(x4, y4);
2632
+ this._pInst.endShape();
2633
+ return this;
2634
+ }
2635
+
2636
+ spline(...args) {
2637
+ if (args.length === 2 * 4) {
2638
+ const [x1, y1, x2, y2, x3, y3, x4, y4] = args;
2639
+ this._pInst.beginShape();
2640
+ this._pInst.splineVertex(x1, y1);
2641
+ this._pInst.splineVertex(x2, y2);
2642
+ this._pInst.splineVertex(x3, y3);
2643
+ this._pInst.splineVertex(x4, y4);
2644
+ this._pInst.endShape();
2645
+ } else if (args.length === 3 * 4) {
2646
+ const [x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4] = args;
2647
+ this._pInst.beginShape();
2648
+ this._pInst.splineVertex(x1, y1, z1);
2649
+ this._pInst.splineVertex(x2, y2, z2);
2650
+ this._pInst.splineVertex(x3, y3, z3);
2651
+ this._pInst.splineVertex(x4, y4, z4);
2652
+ this._pInst.endShape();
2653
+ }
2654
+ return this;
2655
+ }
2656
+
2657
+ beginClip(options = {}) {
2658
+ if (this._clipping) {
2659
+ throw new Error("It looks like you're trying to clip while already in the middle of clipping. Did you forget to endClip()?");
2660
+ }
2661
+ this._clipping = true;
2662
+ this._clipInvert = options.invert;
2663
+ }
2664
+
2665
+ endClip() {
2666
+ if (!this._clipping) {
2667
+ throw new Error("It looks like you've called endClip() without beginClip(). Did you forget to call beginClip() first?");
2668
+ }
2669
+ this._clipping = false;
2670
+ }
2671
+
2672
+ /**
2673
+ * Resize our canvas element.
2674
+ */
2675
+ resize(w, h) {
2676
+ this.width = w;
2677
+ this.height = h;
2678
+ }
2679
+
2680
+ get(x, y, w, h) {
2681
+ const pd = this._pixelDensity;
2682
+ const canvas = this.canvas;
2683
+
2684
+ if (typeof x === 'undefined' && typeof y === 'undefined') {
2685
+ // get()
2686
+ x = y = 0;
2687
+ w = this.width;
2688
+ h = this.height;
2689
+ } else {
2690
+ x *= pd;
2691
+ y *= pd;
2692
+
2693
+ if (typeof w === 'undefined' && typeof h === 'undefined') {
2694
+ // get(x,y)
2695
+ if (x < 0 || y < 0 || x >= canvas.width || y >= canvas.height) {
2696
+ return [0, 0, 0, 0];
2697
+ }
2698
+
2699
+ return this._getPixel(x, y);
2700
+ }
2701
+ // get(x,y,w,h)
2702
+ }
2703
+
2704
+ const region = new Image(w*pd, h*pd);
2705
+ region.pixelDensity(pd);
2706
+ region.canvas
2707
+ .getContext('2d')
2708
+ .drawImage(canvas, x, y, w * pd, h * pd, 0, 0, w*pd, h*pd);
2709
+
2710
+ return region;
2711
+ }
2712
+
2713
+ scale(x, y){
2714
+
2715
+ }
2716
+
2717
+ fill(...args) {
2718
+ this.states.setValue('fillSet', true);
2719
+ this.states.setValue('fillColor', this._pInst.color(...args));
2720
+ this.updateShapeVertexProperties();
2721
+ }
2722
+
2723
+ noFill() {
2724
+ this.states.setValue('fillColor', null);
2725
+ }
2726
+
2727
+ strokeWeight(w) {
2728
+ if (w === undefined) {
2729
+ return this.states.strokeWeight;
2730
+ } else {
2731
+ this.states.setValue('strokeWeight', w);
2732
+ }
2733
+ }
2734
+
2735
+ stroke(...args) {
2736
+ this.states.setValue('strokeSet', true);
2737
+ this.states.setValue('strokeColor', this._pInst.color(...args));
2738
+ this.updateShapeVertexProperties();
2739
+ }
2740
+
2741
+ noStroke() {
2742
+ this.states.setValue('strokeColor', null);
2743
+ }
2744
+
2745
+ getCommonVertexProperties() {
2746
+ return {}
2747
+ }
2748
+
2749
+ getSupportedIndividualVertexProperties() {
2750
+ return {
2751
+ textureCoordinates: false,
2752
+ }
2753
+ }
2754
+
2755
+ updateShapeProperties(modified) {
2756
+ if (!modified || modified.bezierOrder || modified.splineProperties) {
2757
+ const shape = this.currentShape;
2758
+ shape.bezierOrder(this.states.bezierOrder);
2759
+ shape.splineProperty('ends', this.states.splineProperties.ends);
2760
+ shape.splineProperty('tightness', this.states.splineProperties.tightness);
2761
+ }
2762
+ }
2763
+
2764
+ updateShapeVertexProperties(modified) {
2765
+ const props = this.getCommonVertexProperties();
2766
+ if (!modified || Object.keys(modified).some((k) => k in props)) {
2767
+ const shape = this.currentShape;
2768
+ for (const key in props) {
2769
+ shape[key](props[key]);
2770
+ }
2771
+ }
2772
+ }
2773
+
2774
+ _applyDefaults() {
2775
+ return this;
2776
+ }
2777
+
2778
+ }
2779
+ function renderer(p5, fn){
2780
+ /**
2781
+ * Main graphics and rendering context, as well as the base API
2782
+ * implementation for p5.js "core". To be used as the superclass for
2783
+ * Renderer2D and Renderer3D classes, respectively.
2784
+ *
2785
+ * @class p5.Renderer
2786
+ * @param {HTMLElement} elt DOM node that is wrapped
2787
+ * @param {p5} [pInst] pointer to p5 instance
2788
+ * @param {Boolean} [isMainCanvas] whether we're using it as main canvas
2789
+ * @private
2790
+ */
2791
+ p5.Renderer = Renderer;
2792
+ }
2793
+
2794
+ export { Image as I, Renderer as R, image as i, renderer as r };