mouse position problem

edited February 2014 in JavaScript Mode

Hello. I have problem using processingjs. I think that category is the best.

I have problem just like in the topic. It looks like mouse position was wrong !Clipboard05 And my primitive code.

void setup() { size(500,500,JAVA2D); background(0); }

void draw() { ellipse(mouseX, mouseY, 80, 80); }

Answers

  • Why don't you try out your code on these sites and check whether they work there?

    http://sketchpad.cc/
    http://www.openprocessing.org/sketch/create

  • I checked it, it doesn't looks ok. When i am on top of the website it looks OK, but when i use scroll as I said. I am using chrome but on opera it doesn't look ok too.

  • edited February 2014

    I've had the same issue with Chrome. I don't know about Opera but my code was running fine with FireFox and Safari.

    Removing the doctype field in the HTML page solved the issue.

  • I have modified the updateMousePosition function in processing.js (1.4.1).

    function updateMousePosition(curElement, event) { var rect = curElement.getBoundingClientRect(); p.mouseX = event.clientX - rect.left; p.mouseY = event.clientY - rect.top; }

Sign In or Register to comment.