File:Amstrad CPC inks by number.png

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(4,500 × 2,000 pixels, file size: 350 KB, MIME type: image/png)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
English: The Amstrad CPC palette by ink number order
Date
Source Own work
Author Morn
Other versions
Sorted by hue and value/saturation
PNG development
InfoField
 
This PNG graphic was created with Python.
Source code
InfoField

Python code

Source code
# Show Amstrad CPC palette and INK numbers and names

from PIL import Image, ImageDraw, ImageFont

SIZE = 500
BORDER = 20

fnt = ImageFont.truetype('/usr/share/fonts/TTF/Courier Prime.ttf', SIZE//3)
fnt2 = ImageFont.truetype('/usr/share/fonts/TTF/Courier Prime.ttf', SIZE//10)
fnt3 = ImageFont.truetype('/usr/share/fonts/TTF/IBMPlexSans-SemiBold.ttf', SIZE//1.7)
out = Image.new("RGB", (9 * SIZE, 4 * SIZE))
d = ImageDraw.Draw(out)

# colour names from Chapter 1, page 48 of the CPC6128 user manual:
names = (
"Black",
"Blue",
"Bright Blue",
"Red",
"Magenta",
"Mauve",
"Bright Red",
"Purple",
"Bright Magenta",
"Green",
"Cyan",
"Sky Blue",
"Yellow",
"White",
"Pastel Blue",
"Orange",
"Pink",
"Pastel Magenta",
"Bright Green",
"Sea Green",
"Bright Cyan",
"Lime Green",
"Pastel Green",
"Pastel Cyan",
"Bright Yellow",
"Pastel Yellow",
"Bright White",
)

num2c = ("0", "h", "f")

def getcol(j, i):
    "Convert color text to tuple"
    c = ["", "", ""]
    c[1] = num2c[j]
    c[2] = num2c[i % 3]
    c[0] = num2c[i // 3]
    o = []
    for x in c:
        if x == "h":
            o.append(128)
        elif x == "f":
            o.append(255)
        else:
            o.append(0)

    # based on pseudocode at https://www.grimware.org/doku.php/documentations/devices/gatearray
    ink = 0
    if c[0] == "f": ink += 6
    if c[0] == "h": ink += 3
    if c[1] == "f": ink += 18
    if c[1] == "h": ink += 9
    if c[2] == "f": ink += 2
    if c[2] == "h": ink += 1
    return tuple(o), ink

for j in range(3):
    for i in range(9):
        c, ink = getcol(j, i)
        p1 = i * SIZE + BORDER, (j + 1) * SIZE + BORDER
        p2 = (i + 1) * SIZE - BORDER, (j + 2) * SIZE - BORDER
        p3 = p1[0], p1[1] + SIZE//3
        d.rectangle((p1, p2), fill = c)
        d.text(p1, "%u" % ink, font = fnt, fill = (0, 0, 0), align = "left", valign = "top", stroke_width = 15)
        d.text(p1, "%u" % ink, font = fnt, fill = (255, 255, 255), align = "left", valign = "top")
        d.text(p3, names[ink], font = fnt2, fill = (0, 0, 0), align = "left", valign = "top", stroke_width = 6)
        d.text(p3, names[ink], font = fnt2, fill = (255, 255, 255), align = "left", valign = "top")

d.text((1.6 * SIZE, SIZE//6), "Amstrad CPC palette", font = fnt3, fill = (255, 255, 255))

out.save("Amstrad_CPC_inks_by_number.png")

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current19:48, 23 December 2023Thumbnail for version as of 19:48, 23 December 20234,500 × 2,000 (350 KB)Morn (talk | contribs)Uploaded own work with UploadWizard

The following page uses this file: