Jasne, oto zaktualizowana wersja programu z dodanymi nowymi, popularnymi modelami drukarek 3D. Dodałem Creality Ender-3 V3 KE, Prusa Mini+, Anycubic Kobra 2 Neo oraz Bambu Lab P1S.
Zmiany obejmują:
- Dodanie nowych
div z klasą printer-card do sekcji wyboru drukarki.
- Przypisanie przykładowych wartości mocy (w kW) i ceny (w zł) dla nowych modeli.
- Domyślnie zaznaczona jest pierwsza drukarka (Creality Ender 3), ale możesz łatwo zmienić domyślny wybór, przenosząc klasę
selected do innego printer-card.
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kalkulator Kosztów Druku 3D</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
/* Stylizacja pozostaje bez zmian */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Roboto', sans-serif; background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%); color: #333; line-height: 1.6; padding: 20px; min-height: 100vh; }
.container { max-width: 1200px; margin: 0 auto; }
header { text-align: center; padding: 30px 0; color: white; text-shadow: 0 2px 4px rgba(0,0,0,0.2); }
header h1 { font-size: 2.5rem; margin-bottom: 10px; }
header p { font-size: 1.2rem; max-width: 700px; margin: 0 auto; opacity: 0.9; }
.calculator-container { display: flex; flex-wrap: wrap; gap: 30px; margin-bottom: 40px; }
.form-section { flex: 1; min-width: 300px; background: white; border-radius: 15px; padding: 25px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); }
.results-section { flex: 1; min-width: 300px; background: white; border-radius: 15px; padding: 25px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); }
.section-title { display: flex; align-items: center; margin-bottom: 20px; padding-bottom: 15px; border-bottom: 2px solid #f0f0f0; color: #2c3e50; }
.section-title i { margin-right: 10px; font-size: 1.5rem; color: #3498db; }
.form-group { margin-bottom: 20px; }
label { display: block; margin-bottom: 8px; font-weight: 500; color: #2c3e50; }
input, select { width: 100%; padding: 12px 15px; border: 1px solid #ddd; border-radius: 8px; font-size: 1rem; transition: border-color 0.3s; }
input:focus, select:focus { outline: none; border-color: #3498db; box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2); }
.energy-info { background: #e8f4fc; padding: 15px; border-radius: 8px; margin-top: 20px; display: flex; align-items: center; }
.energy-info i { color: #f1c40f; font-size: 1.5rem; margin-right: 15px; }
.btn-calculate { background: linear-gradient(to right, #3498db, #2980b9); color: white; border: none; padding: 14px 25px; font-size: 1.1rem; border-radius: 8px; cursor: pointer; width: 100%; font-weight: 600; transition: transform 0.3s, box-shadow 0.3s; margin-top: 10px; }
.btn-calculate:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.cost-breakdown { margin-top: 20px; }
.cost-item { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid #eee; }
.cost-item:last-child { border-bottom: none; }
.total-cost { background: #f8f9fa; padding: 20px; border-radius: 10px; margin-top: 25px; text-align: center; }
.total-cost h3 { font-size: 1.3rem; margin-bottom: 15px; color: #2c3e50; }
.total-amount { font-size: 2.5rem; font-weight: 700; color: #27ae60; margin: 10px 0; }
.disclaimer { font-size: 0.9rem; color: #7f8c8d; margin-top: 20px; text-align: center; }
.printers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 15px; margin-top: 15px; } /* Zmniejszony min-width dla lepszego dopasowania */
.printer-card { background: #f8f9fa; border-radius: 8px; padding: 15px; text-align: center; cursor: pointer; transition: all 0.3s; border: 2px solid transparent; }
.printer-card:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.printer-card.selected { border-color: #3498db; background: #e8f4fc; }
.printer-card h4 { margin: 10px 0 5px; font-size: 1rem; } /* Zmniejszony font-size */
.printer-card p { font-size: 0.85rem; color: #7f8c8d; } /* Zmniejszony font-size */
.summary-item { display: flex; justify-content: space-between; margin-bottom: 10px; padding: 8px 0; }
.summary-title { font-weight: 500; }
.summary-value { font-weight: 600; }
.results-placeholder { text-align: center; padding: 40px 20px; color: #7f8c8d; }
.results-placeholder i { font-size: 4rem; color: #bdc3c7; margin-bottom: 20px; }
footer { text-align: center; color: white; padding: 20px 0; font-size: 0.9rem; opacity: 0.8; }
@media (max-width: 768px) {
.calculator-container { flex-direction: column; }
header h1 { font-size: 2rem; }
.printers-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } /* Jeszcze mniejsze dla mobilnych */
}
/* Dodatkowe style dla ikon drukarek */
.printer-card i { font-size: 2.5rem; color: #3498db; margin-bottom: 10px; }
</style>
</head>
<body>
<div class="container">
<header>
<h1><i class="fas fa-cube"></i> Kalkulator Kosztów Druku 3D</h1>
<p>Oblicz dokładne koszty wydruku 3D, uwzględniając zużycie energii, filamentu i czasu projektowania</p>
</header>
<div class="calculator-container">
<div class="form-section">
<div class="section-title">
<i class="fas fa-sliders-h"></i>
<h2>Parametry wydruku</h2>
</div>
<div class="form-group">
<label>Wybierz model drukarki</label>
<div class="printers-grid">
<!-- Domyślnie zaznaczony -->
<div class="printer-card selected" data-power="0.2" data-price="1200">
<i class="fas fa-print"></i>
<h4>Creality Ender 3</h4>
<p>~0.2 kW</p>
</div>
<div class="printer-card" data-power="0.35" data-price="1600">
<i class="fas fa-print"></i>
<h4>Ender-3 V3 KE</h4>
<p>~0.35 kW</p>
</div>
<div class="printer-card" data-power="0.18" data-price="2000">
<i class="fas fa-print"></i>
<h4>Prusa Mini+</h4>
<p>~0.18 kW</p>
</div>
<div class="printer-card" data-power="0.25" data-price="2500">
<i class="fas fa-print"></i>
<h4>Prusa i3 MK3</h4>
<p>~0.25 kW</p>
</div>
<div class="printer-card" data-power="0.3" data-price="1200">
<i class="fas fa-print"></i>
<h4>Anycubic Kobra 2 Neo</h4>
<p>~0.3 kW</p>
</div>
<div class="printer-card" data-power="0.3" data-price="5000">
<i class="fas fa-print"></i>
<h4>Ultimaker S5</h4>
<p>~0.3 kW</p>
</div>
<div class="printer-card" data-power="0.3" data-price="3500">
<i class="fas fa-print"></i>
<h4>Bambu Lab P1S</h4>
<p>~0.3 kW</p>
</div>
</div>
</div>
<div class="form-group">
<label for="filamentType">Rodzaj filamentu (cena za kg)</label>
<select id="filamentType">
<option value="80">PLA (80 zł/kg)</option>
<option value="90">ABS (90 zł/kg)</option>
<option value="110">PETG (110 zł/kg)</option>
<option value="150">Nylon (150 zł/kg)</option>
<option value="200">TPU (200 zł/kg)</option>
<option value="250">Materiały specjalne (250 zł/kg)</option>
</select>
</div>
<div class="form-group">
<label for="filamentWeight">Masa filamentu w modelu (gramy)</label>
<input type="number" id="filamentWeight" min="1" max="5000" value="200">
</div>
<div class="form-group">
<label for="printTime">Szacowany czas wydruku (godziny)</label>
<input type="number" id="printTime" min="0.1" step="0.1" value="5">
</div>
<div class="form-group">
<label for="designTime">Czas potrzebny na projektowanie/przygotowanie (godziny)</label>
<input type="number" id="designTime" min="0" step="0.5" value="2">
</div>
<div class="form-group">
<label for="hourlyRate">Twoja stawka za godzinę pracy nad projektem (zł/godz)</label>
<input type="number" id="hourlyRate" min="0" step="5" value="50">
</div>
<div class="energy-info">
<i class="fas fa-bolt"></i>
<div>
<h3>Aktualna cena energii: 0.80 zł/kWh</h3>
<p>Dane szacunkowe (wartość może się różnić w zależności od taryfy i dostawcy)</p>
</div>
</div>
<button class="btn-calculate" id="calculateBtn">
<i class="fas fa-calculator"></i> Oblicz koszt wydruku
</button>
</div>
<div class="results-section">
<div class="section-title">
<i class="fas fa-chart-pie"></i>
<h2>Szczegółowa kalkulacja</h2>
</div>
<div class="results-placeholder" id="resultsPlaceholder">
<i class="fas fa-calculator"></i>
<h3>Wprowadź parametry i kliknij "Oblicz"</h3>
<p>Wyświetlimy tutaj szczegółową kalkulację kosztów Twojego wydruku</p>
</div>
<div class="cost-breakdown" id="costBreakdown" style="display: none;">
<div class="summary-item">
<span class="summary-title">Wybrana drukarka:</span>
<span class="summary-value" id="printerModelName">N/A</span>
</div>
<div class="summary-item">
<span class="summary-title">Moc drukarki:</span>
<span class="summary-value" id="printerPower">N/A</span>
</div>
<div class="summary-item">
<span class="summary-title">Rodzaj filamentu:</span>
<span class="summary-value" id="filamentTypeResult">N/A</span>
</div>
<div class="summary-item">
<span class="summary-title">Użyty filament:</span>
<span class="summary-value" id="filamentUsed">N/A</span>
</div>
<div class="summary-item">
<span class="summary-title">Czas wydruku:</span>
<span class="summary-value" id="printTimeResult">N/A</span>
</div>
<div class="cost-item">
<div>
<h4>Koszt energii elektrycznej</h4>
<p id="energyCalcDesc">...</p>
</div>
<span class="summary-value" id="energyCost">0.00 zł</span>
</div>
<div class="cost-item">
<div>
<h4>Koszt filamentu</h4>
<p id="filamentCalcDesc">...</p>
</div>
<span class="summary-value" id="filamentCost">0.00 zł</span>
</div>
<div class="cost-item">
<div>
<h4>Koszt projektowania/przygotowania</h4>
<p id="designCalcDesc">...</p>
</div>
<span class="summary-value" id="designCost">0.00 zł</span>
</div>
<div class="cost-item">
<div>
<h4>Amortyzacja drukarki</h4>
<p id="depreciationCalcDesc">...</p>
</div>
<span class="summary-value" id="depreciationCost">0.00 zł</span>
</div>
<div class="total-cost">
<h3>Szacowany Całkowity Koszt Wydruku</h3>
<div class="total-amount" id="totalCost">0.00 zł</div>
<p>w tym koszt samego druku: <span id="printCost">0.00 zł</span></p>
</div>
</div>
</div>
</div>
<div class="disclaimer">
<p><i class="fas fa-info-circle"></i> Kalkulator uwzględnia koszt energii elektrycznej, materiału, czasu projektowania oraz amortyzację sprzętu. Koszty amortyzacji obliczane są przy założeniu żywotności drukarki 2000 godzin pracy i podanej ceny zakupu. Ceny filamentów i drukarek są szacunkowe. Wyniki mają charakter informacyjny.</p>
</div>
<footer>
<p>© 2023 Kalkulator Kosztów Druku 3D | Narzędzie dla entuzjastów druku przestrzennego</p>
</footer>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// --- Zmienne globalne ---
const printerCards = document.querySelectorAll('.printer-card');
const calculateBtn = document.getElementById('calculateBtn');
const resultsPlaceholder = document.getElementById('resultsPlaceholder');
const costBreakdown = document.getElementById('costBreakdown');
// --- Stałe ---
const ENERGY_PRICE_PER_KWH = 0.80; // zł/kWh
const PRINTER_LIFESPAN_HOURS = 2000; // Przybliżona żywotność drukarki w godzinach
// --- Funkcje ---
function selectPrinter(clickedCard) {
printerCards.forEach(card => card.classList.remove('selected'));
clickedCard.classList.add('selected');
}
function calculateCosts() {
// Pobranie danych z wybranej drukarki
const selectedPrinter = document.querySelector('.printer-card.selected');
const printerPower = parseFloat(selectedPrinter.dataset.power); // kW
const printerPrice = parseFloat(selectedPrinter.dataset.price); // zł
const printerModelName = selectedPrinter.querySelector('h4').textContent;
// Pobranie danych z formularza
const filamentTypeSelect = document.getElementById('filamentType');
const filamentPricePerKg = parseFloat(filamentTypeSelect.value); // zł/kg
const filamentWeight = parseFloat(document.getElementById('filamentWeight').value); // g
const printTime = parseFloat(document.getElementById('printTime').value); // h
const designTime = parseFloat(document.getElementById('designTime').value); // h
const hourlyRate = parseFloat(document.getElementById('hourlyRate').value); // zł/h
const filamentTypeName = filamentTypeSelect.options[filamentTypeSelect.selectedIndex].text.split(' ')[0]; // Nazwa filamentu
// --- Obliczenia ---
// Koszt energii
const energyCost = printerPower * printTime * ENERGY_PRICE_PER_KWH;
const energyCalcDesc = `${printerPower.toFixed(2)} kW × ${printTime.toFixed(1)} godz. × ${ENERGY_PRICE_PER_KWH.toFixed(2)} zł/kWh`;
// Koszt filamentu
const filamentWeightKg = filamentWeight / 1000; // Konwersja gramów na kilogramy
const filamentCost = filamentWeightKg * filamentPricePerKg;
const filamentCalcDesc = `${filamentWeightKg.toFixed(3)} kg × ${filamentPricePerKg} zł/kg`;
// Koszt projektowania
const designCost = designTime * hourlyRate;
const designCalcDesc = `${designTime.toFixed(1)} godz. × ${hourlyRate} zł/godz.`;
// Amortyzacja drukarki
const depreciationCost = (printTime / PRINTER_LIFESPAN_HOURS) * printerPrice;
const depreciationCalcDesc = `(${printTime.toFixed(1)} godz. / ${PRINTER_LIFESPAN_HOURS} godz.) × ${printerPrice} zł`;
// Koszty samego druku (bez projektowania)
const printOnlyCost = energyCost + filamentCost + depreciationCost;
// Koszt całkowity
const totalCost = printOnlyCost + designCost;
// --- Aktualizacja wyników w UI ---
document.getElementById('printerModelName').textContent = printerModelName;
document.getElementById('printerPower').textContent = `~${printerPower.toFixed(2)} kW`;
document.getElementById('filamentTypeResult').textContent = filamentTypeName;
document.getElementById('filamentUsed').textContent = `${filamentWeight} g`;
document.getElementById('printTimeResult').textContent = `${printTime.toFixed(1)} godz.`;
document.getElementById('energyCost').textContent = energyCost.toFixed(2) + ' zł';
document.getElementById('filamentCost').textContent = filamentCost.toFixed(2) + ' zł';
document.getElementById('designCost').textContent = designCost.toFixed(2) + ' zł';
document.getElementById('depreciationCost').textContent = depreciationCost.toFixed(2) + ' zł';
document.getElementById('totalCost').textContent = totalCost.toFixed(2) + ' zł';
document.getElementById('printCost').textContent = printOnlyCost.toFixed(2) + ' zł';
// Aktualizacja opisów obliczeń
document.getElementById('energyCalcDesc').textContent = energyCalcDesc;
document.getElementById('filamentCalcDesc').textContent = filamentCalcDesc;
document.getElementById('designCalcDesc').textContent = designCalcDesc;
document.getElementById('depreciationCalcDesc').textContent = depreciationCalcDesc;
// Pokazanie wyników
resultsPlaceholder.style.display = 'none';
costBreakdown.style.display = 'block';
}
// --- Event Listeners ---
// Wybór drukarki
printerCards.forEach(card => {
card.addEventListener('click', function() {
selectPrinter(this);
});
});
// Kliknięcie przycisku oblicz
calculateBtn.addEventListener('click', calculateCosts);
// Automatyczne obliczenie przy załadowaniu strony z domyślnymi wartościami
calculateCosts();
});
</script>
</body>
</html>
Nowe modele drukarek dodane do sekcji wyboru:
- Creality Ender-3 V3 KE: ~0.35 kW, ~1600 zł
- Prusa Mini+: ~0.18 kW, ~2000 zł
- Anycubic Kobra 2 Neo: ~0.3 kW, ~1200 zł
- Bambu Lab P1S: ~0.3 kW, ~3500 zł
Drobne usprawnienia:
- Niektóre ikony zostały lekko przesunięte/zmienione dla lepszej estetyki.
- Opisy obliczeń w sekcji wyników są teraz dynamicznie generowane na podstawie wprowadzonych danych.
- Zaktualizowano tekst w
disclaimer i footer dla większej precyzji.
- Zmieniono minimalną szerokość kart drukarek w media query dla lepszego dopasowania na mniejszych ekranach.
Teraz masz szerszy wybór drukarek, co czyni kalkulator jeszcze bardziej wszechstronnym!