lines

How to select lines that are drawn on a HTML5 Canvas?

血红的双手。 提交于 2019-11-30 15:22:53
I am using using HTML5 Canvas to plot lines. A single line is formed by calling drawLine() on multiple intermediate points. For example: (0,0) -> (10, 10) -> (10, 5) -> (20, 12) would show up as one line on the plot. All the (x,y) co-ordinates of a line are stored in an array. I want to provide the users with the ability to select a line when they click on it. It becomes difficult to do this in HTML5 Canvas as the line is not represented by an object. The only option that I am left with is to first find that (x,y) coordinate of any line that is closest to the (x,y) of a mousedown event. Once I

Qt QListWidgetItem Multiple Lines

不打扰是莪最后的温柔 提交于 2019-11-30 14:24:53
问题 I have a really simple QListWidget object and I want to build a folder list. When I add an item to my list here is what I do : void LessCC::on_addFolderButton_clicked() { QString dirName = QFileDialog::getExistingDirectory(this, tr("Choose Directory"), QDir::homePath(), QFileDialog::ShowDirsOnly); QListWidgetItem* newItem = new QListWidgetItem(QIcon(":/resources/icons/folder.png"), dirName, 0, 0); this->ui->folderListWidget->addItem(newItem); } This is working but I want my items to have

More than 1 row in <Input type=“textarea” />

核能气质少年 提交于 2019-11-30 11:42:49
问题 I'm having troubles getting my <input type="textarea" /> to have more than 1 row, I tried adding the properties in the html, like you would do with a normal <textarea></textarea> like this: <input type="textarea" rows="x" cols="x" /> I even tried to do it in CSS, but it did not work. I've searched all over the internet for a solution, but i can't seem to find a topic regarding my exact problem anywhere. The textareas i'm experiencing this with, are on this website: Vilduhelst When you press

Qt QListWidgetItem Multiple Lines

Deadly 提交于 2019-11-30 10:49:28
I have a really simple QListWidget object and I want to build a folder list. When I add an item to my list here is what I do : void LessCC::on_addFolderButton_clicked() { QString dirName = QFileDialog::getExistingDirectory(this, tr("Choose Directory"), QDir::homePath(), QFileDialog::ShowDirsOnly); QListWidgetItem* newItem = new QListWidgetItem(QIcon(":/resources/icons/folder.png"), dirName, 0, 0); this->ui->folderListWidget->addItem(newItem); } This is working but I want my items to have multiple lines or column of informations (with different style). I heard about the QStyledItemDelegate but

Minimal rectangle containing all intersections of lines

不羁岁月 提交于 2019-11-30 09:05:42
问题 I'm trying to find an algorithm that will find all the intersections of a set of lines and compute the minimal rectangle that contains all the intersections in O(n log n) time. So far I'm guessing it has to do with duality and convex hulls, but I'm kinda stuck on how it would actually help me solve this problem. If anyone has an idea on this, please let me know. Thanks :) 回答1: Let's start from a box B[0] that minimally bounds three intersection points in a triangle. If no triangle can be

read lines in txt file [java]

▼魔方 西西 提交于 2019-11-30 08:53:16
问题 I'll try to be as clear as possible but pardon me if my question is not perfect. I have a txt file with several lines of data. example: 123 ralph bose 20000 200 1 2 256 ed shane 30000 100 2 4 ... I need to read each line sequentially and pass it back to a method in a separate class for processing. I know how to break down each line into elements by using StringTokenizer. However, i'm not sure how to read one line at a time, pass back the elements to the other class and then, once the

Finding points on a line with a given distance

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 06:54:34
问题 I have a question i know a line i just know its slope(m) and a point on it A(x,y) How can i calculate the points(actually two of them) on this line with a distance(d) from point A ??? I m asking this for finding intensity of pixels on a line that pass through A(x,y) with a distance .Distance in this case will be number of pixels. 回答1: I would suggest converting the line to a parametric format instead of point-slope. That is, a parametric function for the line returns points along that line

Is StreamReader.Readline() really the fastest method to count lines in a file?

巧了我就是萌 提交于 2019-11-30 06:51:53
While looking around for a while I found quite a few discussions on how to figure out the number of lines in a file. For example these three: c# how do I count lines in a textfile Determine the number of lines within a text file How to count lines fast? So, I went ahead and ended up using what seems to be the most efficient (at least memory-wise?) method that I could find: private static int countFileLines(string filePath) { using (StreamReader r = new StreamReader(filePath)) { int i = 0; while (r.ReadLine() != null) { i++; } return i; } } But this takes forever when the lines themselves from

Why is this C code faster than this C++ code ? getting biggest line in file

99封情书 提交于 2019-11-29 23:55:59
I have two versions of a program that does basically the same thing, getting the biggest length of a line in a file, I have a file with about 8 thousand lines, my code in C is a little bit more primitive (of course!) than the code I have in C++. The C programm takes about 2 seconds to run, while the program in C++ takes 10 seconds to run (same file I am testing with for both cases). But why? I was expecting it to take the same amount of time or a little bit more but not 8 seconds slower! my code in C: #include <stdio.h> #include <stdlib.h> #include <string.h> #if _DEBUG #define DEBUG_PATH "..

Print last 10 lines of file or stdin with read write and lseek [closed]

允我心安 提交于 2019-11-29 16:05:21
I'm working on an implementation of the tail function and I'm only supposed to use read() , write() and lseek() for I/O, and so far I have this: int printFileLines(int fileDesc) { char c; int lineCount = 0, charCount = 0; int pos = 0, rState; while(pos != -1 && lineCount < 10) { if((rState = read(fileDesc, &c, 1)) < 0) { perror("read:"); } else if(rState == 0) break; else { if(pos == -1) { pos = lseek(fileDesc, 0, SEEK_END); } pos--; pos=lseek(fileDesc, pos, SEEK_SET); if (c == '\n') { lineCount++; } charCount++; } } if (lineCount >= 10) lseek(fileDesc, 2, SEEK_CUR); else lseek(fileDesc, 0,