processing

Processing, using texture inside the audio waveform

北城余情 提交于 2019-12-11 10:48:05
问题 I've been trying to make the texture ( the img ) to be visible only where wave form active is. But so far my attempts failed. I didn't quite understand the usage of vertex. PImage img; import ddf.minim.*; Minim minim; AudioPlayer song; void setup() { size(800, 600,P2D); minim = new Minim(this); song = minim.loadFile("song.mp3"); song.play(); img = loadImage("img.jpg"); } void draw() { background(0); stroke(255); for (int i = 0; i < song.bufferSize() - 1; i++) { beginShape(); texture(img);

How to move a circle across a line in processing?

只谈情不闲聊 提交于 2019-12-11 10:47:46
问题 I have a line segment and a circle in a processing sketch. In the sketch the circle finds the closest point on the line segment and another line is created to show that closest point. I want the circle to move across this line towards the closest point. Also I want the circle to find the closest point on the line segment itself, but my sketch right now acts as though the line goes on forever. Any help is appreciated. float x1,y1,x2,y2; float cx,cy; float x4,y4; void setup() { size(600,600); }

How to save strings to SPECIFIC location in p5.js

送分小仙女□ 提交于 2019-12-11 10:14:47
问题 Here I have a code that I was playing around with. It loads a string within my file and saves an unimportant one. var file = "1"; var result; var meString; var splitMeString; function preload() { result = loadStrings("assets/save/"+file+".txt"); } function setup() { createCanvas(1000,650); } function draw() { meString = result+''; splitMeString = splitTokens(meString, ','); text(meString,20,20); console.log(splitMeString[2]); } function mousePressed(){ saveStrings("happy"); } but how would I

how to use ArrayList in Processing?

血红的双手。 提交于 2019-12-11 09:32:12
问题 The official explanation is here: ArrayList However, it uses iteration and confuses me. I am trying to make a drawing pen but something is wrong here: drawings.get(i) = drawing.get(i-1); ArrayList <Drawing> drawings = new ArrayList <Drawing>(); void setup(){ size(400,400); background(255); colorMode(HSB); } void draw(){} void mouseDragged(){ drawings.add(new Drawing(mouseX,mouseY)); for(int i = drawings.size()-1;i>0;i--){ drawings.get(i) = drawing.get(i-1); } for(int i=0;i<drawings.size;i++){

UnsatisfiedLinkError in Processing

强颜欢笑 提交于 2019-12-11 09:24:48
问题 I have recently overcome this problem using eclipse and would like to use the same .dll in the Processing.org environment. Here is my recent post on Stackoverflow. The .dll I want to use is in the C:\Windows\SysWOW64\\ folder, but I am still getting an UnsatisfiedLinkError . I have tried the following solutions with no success: Adding the .dll to the 'code' folder of the sketch Adding C:\\Windows\\SysWOW64\\foo.dll to the Path environment variable Changing the Native.loadLobrary parameter in

Knight's Tour GUI in Processing

╄→尐↘猪︶ㄣ 提交于 2019-12-11 07:12:13
问题 I am working on a knight's tour problem with basic gui,i want to take user input in the two text fields which make up the (x,y) from user and then in one text box i print if solution is posiible and in the other i write the path adopted by the knight.My algorithm works fine and i have problem in gui.i have given a few default values to (x,y) for that i get correct output .But when i change the value of (x,y) in the textfield,no change occurs.this is the main file ,there is another event

Why are the generations in my Game of Life (using Processing) out of order?

雨燕双飞 提交于 2019-12-11 06:47:01
问题 import processing.core.PApplet; import static java.lang.System.out; public class GoL2 extends PApplet { int rectSideLength = 25; // rectSideLength = length of each side of the rectangles drawn that represent cells int generation = 0; int windowWidth = 1920; int windowHeight = 950; int[][] currentGeneration = new int[windowWidth][windowHeight]; // currentGeneration = 2D array to gold cell values of current generation int[][] nextGeneration = new int[windowWidth][windowHeight]; //

Limit the length of a line

╄→尐↘猪︶ㄣ 提交于 2019-12-11 06:38:47
问题 I'm trying to draw a line that represents a 'slingshot' and I want it to have a maximum draw length. in p5 I'm drawing a line between positionA and positionB: line(posA.x, posA.y, posB.x, posB.y); posA is the mouse x and y. posB is the position of a circle on the canvas. What I want to do is limit the length of the line, so that it is never more than 40px long, but still points toward the mouse from the circle. 回答1: The Euclidean distance between 2 points is calculated by sqrt(dx*dx + dy*dy)

dragging objects in processing

徘徊边缘 提交于 2019-12-11 06:34:22
问题 I am having an issue implementing Daniel Shiffman's awesome dragging example into my sketch. I have used it before and it is great, however I am attempting to use it with some "fancy" for looping to apply it to multiple objects(in this case text) but to no avail. Everything works correctly except for the objects don't drag when they should. Logically, this makes since because the offsetX and offsetY properties in the Line class continue to update thus forcing the object to remain stationary.

Walk along PShape contours and divide them?

混江龙づ霸主 提交于 2019-12-11 06:14:04
问题 I’m looking for a proper way of finding points along a PShape contour. My goal is to generate the same number of points along the two distances from a given point to another (right distance and left distance), then mark a point in the exact center between the the two points that are the same step number on each side. (I’m not sure if I’m being easily understandable, and I cannot attach img already, so I attach processing code). I imagine that the first step for getting it done is to calculate