A casino or betting site needs pictures: dice, cards, a roulette wheel, a slot machine. The usual sources are stock images, which look like every other site, and screenshots of games, which show someone else’s brand. This guide shows a third way that partners.rs uses: graphics drawn as SVG from the site’s own colours. The libraries in the examples are ours, published on npm.
Why SVG made by code
An SVG is a text file with shapes. A library that draws one from a few settings gives you a picture that is sharp at any size, weighs a few kilobytes and needs no image hosting. Drawn when the site is built, it lands in the page as markup, so the page needs no script to show it.
Two settings matter most. A seed fixes the shape: the same seed gives the same throw of dice or the same spread of cards on every build. A brand colour sets the palette. Changing the colour never moves the shapes, so a redesign does not reshuffle your pictures.
From one colour to a palette
You give the library one to three colours of your brand. It derives the rest: lighter and darker shades, an accent, the colour of lines and text. When a shade would be too faint against the background, our libraries change its lightness until it is legible and keep its hue. Some roles keep their classic colours on purpose: card stock stays paper white, ink stays ink, and the reels of a slot machine keep their classic look.
Light and dark themes
A site with a dark theme needs pictures that work on both backgrounds. There are two ways.
CSS variables. Each colour role in the SVG can be a CSS variable of your site with a fallback colour. When the visitor switches the theme, the picture follows with no script. This suits pictures with flat colours.
Two renders. The library draws the picture twice, with the light and the dark palette, and CSS hides the one that does not match the theme. partners.rs does this for its charts, such as the freshness map on the home page, because the chart library fits each fill to the surface it sits on.
One picture should not follow the theme: the QR code. Many phone readers cannot scan light modules on a dark field. On partners.rs the QR modules take the text colour, but the field around them stays white in both themes.
On partners.rs
- Dice in the footer come from dice-lite. The pair is drawn at build time, so it shows with scripts off. Colours are pinned (a white die, dark pips) so the pair reads on both themes. A click throws again; the library loads only on that first click.
- QR codes come from qr-svg: one rectangle and one path, a few hundred bytes compressed, nothing that a strict content security policy would block.
Three more libraries draw casino scenes the same way: cards-lite (spreads and poker or blackjack hands), roulette-lite (a wheel seen from above or at an angle) and slots-lite (a slot machine with classic or generated symbols).
Things to check
- Motion. The dice, card, roulette and slot libraries can add a CSS animation: a roll, a spin. It is written as a style block inside the SVG, which a strict content security policy blocks. On such a site keep the pictures still.
- Accessibility. A decorative picture should be hidden from screen readers. The dice, card, roulette and slot libraries do that when no title is given; if the picture carries meaning, give it a title. A QR code has no title of its own, so put the label on the element around it.
- Versions. The same seed gives the same picture only within one version of a library. Pin the exact version, so an update does not change pictures you have already published.
All these libraries are also listed on the Tools page.