P5js question

Hey guys I am new to P5js and somehow not able to fill an array with numbers.

var vertX; //x coord of vertex var vertY; //y coord of vertex var size = 100000; //size of the coord array function setup(){ createCanvas(1000,600); vertX = new Array(size); vertY = new Array(size); vertX[0] = 20*round(random(1,height/20)); vertY[0] = 20*round(random(1,height/20)); for (var i = 0; i< size; i++){ vertX[i] = 10; } frameRate(7); colorMode(HSB); } function draw(){ function draw(){ background(255); stroke(0); text(vertX[0] + " " + vertY[0], 100, 100); text(vertX[1] + " " + vertY[1], 100, 200); } 

This gives me the values for vertX and vertY at place 0 and undefined at place 1.

submitted by /u/RaGonEbker
[link] [comments]

I don’t seem to be able to loop audio files with Minim.

I'm still kind of a newbie with programming, so maybe this is just some rookie mistake, but in any case here's the problem: I'm making a joke game to mess around with what I know about Processing, and I don't seem to be able to loop audio files with Minim. Here's the current code:

import ddf.minim.;
import ddf.minim.analysis.
;
import ddf.minim.effects.;
import ddf.minim.signals.
;
import ddf.minim.spi.;
import ddf.minim.ugens.
;

Minim minim;
AudioPlayer menu, mama, tune;
PFont arial, arialB, comicSans, comicSansB, popTai;
int gameScreen = 0;
int buttonX, buttonY, buttonW, buttonH, buttonY2;
boolean right, left, up, down;
int bepsi;

void setup()
{
size(1550, 950);

arial = createFont("arial.ttf", 100);
arialB = createFont("arialbd.ttf", 100);
comicSans = createFont("comic.ttf", 100);
comicSansB = createFont("comicbd.ttf", 100);
popTai = createFont("hgrppt1.ttc", 100);

left = right = false;

minim = new Minim(this);
menu = minim.loadFile("menuTheme.wav");
mama = minim.loadFile("marioScream.wav");
tune = minim.loadFile("punchOutMC.wav");

mama.setGain(-20);

buttonX = width/2;
buttonY = 550;
buttonW = 250;
buttonH = 150;
buttonY2 = 750;

startJoel();
}

void draw()
{
if (gameScreen == 0) {
initScreen();
} else if (gameScreen == 1) {
gameScreen();
} else if (gameScreen == 2) {
gameOverScreen();
} else if (gameScreen == 3) {
creditsScreen();
}
}

void initScreen() {
background(15, 6, 150);
textSize(40);
textFont(arial, 40);
textAlign(CENTER);
fill(255, 255, 255);
text("Joel Vargskeltin in", width/2, height/5.5);
textSize(160);
textFont(comicSansB, 100);
fill(255, 255, 0);
text("Joel takes one too many Bepsi", width/2, height/3.5);
textSize(25);
textFont(arial, 25);
fill(63.75, 127.5, 255);
text("the pseudo-sequel", width/2, height/2.75);
textSize(15);
text("made in Processing cuz I can't code in any other language (yet)", width/2, height/2.75 + 15);

rectMode(CENTER);
fill(255, 0, 0);
rect(buttonX, buttonY, buttonW, buttonH);

rectMode(CENTER);
fill(0, 255, 0);
rect(buttonX, buttonY2, buttonW, buttonH);

fill(0);
textFont(comicSans, 45);
text("PLAY THIS", buttonX, buttonY-5);
text("GARBAGE", buttonX, buttonY+40);

text("CREDITS", buttonX, buttonY2-5);
text("AND SHIT", buttonX, buttonY2+40);

textFont(arial);

if (mouseX > 650 && mouseX < 900 && mouseY > 475 && mouseY < 625) {
if (mousePressed) {
mama.close();
menu.close();
startGame();
}
mama.setGain(+100);
} else {
mama.setGain(-20);
}

if (mouseX > 650 && mouseX < 900 && mouseY > 675 && mouseY < 825) {
if (mousePressed) {
gotoCredits();
}
mama.setGain(+50);
} else if (mouseX < 650 && mouseX > 900 && mouseY < 675 && mouseY > 825) {
mama.setGain(-20);
}

menu.play();
mama.play();
}
void gameScreen() {
background(0);

updateJoel();

drawJoel();

tune.play();
}
void gameOverScreen() {
}

