Stworzę kompleksową stronę internetową, która pomoże użytkownikom obliczyć koszty druku 3D, uwzględniając wszystkie wymienione czynniki. Strona będzie zawierać formularz do wprowadzania parametrów, wyświetlanie aktualnej ceny energii oraz szczegółową kalkulację kosztów.
html Copy code
<!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>
* {
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(200px, 1fr));
gap: 15px;
margin-top: 15px;
}
.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;
}
.printer-card p {
font-size: 0.9rem;
color: #7f8c8d;
}
.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;
}
}
</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 for="printerModel">Model drukarki</label>
<div class="printers-grid">
<div class="printer-card selected" data-power="0.2" data-price="1200">
<i class="fas fa-print fa-2x"></i>
<h4>Creality Ender 3</h4>
<p>0.2 kW</p>
</div>
<div class="printer-card" data-power="0.25" data-price="2500">
<i class="fas fa-print fa-2x"></i>
<h4>Prusa i3 MK3</h4>
<p>0.25 kW</p>
</div>
<div class="printer-card" data-power="0.3" data-price="5000">
<i class="fas fa-print fa-2x"></i>
<h4>Ultimaker S5</h4>
<p>0.3 kW</p>
</div>
<div class="printer-card" data-power="0.4" data-price="3000">
<i class="fas fa-print fa-2x"></i>
<h4>Anycubic Vyper</h4>
<p>0.4 kW</p>
</div>
</div>
</div>
<div class="form-group">
<label for="filamentType">Rodzaj filamentu</label>
<select id="filamentType">
<option value="0.08">PLA (80 zł/kg)</option>
<option value="0.09">ABS (90 zł/kg)</option>
<option value="0.11">PETG (110 zł/kg)</option>
<option value="0.15">Nylon (150 zł/kg)</option>
<option value="0.20">TPU (200 zł/kg)</option>
<option value="0.25">Materiały specjalne (250 zł/kg)</option>
</select>
</div>
<div class="form-group">
<label for="filamentWeight">Masa filamentu (gramy)</label>
<input type="number" id="filamentWeight" min="1" max="5000" value="200">
</div>
<div class="form-group">
<label for="printTime">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 projektowania (godziny)</label>
<input type="number" id="designTime" min="0" step="0.5" value="2">
</div>
<div class="form-group">
<label for="hourlyRate">Stawka za projektowanie (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 z Polskich Sieci Elektroenergetycznych (stan na dzisiaj)</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">Moc drukarki:</span>
<span class="summary-value" id="printerPower">0.2 kW</span>
</div>
<div class="summary-item">
<span class="summary-title">Rodzaj filamentu:</span>
<span class="summary-value" id="filamentTypeResult">PLA</span>
</div>
<div class="summary-item">
<span class="summary-title">Użyty filament:</span>
<span class="summary-value" id="filamentUsed">200 g</span>
</div>
<div class="summary-item">
<span class="summary-title">Czas wydruku:</span>
<span class="summary-value" id="printTimeResult">5 godz.</span>
</div>
<div class="cost-item">
<div>
<h4>Koszt energii</h4>
<p>0.2 kW × 5 godz. × 0.80 zł/kWh</p>
</div>
<span class="summary-value" id="energyCost">0.80 zł</span>
</div>
<div class="cost-item">
<div>
<h4>Koszt filamentu</h4>
<p>0.2 kg × 80 zł/kg</p>
</div>
<span class="summary-value" id="filamentCost">16.00 zł</span>
</div>
<div class="cost-item">
<div>
<h4>Koszt projektowania</h4>
<p>2 godz. × 50 zł/godz.</p>
</div>
<span class="summary-value" id="designCost">100.00 zł</span>
</div>
<div class="cost-item">
<div>
<h4>Amortyzacja drukarki</h4>
<p>(5 godz. / 2000 godz.) × 1200 zł</p>
</div>
<span class="summary-value" id="depreciationCost">3.00 zł</span>
</div>
<div class="total-cost">
<h3>CAŁKOWITY KOSZT WYDRUKU</h3>
<div class="total-amount" id="totalCost">119.80 zł</div>
<p>w tym koszt samego wydruku: <span id="printCost">19.80 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. Wyniki mają charakter szacunkowy.</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() {
// Obsługa wyboru drukarki
const printerCards = document.querySelectorAll('.printer-card');
let selectedPrinter = document.querySelector('.printer-card.selected');
printerCards.forEach(card => {
card.addEventListener('click', function() {
printerCards.forEach(c => c.classList.remove('selected'));
this.classList.add('selected');
selectedPrinter = this;
});
});
// Obsługa przycisku obliczania
const calculateBtn = document.getElementById('calculateBtn');
const resultsPlaceholder = document.getElementById('resultsPlaceholder');
const costBreakdown = document.getElementById('costBreakdown');
calculateBtn.addEventListener('click', calculateCosts);
function calculateCosts() {
// Pobranie danych z formularza
const printerPower = parseFloat(selectedPrinter.dataset.power);
const printerPrice = parseFloat(selectedPrinter.dataset.price);
const filamentPricePerKg = parseFloat(document.getElementById('filamentType').value);
const filamentWeight = parseFloat(document.getElementById('filamentWeight').value);
const printTime = parseFloat(document.getElementById('printTime').value);
const designTime = parseFloat(document.getElementById('designTime').value);
const hourlyRate = parseFloat(document.getElementById('hourlyRate').value);
// Aktualna cena energii (w rzeczywistości można by pobierać z API)
const energyPricePerKwh = 0.80;
// Obliczenia kosztów
const energyCost = printerPower * printTime * energyPricePerKwh;
const filamentCost = (filamentWeight / 1000) * filamentPricePerKg * 1000; // *1000 bo w zł/kg, a mamy g
const designCost = designTime * hourlyRate;
// Amortyzacja drukarki (przy założeniu żywotności 2000 godzin)
const depreciationCost = (printTime / 2000) * printerPrice;
// Koszt całkowity
const totalCost = energyCost + filamentCost + designCost + depreciationCost;
const printCost = energyCost + filamentCost + depreciationCost;
// Aktualizacja wyników w UI
document.getElementById('printerPower').textContent = printerPower + ' kW';
document.getElementById('filamentTypeResult').textContent = document.getElementById('filamentType').options[document.getElementById('filamentType').selectedIndex].text.split(' ')[0];
document.getElementById('filamentUsed').textContent = filamentWeight + ' g';
document.getElementById('printTimeResult').textContent = printTime + ' 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 = printCost.toFixed(2) + ' zł';
// Aktualizacja opisów obliczeń
document.querySelector('#energyCost').previousElementSibling.querySelector('p').textContent =
`${printerPower} kW × ${printTime} godz. × ${energyPricePerKwh.toFixed(2)} zł/kWh`;
document.querySelector('#filamentCost').previousElementSibling.querySelector('p').textContent =
`${(filamentWeight/1000).toFixed(3)} kg × ${filamentPricePerKg*1000} zł/kg`;
document.querySelector('#designCost').previousElementSibling.querySelector('p').textContent =
`${designTime} godz. × ${hourlyRate} zł/godz.`;
document.querySelector('#depreciationCost').previousElementSibling.querySelector('p').textContent =
`(${printTime} godz. / 2000 godz.) × ${printerPrice} zł`;
// Pokazanie wyników
resultsPlaceholder.style.display = 'none';
costBreakdown.style.display = 'block';
}
// Automatyczne obliczenie przy załadowaniu z domyślnymi wartościami
calculateCosts();
});
</script>
</body>
</html>
Strona jest w pełni responsywna i działa na różnych urządzeniach. Interfejs jest intuicyjny i estetyczny, z wykorzystaniem nowoczesnego gradientu w tle i przejrzystych kart do wprowadzania danych i wyświetlania wyników.