Set the Center of Rotation of an SVG image
in
Programming Questions
•
2 years ago
I have svg graphics consisting of a simple filled and stroked path with 10 - 30 bezier curve control points created with Inkscape (outlines of dolphins and octopus). I want to use svg graphics because of their scalability (and control over color, stroke, and transparency). I haven't learned how to use processing bezier's or to convert my svg's to beziers and it's a lot easy to create artwork as svg's.
I want to be able to rotate these svg's but not around their corner's or svg document center. Whether I use shapeMode(CENTER); shapeMode(CORNER); or //shapeMode(CORNERS); my svg's don't rotate in place. They also look kind of funky when rendered in P3D with smooth();
It would be nice to load them into processing as beziers ... is there a library or a processing sketch that outputs the bezier information from an svg into processing bezier() statements that could be cut and pasted into a sketch?
Sorry, codes kinda worthless w/o the svg's but couldn't figure how to add them to this post:
I want to be able to rotate these svg's but not around their corner's or svg document center. Whether I use shapeMode(CENTER); shapeMode(CORNER); or //shapeMode(CORNERS); my svg's don't rotate in place. They also look kind of funky when rendered in P3D with smooth();
It would be nice to load them into processing as beziers ... is there a library or a processing sketch that outputs the bezier information from an svg into processing bezier() statements that could be cut and pasted into a sketch?
Sorry, codes kinda worthless w/o the svg's but couldn't figure how to add them to this post:
- /**
- * wagon wheel (stroboscope) effect
- * see http://en.wikipedia.org/wiki/Wagon-wheel_effect
- * THIS IS FOR TESTING ROTATION OF SVG'S; NOT A PROJECT
- */
- // IMPORTED LIBRARIES
- // GLOBAL VARIABLES
- float rotoff;
- float x,y;
- // IMAGE, SOUND, FONT, MOVIE OBJECTS
- PShape s;
- PShape s2;
- PShape s3;
- //PShape TestRect;
- PShape TestRect;
- // CLASSES/OBJECTS
- // SETUP
- void setup(){
- size(400,400);
- //frameRate(12);
- smooth();
- //shapeMode(CENTER);
- shapeMode(CORNER);
- //shapeMode(CORNERS);
- s = loadShape("dolphin.svg");
- s2 = loadShape("outline_simple.svg");
- s3 = loadShape("dolphin2.svg");
- //TestRect = rect(200,200,20,60);
- //s.rotate(180);
- }
- // DRAW
- void draw() {
- background(0);
- s.enableStyle();
- //s.scale(.25,.25);
- rotoff = -PI/90;
- s.rotate(rotoff);
- x = x-1;
- y = sin(radians(x))*x/4 + height/2; // cos(2^x) +
- pushMatrix();
- //shape(s, width/2+(rotoff*(width)), height/2,s.width/8,s.height/8);
- //shapeMode(CORNER);
- shape(s, x, y,s.width/8,s.height/8);
- popMatrix();
- if (x <= 0) {
- x = width;
- //y = y * -1;
- }
- pushMatrix();
- //translate(x,-50);
- fill(#F51616);
- shape(s2, width/2+(rotoff*(width)+100), height/2+100,s2.width/8,s2.height/8);
- popMatrix();
- //translate(x,-50);
- shape(s3, width/2+(rotoff*(width)+100), height/2+100,s3.width/8,s3.height/8);
- //rotate(radians(1));
- //s.rotate(+.1);
- //if (random(30) <= 1) {s.rotate(-180);}
- //shape(TestRect,width/2,height/2);
- //TestRect.rotate(rotoff);
- //s.rotate(rotoff);
- s2.rotate(+1);
- s3.rotate(-rotoff);
- }
- void mousePressed() {
- s.rotate(rotoff);
- //s.rotate(PI/3.0);
- //rotate(radians(1));
- }
1