Experimentations processing/arduino

Code Processing :

import apsync.*;

import apsync.*;
import processing.serial.*;
AP_Sync streamer; 

public int pot_1_val;
public int pot_2_val;

String shape = "52.97880172729492:1.2885199785232544/49.5:0/46.02119827270508:1.2885199785232544/44.66510009765625:5.32213020324707/46.02119827270508:11.148500442504883/46.02119827270508:14.50979995727539/37:18.431400299072266/40.89149856567383:30.98040008544922/42.18870162963867:38.207298278808594/39.2406005859375:53.55739974975586/43.07310104370117:71.31649780273438/41.65800094604492:82.96920013427734/45.66749954223633:94.3416976928711/42.42449951171875:98.31929779052734/42.42449951171875:100/56.57550048828125:100/56.57550048828125:98.31929779052734/53.33250045776367:94.3416976928711/57.34199905395508:82.96920013427734/55.92689895629883:71.31649780273438/59.7593994140625:53.55739974975586/56.81129837036133:38.207298278808594/58.10850143432617:30.98040008544922/62:18.431400299072266/52.97880172729492:14.50979995727539/52.97880172729492:11.148500442504883/54.33489990234375:5.32213020324707/";
ArrayList<PVector> points = new ArrayList<PVector>();


float angle_offset = 0;

void setup(){
  size(420,420);

String[] p_data = shape.split("/");
  
  for(String p_d : p_data){
    String[] p_s = p_d.split(":");
    
    float x = Float.parseFloat(p_s[0]);
    float y = Float.parseFloat(p_s[1]);
    
    x = map(x,0,100,0,width);
    y = map(y,0,100,0,height);

    points.add(new PVector(x,y));
  }

  streamer = new AP_Sync(this, "/dev/cu.usbserial-A6027L36", 9600); // Stump out an instance of APsync
  fill(0);
  noStroke();
  rectMode(CENTER);
}

void draw(){
  float t = millis()* 0.001;
  float angle_target = map(pot_1_val,0,1023,0,TWO_PI);
  float intensity = floor(map(pot_2_val,0,1023,1,width));
  background(255);
    angle_offset += (angle_target-angle_offset) * 0.1;

   beginShape();
   for(int i = 0; i < points.size(); i++){
   
     PVector pos = points.get(i).copy();
     PVector n = PVector.fromAngle(angle_offset+noise(i)*TWO_PI);
     n.setMag(intensity);
     
     pos.add(n);
     vertex(pos.x,pos.y);
   }
   endShape(CLOSE);
}

Code Arduino :

#include <AP_Sync.h>
AP_Sync streamer(Serial); 

int pot_1_pin = 0;
int pot_2_pin = 1;

void setup() {
  Serial.begin(9600);
}

void loop() {
  int pot_1_val = analogRead(pot_1_pin);
  int pot_2_val = analogRead(pot_2_pin);
  streamer.sync("pot_1_val",pot_1_val);
  streamer.sync("pot_2_val",pot_2_val);
}