javascript - When using "destination-in," only the last thing drawn seems to render -


i'm making little library emulate curses-like interface in javascript using bitmap font. font png characters in it, , transparent background.

the method i'm using render character follows.

  1. draw square on space character going go. square foreground color of character
  2. change context.globalcompositeoperation destination-in
  3. draw character on square

this done in function called putchar. reason, though, last putchar call seems render.

in following jsfiddle, i've removed library except what's needed reproduce issue. putchar called in lines 56, 57, , 58. should render yellow "a", green "b", , blue "c" in row. third putchar call rendered (the blue "c".)

http://jsfiddle.net/r96lh/3/

this first time using composite operations, must missing something. know why might happening?

from http://www.html5canvastutorials.com/advanced/html5-canvas-global-composite-operations-tutorial/

it's important note canvas context can support 1 composite operation throughout life cycle. if want use multiple composite operations, tutorial does, need apply operations on hidden canvas , copy results onto visible canvas.

so, approach may have use 2 canvases , blit portion of 1 onto other each character.


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -