Questions tagged [line]

The shortest distance between two points. Or, a row of characters in text output.

is mostly used in below context:

  • text line or command line in text processing context;
  • line drawing or plotting in visualization or image-processing context
  • analytic geometry

For the LINE-API / LIFF use line-api or line-messenger

6255 questions
68
votes
12 answers

PHP: Read Specific Line From File

I'm trying to read a specific line from a text file using php. Here's the text file: foo foo2 How would I get the content of the second line using php? This returns the first line:
Sang Froid
  • 973
  • 1
  • 7
  • 10
68
votes
14 answers

How to find the intersection point between a line and a rectangle?

I have a line that goes from points A to B; I have (x,y) of both points. I also have a rectangle that's centered at B and the width and height of the rectangle. I need to find the point in the line that intersects the rectangle. Is there a formula…
John Petterson
  • 683
  • 1
  • 5
  • 4
61
votes
7 answers

count lines in a PHP project

Do you know any tool which can count all the code lines from a PHP project?
Duncan Benoit
  • 3,297
  • 8
  • 29
  • 26
60
votes
2 answers

How to place multiple evenly-spaced arrowheads along an SVG line?

I am new to SVG and I am trying to draw a straight line between two points. I managed so far by using this command: " What is the simplest…
Osprey
  • 1,523
  • 8
  • 27
  • 44
59
votes
8 answers

Is there a C++ iterator that can iterate over a file line by line?

I would like to get an istream_iterator-style iterator that returns each line of the file as a string rather than each word. Is this possible?
thehouse
  • 7,957
  • 7
  • 33
  • 32
58
votes
11 answers

Check is a point (x,y) is between two points drawn on a straight line

I have drawn a line between two points A(x,y)---B(x,y) Now I have a third point C(x,y). I want to know that if C lies on the line which is drawn between A and B. I want to do it in java language. I have found couple of answers similar to this.…
Usman Mahmood
  • 671
  • 1
  • 7
  • 12
58
votes
8 answers

Drawing a 1px thick line in canvas creates a 2px thick line

In this jsfiddle there's a line with a lineWidth of 1. http://jsfiddle.net/mailrox/9bMPD/350/ e.g: ctx.lineWidth = 1; However the line is 2px thick when it's drawn on the canvas, how do you create a 1px thick line. I could draw a rectangle (with…
CafeHey
  • 5,699
  • 19
  • 82
  • 145
58
votes
5 answers

Reading a file line by line in C#

I am trying to read some text files, where each line needs to be processed. At the moment I am just using a StreamReader, and then reading each line individually. I am wondering whether there is a more efficient way (in terms of LoC and readability)…
Luca Spiller
  • 2,248
  • 4
  • 24
  • 28
56
votes
0 answers

Determine which side of a line a point lies

I've got a line through points (x1,y1) and (x2, y2). I'd like to see if point (x3, y3) lies to the "left" or "right" of said line. How would I do so?
Skizit
  • 43,506
  • 91
  • 209
  • 269
54
votes
11 answers

Process very large (>20GB) text file line by line

I have a number of very large text files which I need to process, the largest being about 60GB. Each line has 54 characters in seven fields and I want to remove the last three characters from each of the first three fields - which should reduce the…
Tom_b
  • 549
  • 1
  • 5
  • 5
52
votes
5 answers

Add each array element to the lines of a file in ruby

If I have an array of strings e.g. a = ['a', 'b', 'c', 'd'] and I want to output the elements, to a file (e.g. .txt) one per line. So far I have: File.new("test.txt", "w+") File.open("test.txt", "w+") do |i| i.write(a) end This gives me the…
edc505
  • 871
  • 3
  • 8
  • 14
52
votes
5 answers

clearRect function doesn't clear the canvas

I'm using this script on the body onmousemove function: function lineDraw() { // Get the context and the canvas: var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); // Clear the last canvas …
Carlos Roldán
  • 902
  • 1
  • 9
  • 19
51
votes
3 answers

How remove \n from lines

file, _ := os.Open("x.txt") f := bufio.NewReader(file) for { read_line, _ := ReadString('\n') fmt.Print(read_line) // other code what work with parsed line... } end it add \n on every line , end program to…
tseries
  • 723
  • 1
  • 6
  • 14
51
votes
8 answers

Get each line from textarea

$text = value from this textarea; How to: 1) Get each line from this textarea ($text) and work with…
James
  • 42,081
  • 53
  • 136
  • 161
50
votes
2 answers

Number of non repeating lines - unique count

Here is my problem: Any number of lines of text is given from standard input. Output: number of non repeating lines INPUT: She is wearing black shoes. My name is Johny. I hate mondays. My name is Johny. I don't understand you. She is wearing black…
john blackwood
  • 511
  • 1
  • 4
  • 3