# ikony.ps1 - ikony appky e-digiroot Podpora (styl obrazkov balikov: tmave pozadie, svietiace tenke ciary) # Vystup: android\ikony\res\mipmap-*\*.png, android\ikony\play\ikona-512.png, play\grafika-1024x500.png # Skript je zamerne iba v ASCII. $ErrorActionPreference = 'Stop' Add-Type -AssemblyName System.Drawing $root = Split-Path $PSScriptRoot -Parent $out = Join-Path $root 'ikony' $font = Join-Path $root '..\server\eshop-podpora\archiv\nastroj-pismo-swiss721\swiss721th-ext.ttf' $bgA = [System.Drawing.Color]::FromArgb(255, 12, 22, 34) $bgB = [System.Drawing.Color]::FromArgb(255, 14, 52, 92) $neon = [System.Drawing.Color]::FromArgb(255, 196, 230, 255) function New-Bmp([int]$w, [int]$h) { $b = New-Object System.Drawing.Bitmap $w, $h, ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb) $g = [System.Drawing.Graphics]::FromImage($b) $g.SmoothingMode = 'AntiAlias'; $g.InterpolationMode = 'HighQualityBicubic'; $g.PixelOffsetMode = 'HighQuality'; $g.TextRenderingHint = 'AntiAliasGridFit' return @($b, $g) } function Fill-Bg($g, [int]$w, [int]$h) { $r = New-Object System.Drawing.Rectangle 0, 0, $w, $h $br = New-Object System.Drawing.Drawing2D.LinearGradientBrush $r, $bgA, $bgB, 60 $g.FillRectangle($br, $r); $br.Dispose() } function Rounded([float]$x, [float]$y, [float]$w, [float]$h, [float]$r) { $p = New-Object System.Drawing.Drawing2D.GraphicsPath $p.AddArc($x, $y, 2 * $r, 2 * $r, 180, 90); $p.AddArc($x + $w - 2 * $r, $y, 2 * $r, 2 * $r, 270, 90) $p.AddArc($x + $w - 2 * $r, $y + $h - 2 * $r, 2 * $r, 2 * $r, 0, 90); $p.AddArc($x, $y + $h - 2 * $r, 2 * $r, 2 * $r, 90, 90) $p.CloseFigure(); return $p } # Motive: monitor with a cursor and a small shield with a lock (like the package images), centred in a box of size s at (ox, oy) function Draw-Mark($g, [float]$ox, [float]$oy, [float]$s, $color, [bool]$glow) { $passes = if ($glow) { @(@(0.10, 60), @(0.06, 110), @(0.035, 255)) } else { @(@(0.045, 255)) } foreach ($pp in $passes) { $w = [float]($s * $pp[0]); $c = [System.Drawing.Color]::FromArgb([int]$pp[1], $color.R, $color.G, $color.B) $pen = New-Object System.Drawing.Pen $c, $w; $pen.LineJoin = 'Round'; $pen.StartCap = 'Round'; $pen.EndCap = 'Round' # monitor $m = Rounded ($ox + 0.10 * $s) ($oy + 0.18 * $s) (0.80 * $s) (0.52 * $s) (0.05 * $s) $g.DrawPath($pen, $m); $m.Dispose() $g.DrawLine($pen, $ox + 0.50 * $s, $oy + 0.70 * $s, $ox + 0.50 * $s, $oy + 0.80 * $s) $g.DrawLine($pen, $ox + 0.34 * $s, $oy + 0.82 * $s, $ox + 0.66 * $s, $oy + 0.82 * $s) # cursor arrow $pts = @( (New-Object System.Drawing.PointF ($ox + 0.40 * $s), ($oy + 0.30 * $s)), (New-Object System.Drawing.PointF ($ox + 0.40 * $s), ($oy + 0.58 * $s)), (New-Object System.Drawing.PointF ($ox + 0.47 * $s), ($oy + 0.51 * $s)), (New-Object System.Drawing.PointF ($ox + 0.52 * $s), ($oy + 0.61 * $s)), (New-Object System.Drawing.PointF ($ox + 0.56 * $s), ($oy + 0.59 * $s)), (New-Object System.Drawing.PointF ($ox + 0.51 * $s), ($oy + 0.49 * $s)), (New-Object System.Drawing.PointF ($ox + 0.60 * $s), ($oy + 0.48 * $s)) ) $g.DrawPolygon($pen, [System.Drawing.PointF[]]$pts) $pen.Dispose() } } function Save-Png($b, [string]$path) { New-Item -ItemType Directory -Force (Split-Path $path) | Out-Null $b.Save($path, [System.Drawing.Imaging.ImageFormat]::Png) } $dens = @{ 'mdpi' = 1.0; 'hdpi' = 1.5; 'xhdpi' = 2.0; 'xxhdpi' = 3.0; 'xxxhdpi' = 4.0 } foreach ($d in $dens.Keys) { $k = $dens[$d]; $dir = Join-Path $out "res\mipmap-$d" # legacy square + round (48 dp) $n = [int](48 * $k) foreach ($shape in 'sq', 'round') { $x = New-Bmp $n $n; $b = $x[0]; $g = $x[1]; $g.Clear([System.Drawing.Color]::Transparent) $clip = if ($shape -eq 'round') { $p = New-Object System.Drawing.Drawing2D.GraphicsPath; $p.AddEllipse(0, 0, $n - 1, $n - 1); $p } else { Rounded 0 0 ($n - 1) ($n - 1) ($n * 0.18) } $g.SetClip($clip); Fill-Bg $g $n $n; $g.ResetClip() Draw-Mark $g ($n * 0.12) ($n * 0.10) ($n * 0.76) $neon $true $name = if ($shape -eq 'round') { 'ic_launcher_round.png' } else { 'ic_launcher.png' } Save-Png $b (Join-Path $dir $name); $g.Dispose(); $b.Dispose() } # adaptive foreground (108 dp, safe zone 66 dp in the centre) $n = [int](108 * $k) $x = New-Bmp $n $n; $b = $x[0]; $g = $x[1]; $g.Clear([System.Drawing.Color]::Transparent) Draw-Mark $g ($n * 0.21) ($n * 0.19) ($n * 0.58) $neon $true Save-Png $b (Join-Path $dir 'ic_launcher_foreground.png'); $g.Dispose(); $b.Dispose() # notification icon (24 dp, white on transparent) $n = [int](24 * $k) $x = New-Bmp $n $n; $b = $x[0]; $g = $x[1]; $g.Clear([System.Drawing.Color]::Transparent) Draw-Mark $g 0 ($n * -0.02) $n ([System.Drawing.Color]::White) $false Save-Png $b (Join-Path $dir 'ic_stat_logo.png'); $g.Dispose(); $b.Dispose() } # Google Play: icon 512 and feature graphic 1024x500 $x = New-Bmp 512 512; $b = $x[0]; $g = $x[1]; Fill-Bg $g 512 512 Draw-Mark $g 60 50 392 $neon $true Save-Png $b (Join-Path $out 'play\ikona-512.png'); $g.Dispose(); $b.Dispose() $pfc = New-Object System.Drawing.Text.PrivateFontCollection; $pfc.AddFontFile((Resolve-Path $font).Path); $fam = $pfc.Families[0] $x = New-Bmp 1024 500; $b = $x[0]; $g = $x[1]; Fill-Bg $g 1024 500 Draw-Mark $g 60 90 320 $neon $true $f1 = New-Object System.Drawing.Font $fam, 64, ([System.Drawing.GraphicsUnit]::Pixel) $f2 = New-Object System.Drawing.Font $fam, 30, ([System.Drawing.GraphicsUnit]::Pixel) $white = New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::FromArgb(255, 242, 246, 248)) $grey = New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::FromArgb(255, 170, 190, 205)) $g.DrawString('e-digiroot.net', $f1, $white, 420, 170) $g.DrawString(([string]'Podpora na dia' + [char]0x13E + 'ku'), $f2, $grey, 426, 260) Save-Png $b (Join-Path $out 'play\grafika-1024x500.png'); $g.Dispose(); $b.Dispose() 'ikony hotove: ' + $out