uberchurch
YaBB Newbies
Offline
Posts: 1
Geomerative library help
Oct 4th , 2008, 4:07am
ok so I am very new at this (as you will see by looking at my code) so any help would be great. what I am trying to do is import a svg and draw it to the screen. then change the segment length to deform the svg and draw that to the screen. then combine the deformed and non-deformed svg and draw that to the screen. then deform the combined svg the same way as the original svg was deformed then draw that to the screen. here is the code I have most of which I cobbled together from the tutorials (of which I could only get the first 12 to run but that is another story) import processing.opengl.*; import geomerative.*; import processing.xml.*; RSVG svgLoader; RGroup app; RGroup yama; RPolygon appPoly; RPolygon orgPoly; RGroup polyGrp; RGroup polyGrp2; RGroup polyGrpOrg; float pointSeparation ; size(800, 600, OPENGL); smooth(); g.smooth = true; // VERY IMPORTANT: Allways initialize the library before using it RGeomerative.init(this); svgLoader = new RSVG(); app = svgLoader.toGroup("apple.svg"); app.centerIn(g); svgLoader = new RSVG(); yama = svgLoader.toGroup("yamaha.svg"); yama.centerIn(g); background(255); pointSeparation = 200; frameRate(4); polyGrpOrg = app.toPolygonGroup(); polyGrp = app.toPolygonGroup(); // draw svg as imported pushMatrix(); RGeomerative.ignoreStyles(); translate(width*.25, height*.25); stroke(200, 150,150,150); fill ( 150,50); scale(.5); app.draw(); popMatrix(); // draw svg with SegmentLength transformantation pushMatrix(); translate(width*.75, height*.25); RCommand.setSegmentator(RCommand.UNIFORMLENGTH); RCommand.setSegmentLength(pointSeparation); polyGrp = app.toPolygonGroup(); RGeomerative.ignoreStyles(); stroke(200, 150,150,150); fill ( 150,50); scale(.5); polyGrp.draw(); popMatrix(); // combine first svg with transformed svg with addGroup and draw pushMatrix(); translate(width*.25, height*.75); RGeomerative.ignoreStyles(); stroke(200, 150,150,150); fill ( 150,50); polyGrpOrg.addGroup(polyGrp); scale(.5); polyGrpOrg.draw(); polyGrp = polyGrpOrg.toPolygonGroup(); popMatrix(); // transform svg addGroup with SegmentLength //this is what I can not get to work pushMatrix(); translate(width*.75, height*.75); new RCommand(); svgLoader = new RSVG(); polyGrp2 = svgLoader.toGroup(polyGrpOrg); polyGrp2.centerIn(g); RCommand.setSegmentator(RCommand.UNIFORMLENGTH); RCommand.setSegmentLength(pointSeparation); polyGrp2 = polyGrp.toPolygonGroup(); RGeomerative.ignoreStyles(); stroke(200, 150,150,150); fill ( 150,50); scale(.5); polyGrp2.draw(); popMatrix();