Skip to content

Commit

Permalink
fix web platform white lines
Browse files Browse the repository at this point in the history
  • Loading branch information
jjyr committed Aug 29, 2024
1 parent a73f87e commit 3ce95f6
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/platform/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ impl Platform for WebPlatform {
}
self.buf
.translate(
(dx as f64 * self.device_pixel_ratio).floor(),
(dy as f64 * self.device_pixel_ratio).floor(),
((dx as f64).round() * self.device_pixel_ratio).ceil(),
((dy as f64).round() * self.device_pixel_ratio).ceil(),
)
.unwrap();
self.buf
Expand All @@ -195,13 +195,13 @@ impl Platform for WebPlatform {
)
.unwrap();

let dw = (size.x as f64 * self.device_pixel_ratio).floor();
let dh = (size.y as f64 * self.device_pixel_ratio).floor();
let dw = ((size.x as f64).round() * self.device_pixel_ratio).ceil();
let dh = ((size.y as f64).round() * self.device_pixel_ratio).ceil();

// rotate by center with angle degree in counter clock-wise
if let Some(angle) = angle {
let dw_hf = (dw * 0.5).floor();
let dh_hf = (dh * 0.5).floor();
let dw_hf = (dw * 0.5).round();
let dh_hf = (dh * 0.5).round();
// move to center
self.buf.translate(dw_hf, dh_hf).unwrap();
// rotate counter clockwise
Expand All @@ -211,10 +211,10 @@ impl Platform for WebPlatform {
self.buf
.draw_image_with_html_canvas_element_and_sw_and_sh_and_dx_and_dy_and_dw_and_dh(
&canvas,
uv_offset.x.floor().into(),
uv_offset.y.floor().into(),
uv_size.x.floor().into(),
uv_size.y.floor().into(),
uv_offset.x.round().into(),
uv_offset.y.round().into(),
uv_size.x.round().into(),
uv_size.y.round().into(),
0.0,
0.0,
dw,
Expand Down

0 comments on commit 3ce95f6

Please sign in to comment.