void creditsScreen() {
background(0);

fill(255);
textSize(50);
text("Game made by", width/2, 40);
textSize(75);
text("JoJo0217", width/2, 125);
textSize(30);
text("along with some help from the chat members", width/2, 200);
textSize(45);
text("castlemania9", width/2, 280);
text("ninioszka", width/2, 360);
text("TruePurpleFire", width/2, 440);
text("Scoops89 (self-proclaimed meme expert)", width/2, 520);
textSize(25);
text("ban them. ban them all.", width/2, 600);

mama.setGain(-20);

fill(127.5);
rectMode(CORNER);
rect(0, height-50, 100, 50);
if (mouseX > 0 && mouseX < 100 && mouseY > height-50 && mouseY < height) {
if (mousePressed) {
gameScreen=0;
}
}
}

void startGame() {
gameScreen=1;
}

void gotoCredits() {
gameScreen=3;
}

void keyPressed()
{
if (key == 'w' || key == 'W')
up = true;
if (key == 'a' || key == 'A')
left = true;
if (key == 'd' || key == 'D')
right = true;
if (key == 's' || key == 'S')
down = true;
}

void keyReleased()
{ if (key == 'w' || key == 'W')
up = false;
if (key == 'a' || key == 'A')
left = false;
if (key == 'd' || key == 'D')
right = false;
if (key == 's' || key == 'S')
down = false;
}

boolean collisionTest(float x1, float y1, float l1, float a1, float x2, float y2, float l2, float a2)
{
boolean h = (x1 < x2 + l2) && (x2 < x1 + l1);
boolean v = (y1 < y2 + a2) && (y2 < y1 + a1);

return h && v;
}

As you can see, the audio commands are all as file.play(); , but when I change those commands to file.loop(); the files don't start at all. I tried searching around for a solution, but I couldn't find anything about what's happening. My guess is that it's just some rookie mistake or something, because I don't really know what is causing that problem.

Thanks in advance.

submitted by /u/LordFodha
[link] [comments]

An open heart surgery of the legendary 4004 microprocessor

Created in 1971, Intel’s 4004 was the world’s first commercial microprocessor. It wasn’t particularly powerful though. Its main function was originally to perform simple mathematical operations in a mundane business calculator. However, it wasn’t the 4004 itself that was important but its architecture.


Quentin Destieu, À coeur ouvert, 2017. Photo: Luce Moreau. Installation view of the exhibition Master/Slave at Art-cade Galerie in Marseille, France


Quentin Destieu, À coeur ouvert, 2017. Photo: Luce Moreau. Installation view of the exhibition Master/Slave at Art-cade Galerie in Marseille, France

The 4004 offered a radical new way of thinking and building processors. General purpose computers used to be room-sized equipment but the miniaturization of the 4004 made it possible to commodify computing.

Another extraordinary thing about the 4004 is that it was the first and the last hand-drawn microprocessor. The production of its successors would be so complex that it would be automated, performed on a micro scale by hi-tech machines.

Nowadays it’s not just their technological complexity that leaves microprocessors outside of human understanding, their production itself is shrouded in secrecy, their architecture protected by patents. We’ve completely lost control over components that are at the core of every single connected object in our lives.

Artist Quentin Destieu hoped to reconquer that knowledge by re-creating and magnifying the inner architecture of the 4004 processor so that its size would lay bare its inner working. The objective of the project was also to create a technological support free of copyrights and working on an open source model. Which would have brought the technological understanding of electronics back into the commons (where it belongs.)

To achieve this de-miniutarization process, the artist first needed to go back to the initial drawings, recreate the plans and understand the circuits. With the help of engineers and artists (Bastien Vacherand, Sylvain Huguet, Guillaume Stagnaro, Grégoire Lauvin and many others) and using the plans made available by Intel in 2011, Destieu tried to recreate one by one the 2300 transistors of the 4004 processor. He quickly realized that much of the initial knowledge had been lost. Discussions on forum and with the engineers of the 4004 revealed that the know-how of the original plans was no longer fully mastered by a single person.


