"""A310, CRT, wood blocks and feline visit assets, drawn in the room's palette."""
from PIL import Image,ImageDraw
import runpy

def media_assets(Art,root):
 font=runpy.run_path(str(root/'ExtraArt'))['pixeltext'];assets=[];groups={}
 def group(name,ims):
  groups[name]=len(assets)
  for i,im in enumerate(ims):assets.append((name+str(i),im))
 a=Art(123,163)
 # Domestic oak table, with enough depth for the A310's detached keyboard.
 a.poly([(4,83),(112,83),(122,116),(0,116)],'#936142')
 a.rect((0,116,122,123),'#754c37',1)
 a.poly([(6,123),(13,123),(10,160),(3,160)],'#4c4d51')
 a.poly([(109,123),(116,123),(120,160),(113,160)],'#4c4d51')
 a.line([(2,117),(120,117)],'#b6875a',1)
 # Reference A310: the badge/drive fascia stands proud of the case. Its
 # sloping lower bevel folds back into a recessed dark plinth, not a slab.
 a.poly([(12,63),(94,63),(103,70),(103,82),(96,86),(10,86),(10,72)],'#aaa994')
 a.poly([(12,63),(94,63),(103,70),(4,70)],'#e1dcc6')
 a.poly([(4,70),(103,70),(105,72),(3,72)],'#f0ead3')
 a.poly([(3,72),(105,72),(105,81),(3,81)],'#cfccb5')
 a.poly([(105,72),(105,81),(101,86),(101,75)],'#a9aa93')
 a.poly([(3,81),(105,81),(101,86),(8,86)],'#b4b59d')
 a.poly([(8,86),(101,86),(98,88),(10,88)],'#6e7567')
 a.line([(4,72),(103,72)],'#f1ecd6',.8)
 a.line([(4,81),(103,81)],'#dcd8bd',.7)
 a.rect((9,75,23,79),'#246b70',.3)
 # Tiny gold Acorn emblem and wordmark on its teal badge (not a red stripe).
 a.ellipse((10,75.4,12.5,77.5),'#bfc78b');a.line([(11.2,77),(11.2,78.4)],'#bfc78b',.6)
 for x,h in [(14,1.2),(15.7,1.8),(17.3,1.3),(19,1.8),(20.7,1.5)]:
  a.line([(x,78),(x,78-h)],'#bfc78b',.55)
 a.rect((27,75,29.5,79),'#737d65',.4);a.rect((28,76,29,77.5),'#b7db75')
 # Separate dark 3.5-inch floppy opening, status lamp and lower-right eject.
 a.rect((69,75,96,82),'#a5a58e',.4);a.rect((71,76,94,78.4),'#383d37',.4)
 a.rect((72,76.4,93,77.3),'#212b29');a.rect((90,80,95,81.4),'#e0ddc7',.3)
 a.rect((71,80,72,81),'#69a746')
 for x in range(9,99,2):a.line([(x,82),(x+.8,84.5)],'#8e9580',.5)
 # Cream RGB monitor, thick bevel, lower control-panel seams and right power.
 # Keep screen (25,8)-(83,45) unchanged: the live !Maestro raster fits inside it.
 a.poly([(21,0),(94,0),(97,5),(97,56),(91,60),(20,60)],'#aaaD9c')
 a.rect((18,1,91,58),'#dedcc5',2)
 a.poly([(22,5),(87,5),(84,9),(25,9)],'#b5b6a1')
 a.poly([(22,5),(25,9),(25,44),(22,48)],'#a6aa98')
 a.poly([(22,48),(25,44),(84,44),(87,48)],'#f1ecd6')
 a.poly([(87,5),(87,48),(84,44),(84,9)],'#ece7cf')
 a.rect((24,7,84,46),'#48534a',1);a.rect((25,8,83,45),'#273932',.5)
 a.line([(20,49),(89,49)],'#c0c2ab',.5)
 a.rect((21,52,33,55),'#397066',.3)
 a.ellipse((22,52.4,24,54),'#d1ce9d');a.line([(23,53),(23,54.8)],'#d1ce9d',.5)
 for x in range(26,32):a.line([(x,53),(x,54.3)],'#d1ce9d',.4)
 a.line([(37,50),(37,57)],'#babda6',.5);a.line([(58,50),(58,57)],'#babda6',.5)
 a.line([(61,54),(78,54)],'#919c89',.5)
 a.rect((84,51,88,56),'#7e8673',.4);a.rect((85,52,87,55),'#d8d7bf',.3)
 a.rect((81,52,82,53),'#9ec650')
 a.rect((42,58,67,64),'#a5aa96',1)
 a.poly([(37,63),(73,63),(78,68),(32,68)],'#c7c7ae')
 a.line([(33,68),(78,68)],'#969b86',.7)
 # Detached cream wedge keyboard: RED Esc/function keys, main typing area,
 # separate cursor cluster and numeric keypad; a long cream spacebar below.
 a.poly([(9,88),(103,88),(110,110),(3,110)],'#e2dcc5')
 a.poly([(3,110),(110,110),(109,114),(4,114)],'#aaa891')
 a.poly([(10,89),(101,89),(105,108),(7,108)],'#a5a793')
 for x in [12,20,24,28,32,39,43,47,51,58,62,66,70]:
  a.rect((x,90,x+2.8,93),'#c33f31',.3);a.line([(x+.5,90.5),(x+2,90.5)],'#f07759',.4)
 # Individual rows, staggered just like the physical keyboard.
 for row,(y,offset,count) in enumerate([(95,0,15),(99,1,14),(103,2,13)]):
  for k in range(count):
   x=10+offset+k*4.1
   a.rect((x,y,x+3.3,y+2.8),'#e9e4ce',.3)
   a.line([(x+.8,y+.7),(x+1.8,y+.7)],'#89917e',.4)
 a.rect((10,107,20,109),'#dedbc3',.3);a.rect((23,107,58,109),'#eee7d0',.3)
 a.rect((61,107,70,109),'#dedbc3',.3)
 for x,y in [(75,96),(79,96),(75,100),(79,100),(77,104),(73,108),(77,108),(81,108)]:
  a.rect((x,y,x+2.8,y+2.4),'#e5e0c8',.3)
 for row in range(5):
  for col in range(4):
   x=86+col*4;y=91+row*3.6
   a.rect((x,y,x+2.9,y+2.7),'#e6dfc8',.3)
 a.rect((86,109,93,111),'#e6dfc8',.3)
 # Corded Acorn three-button mouse to the keyboard's right.
 a.line([(116,100),(120,92),(116,87)],'#696f60',.8)
 a.rect((110.5,99.5,121.5,115),'#989d88',3)
 a.rect((111,100,121,113.5),'#e5dfc7',2)
 # Three separate long caps and TWO deep grooves survive native 8bpp
 # quantisation and enlargement. The cross-seam separates the palm rest.
 a.rect((111,101,121,108),'#737d65',.6)
 for x in (111.5,115,118.5):
  a.rect((x,101,x+2,107),'#eee7d0',.5)
 a.line([(112,109),(120,109)],'#b4b59d',.7)
 group('desk',[a.image()])
 # The legacy group name is retained; singing glyphs are now clear orange.
 for name,col in [('goldfont','#ff8b32'),('inkfont','#293d43')]:
  ims=[]
  for n in range(32,96):
   im=Image.new('RGBA',(6,8));font(im,chr(n),0,0,col=col);ims.append(im)
  group(name,ims)
 # Individual number blocks; the Christmas Day greeting also uses these.
 ims=[]
 for n in range(32,96):
  a=Art(7,11);a.rect((1,1,6,10),'#56321e',1);a.rect((0,0,6,9),'#f5dcb1',1);a.line([(1,1),(5,1)],'#fff0cf',.7);im=a.image();font(im,chr(n),1,2,col='#241409');ims.append(im.resize((10,14),Image.Resampling.LANCZOS))
 group('woodfont',ims)
 cats=[]
 for frame in range(8):
  a=Art(62,80);paw=frame%4*3
  a.ellipse((11,31,44,72),'#b57d53');a.ellipse((19,32,43,67),'#c89462');a.arc((0,48,33,77),70,330,'#906047',5)
  a.ellipse((18,66,34,76),'#c49b71');a.ellipse((33,67,50,75),'#c49b71')
  for j in range(3):a.arc((18,37+j*7,39,44+j*7),20,160,'#956347',1.6)
  a.ellipse((27,11,53,36),'#c69162');a.poly([(28,22),(29,3),(38,15)],'#a97856');a.poly([(43,15),(50,4),(53,25)],'#a97856');a.poly([(31,15),(31,8),(35,16)],'#dcafa0');a.poly([(46,16),(49,9),(50,19)],'#dcafa0')
  a.ellipse((38,20,43,25),'#d9d181');a.ellipse((47,20,51,25),'#d9d181');a.line([(41,21),(41,24)],'#293a32');a.line([(50,21),(50,24)],'#293a32');a.poly([(46,27),(51,27),(49,30)],'#95615b')
  a.line([(35,42),(48,32-paw),(57,29-paw)],'#c89a6d',6);a.line([(29,45),(46,44+paw),(57,39+paw)],'#ba8459',5)
  for y in [28-paw,38+paw]:
   for dx in [0,2,4]:a.line([(55+dx,y),(58+dx,y-2)],'#e0ccaa',.6)
  cats.append(a.image())
 group('scratchcat',cats)
 # One continuous wooden plaque for the words, separate from the day digits.
 text='DAYS UNTIL CHRISTMAS!';w=len(text)*6+5
 a=Art(w,11);a.rect((1,1,w-1,10),'#56321e',1)
 a.rect((0,0,w-2,9),'#f5dcb1',1)
 a.line([(1,1),(w-3,1)],'#fff0cf',.7)
 im=a.image();font(im,text,3,2,col='#241409')
 group('woodsign',[im.resize((162,14),Image.Resampling.LANCZOS)])
 # A small landscape handheld rests on the chair's left arm.
 a=Art(24,28)
 a.poly([(3,2),(23,7),(21,24),(0,19)],'#26333b')
 a.poly([(3,0),(23,5),(21,22),(0,17)],'#c6c4b1')
 a.poly([(8,4),(18,6),(17,15),(7,13)],'#364948')
 a.poly([(9,5),(17,7),(16,13),(8,12)],'#789a72')
 a.line([(10,7),(15,8),(14,11),(11,10)],'#c9dab0',.7)
 a.line([(3,7),(3,12)],'#303b41',1.8);a.line([(1,9),(5,10)],'#303b41',1.8)
 a.ellipse((19,10,21,12),'#ae414b');a.ellipse((18,14,20,16),'#ae414b')
 a.line([(8,16),(11,17)],'#727b72',.8);a.line([(12,17),(15,18)],'#727b72',.8)
 group('console',[a.image()])
 return assets,groups
