TA/web_JMW/docs/render-flowchart-user-jpg.ps1

160 lines
6.4 KiB
PowerShell

Add-Type -AssemblyName System.Drawing
$output = Join-Path $PSScriptRoot 'flowchart-sistem-user.jpg'
$width = 1700
$height = 3200
$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', 30, [System.Drawing.FontStyle]::Bold)
$boxFont = New-Object System.Drawing.Font('Segoe UI', 16, [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)
$startBrush = New-Object System.Drawing.SolidBrush([System.Drawing.Color]::FromArgb(232, 240, 255))
$userBrush = New-Object System.Drawing.SolidBrush([System.Drawing.Color]::FromArgb(232, 246, 239))
$systemBrush = New-Object System.Drawing.SolidBrush([System.Drawing.Color]::FromArgb(238, 242, 247))
$decisionBrush = New-Object System.Drawing.SolidBrush([System.Drawing.Color]::FromArgb(250, 250, 252))
$warningBrush = 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 + 34), ($Y + 18), ($W - 68), ($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 - 95), ($midY - 20), 190, 36)
$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, 30, $width, 65), $format)
$graphics.DrawString('Website Jual Mobil Bekas JMW', $smallFont, $textBrush, [System.Drawing.RectangleF]::new(0, 88, $width, 40), $format)
Draw-Box 675 150 350 70 'Mulai' $startBrush
Draw-Box 675 270 350 90 'User membuka website' $userBrush
Draw-Box 675 420 350 95 'Sistem menampilkan halaman awal' $systemBrush
Draw-Decision 640 575 420 130 'User sudah login?'
Draw-Box 170 760 380 95 'Login atau register akun' $userBrush
Draw-Box 170 920 380 100 'Sistem validasi akun user' $systemBrush
Draw-Decision 150 1090 420 130 'Data valid?'
Draw-Box 675 760 350 95 'Masuk ke katalog mobil' $userBrush
Draw-Box 675 920 350 100 'Sistem release reservasi kedaluwarsa' $systemBrush
Draw-Box 675 1085 350 95 'Tampilkan mobil available' $systemBrush
Draw-Decision 640 1245 420 130 'User input budget?'
Draw-Box 185 1445 390 105 'Input budget rekomendasi' $userBrush
Draw-Box 185 1615 390 115 'Sistem proses rekomendasi K-Means' $systemBrush
Draw-Decision 170 1810 420 130 'API rekomendasi berhasil?'
Draw-Box 90 2020 360 105 'Tampilkan rekomendasi Python' $systemBrush
Draw-Box 500 2020 360 105 'Fallback rekomendasi Laravel' $warningBrush
Draw-Box 675 1445 350 105 'User melihat semua mobil' $userBrush
Draw-Box 675 2215 350 105 'User membuka detail mobil' $userBrush
Draw-Box 675 2380 350 105 'User dapat favoritkan mobil atau hubungi WhatsApp' $userBrush
Draw-Decision 640 2550 420 130 'User ingin membeli?'
Draw-Decision 640 2740 420 130 'Mobil masih available?'
Draw-Box 1160 2555 360 105 'Selesai melihat katalog' $startBrush
Draw-Box 1160 2745 360 105 'Tampilkan pesan mobil tidak tersedia' $warningBrush
Draw-Box 675 2920 350 95 'Buat transaksi pending' $systemBrush
Draw-Box 200 2920 350 95 'Transaksi dibatalkan, mobil available' $warningBrush
Draw-Box 1110 2920 390 95 'Upload bukti pembayaran, menunggu konfirmasi' $userBrush
Draw-Arrow 850 220 850 270
Draw-Arrow 850 360 850 420
Draw-Arrow 850 515 850 575
Draw-Arrow 640 640 550 808 'belum'
Draw-Arrow 850 705 850 760 'sudah'
Draw-Arrow 360 855 360 920
Draw-Arrow 360 1020 360 1090
Draw-Arrow 570 1155 675 808 'ya'
Draw-Arrow 150 1155 110 808 'tidak'
Draw-Arrow 850 855 850 920
Draw-Arrow 850 1020 850 1085
Draw-Arrow 850 1180 850 1245
Draw-Arrow 640 1310 575 1498 'ya'
Draw-Arrow 850 1375 850 1445 'tidak'
Draw-Arrow 380 1550 380 1615
Draw-Arrow 380 1730 380 1810
Draw-Arrow 275 1940 275 2020 'ya'
Draw-Arrow 485 1875 680 2020 'tidak'
Draw-Arrow 450 2072 675 2268
Draw-Arrow 680 2072 850 2215
Draw-Arrow 850 1550 850 2215
Draw-Arrow 850 2320 850 2380
Draw-Arrow 850 2485 850 2550
Draw-Arrow 1060 2615 1160 2608 'tidak'
Draw-Arrow 850 2680 850 2740 'ya'
Draw-Arrow 1060 2805 1160 2798 'tidak'
Draw-Arrow 850 2870 850 2920 'ya'
Draw-Arrow 1025 2968 1110 2968
Draw-Arrow 675 2968 550 2968 'lewat 10 menit'
$bitmap.Save($output, [System.Drawing.Imaging.ImageFormat]::Jpeg)
$graphics.Dispose()
$bitmap.Dispose()
Get-Item $output | Select-Object FullName, Length