Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Lines at any angle #271

Open
RChampalbert opened this issue Jul 17, 2023 · 2 comments
Open

Feature: Lines at any angle #271

RChampalbert opened this issue Jul 17, 2023 · 2 comments

Comments

@RChampalbert
Copy link

I would like to be able to draw a line at any angle based on two points. The tool should make a best guess as to how to render that line. There are are ways to make lines at other angles besides 0, 90 and 45 degrees. E.g.

    __,,--''
--'' 

This line drawing method in ASCII is never going to be prefect, but I think that there are plenty of ways to make this somewhat useful.
I don't think that this method needs to interact with other lines. It would be nice just to be able to draw it. The way that I would use it is to start one point, and then move the line around until I get something that looks good enough.

A fancier version of this would allow free line drawing - but rather than only drawing a single character as is currently supported - it would try to figure out the best set of character to represent the curve of the line being drawn.

@thetayloredman
Copy link

This wouldn't work for any vertical or horizontal line, where the program should just use the straight line tool in the background, but for any points $A(a_x, a_y)$ and $B(b_x, b_y)$ where $a_x \ne b_x$ and $a_y \ne b_y$ I would approach this by first drawing a right triangle with a point P $\triangle ABP$ like so, similar to the derivation of the Distance Formula:

image

Now on this, each point corresponds with the bottom left corner of an AsciiFlow cell, however it would need to be stretched to fit properly with the height of the font.

At each interval of 0.5 from the start point, e.g. if drawn from $(3, 4)$ to $(6, 8)$ I would find $f(x)$ for every $x$ 3.5, 4.5, 5.5. This represents the middle of an AsciiFlow cell. ($f$ in this case is the function for $\overleftrightarrow{AB}$, or $f(x)=y-a_y=\frac{b_y-a_y}{b_x-a_x}(x-a_x)$ using two point form)

We'd now have the coordinates of the middle points on each point on the line, and you'd then do something to truncate the whole number part off, to just the decimal, so 4.3 => .3. Then you would lookup that .3 value in a table taking the closest value, e.g. something that maps like

0 => _
0.5 => -
0.9 => '

This also doesn't take into account the direction of the line could give us a better result 🤔

I assume most people think this two, but I wanted to document my opinion.

@thetayloredman
Copy link

I don't know why I mentioned the triangle, I was thinking trig stuff but I realized that's not needed. We could probably factor in information about the slope as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants