basiljs/basil.js

Changing screen drawing mode during execution messes with curr settings

Opened this issue · 0 comments

trych commented

Consider the following script:

// @include ~/Documents/basiljs/basil.js;

function draw() {

  for (var i = 0; i < 20; i++) {
    ellipse(random(width), random(height), 20);
  }

  stroke(20);
  fill(255, 0, 0);

  mode(HIDDEN);

  for (var i = 0; i < 20; i++) {
    ellipse(random(width), random(height), 20);
  }

  mode(VISIBLE);
}

The internal vars currFill and currStroke seem to be overwritten, as soon as mode is changed into hidden.

It works, if the code parts in question are moved behind the mode change:

// @include ~/Documents/basiljs/basil.js;

function draw() {

  for (var i = 0; i < 20; i++) {
    ellipse(random(width), random(height), 20);
  }

  mode(HIDDEN);

  stroke(20);
  fill(255, 0, 0);

  for (var i = 0; i < 20; i++) {
    ellipse(random(width), random(height), 20);
  }

  mode(VISIBLE);
}

Needs some investigation what is happening.