Skip to content

Commit

Permalink
Merge pull request processing#1962 from sixhat/master
Browse files Browse the repository at this point in the history
Set gl.BLEND in texture to allow transparent pngs && added line to webgl primitives
  • Loading branch information
stalgiag authored Jun 20, 2017
2 parents 80ab9c1 + cb66017 commit 8fdd36a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/webgl/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ p5.prototype.texture = function(){
args[i] = arguments[i];
}
var gl = this._renderer.GL;
gl.enable(gl.BLEND);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
this._renderer.drawMode = 'texture';
var shaderProgram = this._renderer._getShader('lightVert',
'lightTextureFrag');
Expand Down
44 changes: 44 additions & 0 deletions src/webgl/primitives.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,4 +787,48 @@ p5.RendererGL.prototype.curve=function
return this;
};

/**
* Draw a line given two points
* @param {Number} x0 x-coordinate of first vertex
* @param {Number} y0 y-coordinate of first vertex
* @param {Number} z0 z-coordinate of first vertex
* @param {Number} x1 x-coordinate of second vertex
* @param {Number} y1 y-coordinate of second vertex
* @param {Number} z1 z-coordinate of second vertex
* @return {p5} The P5 object
* @example
* <div>
* <code>
* //draw a line
* function setup(){
* createCanvas(100, 100, WEBGL);
* }
*
* function draw(){
* background(200);
* rotateX(frameCount * 0.01);
* rotateY(frameCount * 0.01);
* // Use fill instead of stroke to change the color of shape.
* fill(255, 0, 0);
* line(10, 10, 0, 60, 60, 20);
* }
* </code>
* </div>
*/
p5.RendererGL.prototype.line = function(x0,y0,z0,x1,y1,z1) {
if (typeof x0 !== 'undefined' ||
typeof y0 !== 'undefined' ||
typeof z0 !== 'undefined' ||
typeof x1 !== 'undefined' ||
typeof y1 !== 'undefined' ||
typeof z1 !== 'undefined')
{
this.beginShape();
this.vertex(x0, y0, z0);
this.vertex(x1, y1, z1);
this.endShape();
}
return this;
};

module.exports = p5;

0 comments on commit 8fdd36a

Please sign in to comment.