TA/web_JMW/docs/render-flowchart-user-seder...

100 lines
4.7 KiB
PowerShell

Add-Type -AssemblyName System.Drawing
$output = Join-Path $PSScriptRoot 'flowchart-user-sederhana.jpg'
$width = 1400
$height = 1700
$bitmap = New-Object System.Drawing.Bitmap $width, $height
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
$graphics.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias
$graphics.TextRenderingHint = [System.Drawing.Text.TextRenderingHint]::ClearTypeGridFit
$graphics.Clear([System.Drawing.Color]::White)
$titleFont = New-Object System.Drawing.Font('Segoe UI', 28, [System.Drawing.FontStyle]::Bold)
$boxFont = New-Object System.Drawing.Font('Segoe UI', 17, [System.Drawing.FontStyle]::Regular)
$smallFont = New-Object System.Drawing.Font('Segoe UI', 13, [System.Drawing.FontStyle]::Regular)
$textBrush = New-Object System.Drawing.SolidBrush([System.Drawing.Color]::FromArgb(25, 33, 45))
$linePen = New-Object System.Drawing.Pen([System.Drawing.Color]::FromArgb(55, 65, 81), 3)
$arrowPen = New-Object System.Drawing.Pen([System.Drawing.Color]::FromArgb(55, 65, 81), 3)
$arrowPen.CustomEndCap = New-Object System.Drawing.Drawing2D.AdjustableArrowCap(7, 7)
$boxBrush = New-Object System.Drawing.SolidBrush([System.Drawing.Color]::FromArgb(232, 246, 239))
$systemBrush = New-Object System.Drawing.SolidBrush([System.Drawing.Color]::FromArgb(232, 240, 255))
$decisionBrush = New-Object System.Drawing.SolidBrush([System.Drawing.Color]::FromArgb(250, 250, 252))
$endBrush = New-Object System.Drawing.SolidBrush([System.Drawing.Color]::FromArgb(255, 243, 226))
$format = New-Object System.Drawing.StringFormat
$format.Alignment = [System.Drawing.StringAlignment]::Center
$format.LineAlignment = [System.Drawing.StringAlignment]::Center
function Draw-Box {
param([int] $X, [int] $Y, [int] $W, [int] $H, [string] $Text, [System.Drawing.Brush] $Brush)
$rect = [System.Drawing.Rectangle]::new($X, $Y, $W, $H)
$graphics.FillRectangle($Brush, $rect)
$graphics.DrawRectangle($linePen, $rect)
$textRect = [System.Drawing.RectangleF]::new(($X + 14), ($Y + 8), ($W - 28), ($H - 16))
$graphics.DrawString($Text, $boxFont, $textBrush, $textRect, $format)
}
function Draw-Decision {
param([int] $X, [int] $Y, [int] $W, [int] $H, [string] $Text)
$points = @(
[System.Drawing.Point]::new($X + [int]($W / 2), $Y),
[System.Drawing.Point]::new($X + $W, $Y + [int]($H / 2)),
[System.Drawing.Point]::new($X + [int]($W / 2), $Y + $H),
[System.Drawing.Point]::new($X, $Y + [int]($H / 2))
)
$graphics.FillPolygon($decisionBrush, $points)
$graphics.DrawPolygon($linePen, $points)
$textRect = [System.Drawing.RectangleF]::new(($X + 35), ($Y + 18), ($W - 70), ($H - 36))
$graphics.DrawString($Text, $boxFont, $textBrush, $textRect, $format)
}
function Draw-Arrow {
param([int] $X1, [int] $Y1, [int] $X2, [int] $Y2, [string] $Label = '')
$graphics.DrawLine($arrowPen, $X1, $Y1, $X2, $Y2)
if ($Label) {
$midX = [int](($X1 + $X2) / 2)
$midY = [int](($Y1 + $Y2) / 2)
$labelRect = [System.Drawing.RectangleF]::new(($midX - 65), ($midY - 19), 130, 34)
$graphics.FillRectangle([System.Drawing.Brushes]::White, $labelRect)
$graphics.DrawString($Label, $smallFont, $textBrush, $labelRect, $format)
}
}
$graphics.DrawString('Flowchart Sistem User', $titleFont, $textBrush, [System.Drawing.RectangleF]::new(0, 35, $width, 65), $format)
Draw-Box 525 130 350 70 'Mulai' $systemBrush
Draw-Box 525 250 350 85 'User membuka website' $boxBrush
Draw-Decision 500 390 400 120 'Sudah login?'
Draw-Box 120 570 330 85 'Login / Register' $boxBrush
Draw-Box 525 570 350 85 'Lihat katalog mobil' $boxBrush
Draw-Box 525 710 350 85 'Cari rekomendasi / lihat detail' $boxBrush
Draw-Decision 500 850 400 120 'Ingin membeli mobil?'
Draw-Box 970 870 330 85 'Hubungi admin / selesai' $endBrush
Draw-Box 525 1030 350 85 'Buat transaksi pending' $systemBrush
Draw-Box 525 1170 350 85 'Upload bukti pembayaran' $boxBrush
Draw-Decision 500 1310 400 120 'Bukti valid dan tepat waktu?'
Draw-Box 120 1490 330 85 'Transaksi dibatalkan' $endBrush
Draw-Box 525 1490 350 85 'Menunggu konfirmasi admin' $systemBrush
Draw-Box 525 1605 350 60 'Selesai' $systemBrush
Draw-Arrow 700 200 700 250
Draw-Arrow 700 335 700 390
Draw-Arrow 500 450 450 612 'belum'
Draw-Arrow 700 510 700 570 'ya'
Draw-Arrow 450 612 525 612
Draw-Arrow 700 655 700 710
Draw-Arrow 700 795 700 850
Draw-Arrow 900 910 970 912 'tidak'
Draw-Arrow 700 970 700 1030 'ya'
Draw-Arrow 700 1115 700 1170
Draw-Arrow 700 1255 700 1310
Draw-Arrow 500 1370 450 1532 'tidak'
Draw-Arrow 700 1430 700 1490 'ya'
Draw-Arrow 700 1575 700 1605
$bitmap.Save($output, [System.Drawing.Imaging.ImageFormat]::Jpeg)
$graphics.Dispose()
$bitmap.Dispose()
Get-Item $output | Select-Object FullName, Length