Skip to content

Commit

Permalink
change scale border to one unit on each side
Browse files Browse the repository at this point in the history
  • Loading branch information
unlobito committed Jun 28, 2015
1 parent a39ba10 commit e1f71c6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/card_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ static void draw_barcode_matrix(CardLayer *card_layer, GContext* ctx) {
const int16_t MID_HEIGHT = (PEBBLE_HEIGHT - NAME_LAYER_HEIGHT - PAGER_LAYER_HEIGHT) / 2 + NAME_LAYER_HEIGHT;

// Non-linear barcodes are scaled to save persistent storage space. Dynamically calculate
// the maximum integer scaling factor, keep a white border of 2 units around.
// the maximum integer scaling factor, keep a white border of 1 units around.

const int16_t SCALING_FACTOR_X = PEBBLE_WIDTH / (card_layer->barcode_width + 2 + 2);
const int16_t SCALING_FACTOR_Y = MAX_HEIGHT / (card_layer->barcode_height + 2 + 2);
const int16_t SCALING_FACTOR_X = PEBBLE_WIDTH / (card_layer->barcode_width + 2);
const int16_t SCALING_FACTOR_Y = MAX_HEIGHT / (card_layer->barcode_height + 2);

// actual scaling factor is the least of x and y scaling, but at least 1
const int16_t SCALING_FACTOR = MAX( MIN(SCALING_FACTOR_X, SCALING_FACTOR_Y), 1);
Expand Down Expand Up @@ -126,8 +126,8 @@ static void draw_barcode_linear(CardLayer *card_layer, GContext* ctx) {

int16_t img_pixels = card_layer->barcode_width;

// Try to do an integer scale if possible, keep white border of 2 units on each side
const int16_t SCALING_FACTOR_X = PEBBLE_WIDTH / (card_layer->barcode_width + 2 + 2);
// Try to do an integer scale if possible, keep white border of 1 unit on each side
const int16_t SCALING_FACTOR_X = PEBBLE_WIDTH / (card_layer->barcode_width + 2);
const int16_t SCALING_FACTOR = MAX( SCALING_FACTOR_X, 1);

// The comparison part of this loop adds 7 to the barcode width to allow C
Expand Down

0 comments on commit e1f71c6

Please sign in to comment.