Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float angle;
- float arrowX, arrowY, dx, dy;
- PShape arrow;
- void setup() {
- size(400, 400, P2D);
- arrowX = width / 2;
- arrowY = height / 2;
- angle = 0;
- arrow = createShape();
- arrow.beginShape();
- arrow.fill(0);
- arrow.noStroke();
- arrow.vertex(1,0);
- arrow.vertex(0,1);
- arrow.vertex(3,0);
- arrow.vertex(0,-1);
- arrow.endShape(CLOSE);
- }
- void draw() {
- background(255); // clear canvas
- dx = mouseX - arrowX;
- dy = mouseY - arrowY;
- angle = atan2(dy, dx);
- println(mouseX, mouseY, dx, dy, angle);
- translate(arrowX, arrowY);
- rotate(angle);
- shape(arrow, 0, 0, 20, 20);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement