meltingice / CamanJS

Javascript HTML5 (Ca)nvas (Man)ipulation
http://camanjs.com
BSD 3-Clause "New" or "Revised" License
3.55k stars 404 forks source link

First Caman instance won't render #41

Closed bebraw closed 11 years ago

bebraw commented 12 years ago

Consider the test code below:

<body>
  <h1>CamanJS Testing Playground</h1>
  <p>Note: this cannot be accessed locally via the file:// protocol thanks to same-domain origin policy. It must be placed behind a webserver.</p>
..
  <table>
    <tr>
     <td>
       <img id="curve_test" alt="curve test image" src="../images/test1_600.jpg" />
     </td>
     <td>
       <img id="value_test" alt="value test image" src="../images/test1_600.jpg" />
     </td>
   </tr>
  </table>

  <script type="text/javascript">
  Caman.DEBUG = true;

  var curve_test = Caman('#curve_test', function () {
      this.curves('rgb', [0, 0], [100, 30], [180, 240], [255, 255]);

      this.curves('r', [0, 0], [40, 200], [255, 255]);

      this.render();

      console.log('first done');
  }); 

  var value_test = Caman('#value_test', function() {
      this.curves('r', [0, 0], [40, 200], [255, 255]);

      this.render();

      console.log('second done');
  }); 
  console.log(curve_test, value_test);
  </script>
</body>

For some reason it outputs this:

CamanInstance
analyze: Analyze
id: 0
__proto__: CamanInstance

CamanInstance
analyze: Analyze
canvas: HTMLCanvasElement
canvasID: "#value_test"
context: CanvasRenderingContext2D
dimensions: Object
finishedFn: function () {
id: 1
image: HTMLImageElement
imageData: ImageData
options: Object
pixelData: Uint8ClampedArray[962400]
__proto__: CamanInstance
 curves.html:46

second done curves.html:44
BLOCK #0 - Filter: curves, Start: 0, End: 240600 caman.full.js:1309
Block #0 finished! Filter: curves caman.full.js:1309
BLOCK #1 - Filter: curves, Start: 240600, End: 481200 caman.full.js:1309
Block #1 finished! Filter: curves caman.full.js:1309
BLOCK #2 - Filter: curves, Start: 481200, End: 721800 caman.full.js:1309
Block #2 finished! Filter: curves caman.full.js:1309
BLOCK #3 - Filter: curves, Start: 721800, End: 962400 caman.full.js:1309
Block #3 finished! Filter: curves caman.full.js:1309
Filter curves finished! 

As you can see, the first CamanInstance is borked somehow and doesn't render. The latter render shows up just fine. Any idea what might cause this?

Note that I'm using the trunk version with my curve parameter addition at the moment. I gave it a go using invert filter with the same results (rules out an issue with my patch).

bebraw commented 11 years ago

Fixed by pull request #45. Closing.