lib/nakal/base_screen.rb in nakal-0.0.7 vs lib/nakal/base_screen.rb in nakal-0.1.0
- old
+ new
@@ -25,12 +25,26 @@
@image.crop(x_start, y_start, width_to_consider, height_to_consider)
end
end
def compare screen
- diff_img, diff_metric = self.strip.compare_channel(screen.strip, Magick::RootMeanSquaredErrorMetric)
+ diff_img, diff_metric = self.apply_mask.strip.compare_channel(screen.apply_mask.strip, Magick::RootMeanSquaredErrorMetric)
diff_screen = Nakal.current_platform::Screen.new("#{@name}_diff", :none, diff_img)
return diff_screen, diff_metric
+ end
+
+ def apply_mask
+ image_mask_params = Nakal.default_crop_params[Nakal.device_name][image_relative_path.gsub("_current", "")]
+ return self if image_mask_params.nil?
+ image_mask_params.each do |region, params|
+ gc = Magick::Draw.new.fill('black').rectangle(*params)
+ gc.draw @image
+ end
+ self
+ end
+
+ def image_relative_path
+ Nakal.image_relative_dir.eql?(".") ? @name : "#{Nakal.image_relative_dir}/#{@name}"
end
def delete!
FileUtils.rm "#{Nakal.image_location}/#{@name}.png"
end