Created
May 12, 2023 06:26
-
-
Save ScriptRaccoon/d1ac04021c360b433c5ee9d1a1cc4566 to your computer and use it in GitHub Desktop.
SVG with flipped coordinate system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>SVG with flipped coordinate system</title> | |
| <style> | |
| body { | |
| font-family: Arial, Helvetica, sans-serif; | |
| display: flex; | |
| align-items: center; | |
| flex-direction: column; | |
| background-color: rgb(201, 227, 246); | |
| } | |
| h1 { | |
| text-align: center; | |
| } | |
| svg { | |
| box-shadow: 0rem 0rem 1rem #0003; | |
| background-color: white; | |
| width: min(40rem, 90vw); | |
| border-radius: 0.25rem; | |
| } | |
| /* FLIP TEXT BACK */ | |
| svg text { | |
| transform: scale(1, -1); | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>SVG with flipped coordinate system</h1> | |
| <!-- THE TRANSFORM BELOW FLIPS THE COORDINATE SYSTEM --> | |
| <svg viewBox="-1 -1 12 12" transform="translate(0,12) scale(1,-1)"> | |
| <circle cx="2" cy="2" r="0.1"></circle> | |
| <circle cx="4" cy="6" r="0.1"></circle> | |
| <circle cx="7" cy="3" r="0.1"></circle> | |
| <!-- NEED TO TRANSFORM THE TEXT GROUPS, NOT USE x,y on TEXT --> | |
| <g transform="translate(4.2,6)" font-size="0.025rem"> | |
| <text>(4,6)</text> | |
| </g> | |
| <g transform="translate(2.2,2)" font-size="0.025rem"> | |
| <text>(2,2)</text> | |
| </g> | |
| <g transform="translate(7.2,3)" font-size="0.025rem"> | |
| <text>(5,3)</text> | |
| </g> | |
| <line | |
| x1="0" | |
| y1="0" | |
| x2="10" | |
| y2="0" | |
| stroke="gray" | |
| stroke-width="0.05" | |
| ></line> | |
| <line | |
| x1="0" | |
| y1="0" | |
| x2="0" | |
| y2="10" | |
| stroke="gray" | |
| stroke-width="0.05" | |
| ></line> | |
| </svg> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment