Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int circleSize = 20;
- int numberOfPositions = 100;
- int []mousePosX = new int[numberOfPositions];
- int []mousePosY = new int [numberOfPositions];
- void setup()//
- {
- size(842, 480);
- }
- void draw()//
- {
- clear();
- background(0);
- addMousePosition();
- for (int i = 0; i < mousePosX.length; i++) {
- // alpha will define the transparancy (alpha).
- // The number of steps between 255 and 0 will be inline with number of elements in the array.
- float alpha = map(i, 0, mousePosX.length, 255, 0);
- fill(255, alpha);
- ellipse(mousePosX[i], mousePosY[i], circleSize, circleSize);
- }
- }
- void addMousePosition() {
- noStroke();
- fill(255);
- // Shift the array backwards, so the current mouse position can be added to
- // the array on index position 0
- for (int i = mousePosX.length-1; i > 0; i--) {
- mousePosX[i] = mousePosX[i-1];
- mousePosY[i] = mousePosY[i-1];
- }
- mousePosX[0] = mouseX;
- mousePosY[0] = mouseY;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement