Merhabalar
AÇIKLAMA :
Bu powershell betiği, kırmızı, mavi, sarı ve yeşil renklerini “primary” kabul ederek bu renklerin 1’li, 2’li, 3’lü ve 4’lü tüm olası kombinasyonlarını üretir (toplam 15 kombinasyon).
Her kombinasyon için:
Betik şu amaçlarla kullanılabilir:
PrimaryColorCombinations.ps1 İçeriği
EKRAN GÖRÜNTÜSÜ :

Güle güle kullanın...
AÇIKLAMA :
Bu powershell betiği, kırmızı, mavi, sarı ve yeşil renklerini “primary” kabul ederek bu renklerin 1’li, 2’li, 3’lü ve 4’lü tüm olası kombinasyonlarını üretir (toplam 15 kombinasyon).
Her kombinasyon için:
- İçindeki renklerin ortalama RGB değerini hesaplar,
- Bu ortalamadan yeni bir karışım (mix) HEX rengi oluşturur,
- Kombinasyonu BBCode formatında ekrana yazar ve
- Kaç renk içerdiğini ([x1], [x2], [x3], [x4]) renk sayısına göre renklendirerek gösterir.
Betik şu amaçlarla kullanılabilir:
- Renk karışımı/palet oluşturma: Kırmızı, mavi, sarı, yeşil kombinasyonlarından otomatik olarak yeni bir “mix” renk çıkarır.
- Tasarım ve görsel uyum testi: Örneğin afiş, web sayfası veya logo için farklı renk kombinasyonlarını hızlıca görmekte işe yarar.
- BBCode ile paylaşım: Forumda/uygulamalarda renkli yazı formatında sonuçları doğrudan kullanabilmenizi sağlar.
- Renk seti üretme: 1–4 renklik tüm kombinasyonları listeleyerek olası renk varyasyonlarını hızlıca taramanı sağlar.
PrimaryColorCombinations.ps1 İçeriği
Kod:
# Defining the 4 primary colors with their Hex and RGB values
$primaryColors = @(
@{ Name = "Red"; Hex = "#FF0000"; R = 255; G = 0; B = 0 },
@{ Name = "Blue"; Hex = "#0000FF"; R = 0; G = 0; B = 255 },
@{ Name = "Yellow"; Hex = "#FFFF00"; R = 255; G = 255; B = 0 },
@{ Name = "Green"; Hex = "#00FF00"; R = 0; G = 255; B = 0 }
)
Write-Host "=== 4 Primary Colors and Possible Combinations ===" -ForegroundColor Cyan
Write-Host "Primary Colors: $(($primaryColors | ForEach-Object { $_.Name }) -join ', ')`n" -ForegroundColor Yellow
# List to hold the combinations
$allCombinations = @()
# Loop from 1 to 15 (corresponds to binary values 0001 through 1111)
for ($i = 1; $i -le 15; $i++) {
$currentCombination = @()
for ($j = 0; $j -lt $primaryColors.Length; $j++) {
if ($i -band (1 -shl $j)) {
$currentCombination += $primaryColors[$j]
}
}
$allCombinations += ,@($currentCombination)
}
# Print combinations to screen
foreach ($combination in $allCombinations) {
$colorCount = $combination.Count
$names = ($combination | ForEach-Object { $_.Name }) -join " + "
$totalR = 0; $totalG = 0; $totalB = 0
foreach ($color in $combination) {
$totalR += $color.R
$totalG += $color.G
$totalB += $color.B
}
# NOTE: [int] cast added to convert the double average into an integer
$avgR = [int][math]::Round($totalR / $colorCount)
$avgG = [int][math]::Round($totalG / $colorCount)
$avgB = [int][math]::Round($totalB / $colorCount)
# Safely format the Hex code
$mixHex = "#{0:X2}{1:X2}{2:X2}" -f $avgR, $avgG, $avgB
# Generate BBCode
$bbcode = "[color=$mixHex]$names[/color]"
# Print to screen
switch ($colorCount) {
1 { Write-Host "[x1] " -NoNewline -ForegroundColor DarkYellow }
2 { Write-Host "[x2] " -NoNewline -ForegroundColor Green }
3 { Write-Host "[x3] " -NoNewline -ForegroundColor Magenta }
4 { Write-Host "[x4] " -NoNewline -ForegroundColor Red }
default { Write-Host "[x$colorCount] " -NoNewline }
}
Write-Host $names -NoNewline
Write-Host " | Hex: " -NoNewline -ForegroundColor DarkGray
Write-Host $mixHex -NoNewline -ForegroundColor Cyan
Write-Host " | BBCode: " -NoNewline -ForegroundColor DarkGray
Write-Host $bbcode -ForegroundColor Yellow
}
Write-Host "`nTotal Number of Combinations: $($allCombinations.Count)" -ForegroundColor Cyan
# --- Wait Code ---
Read-Host "`nPress ENTER to exit."
EKRAN GÖRÜNTÜSÜ :

Güle güle kullanın...