Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8224945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:14:45+00:00 2026-06-07T15:14:45+00:00

I draw with a mouse Paper.js. I need to keep these strokes and replay

  • 0

I draw with a mouse Paper.js. I need to keep these strokes and replay them at the same rate as in the video replay. How can I accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:14:48+00:00Added an answer on June 7, 2026 at 3:14 pm

    In paper.js, the onFrame() function is called up to 60 times per second, while the onMouseMove() function “is called when the mouse moves within the project view”, and contains the position of the mouse. By using both functions you can store the mouse motions and replay them later with close to the same time between positions.

    var mousePosition = null;
    function onMouseMove(event) {
        if (mousePosition != null) {
            var path = new Path();
            path.strokeColor = 'black';
            path.moveTo(mousePosition);
            path.lineTo(event.point);
        }
        mousePosition = event.point;
    }
    
    var recordedPositions = [];
    var delayFrames = 60;
    function onFrame(event) {
        if (mousePosition != null) {
            recordedPositions.push(mousePosition);
            if (recordedPositions.length > delayFrames) {
                var path = new Path();
                path.strokeColor = 'red';
                delayedPositionIndex = recordedPositions.length - delayFrames;
                path.moveTo(recordedPositions[delayedPositionIndex - 1]);
                path.lineTo(recordedPositions[delayedPositionIndex]);
            }
        }
    }
    

    I do not know the timing accuracy/resolution/dependability of onFrame(). Alternatively you could just use javascript timing events as in this answer: How can I use javascript timing to control on mouse stop and on mouse move events

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to move (draw) rectangle with same mouse position in regard to rectangle.
I am trying to draw a line along with mouse move on a paper.
I'm trying to build a ScrolledWindow that you can draw on using the mouse,
On every mouse move I need to draw on my canvas a radial gradient
I need to detect mouse motion and draw a ball at the mouse's position.
I need to draw polygon using mouse and mark a particular area on Google
I need to draw Line, Circle, and rectangle by mouse drag on canvas and
I have already seen this question Draw a line with two mouse clicks on
I know how to keep my mouse (my g.draw(mouseX, mouseY) cursor) within a Ellipse2D
I need to be able to draw a polygon using mouse click locations. Here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.