Skip to content

Instantly share code, notes, and snippets.

@nst
Last active January 19, 2025 20:27
Show Gist options
  • Save nst/02c87cff127c76ffa3b3584b993a6cc2 to your computer and use it in GitHub Desktop.
Save nst/02c87cff127c76ffa3b3584b993a6cc2 to your computer and use it in GitHub Desktop.
Amstrad CPC Color Palette in PostScript, take 2
%!PS
%%Title: cpc2.ps
%%Creator: Nicolas Seriot
% January 2025
% Amstrad CPC Color Palette
% https://www.cpcwiki.eu/index.php/CPC_Palette
% https://seriot.ch/projects/drawing_with_computers.html
% https://bsky.app/profile/nst021.bsky.social/post/3leytevn6ck25
/S 32 def
/_m_DrawSide {
gsave
concat
0 0 S S rectfill
0 setgray
0 0 S S rectstroke
grestore
} def
/DrawSingleCube {
[ 1 0.5 -1 0.5 0 0 ] _m_DrawSide % top
[ 1 0.5 0 -1 0 0 ] _m_DrawSide % right
[ -1 0.5 0 -1 0 0 ] _m_DrawSide % left
} def
/_from_to_DrawMultiCube {
/to exch def
/from exch def
to from sub /n exch def
gsave
from 0 eq { [-1 0 0 1 0 0] concat } if % flip left-right
from 1 to { /x exch def
from 1 to { /y exch def
from 1 to { /z exch def
x to eq y to eq or z to eq or {
gsave
x neg y add S mul
x neg 2 div y neg 2 div add z add S mul
translate
x n div abs
y n div abs
z n div abs
setrgbcolor
DrawSingleCube
grestore
} if
} for
} for
} for
grestore
} def
200 200 translate
gsave
-2 0 _from_to_DrawMultiCube
240 0 translate
0 2 _from_to_DrawMultiCube
grestore
120 -100 translate
0.5 0.5 0.5 setrgbcolor
DrawSingleCube
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment