```------art_76106_2167914.1181508161243
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hello,

Here is my solution to the quiz. Looking at the pattern for a moment, each
line of the pattern is really just the previous line, shifted over one
pixel. Thus to draw the pattern we can first calculate what all of the
pixels will be. Then we simply iterate over this list, drawing one line at a
time. With that in mind, here is the code I used to create the gradient:

pattern  ]

for i in 0...(width)
(width-i).times { pattern.push(colors[0]) }
(i+1).times { pattern.push(colors[1]) }
end

for i in 0...(width)
(i+1).times { pattern.push(colors[2]) }
(width-i-1).times { pattern.push(colors[1]) }
end

pattern
end

And this function creates solid bands of color:

def create_solid(colors, width)
pattern  ]
for color in colors
width.times { pattern.push(color) }
end
pattern
end

To draw ASCII we simply print each line in turn.

def draw_ascii(pattern, width)
for i in 0...(pattern.size-width+1)
puts pattern.slice(i, width).join
end
end

And to draw a JPEG we get a bit fancier, but its the same basic idea. There
must be a better way to code this, because it takes much too long to run.
But anyway, here it is:

require 'RMagick'
include Magick

def draw(filename, pattern, width, height)
canvas  agick::ImageList.new
canvas.new_image(width, height, Magick::HatchFill.new('white', 'white'))
pts  agick::Draw.new

for y in 0... height
line  attern.slice(y, width)

x
for color in line
pts.fill(color)
pts.point(x, y)
x   + 1
end
end

pts.draw(canvas)
canvas.write(filename)
end

Finally, we draw the ASCII from the Quiz and a picture similar to the one
that was posted.

# 1) Draw the ASCII representation

# 2) Draw a picture of the blanket
mex_flag  reate_solid(['rgb(0, 64, 0)', 'white', 'red'], 5)
border  reate_solid(['rgb(0, 64, 0)'], 25)

pattern  attern + mex_flag
pattern  attern + border
pattern  attern + create_gradient(['black', 'red', 'orange'])
pattern  attern + border
pattern  attern + mex_flag.reverse
pattern  attern + create_gradient(['red', 'purple', 'black'], 8)
draw("mexican_blanket.jpg", pattern, 100, 200)

Here is a picture of the final blanket, if anyone is interested: