Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed no_tint issue while rendering #7695

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>P5 Sketch</title>
<!-- Add full p5.js with WebGL support -->
<script src="lib/p5.js"></script>

<script src="test_tint.js"></script>
<style>
#debug {
position: fixed;
top: 10px;
left: 10px;
background: #333;
color: white;
padding: 10px;
font-family: monospace;
}
</style>
</head>
<body>
<div id="debug"></div>
</body>
</html>
4 changes: 2 additions & 2 deletions src/image/loading_displaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@ p5.prototype.tint = function(...args) {
* </div>
*/
p5.prototype.noTint = function() {
this._renderer._tint = null;
this._renderer._tint = [255, 255, 255, 255];
};

/**
Expand Down Expand Up @@ -1501,4 +1501,4 @@ p5.prototype.imageMode = function(m) {
}
};

export default p5;
export default p5;
2 changes: 1 addition & 1 deletion src/webgl/p5.RendererGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -2545,4 +2545,4 @@ p5.prototype._assert3d = function (name) {

p5.RendererGL.prototype.tessyVertexSize = 12;

export default p5.RendererGL;
export default p5.RendererGL;
2 changes: 1 addition & 1 deletion src/webgl/p5.Shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1494,4 +1494,4 @@ p5.Shader = class {
}
};

export default p5.Shader;
export default p5.Shader;
2 changes: 1 addition & 1 deletion src/webgl/shaders/basic.frag
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ void main(void) {
HOOK_beforeFragment();
OUT_COLOR = HOOK_getFinalColor(vec4(vColor.rgb, 1.) * vColor.a);
HOOK_afterFragment();
}
}
52 changes: 52 additions & 0 deletions test_tint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
let img;
let tintOn = true;
let button;

function preload() {
img = loadImage('testfile.png');
}

function setup() {
createCanvas(600, 400);

// Create button
button = createButton('Toggle Tint');
button.position(10, height + 10);
button.mousePressed(toggleTint);

// Initial button styling
button.style('background-color', '#4CAF50');
button.style('color', 'white');
button.style('padding', '10px 20px');
button.style('border', 'none');
button.style('border-radius', '4px');
button.style('cursor', 'pointer');
}

function draw() {
background(220);

// Apply tint if enabled
if (tintOn) {
tint(255, 0, 0); // Red tint
} else {
noTint();
}

// Draw image centered
imageMode(CENTER);
image(img, width/2, height/2);

// Add text to show current state
noTint(); // Reset tint for text
fill(0);
textSize(16);
textAlign(LEFT, TOP);
text('Tint: ' + (tintOn ? 'ON' : 'OFF'), 10, 10);
}

function toggleTint() {
tintOn = !tintOn;
// Update button color based on state
button.style('background-color', tintOn ? '#4CAF50' : '#f44336');
}
Binary file added testfile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.