Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Trying to have mousePressed 'graffiti' with a news ticker running behind - cannot stop fill.

$
0
0

Hello.

I am trying to create a news ticker running across the screen but with the function of

if (mousePressed == true) {
    line (mouseX, mouseY, pmouseX, pmouseY);
  }

I have the ticker working almost correctly OR the graffiti, but not both. I know that it is because the background is being re-drawn over the graffiti, but cannot for the life of me, work out how to adjust my code.

The full code (although I have removed some of the text array) is

String[] tickerText =
{
  "children were some of the greatest victims", "I was a child soldier",
};


color black;
color white;
int SZ; // initiate variables

PFont font;  // Global font variable
float x;  // horizontal location of headline
int index = 0;


void setup() {
  // sound
  minim = new Minim(this); //define construction
  sound = minim.loadFile("Children_Playing_Sound.mp3");
  sound.loop(); // is looped
  black = (0);
  white = (255);
  SZ = 800; //asign variables for colours and screen size

  size(SZ, SZ); // set size of screen
  font = createFont("CourierNewPS-BoldMT-48", 16, true);
  x = 0; // ticker text enters screen from the right

  background(black);
  // fill(white);
}

void draw() {
  background(black);
  fill(white);

  // Display headline
  textFont(font, 16);
  textAlign(LEFT);
  text(tickerText[index], x, 180);

  x = x - 3;
  float w = textWidth(tickerText[index]); // takes length of text in tickerText to determine when the text is off-screen
  if (x < -w) {
    x = width;
    index = (index + 1) % tickerText.length;

    stroke (white);
    strokeWeight (20); // set thickness of 'paint'

    if (mousePressed == true) {
      line (mouseX, mouseY, pmouseX, pmouseY);
    }
  }
}

I have different code which creates the graffiti effect I want. Very basic mousePressed - draw. It's trying to combine the two that I've come unstuck.

Many thanks to anyone who can help me.


Viewing all articles
Browse latest Browse all 2896

Trending Articles