From: David Vallner Date: 2006-01-16T02:21:18+09:00 Subject: Re: "Programming Ruby", ed. 2, P747. Script generated different image to book's example On Sun, 15 Jan 2006 18:02:20 +0100, Hidetoshi NAGAI wrote: > > [snip] > >> >> TkcLine.new(canvas, >> >> points[0],[0], points[0],[1], >> >> points[1],[0], points[1],[1], >> >> points[2],[0], points[2],[1], >> >> 'smooth' => 'on', >> >> 'width' => 7, >> >> 'fill' => col, >> >> 'capstyle' => 'round') > > On current Ruby/Tk, a canvas Item can accept an array or arrays > as its coords. > That is, all of the followings are valid. > ---------------------------------------------------------------- > (0) TkcLine.new(canvas, > points[0][0], points[0][1], > points[1][0], points[1][1], > points[2][0], points[2][1], > :smooth=>'on', :width =>7, :fill=>col, > :capstyle=>'round') > > (1) TkcLine.new(canvas, > points[0], points[1], points[2], > :smooth=>'on', :width =>7, :fill=>col, > :capstyle=>'round') > > (2) TkcLine.new(canvas, > points.flatten, > :smooth=>'on', :width =>7, :fill=>col, > :capstyle=>'round') > > (3) TkcLine.new(canvas, > points, > :smooth=>'on', :width =>7, :fill=>col, > :capstyle=>'round') > ---------------------------------------------------------------- The bug was passing in literal arrays with one element, 0, or 1, to TkcLine::new. Using the whole 2D array at once looks nifty, it would indeed prevent that typo / slip of mind. David Vallner