Skip to content


Subversion checkout URL

You can clone with
Download ZIP


render_tiled_image is broken #1

lilalinux opened this Issue · 1 comment

2 participants


The iterator is wrong, you can't do (0...@tiled_rows) because @tiled_rows is an array. You should iterate over the indexes of @tiled_rows.
spans then is the current index.

(Maybe there is a smarter way to iterate over an array, but actually I don't know anything about ruby)

1) (0...@tiled_rows.size).each do |spans|
2) replace all occurences of spans by @tiled_rows[spans]

like this:

# render a complete tiled image to gcode and gmask streams
def render_tiled_image gcode, gmask
debug "rendering tiled image"
job_id = job_hash
hyst = -@scale[0]/2
gcode.comment "raster gcode for job #{job_id}"
gcode.comment "image: #{@image.filename} #{@image.size.inspect}"
gcode.comment "config: #{@config.inspect}"

gcode.preamble :feed => @config[:feed], :mask => true

@config[:repeat][1].times do |ytile|
  debug "begin tile row #{ytile}"
  ypix = 0
  (0...@tiled_rows.size).each do |spans|
    debug "pixel row #{ypix} is empty" if @tiled_rows[spans].empty?
    unless @tiled_rows[spans].empty?
      yinches = y_inches(ytile, ypix)
      forward = @tiled_rows[spans][0][0] < @tiled_rows[spans][-1][1]
      dir = forward ? 1 : -1

      debug "pixel row #{ypix} at #{yinches} inches going #{forward ? 'forward' : 'backward'} with #{@tiled_rows[spans].size} spans"

      gcode.g0 :x => @tiled_rows[spans][0][0] - dir*@config[:overshoot], :y => yinches
      gcode.g1 :x => @tiled_rows[spans][-1][1] + dir*@config[:overshoot], :y => yinches
      gmask.begin_row forward
      @tiled_rows[spans].each {|span| gmask.span forward, span[0]+hyst, span[1]+hyst }
    end # unless spans.empty?
    ypix += 1
  end # @image.each_row
  debug "end tile row #{ytile}"
end # @config[:repeat][i].times


end # def render_tiled_image

@alown alown referenced this issue from a commit in alown/graster
@alown alown Fixes issue #1: render_tiled_image failure c13d686

I have put this into a patch, and sent as a pull request to jebediah.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.