error sending serial data when serialEvent() is used

I am trying to use Arduino and Processing using a potentiometer to control the sizes of the squares that are drawn on top of this image

Getting the color from its same location, so I can blur the picture with the potentiometer by increasing and reducing the size of the squares.

Unfortunately I keep getting this message:

error, disabling serialEvent() for /dev/tty.usbmodem1421
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at processing.serial.Serial.serialEvent(Serial.java:279)
at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732)
at gnu.io.RXTXPort.eventLoop(Native Method)
at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1575)
Caused by: java.lang.NullPointerException
at image_pixels_arduino_controller.serialEvent(image_pixels_arduino_controller.java:70)
… 8 more

This is the code. Any suggestion will be much appreciated!

import processing.serial.*;
Serial myPort;
PImage myImage;

void setup() {
  size(500, 399);
  // List all the available serial ports
  println(Serial.list());
  // I know that the first port in the serial list on my mac
  // is always my  Arduino, so I open Serial.list()[0].
  // Open whatever port is the one you're using.
  myPort = new Serial(this, Serial.list()[4], 9600);
  // don't generate a serialEvent() unless you get a newline character:
  myPort.bufferUntil('\n');
  imageMode(CENTER);
  myImage = loadImage("rdjr.jpg");
  image(myImage, width/2, height/2);
  noStroke();
}

void draw() {
}

void serialEvent( Serial myPort) {

  // get the ASCII string:
  String inString = myPort.readStringUntil('\n');

  if (inString != null) {
    // trim off any whitespace:
    inString = trim(inString);
    // convert to an int and map to the screen:

    for ( int i = 0; i < 1000; i++) {

      float inByte = float(inString); 
      float diagonal = dist(0, 0, width, height);
      inByte = map(inByte, 0, 1023, 0, diagonal);

      int x = int(random(0, width));
      int y = int(random(0, height));

      color getColor = myImage.get(x, y);
      fill(getColor, 50);

      rect(x, y, inByte, inByte);
    }
  }

  println(inString);
}
    // convert to an int and map to the screen:

    for ( int i = 0; i < 1000; i++) {

      float inByte = float(inString);

Most people don’t spell int ‘f’, ‘l’, ‘o’, ‘a’, ‘t’.

Most people don’t feel compelled to do the same thing 1000 times.

  println(Serial.list());

What does this print?

  String inString = myPort.readStringUntil('\n');

What did you get?

I am trying to use Arduino and Processing

Where is the Arduino code?