ControlP5: Textarea

edited December 2016 in Library Questions

Does displaying an updating text at CP5 textarea is ambiguous? Is there other way to output a text in the display except using text() ? My issue with text is that, changing background is a must. Here's my code..

import controlP5.*;
import processing.serial.*;

String ser;
ControlP5 cp5;
Textarea myTextarea;

Serial port;
PImage bg;
void setup() {
  size(800, 480);
  bg = loadImage("APSS.png");
  port = new Serial(this, Serial.list()[0], 9600);
  cp5 = new ControlP5(this);

  myTextarea = cp5.addTextarea("txt")
    .setPosition(100, 100)
    .setSize(200, 200)
    .setFont(createFont("arial", 12))
    .setLineHeight(14)
    .setColor(color(128))
    .setColorBackground(color(255, 100))
    .setColorForeground(color(255, 100));
  ;
}

void draw() {
  ser = port.readString();
  delay(1000);
  drawBackground();

}

void drawBackground() {
  background(bg);
  myTextarea.setText(ser);
}

Answers

Sign In or Register to comment.