• API
• FAQ
• Tools
• Archive
daily pastebin goal
76%
SHARE
TWEET

# Untitled

Cryptogee Mar 19th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. Point[] points = new Point[200];
2.
3. void setup() {
4. fullScreen(FX2D); // FX2D works better for this sketch
5.
6. for (int i = 0; i < points.length; i++)
7. points[i] = new Point(random(width), random(height), 0.002f, 50);
8. }
9.
10. void draw() {
11. background(0);
12. stroke(#45DFE3);
13. strokeWeight(0.3f);
14.
15. for (int i = 0; i < points.length; i++) {
16. points[i].update();
17.
18. for (int j = 0; j < points.length; j++) {
19. if (i != j && points[i].isNear(points[j])) {
20. line(points[i].x, points[i].y, points[j].x, points[j].y);
21. points[i].show();
22. }
23. }
24. }
25. //println((int) frameRate);
26. }
27.
28. class Point {
29. float x, y;
30. float xoff, yoff, speed;
31. float proximity;
32.
33. Point(float x, float y, float speed, float proximity) {
34. this.x = x;
35. this.y = y;
36. this.speed = speed;
37. this.proximity = proximity;
38. xoff = random(50000);
39. yoff = random(50000);
40. }
41.
42. void show() {
43. noStroke();
44. fill(255, 30);
45. ellipse(x, y, 8, 8);
46. }
47.
48. void update() {
49. x = noise(xoff) * (height);
50. x += width/4; // this is here just to offset (to "center") the x coordinate.
51. xoff += speed;
52.
53. y = noise(yoff) * (height);
54. yoff += speed;
55. }
56.
57. boolean isNear(Point other) {
58. float d = dist(this.x, this.y, other.x, other.y);
59. return d < proximity ;
60. }
61. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top