@@ -949,17 +949,24 @@ impl GraphicElementRendered for RasterDataTable<CPU> {
949
949
950
950
if render_params. to_canvas ( ) {
951
951
let id = generate_uuid ( ) ;
952
+ let scale = DVec2 :: new ( transform. x_axis . x , transform. y_axis . y ) ;
952
953
render. image_data . push ( ( id, image. data ( ) . clone ( ) , TransformImage ( transform) ) ) ;
954
+ log:: debug!( "{transform} {} {}" , image. width, image. height) ;
953
955
render. parent_tag (
954
956
"foreignObject" ,
955
957
|attributes| {
956
- attributes . push ( " width" , "1" ) ;
957
- attributes . push ( "height" , "1" ) ;
958
-
959
- let matrix = format_transform_matrix ( transform ) ;
958
+ let size = DVec2 :: new ( image . width as f64 , image . height as f64 ) ;
959
+ let scale = scale / size ;
960
+ let scale = DAffine2 :: from_scale ( scale ) ;
961
+ let matrix = format_transform_matrix ( scale ) ;
960
962
if !matrix. is_empty ( ) {
961
963
attributes. push ( "transform" , matrix) ;
964
+ attributes. push ( "transform-origin" , "top-left" ) ;
962
965
}
966
+ attributes. push ( "width" , transform. matrix2 . x_axis . x . to_string ( ) ) ;
967
+ attributes. push ( "height" , transform. matrix2 . y_axis . y . to_string ( ) ) ;
968
+ attributes. push ( "x" , transform. translation . x . to_string ( ) ) ;
969
+ attributes. push ( "y" , transform. translation . y . to_string ( ) ) ;
963
970
964
971
let factor = if render_params. for_mask { 1. } else { instance. alpha_blending . fill } ;
965
972
let opacity = instance. alpha_blending . opacity * factor;
@@ -973,7 +980,6 @@ impl GraphicElementRendered for RasterDataTable<CPU> {
973
980
|render| {
974
981
render. leaf_tag ( "div" , |attributes| {
975
982
attributes. push ( "data-canvas-placeholder" , format ! ( "canvas{}" , id) ) ;
976
- attributes. push ( "style" , "width: 100%; height: 100%;" . to_string ( ) ) ;
977
983
} )
978
984
} ,
979
985
) ;
0 commit comments