Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Converting Text File To Rectangles Date: Mon, 11 Feb 2013 21:02:47 -0500 Organization: A noiseless patient Spider Lines: 31 Message-ID: References: <7f49c487-f016-43a3-83a4-feebe072f76c@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 12 Feb 2013 02:02:13 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="0d73d8cc209bff1c6395088b400d0605"; logging-data="28065"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18O4O8iAnwWoAOIWH1nR4Qp" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 In-Reply-To: <7f49c487-f016-43a3-83a4-feebe072f76c@googlegroups.com> Cancel-Lock: sha1:gzsQBLJEEWppW8OaIOdXC8g4PjE= Xref: csiph.com comp.lang.java.programmer:22279 On 2/11/2013 8:51 PM, Scyth3 wrote: > I have a save and load method for certain rectangles I need for a game. Say the user wants to save a map. The outputted map would look like this: > > > 50 250 50 50 > 50 350 50 50 > 50 400 50 50 > 50 500 50 50 > 150 300 50 50 > 200 450 50 50 > 200 500 50 50 > 250 150 50 50 > 300 100 50 50 > 400 50 50 50 > 450 150 50 50 > 550 100 50 50 > > X Y Width Height > > Now, how would I read this, and turn it into a rectangle? Turning it into twelve rectangles would be easy, but I don't know how you'd turn it into one. Perhaps you could keep track of the minimum X,Y and the maximum implied X,Y and form one rectangle that surrounds the entire thing. That rectangle might not be the minimal surrounding rectangle, but it would be minimal among those whose sides were parallel to the axes. -- Eric Sosman esosman@comcast-dot-net.invalid