Skip to content

Commit 7d2df7d

Browse files
authored
Merge pull request #7270 from limzykenneth/2.0-modules
[p5.js 2.0] State machines and renderer refactoring
2 parents acb5ac4 + 2641218 commit 7d2df7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+33276
-32710
lines changed

preview/index.html

-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
<body>
1919
<script type="module">
2020
import p5 from '../src/app.js';
21-
// import calculation from './src/math/calculation.js';
22-
23-
// p5.registerAddon(calculation);
2421

2522
const sketch = function (p) {
2623
p.setup = function () {

src/accessibility/outputs.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,8 @@ function outputs(p5, fn){
547547
this.drawingContext.getTransform();
548548
const { x: transformedX, y: transformedY } = untransformedPosition
549549
.matrixTransform(currentTransform);
550-
const canvasWidth = this.width * this._pixelDensity;
551-
const canvasHeight = this.height * this._pixelDensity;
550+
const canvasWidth = this.width * this._renderer._pixelDensity;
551+
const canvasHeight = this.height * this._renderer._pixelDensity;
552552
if (transformedX < 0.4 * canvasWidth) {
553553
if (transformedY < 0.4 * canvasHeight) {
554554
return 'top left';
@@ -653,8 +653,8 @@ function outputs(p5, fn){
653653
// (Ax( By − Cy) + Bx(Cy − Ay) + Cx(Ay − By ))/2
654654
}
655655
// Store the positions of the canvas corners
656-
const canvasWidth = this.width * this._pixelDensity;
657-
const canvasHeight = this.height * this._pixelDensity;
656+
const canvasWidth = this.width * this._renderer._pixelDensity;
657+
const canvasHeight = this.height * this._renderer._pixelDensity;
658658
const canvasCorners = [
659659
new DOMPoint(0, 0),
660660
new DOMPoint(canvasWidth, 0),

src/app.js

+4-19
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
11
// core
22
import p5 from './core/main';
3-
import './core/constants';
4-
import './core/environment';
53
import './core/friendly_errors/stacktrace';
64
import './core/friendly_errors/validate_params';
75
import './core/friendly_errors/file_errors';
86
import './core/friendly_errors/fes_core';
97
import './core/friendly_errors/sketch_reader';
10-
import './core/helpers';
11-
import './core/legacy';
12-
// import './core/preload';
138
import './core/p5.Element';
14-
import './core/p5.Graphics';
15-
// import './core/p5.Renderer';
16-
import './core/p5.Renderer2D';
17-
import './core/rendering';
18-
import './core/structure';
19-
import './core/transform';
20-
import './core/shape/2d_primitives';
21-
import './core/shape/attributes';
22-
import './core/shape/curves';
23-
import './core/shape/vertex';
9+
// import './core/p5.Graphics';
10+
// import './core/rendering';
11+
import shape from './shape';
12+
shape(p5);
2413

2514
//accessibility
2615
import accessibility from './accessibility';
@@ -71,10 +60,6 @@ utilities(p5);
7160
// webgl
7261
import webgl from './webgl';
7362
webgl(p5);
74-
import './webgl/p5.RendererGL.Immediate';
75-
import './webgl/p5.RendererGL';
76-
import './webgl/p5.RendererGL.Retained';
77-
import './webgl/p5.Texture';
7863

7964
import './core/init';
8065

src/color/creating_reading.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ function creatingReading(p5, fn){
683683
}
684684

685685
const arg = Array.isArray(args[0]) ? args[0] : args;
686-
return new p5.Color(this, arg);
686+
return new p5.Color(arg, this._colorMode, this._colorMaxes);
687687
};
688688

689689
/**
@@ -1027,7 +1027,7 @@ function creatingReading(p5, fn){
10271027
space: c1.color.space.path[spaceIndex].id
10281028
})(amt);
10291029

1030-
return new p5.Color(this, lerpColor);
1030+
return new p5.Color(lerpColor, this._colorMode, this._colorMaxes);
10311031
};
10321032

10331033
/**

0 commit comments

Comments
 (0)