We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › converting vector to raster
Page Index Toggle Pages: 1
converting vector to raster (Read 1001 times)
converting vector to raster
Jan 9th, 2010, 7:44pm
 
I'm writing a program that will place vector graphics onto a canvass randomly.  What I want to do in some cases is be able to have the program run a test to make sure that the shape will not intersect any other graphic elements. I think this would be very easy if I could just convert the vector image to raster and then access the array (or possibly skip the rasterization and just populate an array somehow)

I know that I could convert it in Photoshop and then access the array, but I'd like to be able to do this a massive scale with randomized shapes. So it would need to be done with processing code.

Does anybody have any ideas for me?
Re: converting vector to raster
Reply #1 - Jan 9th, 2010, 7:50pm
 
you can get the pixelarray of the actual screen by using http://processing.org/reference/loadPixels_.html

or use Pgraphics. here is an example that creates PGraphics of the Chars ( could be your vector files instead)
http://www.openprocessing.org/visuals/?visualID=1811

you can check for intersections of svgs or other shapes using Geomerative it has intersection() and contains() for shape intersections:http://ricardmarxer.com/geomerative/


Re: converting vector to raster
Reply #2 - Jan 10th, 2010, 1:35am
 
By vector graphics, do you mean SVG?
Cedric pointed at useful resources: you can render SVG into a PGraphics to rasterize it. And loadPixels give access to already drawn shapes, thus you can check collision by comparing these pixels with those in the PGraphics (a classical way of checking collisions, testing that tinted pixels do not overlap).
Re: converting vector to raster
Reply #3 - Jan 10th, 2010, 7:12am
 
Thank you very much.
Page Index Toggle Pages: 1