@@ -949,17 +949,24 @@ impl GraphicElementRendered for RasterDataTable<CPU> {
949949
950950 if render_params. to_canvas ( ) {
951951 let id = generate_uuid ( ) ;
952+ let scale = DVec2 :: new ( transform. x_axis . x , transform. y_axis . y ) ;
952953 render. image_data . push ( ( id, image. data ( ) . clone ( ) , TransformImage ( transform) ) ) ;
954+ log:: debug!( "{transform} {} {}" , image. width, image. height) ;
953955 render. parent_tag (
954956 "foreignObject" ,
955957 |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 ) ;
960962 if !matrix. is_empty ( ) {
961963 attributes. push ( "transform" , matrix) ;
964+ attributes. push ( "transform-origin" , "top-left" ) ;
962965 }
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 ( ) ) ;
963970
964971 let factor = if render_params. for_mask { 1. } else { instance. alpha_blending . fill } ;
965972 let opacity = instance. alpha_blending . opacity * factor;
@@ -973,7 +980,6 @@ impl GraphicElementRendered for RasterDataTable<CPU> {
973980 |render| {
974981 render. leaf_tag ( "div" , |attributes| {
975982 attributes. push ( "data-canvas-placeholder" , format ! ( "canvas{}" , id) ) ;
976- attributes. push ( "style" , "width: 100%; height: 100%;" . to_string ( ) ) ;
977983 } )
978984 } ,
979985 ) ;
0 commit comments