final int WIDTH=300,HEIGHT=200;int x=WIDTH/2,y=HEIGHT/3,r=10;int xdirection = 1;void setup() {size(WIDTH, HEIGHT,P2D);textSize(32);}void draw() {background(0);text("ABCDE", WIDTH/4, HEIGHT/2);x += xdirection ;if(x+r>WIDTH || x-r <0){xdirection *= -1;}ellipse(x,y,r*2,r*2);//以下の3つを追加することで、既存のキャンバスを反転させるPImage img = g.get();//既に描画しているキャンバスのイメージ画像を取得するscale(-1,1); //以降のものは反転させるimage(img,-WIDTH,0); //}