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

  • Home
  • SEARCH
  • 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 8352327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:55:53+00:00 2026-06-09T08:55:53+00:00

I am developping a web application, basically its a simple version of Illustrator/Flash. So

  • 0

I am developping a web application, basically its a simple version of Illustrator/Flash.
So soccer trainers can make schemes.
I made different tools like in Photoshop (line tool, rectangle tool, ..).
All of these work.

However now i need to develop a tool where the user can draw a double parallel line. I would like to be able to define the distance between those 2 lines in a variable.
I need to draw 2 parallel lines between any 2 points on the stage. Like the line tool in Photoshop/Illustrator , but it draws 2 lines at once.


It should basically work like this

1) on mouse down:

create a new graphics object and register the X and Y where the user clicked. start to listen for Mouse Move.


2) on mouse move:


clear the graphics object, draw the double line from the original mouse position to the current mouse position. redraw on every mouse move.


3) on mouse up:



stop listening for events and add the double line to the stage.


This worked perfectly for drawing a single line, but I’m having troubles with 2 parallel lines. They don’t stay parallel to each other or the rotation doesn’t work properly.

  • 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-09T08:55:55+00:00Added an answer on June 9, 2026 at 8:55 am

    You will need to plot the points this way:

    90 degrees (UP from the START point)        90 degrees (UP from the END point)
    |                                                                            |
    START- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - END
    |                                                                            |
    90 degrees (DOWN from the START point)    90 degrees (DOWN from the END point)
    

    Once you determine those 6 points (2 for the top-line, 2 for the mouse start and end, and 2 for the bottom-line), you can join the pair of points for the top-line and bottom-line together with a lineTo(…) command to give you this:

    ------------------------------------------------------------------------------
    
    START                                                                      END
    
    ------------------------------------------------------------------------------
    

    To know what is the current angle formed by your START and END point, you need the deltas (difference between two values) of your point’s X and Y values.

    So X2 – X1 = DeltaX, and Y2 – Y1 = DeltaY.

    Then, put those deltas in Math.atan2(y:Number, x:Number):Number. The returned value is in radians I believe, so to work with degrees, you can do the conversion by multiplying the result with 180 / Math.PI.

    This won’t be really necessary however, as we can resume the rest of the calculations in radians. It would be useful to store the above value (180/Math.PI) in a variable.

    If we continue with Radians, it is important to convert our 90 degrees to Radians.

    • 90 / radians gives us a number to offset from our START and END point to solve the top line.
    • -90 / radians gives us the number to offset from our START and END point to solve the bottom line.

    in other words…

    This is a whole solution that I quickly tested, I apologize if it doesn’t work 100%:

    var startPoint:Point = new Point(10, 0); //Replace by start-mouse location
    var endPoint:Point = new Point(20, 0); //Replace by end-mouse location
    
    var mouseAngle:Number = Math.atan2( endPoint.y - startPoint.y, endPoint.x - startPoint.x );
    
    var angle:Number;
    var lineHalfGap:Number = 100 * .5; //Replace 100 by your seperation value
    var radians:Number = 180 / Math.PI;
    angle = 90 / radians + mouseAngle;
    var topOffsetX:Number = Math.cos( angle ) * lineHalfGap;
    var topOffsetY:Number = Math.sin( angle ) * lineHalfGap;
    angle = -90 / radians + mouseAngle;
    var bottomOffsetX:Number = Math.cos( angle ) * lineHalfGap;
    var bottomOffsetY:Number = Math.sin( angle ) * lineHalfGap;
    
    var topStart:Point = new Point(startPoint.x + topOffsetX, startPoint.y + topOffsetY);
    var topEnd:Point = new Point(endPoint.x + topOffsetX, endPoint.y + topOffsetY);
    
    var bottomStart:Point = new Point(startPoint.x + bottomOffsetX, startPoint.y + bottomOffsetY);
    var bottomEnd:Point = new Point(endPoint.x + bottomOffsetX, endPoint.y + bottomOffsetY);
    
    trace(topStart, topEnd, bottomStart, bottomEnd);
    

    Obviously there’s a few variables you will have to replace / substitute for your own (like the mouse locations and the separation value for your line gap), but this should do the trick.

    A running example can be found here:

    http://pierrechamberlain.ca/blog/2012/08/math-101-parallel-lines-two-points/

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

Sidebar

Related Questions

We currently have a fully developed web forms application, basically its like WordPress using
I im developing a web application, its a servlet which basically acts as a
I am developping a web application by using the ASP .NET MVC 3 framework.
i'm new to java and i got some problems. i'm developping a web application
I am developping a web application by using the ASP .NET MVC 3 framework.
I'm developing a C# asp.net web application. I'm basically done with it, but I
Guys I am currently developing a web application, in which rules, which are basically
I am currently building a gallery web application using php. I am currently developping
I'm developping an application in android which consumes a wcf web-service. What I currently
I'm developing a web- application using NHibernate. Can you tell me how to write

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.