Painting By Code
Galleries: Constellations
Home About Galleries Development Contact Shop
Home About Galleries Development Contact Shop

Images of starry skies and constellations created by "Painting By Code" Version 3

Random Stars

Having previously created images of starry skies using completely random stars (like these) I wondered if there was a source of astronomical star data which I could use to create a starry sky showing actual stars and constellations?

HYG Database

I came across the HYG database compiled by David Nash. This contains information about approximately 120,000 stars, including all of those visible to the naked eye from earth. Among other things, the database gives the position of each star in the sky and a value for its apparent magnitude. After spending a bit of time getting my head around the celestial coordinate system and working out how to map it onto my image plane, I can now focus on an area of the sky, select the magnitude of stars I want, and display them using a circle which varies according to the star's magnitude. The database also contains a colour index for each star which allows me to colour the circles (admittedly based on a slightly sketchy understanding of what the colour index actually represents). These are the stars in the region of the Big Dipper (part of Ursa Major).

Selecting Magnitude

I can add more stars by selecting a wider range of magnitudes. This is the area around the constellation of Orion, initially just showing magnitude 1 stars (the brightest) but progressively adding more stars up to magnitude 20 (the dimmest). Dimmer stars have higher magnitude numbers than brighter stars, and anything with a magnitude greater than about 6 is not normally visible to the naked eye.

Selecting Magnitude - caption
Constellation Lines

I hadn't planned on showing constellation lines, but found that in the initial stages adding them helped me to see whether I was displaying the stars in the expected positions. I then realised I could vary the way stars and constellation lines were drawn to create different effects.


There are 88 constellations officially recognised by the International Astronomical Union.

I haven't (yet...) found a data source which defines how these should be drawn, so have had to manually examine each one to work out which stars in the HYG database to draw lines between to map them out!

Here are the 12 which make up the zodiac:

Zodiac - caption
Landscapes Again

The whole point of this was to add real stars to a landscape, so here's one.

Comparing this image with the ones at the top of the page (which contain completely random stars) it's far from obvious that this one is any less random, and that it does in fact contain an astronomically accurate sky, but at least I know it's the case!

Adding constellation lines makes it a bit more obvious that we're looking at Leo and Virgo, with Hydra stretched out along the bottom:

Milky Way

This does show how the distribution of stars is not random though. Here's a portion of the milky way between Crux and Canis Major. Initially just showing the brightest stars then gradually bringing in dimmer and dimmer stars.

More Constellations

More constellations in a landscape...

Pegasus, Orion, Canis Major with Gemini, Hydra with Crater, Ursa Major with Ursa Minor, Scorpio, Pisces, Cancer, Taurus, Sagittarius, Leo (with and without constellation lines)


I wanted something more going on in the landscape with these constellation images, so I've taken Pegasus and added some horses

Pegasus (H.A.Rey)

In his book "The Stars, A New Way to See Them" H.A. Rey redrew the constellations in a way that he thought more closely resembled what they were meant to depict. I like his Pegasus, although it does maybe seem a little insect-like here...


And here's the constellation Cygnus with some swans

© 2023