Skip to content

Commit

Permalink
Fix last_pos shifting and add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
alranel committed Jan 27, 2013
1 parent ad48fdc commit ddaeaa7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Expand Up @@ -59,6 +59,7 @@ t/collinear.t
t/custom_gcode.t
t/dynamic.t
t/fill.t
t/gcode.t
t/geometry.t
t/layers.t
t/loops.t
Expand Down
1 change: 1 addition & 0 deletions lib/Slic3r/GCode.pm
Expand Up @@ -62,6 +62,7 @@ sub set_shift {
my $self = shift;
my @shift = @_;

# if shift increases (goes towards right), last_pos decreases because it goes towards left
$self->last_pos->translate(
scale ($self->shift_x - $shift[X]),
scale ($self->shift_y - $shift[Y]),
Expand Down
20 changes: 20 additions & 0 deletions t/gcode.t
@@ -0,0 +1,20 @@
use Test::More tests => 1;
use strict;
use warnings;

BEGIN {
use FindBin;
use lib "$FindBin::Bin/../lib";
}

use Slic3r;
use Slic3r::Geometry qw(scale);

{
local $Slic3r::Config = Slic3r::Config->new_from_defaults;
my $gcodegen = Slic3r::GCode->new(layer_count => 1);
$gcodegen->set_shift(10, 10);
is_deeply $gcodegen->last_pos, [scale -10, scale -10], 'last_pos is shifted correctly';
}

__END__

0 comments on commit ddaeaa7

Please sign in to comment.