X-Received: by 10.157.45.200 with SMTP id g66mr10290921otb.84.1477330224923; Mon, 24 Oct 2016 10:30:24 -0700 (PDT) X-Received: by 10.36.238.131 with SMTP id b125mr106829iti.3.1477330224868; Mon, 24 Oct 2016 10:30:24 -0700 (PDT) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!g45no2240401qte.1!news-out.google.com!w25ni31797qtc.0!nntp.google.com!g45no2240398qte.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.sys.apple2.programmer Date: Mon, 24 Oct 2016 10:30:24 -0700 (PDT) In-Reply-To: <067e080a-f706-41a8-a3aa-414b82375a2d@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=67.168.182.173; posting-account=9Dd-GgoAAAAjVgCPcBurQ6c4EXW6Wi8v NNTP-Posting-Host: 67.168.182.173 References: <78d160d0-2aef-49e5-a6b4-5af5aacc2db5@googlegroups.com> <3162a740-1ea8-4835-8afa-be8322709228@googlegroups.com> <067e080a-f706-41a8-a3aa-414b82375a2d@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <5ea5f29f-a456-4165-afe6-ddfc8d3dcafe@googlegroups.com> Subject: Re: hi-res graphics animation, dynamically generated shape tables From: Michael Pohoreski Injection-Date: Mon, 24 Oct 2016 17:30:24 +0000 Content-Type: text/plain; charset=UTF-8 Xref: csiph.com comp.sys.apple2.programmer:3156 On Monday, October 24, 2016 at 9:01:44 AM UTC-7, Michael Pohoreski wrote: Part 3b -- Supplement > Our **integer** line drawing function ends up like: > > function line2( x0, y0, x1, y1, color ) > { > var x, y = y0; > var dx = x1 - x0; > var dy = y1 - y0; > var s = 2*dy - dx; > > for( x = x0; x <= x1; ++x ) > { > putpixel( x, y, color ); > > if (s > 0) > { > s -= dx; > y++; > } > s += dy; > } > } Update: In order to preserve symmetry, the compare should be: >= instead of > if (s >= 0) Check out linei() and linej() in line.js