chamesle

chamesle.org: the site of Chamesle, a small Linux distribution
git clone https://github.com/tortr-rs/chamesle
Log | Files | Refs | README

teal.py (1568B)


      1 #!/usr/bin/env python3
      2 # the default wallpaper from 0.8: one teal, the ring in the middle. like a computer just after
      3 # you installed it, around 2001. python3 artwork/teal.py
      4 import os, sys, importlib.util
      5 import gi
      6 gi.require_version('Rsvg', '2.0')
      7 from gi.repository import Rsvg
      8 import cairo
      9 from PIL import Image
     10 
     11 HERE = os.path.dirname(os.path.abspath(__file__))
     12 REPO = os.path.join(HERE, '..')
     13 spec = importlib.util.spec_from_file_location('m', os.path.join(HERE, 'logo', 'make.py'))
     14 m = importlib.util.module_from_spec(spec); spec.loader.exec_module(m)
     15 
     16 TEAL = (36, 96, 112)
     17 
     18 def wallpaper(w, h):
     19 	n = h * 8 // 27   # the ring is 640 tall on a 2160 screen
     20 	svg = m.svg('flat', n, 'w').replace('viewBox="-16 -16 544 560"', 'viewBox="0 0 512 512"')
     21 	s = cairo.ImageSurface(cairo.FORMAT_ARGB32, n, n)
     22 	v = Rsvg.Rectangle(); v.x = v.y = 0; v.width = v.height = n
     23 	Rsvg.Handle.new_from_data(svg.encode()).render_document(cairo.Context(s), v)
     24 	ring = Image.frombuffer('RGBA', (n, n), bytes(s.get_data()), 'raw', 'BGRa', 0, 1)
     25 	im = Image.new('RGB', (w, h), TEAL)
     26 	im.paste(ring, ((w - n) // 2, (h - n) // 2), ring)
     27 	return im
     28 
     29 big = wallpaper(3840, 2160)
     30 for p in ('tools/pkg/chamesle-artwork/files/usr/share/backgrounds/chamesle/teal.jpg',
     31 		'tools/pkg/chamesle-kde/files/usr/share/wallpapers/Chamesle/contents/images/3840x2160.jpg'):
     32 	big.save(os.path.join(REPO, p), quality=94)
     33 big.resize((400, 225), Image.LANCZOS).save(
     34 	os.path.join(REPO, 'tools/pkg/chamesle-kde/files/usr/share/wallpapers/Chamesle/contents/screenshot.jpg'), quality=90)
     35 print('wallpaper done')