Skip to content

Commit

Permalink
Changed the inline doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenpaiSharma committed Sep 13, 2022
1 parent 4cc5595 commit 89506b2
Showing 1 changed file with 10 additions and 36 deletions.
46 changes: 10 additions & 36 deletions src/webgl/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import './p5.Texture';
* shader(mandel);
* noStroke();
* mandel.setUniform('p', [-0.74364388703, 0.13182590421]);
* describe('zooming Mandelbrot set. a colorful, infinitely detailed fractal.');
* }
*
* function draw() {
Expand Down Expand Up @@ -163,7 +162,6 @@ p5.prototype.loadShader = function(
*
* // 'p' is the center point of the Mandelbrot image
* mandel.setUniform('p', [-0.74364388703, 0.13182590421]);
* describe('zooming Mandelbrot set. a colorful, infinitely detailed fractal.');
* }
*
* function draw() {
Expand Down Expand Up @@ -235,10 +233,6 @@ p5.prototype.createShader = function(vertSrc, fragSrc) {
* orangeBlue.setUniform('colorBackground', [0.226, 0.0, 0.615]);
*
* noStroke();
*
* describe(
* 'canvas toggles between a circular gradient of orange and blue vertically. and a circular gradient of red and green moving horizontally when mouse is clicked/pressed.'
* );
* }
*
* function draw() {
Expand Down Expand Up @@ -332,10 +326,6 @@ p5.prototype.shader = function(s) {
*
* // Create our shader
* shaderProgram = createShader(vertSrc, fragSrc);
*
* describe(
* 'Two rotating cubes. The left one is painted using a custom (user-defined) shader, while the right one is painted using the default fill shader.'
* );
* }
*
* // prettier-ignore
Expand Down Expand Up @@ -402,7 +392,6 @@ p5.prototype.resetShader = function() {
*
* function setup() {
* createCanvas(100, 100, WEBGL);
* describe('spinning cube with a texture from an image');
* }
*
* function draw() {
Expand All @@ -428,7 +417,6 @@ p5.prototype.resetShader = function() {
* createCanvas(100, 100, WEBGL);
* pg = createGraphics(200, 200);
* pg.textSize(75);
* describe('plane with a texture from an image created by createGraphics()');
* }
*
* function draw() {
Expand Down Expand Up @@ -456,7 +444,6 @@ p5.prototype.resetShader = function() {
* }
* function setup() {
* createCanvas(100, 100, WEBGL);
* describe('rectangle with video as texture');
* }
*
* function draw() {
Expand Down Expand Up @@ -486,7 +473,6 @@ p5.prototype.resetShader = function() {
*
* function setup() {
* createCanvas(100, 100, WEBGL);
* describe('quad with a texture, mapped using normalized coordinates');
* }
*
* function draw() {
Expand Down Expand Up @@ -543,7 +529,6 @@ p5.prototype.texture = function(tex) {
*
* function setup() {
* createCanvas(100, 100, WEBGL);
* describe('quad with a texture, mapped using normalized coordinates');
* }
*
* function draw() {
Expand Down Expand Up @@ -572,7 +557,6 @@ p5.prototype.texture = function(tex) {
*
* function setup() {
* createCanvas(100, 100, WEBGL);
* describe('quad with a texture, mapped using image coordinates');
* }
*
* function draw() {
Expand Down Expand Up @@ -631,7 +615,6 @@ p5.prototype.textureMode = function(mode) {
* function setup() {
* createCanvas(100, 100, WEBGL);
* textureWrap(MIRROR);
* describe('an image of the rocky mountains repeated in mirrored tiles');
* }
*
* function draw() {
Expand Down Expand Up @@ -692,7 +675,6 @@ p5.prototype.textureWrap = function(wrapX, wrapY = wrapX) {
* <code>
* function setup() {
* createCanvas(100, 100, WEBGL);
* describe('Sphere with normal material');
* }
*
* function draw() {
Expand All @@ -719,7 +701,7 @@ p5.prototype.normalMaterial = function(...args) {
};

/**
* Sets the current material as an ambient material of the given color.
* Sets the ambient color of the current material.
*
* The ambientMaterial() color is the color the object will reflect
* under **any** lighting.
Expand Down Expand Up @@ -749,7 +731,6 @@ p5.prototype.normalMaterial = function(...args) {
* <code>
* function setup() {
* createCanvas(100, 100, WEBGL);
* describe('sphere reflecting red, blue, and green light');
* }
* function draw() {
* background(0);
Expand All @@ -770,7 +751,6 @@ p5.prototype.normalMaterial = function(...args) {
* // so object only reflects it's red and blue components
* function setup() {
* createCanvas(100, 100, WEBGL);
* describe('box reflecting only red and blue light');
* }
* function draw() {
* background(70);
Expand All @@ -790,7 +770,6 @@ p5.prototype.normalMaterial = function(...args) {
* // green, it does not reflect any light
* function setup() {
* createCanvas(100, 100, WEBGL);
* describe('box reflecting no light');
* }
* function draw() {
* background(70);
Expand Down Expand Up @@ -823,7 +802,9 @@ p5.prototype.ambientMaterial = function(v1, v2, v3) {
p5._validateParameters('ambientMaterial', arguments);

const color = p5.prototype.color.apply(this, arguments);
this._renderer.curAmbientColor = color._array;
this._renderer.curFillColor = color._array;
this._renderer._useSpecularMaterial = false;
this._renderer._useEmissiveMaterial = false;
this._renderer._useNormalMaterial = false;
this._renderer._enableLighting = true;
this._renderer._tex = null;
Expand Down Expand Up @@ -860,7 +841,6 @@ p5.prototype.ambientMaterial = function(v1, v2, v3) {
* <code>
* function setup() {
* createCanvas(100, 100, WEBGL);
* describe('sphere with green emissive material');
* }
* function draw() {
* background(0);
Expand Down Expand Up @@ -895,7 +875,8 @@ p5.prototype.emissiveMaterial = function(v1, v2, v3, a) {
p5._validateParameters('emissiveMaterial', arguments);

const color = p5.prototype.color.apply(this, arguments);
this._renderer.curEmissiveColor = color._array;
this._renderer.curFillColor = color._array;
this._renderer._useSpecularMaterial = false;
this._renderer._useEmissiveMaterial = true;
this._renderer._useNormalMaterial = false;
this._renderer._enableLighting = true;
Expand Down Expand Up @@ -935,7 +916,6 @@ p5.prototype.emissiveMaterial = function(v1, v2, v3, a) {
* function setup() {
* createCanvas(100, 100, WEBGL);
* noStroke();
* describe('torus with specular material');
* }
*
* function draw() {
Expand Down Expand Up @@ -982,8 +962,9 @@ p5.prototype.specularMaterial = function(v1, v2, v3, alpha) {
p5._validateParameters('specularMaterial', arguments);

const color = p5.prototype.color.apply(this, arguments);
this._renderer.curSpecularColor = color._array;
this._renderer.curFillColor = color._array;
this._renderer._useSpecularMaterial = true;
this._renderer._useEmissiveMaterial = false;
this._renderer._useNormalMaterial = false;
this._renderer._enableLighting = true;
this._renderer._tex = null;
Expand All @@ -1005,7 +986,6 @@ p5.prototype.specularMaterial = function(v1, v2, v3, alpha) {
* <code>
* function setup() {
* createCanvas(100, 100, WEBGL);
* describe('two spheres, one more shiny than the other');
* }
* function draw() {
* background(0);
Expand Down Expand Up @@ -1050,10 +1030,7 @@ p5.RendererGL.prototype._applyColorBlend = function(colors) {

const isTexture = this.drawMode === constants.TEXTURE;
const doBlend =
isTexture ||
this.curBlendMode !== constants.BLEND ||
colors[colors.length - 1] < 1.0 ||
this._isErasing;
isTexture || colors[colors.length - 1] < 1.0 || this._isErasing;

if (doBlend !== this._isBlending) {
if (
Expand Down Expand Up @@ -1084,12 +1061,9 @@ p5.RendererGL.prototype._applyBlendMode = function() {
const gl = this.GL;
switch (this.curBlendMode) {
case constants.BLEND:
gl.blendEquation(gl.FUNC_ADD);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
break;
case constants.ADD:
gl.blendEquation(gl.FUNC_ADD);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
break;
case constants.REMOVE:
gl.blendEquation(gl.FUNC_REVERSE_SUBTRACT);
Expand Down

0 comments on commit 89506b2

Please sign in to comment.