Why blendMode(ADD) is not working?

edited September 2015 in p5.js

Hey there! I wanted to use blendMode(ADD) but it seems it's not working because as the console said it's not defined. Any suggestion?

Tagged:

Answers

  • edited September 2015

    I've visited its reference page here:
    http://p5js.org/reference/#/p5/blendMode

    Hit F12 key in order to open browser's JS console.
    Then clicked "edit" button and changed the constant being used in blendMode() to ADD.
    After clicking "run", nothing wrong shown up to me though... :-\"

    Cross-posted here: https://GitHub.com/processing/p5.js/issues/882

  • edited September 2015

    I see, but it's not working in my browser when I try to blend images like this:

    ```var front;

    var back;

    var bolas = []; // Array Bola objects

    // Images function preload() { front = loadImage('assets/bolaColFront.png'); back = loadImage('assets/bolaColBack.png'); }

    function setup() { createCanvas( windowWidth, windowHeight ); colorMode(HSB, 360, 100, 100); noStroke();

    // Create objects for (var i=0; i<50; i++) { bolas.push(new Bola()); } }

    function draw() { background(5); smooth();

    for (var i=0; i<bolas.length; i++) { bolas[i].move(); bolas[i].display(); } }

    function windowResized() { resizeCanvas(windowWidth, windowHeight); }

    // Bola class function Bola() { this.diameter = random(90, 190); this.radRan = random(1.4, 3); this.radius = this.diameter/this.radRan; var loc = createVector(random(width), random(height/4, height-height/4)); var vel = createVector(random(-.3,.3),random(-.1,.1)); var newSize = random(1.5, 2.5); var newSize2 = random(1.5, 2.5);

    this.move = function() { loc.add(vel); };

    this.display = function() { blendMode(SCREEN); imageMode(CENTER); image(back, loc.x, loc.y, this.diameter, this.diameter); image(front, loc.x, loc.y, this.radius, this.radius);

    };

    }```

  • edited September 2015

    http://forum.Processing.org/two/discussion/8045/how-to-format-code-and-text

    And I can't see any blendMode(ADD); but blendMode(SCREEN); instead! ~:>

  • Hi, sorry for the format. I was using and old version of p5js. Now it works perfect. Thank you!

Sign In or Register to comment.