3 ms·
My Union Jack (in SVG) is coded to reflect the union of England, Scotland and Northern Ireland. I live in Scotland where it is commonly known that the English f
by Theodores 20d ago
My Union Jack (in SVG) is coded to reflect the union of England, Scotland and Northern Ireland. I live in Scotland where it is commonly known that the English flag is plastered over the Scottish Saltire, and they don't even get the same colour blue in each.
There are different aspect ratios too, plus there is the 'jack'. I don't care for AI but I do like SVG to be human readable to some extent, although I do like oklch colours, which are not something I consider 'human readable'.
Here I have the Scottish flag, the English one, a 'GB' flag which slaps one on top of the other with those Irish extras, to make a UK 'Jack' that waves badly because SVG filters are not something I am good at.
Excuse the SVG code:
<defs id="flags">
<symbol id="england" fill="white" clip-path="url(#flag-clip-two-by-one)">
<title>England</title>
<use href="#bounding-square"/>
<g id="st-george-cross" stroke="oklch(0.5472 0.242 22.16)" stroke-width="12">
<g id="england-flag-cross" transform="translate(60 60)">
<line id="england-flag-line" x1="-60" x2="60"/>
<use href="#england-flag-line" transform="rotate(90)"/>
</g>
</g>
</symbol>
<symbol id="gb" clip-path="url(#flag-clip-two-by-one)">
<title>United Kingdom</title>
<use fill="oklch(0.2873 0.139 259.18)" href="#saltire"/>
<g id="st-patrick-lhs" stroke-linecap="square">
<line id="st-patrick-red-line" x2="60" y1="32" y2="62" stroke="oklch(0.5472 0.242 22.16)"
stroke-width="4"/>
<use href="#st-patrick-red-line" transform="translate(0 124) scale(1 -1)"/>
</g>
<use href="#st-patrick-lhs" transform="translate(120 -4) scale(-1 1)"/>
<use stroke="white" stroke-width="20" href="#england-flag-cross"/>
<use href="#st-george-cross"/>
</symbol>
<symbol id="scotland">
<title>Scotland</title>
<g fill="oklch(0.5079 0.1766 247.88)" clip-path="url(#flag-clip-two-by-one)">
<g id="saltire">
<use href="#bounding-square"/>
<g transform="translate(60 60)">
<line id="saltire-white" x1="-60" x2="60" y1="-30" y2="30" stroke="white"
stroke-width="12"/>
<use href="#saltire-white" transform="scale(-1 1)"/>
</g>
</g>
</g>
</symbol>
<symbol id="union-jack">
<title>Union Jack</title>
<defs>
<filter id="flag-wave">
<feTurbulence type="fractalNoise" baseFrequency="0.0025" numOctaves="3"
result="flag-wave-fractal-noise" seed="42">
<animate attributeName="baseFrequency" values="0.0025;0.01;0.002;0.005;0.004;0.0025"
dur="12s" repeatCount="indefinite"/>
</feTurbulence>
<feDisplacementMap xChannelSelector="R" yChannelSelector="B" in="SourceGraphic"
in2="flag-wave-fractal-noise" result="flag-wave-fractal-source" scale="50"/>
<feGaussianBlur in="flag-wave-fractal-source" stdDeviation="0.4"/>
<feMorphology operator="dilate" radius="0.5"/>
</filter>
<radialGradient id="radial-glow">
<stop offset="0%" stop-color="white"/>
<stop offset="100%" stop-color="grey"/>
</radialGradient>
<linearGradient id="flagpole-gradient">
<stop offset="0%" stop-color="grey"/>
<stop offset="55%" stop-color="white"/>
<stop offset="90%" stop-color="darkgrey"/>
</linearGradient>
</defs>
<g transform="rotate(10)translate(25,10)">
<use href="#gb" transform="translate(7, -10)scale(0.75)" filter="url(#flag-wave)"/>
<circle r="3.5" fill="url(#radial-glow)" stroke="none"/>
<rect y="2.5" x="-2.5" width="5" height="120" stroke="none" fill="url(#flagpole-gradient)"/>
</g>
</symbol>
</defs>
- Theodores 20d agoHere is the Union Jack from the article. Concise and surprisingly human readable (I could draw this with felt tip pens on graph paper). One problem though. The Union Jack is not symmetrical. This is tantamount to spelling someone's name incorrectly, and could be taken the wrong way, much like how some Americans would be offended if there weren't all the stars or stripes depicted. <g xmlns="http://www.w3.org/2000/svg" clip-path="url(#cxr741hpqpxhvpg0uu2qvnr_0)"> <rect x="0" y="0" width="1" height="0.5" fill="#012169"/> <line x1="0" y1="0.5" x2="1" y2="0" stroke="#fff" stroke-width="0.09"/> <line x1="0" y1="0" x2="1" y2="0.5" stroke="#fff" stroke-width="0.09"/> <line x1="0" y1="0.5" x2="1" y2="0" stroke="#c8102e" stroke-width="0.0375"/> <line x1="0" y1="0" x2="1" y2="0.5" stroke="#c8102e" stroke-width="0.0375"/> <rect x="0" y="0.2" width="1" height="0.1" fill="#fff"/> <rect x="0.45" y="0" width="0.1" height="0.5" fill="#fff"/> <rect x="0" y="0.22" width="1" height="0.06" fill="#c8102e"/> <rect x="0.47" y="0" width="0.06" height="0.5" fill="#c8102e"/> </g> There are some optimisations to be made, if concision rather than human readable is the ultimate goal. For example, x1="0" y1="0" is not needed, the use of a 1 x 1 viewBox means not using integers, even a 2 x 1 viewBox remedies that. For 'human readable', if something is mirrored, the code should reflect that, with 'use' and transform 'scale(-1, 1)'. More groups could be used to contain elements that share the same colour or stroke. In my 'hand coded' GB flag the weird offset-symmetry of the Northern Ireland 'red diagonals' is explained in SVG. I am not that keen on CSS in SVG, however, for colours, I could be using CSS variables.