processing

how to loop over the pixels using 2D array?

泄露秘密 提交于 2019-12-11 03:52:51
问题 For example: loadPixels(); for (int i = 0; i < 240; i++) { for(int j =0; i < 240; j++) { color p = pixels[i][j]; // ERROR : The type of the expression must be an array type but it resolved to int float cRed = 0.2989 * red(p); float cGreen = 0.5870 * green(p); float cBlue = 0.1140 * blue(p); pixels[i][j] = color(cRed, cGreen, cBlue); } } updatePixels(); 回答1: According to the pixels documentation, pixels is a one dimensional array. So you'll probably need to do something like int row = i; int

How to move object along the polygons

ⅰ亾dé卋堺 提交于 2019-12-11 03:34:35
问题 Suppose (say triangle), I want to move an object from A to B then B to C and then C to A. How can I do this? I googled a lot, but can't find an example of moving an object (say ball) around polygon. I know, i can done it with bezier curves, but for a simple triangle or rectangle how can I do without it? Please give some pseudo code or code in any language. (prefer JavaScript/Processing). 回答1: Interpolate You can get the position by using interpolation: x = x1 + (x2 - x1) * f; y = y1 + (y2 -

Rotating camera around object axis with Peasycam

淺唱寂寞╮ 提交于 2019-12-11 03:04:23
问题 I'm trying to use Jonathan Feinberg's Peasycam library for processing to rotate the camera around the objects' Z axis. The documentation specifies for rotation is around subject, but not the object. This seems incredibly difficult to achieve. The peasycam rotations act around the subject (i.e. camera) not object, although in control sense peasycam's emphasis is object-oriented. And setting the camera() seems problematic too, as I can't get the peasycam to remember the assigned camera's

How to solve “The hierarchy of the type is inconsistent” error in Java Eclipse?

隐身守侯 提交于 2019-12-11 02:58:29
问题 I was trying to create an Android Application in Java Eclipse with the use of the Processing for Android but when I was about to compile it, I got this error message " The hierarchy of the type MainAcitvity is inconsistent ". Here is my code: public class MainActivity extends PApplet { public static void main(String args[]) { PApplet.main(new String[] { "--present", "com.RDP.MainActivity" }); } Vector path = new Vector(); public void setup(){ size(550,550, P3D); smooth(); } public void draw()

Processing - No library found

自作多情 提交于 2019-12-11 02:56:30
问题 In Processing, I have the following error : No library found for bezierVertex Libraries must be installed in a folder named 'libraries' inside the 'sketchbook' I am trying to run "exemplePPhys2D_geeknessrain.pde", that can be found at https://projets.pingbase.net/libro/projects/hub/repository/revisions/7/entry/EXEMPLES/pphys2d/examples/exemplePPhys2D_geeknessrain/exemplePPhys2D_geeknessrain.pde The error is puzzling, since I did install the bezierVertex.jar library in .\pphys2d\examples

Processing minim null pointer

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 02:34:29
问题 I am using processing with Minim, but I can't figure out how to play files, if the minim loading files are in another class. I used both AudioSnippet and AudioSample and they both give me NullPointerException . Here is a the PlayAudio class. Minim minim; AudioSample sample; AudioSnippet snippet; class PlayAudio { PlayAudio() { minim = new Minim(this); sample = minim.loadSample("Audio/hover1.mp3", 2048); snippet = minim.loadSnippet("Audio/hover1.mp3"); } void playSnippet() { sample.trigger();

Processing 2.0 - Open file dialog

泄露秘密 提交于 2019-12-11 02:09:53
问题 my goal is to select a file from a "file open" dialog box, read it and draw objects based on the content of the file. I found a way to open that dialog box (see skeleton code below), however the PDE program starts drawing BEFORE I can select the file. As the drawing depends on the content of the selected file, I get a null pointer error. My question is how can I select the file before the draw method starts ? If I define my file (Amas.in) explicitely in setup(), all is well, the program shows

Need help about sound processing

浪子不回头ぞ 提交于 2019-12-11 01:51:29
问题 How to get the sample data from stereo sound file (.mp3) and push them into the buffer? Is there any specific library with that function? Sorry if the question is really noob, I'm very new to audio programming. Thanks in advance =) 回答1: "The only way you can play an MP3 file via direct Android API is MediaPlayer which is heavyweight, slow and presents only high-level API. If you need to mix or modify audio streams or manage them with low latency, you are on your own." (Via: http:/

How do I install the openCV library for the Arduino IDE?

空扰寡人 提交于 2019-12-11 01:07:50
问题 I am working on an Arduino project that uses facial tracking, object tracking, facial recognition etc. To accomplish this, I decided to use the OpenCV library. The problem is, however, I don't know how to install the OpenCV library for Arduino, and Processing. Can anyone tell me how to do this? Thank you. 回答1: If you're using the Processing Editor: Go to the Sketch menu, then select Import Library...* and then go to **Add Library... That brings up the Contribution Manager where you can search

Motion: Drawing a Line from an Origin to a Destination in Processing

淺唱寂寞╮ 提交于 2019-12-11 00:58:20
问题 I'm trying to create a graphic that plots a map of the United States using coordinates stored in Map2.csv . Then I add the great lakes using information from Water.csv . I then have origin and destination coordinates for various shipments that were made stored in data1.csv . I want processing to draw a line from origin to destination slowly enough that you can track the path of the shipment with your eye. I'd like there to be a sequential element so the lines could be drawn in certain orders