rotation - How do you rotate SVG images in processing.js -
i staring processing.js , have been having trouble because every time rotate image changes location on screen. processing seems is, rotate image around point told place it, instead of rotating first around own axis , placing told (which figured cannot done in way/order).
this code
pshape s; float angle = 0.1; //rads s = loadshape("sensor.svg"); s.rotate(angle); //i change angle manually or clickmouse function isnt shown. void setup(){ size(400,350); framerate(30); //30 frames per seconds } void draw(){ //shape( shape, x, y, width, height); smooth(); fill(153); ellipse(200, 350/2, 100, 100); shape(s, 200, 350/2, 20, 20); ellipse(200, 350/2, 2, 2); }
what trying make "sensor" image rotate in correct orientation around circle (ellipse) drew. thats idea. doing neither. maybe having click function rotates svg image around circle. instead rotates around coordinates of shape(image, x_coord, y_coord, width, height) function. if has suggestions, happy! hope question makes sense, if doesnt more happy clarify part of it.
thanks! :)
it's easier not rotate shape, rotate coordinate system.
void draw() { translate(s.width/2,s.height/2); rotate(pi/4); shape(s); resetmatrix(); // keep on drawing here }
this first moves coordinate system (0,0) on top of center of shape, rotates entire coordinate system 45 degrees, draws shape. reset coordinate system , keep drawing usual.
Comments
Post a Comment