processing

How to rotate a PShape around its centre?

南楼画角 提交于 2019-12-23 17:19:56
问题 The Processing handbook (second edition) has this as example 17-10: PShape zig; void setup() { size(100, 100); zig = createShape(); zig.beginShape(); zig.fill(0); zig.noStroke(); zig.vertex(10, 0); zig.vertex(100, 30); zig.vertex(90, 70); zig.vertex(100, 70); zig.vertex(10, 90); zig.vertex(50, 40); zig.endShape(); zig.scale(0.7); zig.translate(-50, -50); } void draw() { background(204); shape(zig, 50, 50); zig.rotate(0.01); } And the images in the book that accompany this example show the

How to add mouse drag function to double pendulum

醉酒当歌 提交于 2019-12-23 12:54:43
问题 I have code for a double pendulum that traces the second pendulums centre with a line by using the previous position of the pendulum. I need to add a function that when the mouse is clicked (on or not on the pendulum, it doesnt matter), the pendulum can be dragged around the screen within the boundaries of the pendulum, im not sure if mouse dragged() would work or if i should use a class for the pendulum to make it easier float r1 = 200; float r2 = 200; float m1 = 40; float m2 = 40; float a1

Get value from an Arraylist of Objects - processing

北城余情 提交于 2019-12-23 05:32:35
问题 I'm making a virtual pet game, and I am now trying to include hunger, however I'm not sure how to make the eat function work. I am trying to make it decrease through the addition of the nutrition value of an item of food. This value is in an object that is stored in an arraylist. Is there a way to reference int nutrition(int eaten) { nutrition = nutrition - eaten; return nutrition; (int eaten will be passed in later) inside ArrayList items; void setup() { items = new ArrayList(); } void draw(

open CV with processing - Error

≡放荡痞女 提交于 2019-12-23 04:33:11
问题 I'm trying to work with the openCV library. I keep getting errors (I've tried to install both 32-bit and 64-bit processing, and followed the exact instructions online). This is the code I'm trying to run (the most basic one i think): import hypermedia.video.*; // Imports the OpenCV library OpenCV opencv; // Creates a new OpenCV Object void setup() { size( 320, 240 ); opencv = new OpenCV( this ); // Initialises the OpenCV object opencv.capture( 320, 240 ); // Opens a video capture stream }

What is the most reliable way to record a Kinect stream for later playback?

蓝咒 提交于 2019-12-23 04:10:53
问题 I have been working with Processing and Cinder to modify Kinect input on the fly. However, I would also like to record the full stream (depth+color+accelerometer values, and whatever else is in there). I'm recording so I can try out different effects/treatments on the same material. Because I am still just learning Cinder and Processing is quite slow/laggy, I have had trouble finding advice on a strategy for capturing the stream - anything (preferably in Cinder, oF, or Processing) would be

ClassNotFoundException when accessing Processing from Eclipse

ⅰ亾dé卋堺 提交于 2019-12-23 03:04:30
问题 I'm trying to run Processing from Eclipse but whenever I run the application as a Java Application I get java.lang.ClassNotFoundException . Here's my full code: import processing.core.PApplet; public class App extends PApplet { public void setup() { size(200,200); background(0); } public void draw() { stroke(255); if (mousePressed) { line(mouseX,mouseY,pmouseX,pmouseY); } } public static void main(String args[]) { PApplet.main(new String[] { "--present", "App" }); } } Exception: java.lang

Python processing学习

半世苍凉 提交于 2019-12-23 03:01:02
原文地址: http://blog.csdn.net/imzoer/article/details/8701116 The processing.Process class follows the API of threading.Thread . 上面是python doc的原话。 安装processing模块的时候遇到找不到python.h这个文件的问题。 网上搜了很多资料。都说是缺少python-dev。但是使用apt-get却一直提示缺少Python.h。我是这样解决的: 1、安装aptiude 2、使用aptitude安装python-dev 3、easy_install安装processing模块。 ------------------------------------------------------ 下面使用proessing来做一些例子。 [python] view plain copy from processing import Process,Queue import time def f(q): x=q.get() print "Process number %s,sleeps for %s seconds." % (x,x) time.sleep(x) print "Process number %s finished!" % x q=Queue()

Processing, ellipse not following alpha values?

人走茶凉 提交于 2019-12-23 02:23:20
问题 class Particle{ PVector velocity, location; //PVector variables for each particle. Particle(){ //Constructor - random location and speed for each particle. velocity = new PVector(random(-0.5,0.5), random(-0.5,0.5)); location = new PVector(random(0,width),random(0,width)); } void update() { location.add(velocity); } //Motion method. void edge() { //Wraparound case for particles. if (location.x > width) {location.x = 0;} else if (location.x < 0) {location.x = width;} if (location.y > height)

Processing 3 improving intensive math calculation

那年仲夏 提交于 2019-12-23 02:22:28
问题 I wrote a very simple sketch to simulate the interference of two planar waves, very easy. The problem seems to be a little to much intensive for the cpu (moreover processing uses only one core) and I get only 1 o 2 fps. Any idea how to improve this sketch? float x0; float y0; float x1; float y1; float x2; float y2; int t = 0; void setup() { //noLoop(); frameRate(30); size(400, 400, P2D); x0 = width/2; y0 = height/2; x1 = width/4; y1 = height/2; x2 = width * 3/4; y2 = height / 2; } void draw()

Processing, ellipse not following alpha values?

独自空忆成欢 提交于 2019-12-23 02:22:09
问题 class Particle{ PVector velocity, location; //PVector variables for each particle. Particle(){ //Constructor - random location and speed for each particle. velocity = new PVector(random(-0.5,0.5), random(-0.5,0.5)); location = new PVector(random(0,width),random(0,width)); } void update() { location.add(velocity); } //Motion method. void edge() { //Wraparound case for particles. if (location.x > width) {location.x = 0;} else if (location.x < 0) {location.x = width;} if (location.y > height)