{"id":131,"date":"2007-05-12T14:55:01","date_gmt":"2007-05-12T12:55:01","guid":{"rendered":" http:\/\/www.nsonic.de\/blog\/2007\/05\/triangle-algorithm\/"},"modified":"2007-05-12T14:55:03","modified_gmt":"2007-05-12T12:55:03","slug":"triangle-algorithm","status":"publish","type":"post","link":"https:\/\/www.nsonic.de\/blog\/2007\/05\/triangle-algorithm\/","title":{"rendered":"Triangle algorithm"},"content":{"rendered":"<p><em>Lars Gollub  a \u00e9crit dans l&#8217;article<br \/>\n<6up816$k8u36@forums.borland.com \n \n>&#8230;<br \/>\n> >Can you use the fillpoly routine or something like that?<br \/>\n><br \/>\n> Well, no. This is why I am asking for the algorithm. Windows is<br \/>\n> very slow in drawing *many small* Objects. So I draw them<br \/>\n<\/em><br \/>\n<!--more--><br \/>\nwell, take a look in the good all SWAG ! Von: Paul TOTH<br \/>\nBetreff: Re: Triangle algorithm<br \/>\nDatum: Dienstag, 29. September 1998 08:28<\/p>\n<p>look on my Pascal Page for ZED &#038; BODY.<br \/>\n&#8212;<br \/>\nsee the triangle as a array of horizontal lines&#8230;(or vertical for fast VGA<br \/>\nX-Mode)<\/p>\n<p>0<br \/>\n.<br \/>\nRightX&#8230;..LeftX<br \/>\n.      A<br \/>\n.     BBBB<br \/>\n.    CCCCCC<br \/>\n.   DDDDDDDD<br \/>\n.<br \/>\nMaxY<\/p>\n<p>[code lang=&#8221;delphi&#8221;]Var<br \/>\n RightX:array[0..MaxY] of word;<br \/>\n LeftX :array[0..MaxY] of word;     <\/p>\n<p>procedure DrawTriangle(color:TColor);<br \/>\n var<br \/>\n  x1,x2,y:integer;<br \/>\n begin<br \/>\n  for y:=0 to MaxY do begin<br \/>\n    x1:=RightX;<br \/>\n    x2:=LeftX;<br \/>\n    if x1<0 then begin dx:=-dx; ix:=-1 end else ix:=+1;\n  dy:=y2-y1; if dy<0 then begin dy:=-dy; iy:=-1 end else iy:=+1;\n  if dx>dy then begin<br \/>\n   e1:= 2*dy;<br \/>\n   e2:=e1-dx;<br \/>\n   e3:=e2-dx;<br \/>\n   for i:=0 to dx do begin<br \/>\n     if x1LeftSX[y1]  then LeftX[y1] :=x1;<br \/>\n     inc(x1,ix);<br \/>\n     if e2<0 then inc(e2,e1) else begin\n      inc(e2,e3);\n      inc(y1,iy);\n     end;\n   end;\n  end else begin\n   e1:= 2*dx;\n   e2:=e1-dy;\n   e3:=e2-dy;\n   for i:=0 to dy do begin\n     if x1LeftX[y1]  then LeftX[y1] :=x1;\n     inc(y1,iy);\n     if e2<0 then inc(e2,e1) else begin\n      inc(e2,e3);\n      inc(x1,ix);\n     end;\n   end;\n  end;\n end;\n\nprocedure Triangle(x1,y1,x2,y2,x3,y3,color:integer);\n begin\n  fillchar(RightX,SizeOf(RightX),255); \/\/ default 65535\n  fillchar(LeftX,SizeOf(LeftX),0); \/\/ default 0\n  scan(x1,y1,x2,y2);\n  scan(x2,y2,x3,y3); \n  scan(x3,y3,x1,y1);\n  DrawTriangle(Color);\n end;\n[\/code]\n\n[tags]Delphi, Graphic[\/tags]\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lars Gollub a \u00e9crit dans l&#8217;article &lt;6up816$k8u36@forums.borland.com >&#8230; > >Can you use the fillpoly routine or something like that? > > Well, no.&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[11],"tags":[75,101],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p71Tml-27","_links":{"self":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/131"}],"collection":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/comments?post=131"}],"version-history":[{"count":0,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/131\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/media?parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/categories?post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/tags?post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}