Results 1 to 8 of 8

Thread: create moving object from a set of data points

  1. #1
    Join Date
    Nov 2015
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default create moving object from a set of data points

    Hi,
    I want to create a moving image based on a set of data points that I have in a json file.

    What would be the best way to create this?
    Should I just use plain javascript, or should I use d3 ? SVG?

    Please can you point me to a few resources for the same.

  2. #2
    Join Date
    Nov 2014
    Location
    On A Scottish Island
    Posts
    488
    Thanks
    0
    Thanked 62 Times in 58 Posts

    Default

    "Moving image" covers a lot of possibilities. Do you want a fixed image to appear at different places on the page or do you want the contents of a rendered image to be dynamic in some way?

  3. #3
    Join Date
    Nov 2015
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by styxlawyer View Post
    "Moving image" covers a lot of possibilities. Do you want a fixed image to appear at different places on the page or do you want the contents of a rendered image to be dynamic in some way?
    styxlawyer, Given a set of coordinates, I want, say a ball, to draw the line between those points.

    Say If I give screen coordinates like
    50 200,
    200 250,
    250 20

    I want to see three lines drawn one after another between the coordinates mentioned above, with a small time gap in between.

  4. #4
    Join Date
    Nov 2014
    Location
    On A Scottish Island
    Posts
    488
    Thanks
    0
    Thanked 62 Times in 58 Posts

    Default

    Ah, you actually want to plot lines. I suggest you look at the HTML canvas methods, in particular the lineTo() function.

  5. #5
    Join Date
    Nov 2015
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by styxlawyer View Post
    Ah, you actually want to plot lines. I suggest you look at the HTML canvas methods, in particular the lineTo() function.
    Thanks styxlawyer, this is useful. I have been looking at it now, and trying out a few examples.

    However, I wanted a pen at the end of the line, and add some delay to see the line being drawn, basically it should look like the line is coming out of the pen. Can you give me some pointers on how I can do this?
    Imagine drawing a line using a pen from a source point (0, 0) to destination point (300, 150), so you want to see the pen moving from source to destination slowly, and I want to do this in javascript.

  6. #6
    Join Date
    Nov 2014
    Location
    On A Scottish Island
    Posts
    488
    Thanks
    0
    Thanked 62 Times in 58 Posts

    Default

    You will have to calculate the intermediate points in JavaScript and simply redraw the line many times (each one a little longer than the previous) and place the image of a pen at the drawing end of the line using the calculated x & y coordinates.

  7. #7
    Join Date
    Nov 2015
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by styxlawyer View Post
    You will have to calculate the intermediate points in JavaScript and simply redraw the line many times (each one a little longer than the previous) and place the image of a pen at the drawing end of the line using the calculated x & y coordinates.
    Thanks styxlawyer, shall work around this.

  8. #8
    Join Date
    Nov 2014
    Location
    On A Scottish Island
    Posts
    488
    Thanks
    0
    Thanked 62 Times in 58 Posts

    Default

    Have a look at this page.

Similar Threads

  1. Replies: 1
    Last Post: 07-11-2014, 10:14 AM
  2. Moving an object/element in Parallax
    By Shammus in forum JavaScript
    Replies: 6
    Last Post: 03-01-2011, 03:52 PM
  3. create moving banner PhotoShop CS3
    By chechu in forum Graphics
    Replies: 5
    Last Post: 08-10-2010, 04:36 AM
  4. Create object; load file in the object
    By molendijk in forum JavaScript
    Replies: 0
    Last Post: 03-09-2008, 07:30 PM
  5. Replies: 7
    Last Post: 01-08-2007, 05:07 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •