Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixes issue #1 - render_tiled_image #3

Merged
merged 1 commit into from

2 participants

@alown

Given the lack of fixing after lilalinux opened an issue (and even told you how to), I decided to do it myself - since I wanted to use graster with my own CNC.

Here is lilalinux's changes in a patch.

@jedediah jedediah merged commit 45ab0bd into jedediah:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 19, 2011
  1. @alown
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 13 deletions.
  1. +13 −13 lib/graster.rb
View
26 lib/graster.rb
@@ -5,14 +5,14 @@
require 'RMagick'
class Graster
-
+
autoload :Runner, File.join(File.dirname(__FILE__), 'graster', 'runner')
autoload :Image, File.join(File.dirname(__FILE__), 'graster', 'image')
autoload :GcodeFile, File.join(File.dirname(__FILE__), 'graster', 'gcode_file')
autoload :GmaskFile, File.join(File.dirname(__FILE__), 'graster', 'gmask_file')
-
+
ROOT2 = Math.sqrt(2)
-
+
OPTIONS = {
:dpi => [[Float],"X,Y","Dots per inch of your device"],
:on_range => [[Float],
@@ -197,20 +197,20 @@ def render_tiled_image gcode, gmask
@config[:repeat][1].times do |ytile|
debug "begin tile row #{ytile}"
ypix = 0
- (0...@tiled_rows).each do |spans|
- debug "pixel row #{ypix} is empty" if spans.empty?
- unless spans.empty?
+ (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 = spans[0][0] < spans[-1][1]
+ forward = @tiled_rows[spans][0][0] < spans[-1][1]
dir = forward ? 1 : -1
- debug "pixel row #{ypix} at #{yinches} inches going #{forward ? 'forward' : 'backward'} with #{spans.size} spans"
+ debug "pixel row #{ypix} at #{yinches} inches going #{forward ? 'forward' : 'backward'} with #{@tiled_rows[spans].size} spans"
- gcode.g0 :x => spans[0][0] - dir*@config[:overshoot], :y => yinches
- gcode.g1 :x => spans[-1][1] + dir*@config[:overshoot], :y => yinches
+ 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
- spans.each {|span| gmask.span forward, span[0]+hyst, span[1]+hyst }
- end # unless spans.empty?
+ @tiled_rows[spans].each {|span| gmask.span forward, span[0]+hyst, span[1]+hyst }
+ end # unless @tiled_rows[spans].empty?
ypix += 1
end # @image.each_row
debug "end tile row #{ytile}"
@@ -300,7 +300,7 @@ def debug msg
def initialize opts={}
self.config = DEFAULTS.dup
-
+
if opts[:config_file]
self.merge_config load_config_file opts[:config_file]
elsif opts[:default_config_file] && c = try_load_default_config_file
Something went wrong with that request. Please try again.