Center the SVG in the 2D demo
@@ -759,7 +759,8 @@ impl Camera {
fn new_2d(view_box: RectF32, drawable_size: Point2DI32) -> Camera {
let scale = i32::min(drawable_size.x(), drawable_size.y()) as f32 *
scale_factor_for_view_box(view_box);
- Camera::TwoD(Transform2DF32::from_scale(&Point2DF32::splat(scale)))
+ let origin = drawable_size.to_f32().scale(0.5) - view_box.size().scale(scale * 0.5);
+ Camera::TwoD(Transform2DF32::from_scale(&Point2DF32::splat(scale)).post_translate(origin))
}
fn new_3d(view_box: RectF32) -> Camera {