Quentin Destieu, À coeur ouvert, 2017. Photo: Luce Moreau. Installation view of the exhibition Master/Slave at Art-cade Galerie


Quentin Destieu, À coeur ouvert, 2017. Photo: Luce Moreau. Installation view of the exhibition Master/Slave at Art-cade Galerie

As a result, the sculptural form of À coeur ouvert (“at open heart” because, like an open heart surgery, the project aims to reach the vital organs of the processor) was guided by this conclusion that planned obsolescence had reached not just consumer electronics but also human knowledge itself.

The installation is made of 3 circuits that measure in total 1,90m by 80cm, the scale of a human body. The black colour echoes the fact that mainstream technology is now running from inside a inscrutable black box. The circuits are enclosed inside a kind of mausoleum that acknowledges the demise of our control over information technology.


Quentin Destieu, À coeur ouvert, 2017. Photo: Luce Moreau. Installation view of the exhibition Master/Slave at Art-cade Galerie


Quentin Destieu, À coeur ouvert, 2017. Photo: Luce Moreau. Installation view of the exhibition Master/Slave at Art-cade Galerie


Quentin Destieu, À coeur ouvert, 2017. Photo: Luce Moreau. Installation view of the exhibition Master/Slave at Art-cade Galerie


Quentin Destieu, À coeur ouvert, 2017. Photo: Luce Moreau. Installation view of the exhibition Master/Slave at Art-cade Galerie

If you’re curious about the work, do check out Master/Slave, Quentin Destieu solo show at Art-cade Galerie, Grands Bains Douches de la Plaine, in Marseille, until 15 December 2018.

Expel an object with the cursor

I am facing some troubles here.
I have a code and I want to expel an ellipse with the cursor, so it will go to the other side instead of following it. But I also have a bigger ellipse, which I want to be the biggest "fence" for the smaller one not to flee off screen.

So far what I have is like this.

What should I do?

float x, y;

float easing = 0.05;

PVector circle = new PVector(300, 300);

int radius = 300;

void setup() {

size(600, 600);

x = y = width/3;

}

void draw () {

background(255);

ellipseMode(CENTER);

strokeWeight(3);

stroke(0);

fill(255,0,0);

ellipse(circle.x, circle.y, radius, radius);

strokeWeight(1);

PVector m = new PVector(mouseX, mouseY);

if (dist(m.x, m.y, circle.x, circle.y) > radius/2) {

m.sub(circle);

m.normalize();

m.mult(radius/2);

m.add(circle);

}

x = x + (m.x - x) * easing;

y = y + (m.y - y) * easing;

fill(0);

strokeWeight(1);

stroke(0);

ellipse(x, y, 24, 24);

}

Or is there any other way for me to do it?
And in this code the smaller ellipse tends flee half of it's size from the main "fence", is there any way to keep it totally inside the bigger one?

Thank you really much in advance.

submitted by /u/alexwitchfinder
[link] [comments]

Can someone explain the error for me

The sketch path is not set.

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException

at processing.core.PApplet.runSketch([PApplet.java:10741](https://PApplet.java:10741)) at processing.core.PApplet.main([PApplet.java:10511](https://PApplet.java:10511)) 

Caused by: java.lang.reflect.InvocationTargetException

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance([NativeConstructorAccessorImpl.java:62](https://NativeConstructorAccessorImpl.java:62)) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance([DelegatingConstructorAccessorImpl.java:45](https://DelegatingConstructorAccessorImpl.java:45)) at java.lang.reflect.Constructor.newInstance([Constructor.java:423](https://Constructor.java:423)) at processing.core.PApplet.runSketch([PApplet.java:10735](https://PApplet.java:10735)) ... 1 more 

Caused by: java.lang.RuntimeException: Files must be loaded inside setup() or after it has been called.

at processing.core.PApplet.createInputRaw([PApplet.java:7039](https://PApplet.java:7039)) at processing.core.PApplet.createInput([PApplet.java:7011](https://PApplet.java:7011)) at processing.core.PApplet.loadTable([PApplet.java:6148](https://PApplet.java:6148)) at Milestone.<init>([Milestone.java:21](https://Milestone.java:21)) ... 6 more 

submitted by /u/mohsenation
[link] [comments]