Skip to content

Commit fa007be

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/rollup-4.61.1
2 parents 683e903 + 36a6e2d commit fa007be

19 files changed

Lines changed: 1413 additions & 311 deletions

File tree

.github/workflows/continuous-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Publish approved pull requests and latest commit to pkg.pr.new
22
on:
33
pull_request:
44
branches:
5-
- 'dev-2.0'
5+
- 'main'
66
push:
77
branches:
8-
- 'dev-2.0'
8+
- 'main'
99
tags:
1010
- '!**'
1111

@@ -52,4 +52,4 @@ jobs:
5252
uses: actions/upload-artifact@v4
5353
with:
5454
name: output.zip
55-
path: output.json
55+
path: output.json

src/color/creating_reading.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ function creatingReading(p5, fn){
132132
* The version of `color()` with four parameters interprets them as RGBA, HSBA,
133133
* or HSLA colors, depending on the current `colorMode()`. The last parameter
134134
* sets the alpha (transparency) value.
135+
* In p5.strands shader callbacks, `color()` accepts the same input
136+
* formats but returns a `vec4` instead of a `p5.Color` object, with
137+
* RGBA components normalized to the 0–1 range. All colors in strands
138+
* are RGB-based; `colorMode()` has no effect inside shader callbacks.
139+
* Color utility functions such as `red()`, `green()`, `blue()`,
140+
* `alpha()`, `hue()`, `saturation()`, `brightness()`, and
141+
* `lightness()` also return values in the 0–1 range when used in
142+
* strands.
135143
*
136144
* @method color
137145
* @param {Number} gray number specifying value between white and black.

src/core/p5.Renderer2D.js

Lines changed: 27 additions & 196 deletions
Original file line numberDiff line numberDiff line change
@@ -705,96 +705,32 @@ class Renderer2D extends Renderer {
705705
}
706706

707707
line(x1, y1, x2, y2) {
708-
const ctx = this.drawingContext;
709-
if (!this.states.strokeColor) {
710-
return this;
711-
} else if (this._getStroke() === styleEmpty) {
712-
return this;
713-
}
714-
if (this._clipping) {
715-
const tempPath = new Path2D();
716-
tempPath.moveTo(x1, y1);
717-
tempPath.lineTo(x2, y2);
718-
const currentTransform = this.drawingContext.getTransform();
719-
const clipBaseTransform = this._clipBaseTransform.inverse();
720-
const relativeTransform = clipBaseTransform.multiply(currentTransform);
721-
this.clipPath.addPath(tempPath, relativeTransform);
722-
return this;
723-
}
724-
ctx.beginPath();
725-
ctx.moveTo(x1, y1);
726-
ctx.lineTo(x2, y2);
727-
ctx.stroke();
708+
const shape = new p5.Shape({ position: new p5.Vector(0, 0) });
709+
shape.beginShape();
710+
shape.line(x1, y1, x2, y2);
711+
shape.endShape();
712+
this.drawShape(shape);
728713

729714
return this;
730715
}
731716

732717
point(x, y) {
733-
const ctx = this.drawingContext;
734-
if (!this.states.strokeColor) {
735-
return this;
736-
} else if (this._getStroke() === styleEmpty) {
737-
return this;
738-
}
739-
const s = this._getStroke();
740-
const f = this._getFill();
741-
if (this._clipping) {
742-
const tempPath = new Path2D();
743-
const drawingContextWidth = this.drawingContext.lineWidth;
744-
tempPath.arc(x, y, drawingContextWidth / 2, 0, constants.TWO_PI);
745-
const currentTransform = this.drawingContext.getTransform();
746-
const clipBaseTransform = this._clipBaseTransform.inverse();
747-
const relativeTransform = clipBaseTransform.multiply(currentTransform);
748-
this.clipPath.addPath(tempPath, relativeTransform);
749-
return this;
750-
}
751-
this._setFill(s);
752-
ctx.beginPath();
753-
ctx.arc(x, y, ctx.lineWidth / 2, 0, constants.TWO_PI, false);
754-
ctx.fill();
755-
this._setFill(f);
718+
const shape = new p5.Shape({ position: new p5.Vector(0, 0) });
719+
shape.beginShape();
720+
shape.point(x, y);
721+
shape.endShape();
722+
this.drawShape(shape);
756723

757724
return this;
758725
}
759726

760727
quad(x1, y1, x2, y2, x3, y3, x4, y4) {
761-
const ctx = this.drawingContext;
762-
const doFill = !!this.states.fillColor,
763-
doStroke = this.states.strokeColor;
764-
if (doFill && !doStroke) {
765-
if (this._getFill() === styleEmpty) {
766-
return this;
767-
}
768-
} else if (!doFill && doStroke) {
769-
if (this._getStroke() === styleEmpty) {
770-
return this;
771-
}
772-
}
773-
if (this._clipping) {
774-
const tempPath = new Path2D();
775-
tempPath.moveTo(x1, y1);
776-
tempPath.lineTo(x2, y2);
777-
tempPath.lineTo(x3, y3);
778-
tempPath.lineTo(x4, y4);
779-
tempPath.closePath();
780-
const currentTransform = this.drawingContext.getTransform();
781-
const clipBaseTransform = this._clipBaseTransform.inverse();
782-
const relativeTransform = clipBaseTransform.multiply(currentTransform);
783-
this.clipPath.addPath(tempPath, relativeTransform);
784-
return this;
785-
}
786-
ctx.beginPath();
787-
ctx.moveTo(x1, y1);
788-
ctx.lineTo(x2, y2);
789-
ctx.lineTo(x3, y3);
790-
ctx.lineTo(x4, y4);
791-
ctx.closePath();
792-
if (doFill) {
793-
ctx.fill();
794-
}
795-
if (doStroke) {
796-
ctx.stroke();
797-
}
728+
const shape = new p5.Shape({ position: new p5.Vector(0, 0) });
729+
shape.beginShape();
730+
shape.quad(x1, y1, x2, y2, x3, y3, x4, y4);
731+
shape.endShape();
732+
this.drawShape(shape);
733+
798734
return this;
799735
}
800736

@@ -807,134 +743,29 @@ class Renderer2D extends Renderer {
807743
let tr = args[5];
808744
let br = args[6];
809745
let bl = args[7];
810-
const ctx = this.drawingContext;
811-
const doFill = !!this.states.fillColor,
812-
doStroke = this.states.strokeColor;
813-
if (doFill && !doStroke) {
814-
if (this._getFill() === styleEmpty) {
815-
return this;
816-
}
817-
} else if (!doFill && doStroke) {
818-
if (this._getStroke() === styleEmpty) {
819-
return this;
820-
}
821-
}
822-
if (this._clipping) {
823-
const tempPath = new Path2D();
824-
if (typeof tl === 'undefined') {
825-
tempPath.rect(x, y, w, h);
826-
} else {
827-
tempPath.roundRect(x, y, w, h, [tl, tr, br, bl]);
828-
}
829-
const currentTransform = this.drawingContext.getTransform();
830-
const clipBaseTransform = this._clipBaseTransform.inverse();
831-
const relativeTransform = clipBaseTransform.multiply(currentTransform);
832-
this.clipPath.addPath(tempPath, relativeTransform);
833-
return this;
834-
}
835-
ctx.beginPath();
836-
if (typeof tl === 'undefined') {
837-
// No rounded corners
838-
ctx.rect(x, y, w, h);
839-
} else {
840-
// At least one rounded corner
841-
// Set defaults when not specified
842-
if (typeof tr === 'undefined') {
843-
tr = tl;
844-
}
845-
if (typeof br === 'undefined') {
846-
br = tr;
847-
}
848-
if (typeof bl === 'undefined') {
849-
bl = br;
850-
}
851746

852-
// corner rounding must always be positive
853-
const absW = Math.abs(w);
854-
const absH = Math.abs(h);
855-
const hw = absW / 2;
856-
const hh = absH / 2;
857-
858-
// Clip radii
859-
if (absW < 2 * tl) {
860-
tl = hw;
861-
}
862-
if (absH < 2 * tl) {
863-
tl = hh;
864-
}
865-
if (absW < 2 * tr) {
866-
tr = hw;
867-
}
868-
if (absH < 2 * tr) {
869-
tr = hh;
870-
}
871-
if (absW < 2 * br) {
872-
br = hw;
873-
}
874-
if (absH < 2 * br) {
875-
br = hh;
876-
}
877-
if (absW < 2 * bl) {
878-
bl = hw;
879-
}
880-
if (absH < 2 * bl) {
881-
bl = hh;
882-
}
747+
const shape = new p5.Shape({ position: new p5.Vector(0, 0) });
748+
shape.beginShape();
749+
shape.rectPrimitive(x, y, w, h, tl, tr, br, bl);
750+
shape.endShape();
751+
this.drawShape(shape);
883752

884-
ctx.roundRect(x, y, w, h, [tl, tr, br, bl]);
885-
}
886-
if (doFill) {
887-
ctx.fill();
888-
}
889-
if (doStroke) {
890-
ctx.stroke();
891-
}
892753
return this;
893754
}
894755

895-
896756
triangle(args) {
897-
const ctx = this.drawingContext;
898-
const doFill = !!this.states.fillColor,
899-
doStroke = this.states.strokeColor;
900757
const x1 = args[0],
901758
y1 = args[1];
902759
const x2 = args[2],
903760
y2 = args[3];
904761
const x3 = args[4],
905762
y3 = args[5];
906-
if (doFill && !doStroke) {
907-
if (this._getFill() === styleEmpty) {
908-
return this;
909-
}
910-
} else if (!doFill && doStroke) {
911-
if (this._getStroke() === styleEmpty) {
912-
return this;
913-
}
914-
}
915-
if (this._clipping) {
916-
const tempPath = new Path2D();
917-
tempPath.moveTo(x1, y1);
918-
tempPath.lineTo(x2, y2);
919-
tempPath.lineTo(x3, y3);
920-
tempPath.closePath();
921-
const currentTransform = this.drawingContext.getTransform();
922-
const clipBaseTransform = this._clipBaseTransform.inverse();
923-
const relativeTransform = clipBaseTransform.multiply(currentTransform);
924-
this.clipPath.addPath(tempPath, relativeTransform);
925-
return this;
926-
}
927-
ctx.beginPath();
928-
ctx.moveTo(x1, y1);
929-
ctx.lineTo(x2, y2);
930-
ctx.lineTo(x3, y3);
931-
ctx.closePath();
932-
if (doFill) {
933-
ctx.fill();
934-
}
935-
if (doStroke) {
936-
ctx.stroke();
937-
}
763+
764+
const shape = new p5.Shape({ position: new p5.Vector(0, 0) });
765+
shape.beginShape();
766+
shape.triangle(x1, y1, x2, y2, x3, y3);
767+
shape.endShape();
768+
this.drawShape(shape);
938769

939770
return this;
940771
}

src/events/pointer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,10 @@ function pointer(p5, fn, lifecycles){
10691069
this._activePointers.set(e.pointerId, e);
10701070
this._setMouseButton(e);
10711071

1072+
if (this.mouseIsPressed && e.buttons === 0) {
1073+
this._onpointerup(e);
1074+
}
1075+
10721076
if (
10731077
!this.mouseIsPressed &&
10741078
typeof this._customActions.mouseMoved === 'function'

0 commit comments

Comments
 (0)