Question

I am trying to get the raw pixel data from two "items" in paper.js. One is already a Raster object so that's not too bad. The problem is that I have another Group object containing a bunch of triangles and I want to capture the Raster data for that layer and then be able to compare it.

I have the following (highlighted lines) code: https://gist.github.com/mtahmed/2b27c4c6aee42d3ac3fb#file-paper_update-js

It seems to always return 0 or some other odd unexpected number. Any hints/ideas?

Thanks! :)

Was it helpful?

Solution

It looks like you are always setting child_gene.visible = false, but never set it back to visible = true before you rasterize the layer in computeFitness(). I'm not sure that there's a need for juggling layers in each frame - it should work just as well without it.

Here's a simplified example that uses a square with a gradient as the target raster.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top