I have the classic balls that move in a line:
However, i don't want them moving in a line.
I want them moving in unregular curves. What can i add? noise? sin? cos?
Many thanks.
We all know how to draw a line in Processing.
But when we draw a line, the line is shown immediately.
What if i want to witness the drawing process, namely, to see the line moving forward, gradually completes a whole line.
Here's what i want to realize: to DRAW several lines and curves which finally turn into some pattern.
So how to make that happen? Using array?
Many thanks.
btw, there was a guy casting doubt on my question, i accidentally delete the question instead of editing it, so i rewrite this one, sorry >_<
i use jQuery to detect the size of the browser window, if it's smaller than a certain size, the canvas' content won't be shown, also an alert for extending your browser window will appear.
the html looks like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="jQuery.js"></script>
<script type="text/javascript" src="dirtyhand9.js"></script>
<script type="text/javascript" src="processing.js"></script>
<script type="text/processing" data-processing-target="mycanvas">
void setup(){.........
In the canvas, i use processing.js combined with jQuery. Only when the size larger than that will the draw function work
void setup(){
size( $(window).width()-20,$(window).height()-20 );}
void draw(){
background(255);
if(width>= 1024 && height>=768 ){......
and then i write dirtyhand9.js for the alert :
$(document).ready(function(){
$("#alert").hide();
if( $(window).width()-20<1024 || $(window).height()-20<768){
$("#alert").show();};
And now is the problem:
it works just the way i want in Firefox; However in Chrome, it doesn't.
Every first time i open it with Chrome, it always shows the alert and nothing in canvas no matter what size the windows is. But it works fine after i refresh the page in Chrome.
I guess the cause of this problem lies in Chrome's jQuery detecting??
it detects the size after document is ready??
But before it is ready, the processing.js fails to get the width and height, so it shows nothing. and why the alert shown?? Have no idea.
So does anyone know the cause? Or the possible solution????
Many thanks.
size( $(window).width(),
$(window).height() );
As title, what i want to realize with Processing:
There are classical circles running across on the screen, then:
the first time you click the mouse,all the circles freeze(stop moving);
the second time you click the mouse, you draw a new circle with your mouse position.
Okay now is the problem: how to tell the computer to act differently? After all, they are all clicks, seem the same to the computer.
Does anybody know? Thank you very much.
Two questions:
1.Why doesn't the line function work?
2.How can i make circles move smoothly(respectively) following my mouse instead of squeezing into one point abruptly?
Thank you very much.
My intention is to draw two eyes based on the mouse location.So i define an Eye class and then call its draw method with valiable mouseX and mouseY. However, it shows nothing on the browser.
Also, i wonder how to detect the size of the browser because screen.width and screen.height don't seem to work within a browser.
void setup(){
size(800,800);
smooth();
background(225);
}
if (mousePressed){
Face.draw(mouseX,mouseY);}
class Face{
float x,y,a;
Face(float ax,float ay){
x=ax;
y=ay;
a=random(1,5);}
void draw{
noFill();
stroke(0);
//eye1
ellipse(x+2.2*a,y-a,a/2,a/2);
//eyelashes1
arc(x+2.2*a,y-.5*a,1.2*a,1.2*a,PI,2*PI);
//eyebrows1
arc(x+3*a,y-.3,2*a,2*a,5/4*PI,9/4*PI);
//eye2
ellipse(x-2.2*a,y-a,a/2,a/2);
//eyelashes2
arc(x-2.2*a,y-.5*a,1.2*a,1.2*a,PI,2*PI);
//eyebrows2
arc(x-3*a,y-.3,2*a,2*a,5/4*PI,9/4*PI);}}
</script>
</head>
<body></body>
<canvas id="mycanvas"></canvas>
</html>
i'm a beginner, so i don't know if my problem is stupid or not.
But any hint is welcomed:)
Thank you.
Firstly, i draw lots of circles and they are moving slightly because I add noise in the centre of a circle.
Second, I draw some patterns combining ellipse(mouseX,mouseY,random(1,3),random(1,3))
,rect
, line
, etc.
Third, and this is the problem, I want to make the circles change color if they have a distance from the patterns less than a certain amount.
How could I calculate the distance between those circles' center and the pattern's border? They are both dependent variables.
Maybe because the shape functions are so well-packaged that they're not easy to break and use . i found a way to calculate Point to line distance : processing.org/discourse/beta/num_1276644884.html
However i don't understand it.
And then i found another way to think : to make it a problem of compare each element in the array with every other element in the array https://forum.processing.org/topic/constantly-resizing-ellipse-based-on-distance,
but i still dont know how to modify shape function like ellipse(x,y,radius1,radius2)into an array.
Please give me any hint.Thanks.