processing

Generate a n-color rainbow palette

◇◆丶佛笑我妖孽 提交于 2019-12-06 07:22:18
I'm trying to generate a rainbow with 15 different colors with ( runnable code here ): size(360,100); colorMode(HSB, 360, 100, 100); // Hue in degrees in [0, 360], // saturation/brightness in [0, 100] // like in Photoshop noStroke(); for (int i = 0; i < 15; i++) { fill(i*24, 100, 100); // 24*15 = 360 rect(i*24, 0, 25, 100); } but it doesn't produce a rich 15 rainbow-color palette, instead some colors are missing (vivid yellow for example). Is there a well known algorithm to produce a vivid rainbow color palette? To understand what's going on, try creating a program that shows a line for each

How to run Processing applications from the terminal

笑着哭i 提交于 2019-12-06 06:46:54
问题 I'm currently using Processing for a small project, however I'm not liking the text-editor that comes with it. I use vim to write all of my code. I've found where the .pde file are and I've been editing them from vim and then I'm reopening them and running them (it takes a lot to reload the script and running it). That's why I want a solution where I can compile everything from the terminal. On close inspection I've found the processing-java file that supposedly compiles and runs a sketch.

High-Resolution Processing Output

纵然是瞬间 提交于 2019-12-06 05:22:38
I'm looking for help with the programming language/environment Processing. I'm fairly new to Processing and I am experimenting with a piece of code from someone over at openprocessing.org. I really like the visual results this code delivers and I would like to further work with it. Unfortunately, the output is very low resolution. Hence I'm looking for someone who might be able to help me figure out how to a) Increase the size or resolution of the shapes generated and b) save everything as a pdf file. You can find the original code in action here: https://www.openprocessing.org/sketch/377730

Embed processing 3 into swing

徘徊边缘 提交于 2019-12-06 05:13:30
问题 I'm trying to integrate Processing 3 into a swing application, but because PApplet doesn't extend Applet anymore I can't just add it as a component right away. Is there anyway of embeding a Processing 3 sketch into Swing, it would be enough if I could just open the sketch in a seperate window without the PDE. 回答1: You can run a sketch from Java by extending PApplet and then using the runSketch() function to run that PApplet. It'll look something like this: String[] args = {"MyPapplet "};

Integrate Processing with Minim Libraries in Website

爱⌒轻易说出口 提交于 2019-12-06 04:13:05
I have seen similar questions posted before but seems the general answer is that it cannot be done. So, here is my HTML code : <head> … <script type="text/javascript" src="js/processing.js"></script> … </head> <body> … <canvas id="my_prog" data-processing-sources="project/my_prog.pde project/my_class.pde"/></canvas> … </body> And in my sketch I use Minim libraries : import ddf.minim.*; import ddf.minim.spi.*; import ddf.minim.ugens.*; Instead of having my project on my website, there is a rectangular shape proportional to the project size, but without image and sound. Moreover, this method

how to calculate the dist() from mouseX, mouseY to a rectangle in Processing

ε祈祈猫儿з 提交于 2019-12-06 04:01:23
问题 If it was the dist to a point it would be dist(mouseX, mouseY, x, y) for point(x,y) but how can I calculate dist() from the mouse's current position to rectMode(CORNERS); rect(x1,y2,x2,y2); Thanks 回答1: Something like this should do it: float distrect(float x, float y, float x1, float y1, float x2, float y2){ float dx1 = x - x1; float dx2 = x - x2; float dy1 = y - y1; float dy2 = y - y2; if (dx1*dx2 < 0) { // x is between x1 and x2 if (dy1*dy2 < 0) { // (x,y) is inside the rectangle return min

Android - Processing Build not compiling

…衆ロ難τιáo~ 提交于 2019-12-06 03:04:58
I'm having issues with the IDE Processing. I'm trying to compile something to Android. I'm on Android Mode, of course. But I'm getting this Error at the time of compiling. (It's not the code itself) I've installed "adb devices", it seems Ok. I've done all the "51-android.rules" process. I've installed API 10(the one requested) and Android Tools. I don't really know what should be wrong. ----------------- API<=15: Adding annotations.jar to the classpath. [echo] ---------- [echo] Building Libraries with 'debug'... [subant] No sub-builds to iterate on -code-gen: Merging AndroidManifest files into

Using JSON from Processing-JS

五迷三道 提交于 2019-12-06 01:21:06
I want to write an application using processing-JS , and I'd like to be able to load it with server-side data. I haven't written the server side yet so I can use anything, but it seems the obvious AJAX thing would be to use JSON to upload the data into the page. How can I get access to that data from my processing code? Is it something as easy as the data is in scope, or could be attached to the window object and directly accessed from the processing code? Update : Let me refine the question a little bit. I'm comfortable with JSON (but thanks for the links) and with writing code for both the

Buggy bouncing balls

╄→гoц情女王★ 提交于 2019-12-05 23:20:02
I was making a colliding ball sketch in Processing, and I encountered a weird bug. Despite having a condition for bouncing off of the walls, some balls get stuck to it . I can't find the source of error here. Can someone help? I also realise that there maybe few (a lot) bad coding practices, but I apologise beforehand. I am posting the codes below. 1) Main : https://pastebin.com/hv0H14gZ particle[] elec = new particle[5]; boolean record = false; void setup(){ float x=0,y=0; int i,j; float diam = 100; size(800,400); //Initialising the particle objects for (int k = 0; k < elec.length; k++){ x =

codeforces 833 I. Photo Processing

社会主义新天地 提交于 2019-12-05 14:29:43
1.首先二分group的差值,然后判断在差值x下能否分成每组数量大于等于K的要求。 2.利用dp check,dp[i]表示考虑1-i使得1-dp[i]全部划分合法的最大值,即离i最近的位置P,且1-P能够划分合法。如果从dp[i-k]+1到i差值小于等于x,则说明dp[i-k]-i可以划分为一组,所以dp[i]=i。最后判断dp[n]=n即可。 #include <stdio.h> #include <algorithm> #include <string.h> using namespace std; #define maxn 300010 typedef long long ll; const ll mod=(1e9)+7; int n,k; int dp[maxn],v[maxn]; bool check(ll x){ int pos=0; for(int i=k;i<=n;i++){ int prp=dp[i-k]; if(v[i]-v[prp+1]<=x){ pos=i; } dp[i]=pos; } return dp[n]==n; } int main(){ scanf("%d%d",&n,&k); for(int i=1;i<=n;i++)scanf("%d",&v[i]); sort(v+1,v+1+n); int L=0,R=v[n]-v[1],P;