Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
The straight line drawing algorithm. Each number in the list holds information of x,y coordinates and gradient information. The format is x1,y1,x2,y2. I have modified this program to draw a little house ... :-D

for (589840,117506056,134225920,671555840,534280,1058576,654911248,151718157,269160461,168496907,168627981){($x,$y,$v,$w)=unpack"c*",pack"l",$_;$e=$v-$x;$g=$w-$y;$h=abs$e;$k=abs$g;$d=$h>$k;for(0..(($d)?$h:$k)){$f+=$d?$g/$e:$e/$g;$f1=$f;int$f&&do{$y+=$d?$g>0?1:-1:0;$x+=$d?0:$e>0?1:-1;$f+=$f>0?-1:1};$c$y||=' 'x 60;substr($c$y,$x+1,1)=abs$f1>=1?$f1>0?"\\":"/":$d?"-":"|"; $d?($x+=$e>0?1:-1):($y+=$g>0?1:-1);}};$"="\n";print"@c";

In reply to Re: LineDraw Japh by Roger
in thread LineDraw Japh by benn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-19 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found