// loadShapeMobile.pde adapted from https://processing.org/reference/loadShape_.html // D. Parson, 2/15/2018 PShape s; int xloc = 0, xspeed = 2, yloc = height-1 , yspeed = -1 ; int wiggleamt = 0, wigglespeed = 10 ; void setup() { size(500, 500); // The file "loadShape.svg" must be in the sketch or data folder // of the current sketch to load successfully s = loadShape("loadShape.svg"); } void draw() { background(0, 255, 255); shapeMode(CENTER); // START OF AVATAR pushMatrix(); translate(xloc, yloc); // PUT ALL YOUR AVATAR DRAWING CODE AFTER translate() // AND BEFORE THE MOVE AND popMatrix(). float swidth = s.width ; float sheight = s.height ; float aspectRatio = swidth / sheight ; float displayWidth = 50 ; // width / 2 ; // Make this whatever you want, // all these other float calculations stay the same. float displayHeight = displayWidth / aspectRatio ; stroke(0); strokeWeight(6); line(-40, wiggleamt, 0, 0); line(40, 0, 0, 0); shape(s, 0, 0, displayWidth, displayHeight); // THIS IS MOVE CODE, KEEP IT. xloc = xloc + xspeed ; if (xloc < 0 || xloc >= width) { xspeed = - xspeed ; // reverse direction } yloc = yloc + yspeed ; if (yloc < 0 || yloc >= height) { yspeed = - yspeed ; // reverse direction } wiggleamt = wiggleamt + wigglespeed ; if (wiggleamt < -15 || wiggleamt >= 10) { wigglespeed = - wigglespeed ; // reverse direction } popMatrix() ; // END OF AVATAR }