javascript - SVG side by side - rotate 90 all of them -
i have 2 svg (horizontal view):
<svg id="svgc1" height="52.215796" width="257.597148" xmlns="http://www.w3.org/2000/svg"> <polyline points="0,6.326886 178.017424,6.326886 178.017424,45.888910 0,45.888910" fill="green"></polyline> <polyline points="178.017424,7.892542 257.597148,7.892542 257.597148,44.323254 178.017424,44.323254" fill="blue"></polyline> </svg> <svg id="svgc2" height="52.215796" width="257.597148" xmlns="http://www.w3.org/2000/svg"> <polyline points="0,6.326886 178.017424,6.326886 178.017424,45.888910 0,45.888910" fill="blue"></polyline> <polyline points="178.017424,7.892542 257.597148,7.892542 257.597148,44.323254 178.017424,44.323254" fill="green"></polyline> </svg>
i have tried group polylines , apply transform rotate 90, "losing" images since main svg wide , narrow.
what easiest way rotate them 90 degrees , place them side side (vertical view)?
you want rotate each picture around point near left end, become vertical @ left side of new object. since svgs have height of 252.125, chose roation point of approx 26.17.
the simplest way add group element surrounding polylines , add transform that.
<g transform="rotate(90,26.17,26.17)"> <polyline points="0,6.326886 178.017424,6.326886 178.017424,45.888910 0,45.888910" fill="green"></polyline> <polyline points="178.017424,7.892542 257.597148,7.892542 257.597148,44.323254 178.017424,44.323254" fill="blue"></polyline> </g>
then turn svgs "landscape" "portrait" switching width , height on each.
<svg id="svgc1" width="52.215796" height="257.597148" xmlns="http://www.w3.org/2000/svg"> <g transform="rotate(90,26.17,26.17)"> <polyline points="0,6.326886 178.017424,6.326886 178.017424,45.888910 0,45.888910" fill="green"></polyline> <polyline points="178.017424,7.892542 257.597148,7.892542 257.597148,44.323254 178.017424,44.323254" fill="blue"></polyline> </g> </svg>
https://jsfiddle.net/y85s290r/5/
to rotate anti-clockwise, rotate -90 degrees instead. leave object sitting off top of svg, need move down. use translate()
transform after rotate.
<g transform="translate(0,257.6) rotate(-90)">
note: translate occurs first in list because transform operations applied right left.
Comments
Post a Comment