from PIL import Image, ImageDraw, ImageFilter, ImageChops import math S=2048 # supersampled def lerp(a,b,t): return tuple(int(a[i]+(b[i]-a[i])*t) for i in range(len(a))) def vgrad(w,h,top,bot): g=Image.new('RGBA',(w,h)) d=ImageDraw.Draw(g) for y in range(h): d.line([(0,y),(w,y)],fill=lerp(top,bot,y/(h-1))) return g def squircle_mask(size, box, n=5.0): m=Image.new('L',(size,size),0); d=ImageDraw.Draw(m) x0,y0,x1,y1=box; cx=(x0+x1)/2; cy=(y0+y1)/2; a=(x1-x0)/2; b=(y1-y0)/2 pts=[] for i in range(720): t=2*math.pi*i/720; c=math.cos(t); s=math.sin(t) pts.append((cx+a*math.copysign(abs(c)**(2/n),c), cy+b*math.copysign(abs(s)**(2/n),s))) d.polygon(pts,fill=255); return m def rrect_mask(size,box,r): m=Image.new('L',size,0); ImageDraw.Draw(m).rounded_rectangle(box,radius=r,fill=255); return m img=Image.new('RGBA',(S,S),(0,0,0,0)) pad=int(S*0.098); box=(pad,pad,S-pad,S-pad) # drop shadow of body sh=Image.new('RGBA',(S,S),(0,0,0,0)); shm=squircle_mask(S,(box[0],box[1]+30,box[2],box[3]+30)) sh.putalpha(shm.point(lambda v:int(v*0.45))); sh=sh.filter(ImageFilter.GaussianBlur(40)); img=Image.alpha_composite(img,sh) # body: deep graphite → midnight blue body=vgrad(S,S,(52,58,72,255),(16,19,28,255)); bm=squircle_mask(S,box) layer=Image.new('RGBA',(S,S),(0,0,0,0)); layer.paste(body,(0,0),bm); img=Image.alpha_composite(img,layer) # light table panel (glowing) pw,ph=int(S*0.60),int(S*0.46); px=(S-pw)//2; py=int(S*0.30) glow=Image.new('RGBA',(S,S),(0,0,0,0)); gd=ImageDraw.Draw(glow) gd.rounded_rectangle((px-60,py-60,px+pw+60,py+ph+60),radius=120,fill=(255,214,140,170)) glow=glow.filter(ImageFilter.GaussianBlur(90)); glow.putalpha(ImageChops.multiply(glow.getchannel('A'),bm)) img=Image.alpha_composite(img,glow) panel=vgrad(pw,ph,(255,250,236,255),(255,226,170,255)) pm=rrect_mask((pw,ph),(0,0,pw-1,ph-1),70) img.paste(panel,(px,py),pm) # subtle grid lines on the light table grid=Image.new('RGBA',(S,S),(0,0,0,0)); gdd=ImageDraw.Draw(grid) for i in range(1,6): x=px+pw*i//6; gdd.line([(x,py+20),(x,py+ph-20)],fill=(210,160,90,60),width=4) for j in range(1,4): y=py+ph*j//4; gdd.line([(px+20,y),(px+pw-20,y)],fill=(210,160,90,60),width=4) img=Image.alpha_composite(img,grid) def slide(cx,cy,w,angle,photo): s=Image.new('RGBA',(w,w),(0,0,0,0)); d=ImageDraw.Draw(s) d.rounded_rectangle((0,0,w-1,w-1),radius=int(w*0.09),fill=(250,250,246,255)) iw,ih=int(w*0.66),int(w*0.46); ix=(w-iw)//2; iy=int(w*0.20) ph=photo(iw,ih); s.paste(ph,(ix,iy),rrect_mask((iw,ih),(0,0,iw-1,ih-1),10)) # label strip d.rounded_rectangle((ix,iy+ih+int(w*0.07),ix+int(iw*0.55),iy+ih+int(w*0.11)),radius=8,fill=(200,200,195,255)) s=s.rotate(angle,resample=Image.BICUBIC,expand=True) shadow=Image.new('RGBA',s.size,(0,0,0,0)); shadow.putalpha(s.getchannel('A').point(lambda v:int(v*0.35))) shadow=shadow.filter(ImageFilter.GaussianBlur(22)) return s,shadow def photo_stadium(w,h): p=vgrad(w,h,(24,70,140,255),(255,150,70,255)); d=ImageDraw.Draw(p) d.rectangle((0,int(h*0.68),w,h),fill=(28,120,70,255)) # pitch for k in range(5): d.line([(int(w*k/4),int(h*0.68)),(int(w*(k/4-0.1)),h)],fill=(40,140,85,255),width=5) d.ellipse((int(w*0.62),int(h*0.15),int(w*0.80),int(h*0.15)+int(w*0.18)),fill=(255,236,190,255)) # floodlight/sun return p def photo_mountain(w,h): p=vgrad(w,h,(120,170,220,255),(230,235,240,255)); d=ImageDraw.Draw(p) d.polygon([(0,h),(int(w*0.35),int(h*0.35)),(int(w*0.6),int(h*0.75)),(int(w*0.78),int(h*0.45)),(w,h)],fill=(52,70,95,255)) return p for (cx,cy,w,ang,ph) in [(int(S*0.40),int(S*0.53),int(S*0.30),8,photo_mountain),(int(S*0.60),int(S*0.52),int(S*0.33),-6,photo_stadium)]: s,shadow=slide(cx,cy,w,ang,ph) ox,oy=cx-s.size[0]//2,cy-s.size[1]//2 img.alpha_composite(shadow,(ox+14,oy+26)); img.alpha_composite(s,(ox,oy)) # loupe L=Image.new('RGBA',(S,S),(0,0,0,0)); ld=ImageDraw.Draw(L) lcx,lcy,lr=int(S*0.64),int(S*0.62),int(S*0.105) ld.line([(lcx+int(lr*0.72),lcy+int(lr*0.72)),(lcx+int(lr*1.32),lcy+int(lr*1.32))],fill=(30,32,40,255),width=int(S*0.045)) ld.ellipse((lcx-lr,lcy-lr,lcx+lr,lcy+lr),outline=(30,32,40,255),width=int(S*0.028)) ld.ellipse((lcx-lr+30,lcy-lr+30,lcx+lr-30,lcy+lr-30),fill=(200,225,255,70)) ld.arc((lcx-lr+70,lcy-lr+70,lcx+lr-70,lcy+lr-70),200,250,fill=(255,255,255,200),width=18) lsh=Image.new('RGBA',(S,S),(0,0,0,0)); lsh.putalpha(L.getchannel('A').point(lambda v:int(v*0.4))); lsh=lsh.filter(ImageFilter.GaussianBlur(20)) img.alpha_composite(lsh,(10,22)); img=Image.alpha_composite(img,L) # PM-style tag check (accent) bottom-left of panel T=Image.new('RGBA',(S,S),(0,0,0,0)); td=ImageDraw.Draw(T) tx,ty,ts=int(S*0.235),int(S*0.645),int(S*0.12) td.rounded_rectangle((tx,ty,tx+ts,ty+ts),radius=int(ts*0.22),fill=(232,64,52,255)) td.line([(tx+ts*0.24,ty+ts*0.53),(tx+ts*0.43,ty+ts*0.72),(tx+ts*0.78,ty+ts*0.30)],fill=(255,255,255,255),width=int(ts*0.13),joint='curve') tsh=Image.new('RGBA',(S,S),(0,0,0,0)); tsh.putalpha(T.getchannel('A').point(lambda v:int(v*0.35))); tsh=tsh.filter(ImageFilter.GaussianBlur(16)) img.alpha_composite(tsh,(8,18)); img=Image.alpha_composite(img,T) # soft top sheen shm2=Image.new('L',(S,S),0); ImageDraw.Draw(shm2).ellipse((-S*0.3,-S*0.75,S*1.3,S*0.42),fill=70) shm2=ImageChops.multiply(shm2.filter(ImageFilter.GaussianBlur(120)),squircle_mask(S,box)) sl=Image.new('RGBA',(S,S),(255,255,255,0)); sl.putalpha(shm2); img=Image.alpha_composite(img,sl) out=img.resize((1024,1024),Image.LANCZOS) out.save('/home/user/Lichtkasten/Resources/Icon/AppIcon-1024.png') out.save('/home/user/Lichtkasten/Resources/AppIcon.icns', sizes=[(16,16),(32,32),(64,64),(128,128),(256,256),(512,512),(1024,1024)]) out.resize((256,256),Image.LANCZOS).save('/home/user/Lichtkasten/Resources/Icon/AppIcon-256.png') print('ok')