Open
Description
Most appropriate sub-area of p5.js?
- AccessibilityColorCore/Environment/RenderingDataDOMEventsImageIOMathTypographyUtilitiesWebGLBuild ProcessUnit TestingInternalizationFriendly ErrorsOther (specify if possible)
p5.js version
1.6.0
Web browser and version
No response
Operating System
No response
Steps to reproduce this
I first identified this issue in the discussion for PR #6122
When using WEBGL mode, textOutput() and gridOutput() only produce descriptions of 2D shapes, and the descriptions are inaccurate because they do not take into account the difference in origin point or the camera settings.
In the example below, the textOutput describes a square in the upper left corner (rather than lower right where it appears on the canvas) and does not include the sphere.
function setup() {
createCanvas(400, 400, WEBGL);
textOutput();
}
function draw() {
background(220);
sphere();
square(100, 100, 100);
}
I think producing accurate descriptions in WEBGL would be a big undertaking, and in the meantime, I think it would be best for textOuput() and gridOutput() to throw a friendly error when called in WEBGL mode. I'm happy to open a PR for this.
Metadata
Metadata
Assignees
Type
Projects
Status
Open for Discussion
Activity
davepagurek commentedon Dec 23, 2023
If anyone is interested in taking this on, the way I've calculated screen-space positions out of WebGL coordinates in the past is by doing this:
Garavitey commentedon Dec 24, 2023
i would like to contribute
davepagurek commentedon Dec 24, 2023
Thanks @Gaurav-1306! I'll assign it to you. Let me know if I can help clarify anything!
Garavitey commentedon Dec 25, 2023
p5.js/src/accessibility/outputs.js
Lines 544 to 550 in cea9e09
@davepagurek
in this code, I think the values of x and y are wrong, and solving that could remove the error(for textoutput()). So after the condition check that the renderer is 3d or not what should I do? should i make a new function that calculates the correct x and y position(using your suggestion for 3d and checking what is wrong with 2d) or do I have to change
this._renderer.uMVMatrix.mat4
andthis.drawingContext.getTransform()
to find the correct value of x and y.Garavitey commentedon Dec 27, 2023
hey @davepagurek
i tried solving the problem using this, but i am unable to do it. can you help!
davepagurek commentedon Dec 28, 2023
That looks like a good start! It looks like the function currently returns some strings for the location:
p5.js/src/accessibility/outputs.js
Lines 553 to 559 in cea9e09
so maybe rather than returning an object with an x and y position, your code should be something like this, where both branches set
transformedX
andtransformedY
, to be used later on when returning a string:Forchapeatl commentedon Aug 27, 2024
We can close this issue ,
textOutput
andgridOutput
works perfectly with the latest version ofp5.js
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.10.0/p5.js"></script>
calebfoss commentedon Aug 27, 2024
Updated example with v1.10
The label now correctly describes the square's position as the bottom right! That's awesome!
Unfortunately, the sphere is still not described, and now the label says that the square takes up 15625% of the canvas, whereas before it said 6%.
Forchapeatl commentedon Aug 27, 2024
Thank you for the update @calebfoss . We can Identify 2 issues here. Unreported shapes and inaccurate percentage. Please take a look at my code . It seems seems all 3D shapes are not reported by the function.
calebfoss commentedon Aug 27, 2024
@Forchapeatl, exactly! 3D shape descriptions were never implemented. That's what I was referring to here:
In this accessibility features proposal, I go into more detail on the future of these functions.
I'm glad you're looking into improving the accessibility features!