Skip to content

Commit

Permalink
Add custom_shapes.js to eventually replace vertex.js
Browse files Browse the repository at this point in the history
  • Loading branch information
GregStanton committed Nov 9, 2024
2 parents 62567a9 + b66247f commit 2107ecb
Show file tree
Hide file tree
Showing 81 changed files with 35,904 additions and 34,951 deletions.
11 changes: 8 additions & 3 deletions preview/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
<body>
<script type="module">
import p5 from '../src/app.js';
// import calculation from './src/math/calculation.js';

// p5.registerAddon(calculation);

const sketch = function (p) {
let g, f;

p.setup = function () {
p.createCanvas(200, 200);
g = p.createGraphics(200, 200);
f = p.createGraphics(200, 200, p.WEBGL);
};

p.draw = function () {
Expand All @@ -34,6 +35,10 @@
p.fill('white');
p.textSize(30);
p.text('hello', 10, 30);

// f.fill('red');
f.sphere();
p.image(f, 0, 0);
};
};

Expand Down
8 changes: 4 additions & 4 deletions src/accessibility/outputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,8 @@ function outputs(p5, fn){
this.drawingContext.getTransform();
const { x: transformedX, y: transformedY } = untransformedPosition
.matrixTransform(currentTransform);
const canvasWidth = this.width * this._pixelDensity;
const canvasHeight = this.height * this._pixelDensity;
const canvasWidth = this.width * this._renderer._pixelDensity;
const canvasHeight = this.height * this._renderer._pixelDensity;
if (transformedX < 0.4 * canvasWidth) {
if (transformedY < 0.4 * canvasHeight) {
return 'top left';
Expand Down Expand Up @@ -653,8 +653,8 @@ function outputs(p5, fn){
// (Ax( By − Cy) + Bx(Cy − Ay) + Cx(Ay − By ))/2
}
// Store the positions of the canvas corners
const canvasWidth = this.width * this._pixelDensity;
const canvasHeight = this.height * this._pixelDensity;
const canvasWidth = this.width * this._renderer._pixelDensity;
const canvasHeight = this.height * this._renderer._pixelDensity;
const canvasCorners = [
new DOMPoint(0, 0),
new DOMPoint(canvasWidth, 0),
Expand Down
25 changes: 4 additions & 21 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
// core
import p5 from './core/main';
import './core/constants';
import './core/environment';
import './core/friendly_errors/stacktrace';
import './core/friendly_errors/validate_params';
import './core/friendly_errors/file_errors';
import './core/friendly_errors/fes_core';
import './core/friendly_errors/sketch_reader';
import './core/helpers';
import './core/legacy';
// import './core/preload';
import './core/p5.Element';
import './core/p5.Graphics';
// import './core/p5.Renderer';
import './core/p5.Renderer2D';
import './core/rendering';
import './core/structure';
import './core/transform';
import './core/shape/2d_primitives';
import './core/shape/attributes';
import './core/shape/curves';
import './core/shape/vertex';
import shape from './shape';
shape(p5);

// shapes
import customShapes from './shape';
Expand All @@ -44,7 +30,8 @@ import data from './data';
data(p5);

// DOM
import './dom/dom';
import dom from './dom';
dom(p5);

// events
import events from './events';
Expand Down Expand Up @@ -74,10 +61,6 @@ utilities(p5);
// webgl
import webgl from './webgl';
webgl(p5);
import './webgl/p5.RendererGL.Immediate';
import './webgl/p5.RendererGL';
import './webgl/p5.RendererGL.Retained';
import './webgl/p5.Texture';

import './core/init';

Expand Down
4 changes: 2 additions & 2 deletions src/color/creating_reading.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ function creatingReading(p5, fn){
}

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

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

return new p5.Color(this, lerpColor);
return new p5.Color(lerpColor, this._colorMode, this._colorMaxes);
};

/**
Expand Down
Loading

0 comments on commit 2107ecb

Please sign in to comment.