Similar to groove/ridge case, inset/outset would scale the color to

decorate the border. Scale fails when the color is black (i.e. zero),
thus this patch will fix this issue by using a fixed color.
This commit is contained in:
Adenilson Cavalcanti 2014-12-18 12:01:05 -08:00
parent a80d88897d
commit 4bfe134c84

View file

@ -642,11 +642,22 @@ impl<'a> PaintContext<'a> {
};
// original bounds as a Rect<f32>
let original_bounds = self.get_scaled_bounds(bounds, border, 0.0);
// select and scale the color appropriately.
let scaled_color = match direction {
Direction::Top | Direction::Left => self.scale_color(color, if is_inset { 2.0/3.0 } else { 1.0 }),
Direction::Right | Direction::Bottom => self.scale_color(color, if is_inset { 1.0 } else { 2.0/3.0 })
};
let mut scaled_color;
// You can't scale black color (i.e. 'scaled = 0 * scale', equals black).
if color.r != 0.0 || color.g != 0.0 || color.b != 0.0 {
scaled_color = match direction {
Direction::Top | Direction::Left => self.scale_color(color, if is_inset { 2.0/3.0 } else { 1.0 }),
Direction::Right | Direction::Bottom => self.scale_color(color, if is_inset { 1.0 } else { 2.0/3.0 })
};
} else {
scaled_color = match direction {
Direction::Top | Direction::Left => if is_inset { Color::new(0.3, 0.3, 0.3, color.a) } else { Color::new(0.7, 0.7, 0.7, color.a) },
Direction::Right | Direction::Bottom => if is_inset { Color::new(0.7, 0.7, 0.7, color.a) } else { Color::new(0.3, 0.3, 0.3, color.a) }
};
}
self.draw_border_path(&original_bounds, direction, border, radius, scaled_color);
}