New beginner needs help
in
Core Library Questions
•
5 months ago
Hi, I discovered Processing a couple of weeks ago, and I am really interested to learn it. My first attempt is to try to visualize sound. So far I have only managed to create a pattern based on the ellipse...
I have two questions for you:
1. I want to experiement more with the pattern, but my Processing skills are limiting me. Do you have any suggestions for what I might add to make it more visual interesting?
2. I also want to export a pdf when mousePressed, but the exported pdf looks really bad; it saves the pdf in a square (35mmx35mm) and it only saves parts of the graphics. Do you know what I do wrong?
I really appreciate if you would help me.
- import processing.pdf.*;
- PGraphicsPDF pdf;
- import ddf.minim.*;
- float x, y, r, g, b, radius;
- int timer;
- Minim minim;
- AudioInput input;
- void setup () {
- pdf = (PGraphicsPDF)beginRecord(PDF, "Lines.pdf");
- beginRecord(pdf);
- size (1620, 440);
- smooth();
- fill (0);
- strokeWeight(0.7);
- x = 0;
- y = 20;
- minim = new Minim (this);
- input = minim.getLineIn (Minim.STEREO, 512);
- }
- void draw () {
- x = constrain(x,0,width);
- y = constrain(y,0,height);
- float dim = input.mix.level () * width;
- x += input.mix.level () * 20;
- // use frameCount to move x, use modulo to keep it within bounds
- x = frameCount % width;
- if (millis() - timer >= 5000) {
- y += 10;
- timer = millis();
- }
- //change the red color component
- r = noise(frameCount * 1) * 255;
- //change the green color component
- g = frameCount % 255;
- // change the blue color component
- b = 255 - noise(1 + frameCount * 1) * 255;
- // use frameCount and noise to change the radius
- radius = noise(frameCount * 1) * 0.001;
- color c = color(r, g, b);
- stroke(c);
- ellipse(x, y, dim, dim);
- if (x > width) {
- x = 0;
- y += 10;
- }
- }
- void mousePressed() {
- endRecord();
- exit();
- }
1