That sounds like the Discworld iconograph.
An iconograph is a wonderful device that allows you to make "instantaneous paintings". In fact, an imp with brushes, pencils and a good eye for colours is put in a box, and when you push the button, you open a little window on the box and the imp draws really fast what it sees through the opening. Salamanders are used when more light is necessary for the imp to paint a good picture. All but the cheapest of today's iconographs can paint in colour.
Imps have no imagination whatsoever, and as a result, paint very accurate pictures. They do whatever they are told so long as it is within the limits of their training, such as being able to "zoom" in and paint in very small detail, or even to paint the picture of a cart and its number if it exceeds the speed limit.
....
Theoretically the lifespan of the imp is endless, but the imps of the cheaper iconographs seem to disappear rather quickly. Independently of this, the painting colours used by the imp have to be refilled as they are used up, and the imps themselves require regular feeding, though they seem to be able to survive without any form of sustenance for several weeks.
The most likely quote is from The Color of Magic, following this passage.
A prolonged session at the Whore Pits produced a number of colourful and instructive pictures, a number of which Rincewind concealed about his person for detailed perusal in private. As the fumes cleared from his brain he began to speculate seriously as to how the iconograph worked.
....
The box said, "It's no good. I've run out of pink."
A hitherto unnoticed door opened in front of his eyes. A small, green and hideously warty humanoid figure leaned out, pointed at a colour-encrusted palette in one clawed hand, and screamed at him.
"No pink, See?" screeched the homunculus. "No good you going on pressing the lever when there's no pink, is there? If you wanted pink you shouldn't of took all those pictures of young ladies, should you? It's monochrome from now on, friend. Alright?"
"Alright. Yeah, Sure," said Rincewind. In one dim corner of the little box he thought he could see an easel, and a tiny unmade bed. He hoped he couldn't. "So long as that's understood," said the imp, and shut the door. Rincewind thought he could hear the muffled sound of grumbling and the scrape of a stool being dragged across the floor.
As noted in the comments, The Light Fantastic has another scene involving colors running out. No sunsets are mentioned, and black is indicated to be what the imp is running low on.
'This red star thing.'
'Right. It's very important that you —'
'Hallo? Hallo? Anyone out there?'
It was a small and squeaky voice and came from the picture box still slung around Twoflower's inert neck.
The picture imp opened his hatch and squinted up at Rincewind.
'Where's this, squire?' it said.
'I'm not sure.'
'We still dead?'
'Maybe.'
'Well, let's hope we go somewhere where we don't need too much black, because I've run out.' The hatch slammed shut.