// Finds the point which is percentage between the two specified points x1,y1 and x2,y2. // This can also be used to find points that are beyond the bounds of the segment as well. // Percentages accepted are typically 1 - 100 // Returns an object literal with an .x and .y property. (A Point) function findPointInSegment(x1, y1, x2, y2, percentage) { let newX = (x1 + ((percentage / 100) * (x2 - x1))); let newY = (y1 + ((percentage / 100) * (y2 - y1))); return {x: newX, y: newY}; }

**Posted:** March 20, 2023

Return to the snippets listing

© 2023 The Coders Lexicon. All rights reserved. Privacy Policy