aspectratio.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /* screen-calculator.php – korrigierte ASCII‑Art */
  3. ?>
  4. <!DOCTYPE html>
  5. <html lang="de">
  6. <head>
  7. <meta charset="UTF-8">
  8. <title>Bildschirm‑Rechner</title>
  9. <style>
  10. body {font-family:Arial, sans-serif; margin:24px; color:#111; background:#fafafa;}
  11. .card {max-width:760px; margin:auto; padding:18px; border:1px solid #ddd;
  12. border-radius:8px; box-shadow:0 2px 6px rgba(0,0,0,0.03); background:#fff;}
  13. h1 {font-size:20px; margin-bottom:8px;}
  14. .control {margin:14px 0;}
  15. label {display:block; font-size:13px; margin-bottom:6px; color:#333;}
  16. select, input[type="range"] {width:100%;}
  17. .muted {color:#666; font-size:13px;}
  18. .value {font-weight:700; margin-left:6px;}
  19. .results {margin-top:18px; display:grid; grid-template-columns:1fr 1fr; gap:12px;}
  20. .result {padding:12px; border-radius:6px; background:#f9f9f9; border:1px solid #eee;}
  21. .footer {margin-top:14px; font-size:13px; color:#444;}
  22. @media (max-width:600px){ .results{grid-template-columns:1fr;} }
  23. #ascii {font-family:"Courier New",Courier,monospace; white-space:pre; line-height:1;}
  24. </style>
  25. </head>
  26. <body>
  27. <div class="card">
  28. <h1>Bildschirm‑Rechner</h1>
  29. <div class="control">
  30. <label for="ratio">Seitenverhältnis</label>
  31. <select id="ratio">
  32. <option value="1/1">1:1</option>
  33. <option value="3/2">3:2</option>
  34. <option value="3/4">3:4</option>
  35. <option value="4/3">4:3</option>
  36. <option value="5/4">5:4</option>
  37. <option value="15/9">15:9</option>
  38. <option value="16/10">16:10</option>
  39. <option value="16/9" selected>16:9</option>
  40. <option value="17/9">17:9</option>
  41. <option value="21/9">21:9</option>
  42. <option value="24/10">24:10</option>
  43. <option value="32/9">32:9</option>
  44. </select>
  45. </div>
  46. <div class="control">
  47. <label for="diag">Diagonale (Zoll)</label>
  48. <input type="range" id="diag" min="4" max="100" step="1" value="16">
  49. <div class="muted">Auswahl: <span id="diagVal" class="value">16 ″ / 40.64 cm</span></div>
  50. </div>
  51. <div class="results">
  52. <div class="result"><pre id="ascii"></pre></div>
  53. <div class="result">
  54. <div>Höhe: <span id="height" class="value"></span> cm / <span id="heightIn" class="value"></span> ″</div>
  55. <div>Breite: <span id="width" class="value"></span> cm / <span id="widthIn" class="value"></span> ″</div>
  56. </div>
  57. </div>
  58. <div class="footer">
  59. Hinweis: Die Werte basieren ausschließlich auf den eingegebenen Parametern.
  60. Tatsächliche Bildschirme können abweichen.
  61. </div>
  62. </div>
  63. <script>
  64. const ratioSelect = document.getElementById('ratio');
  65. const diagSlider = document.getElementById('diag');
  66. const diagValSpan = document.getElementById('diagVal');
  67. const asciiBox = document.getElementById('ascii');
  68. const heightSpan = document.getElementById('height');
  69. const heightInSpan = document.getElementById('heightIn');
  70. const widthSpan = document.getElementById('width');
  71. const widthInSpan = document.getElementById('widthIn');
  72. function calc() {
  73. const [a, b] = ratioSelect.value.split('/').map(Number);
  74. const ratioText = `${a}:${b}`;
  75. const dIn = parseInt(diagSlider.value, 10); // ganzzahliges Zoll
  76. const dCm = dIn * 2.54;
  77. const factor = Math.sqrt(a*a + b*b);
  78. const widthCm = dCm * a / factor;
  79. const heightCm = dCm * b / factor;
  80. const widthIn = widthCm / 2.54;
  81. const heightIn = heightCm / 2.54;
  82. diagValSpan.textContent = `${dIn} ″ / ${dCm.toFixed(2)} cm`;
  83. heightSpan.textContent = heightCm.toFixed(2);
  84. heightInSpan.textContent = heightIn.toFixed(2);
  85. widthSpan.textContent = widthCm.toFixed(2);
  86. widthInSpan.textContent = widthIn.toFixed(2);
  87. // ASCII‑Art (10 Zeilen, Breite proportional)
  88. const rows = 10;
  89. const cols = Math.max(4, Math.round((widthCm/heightCm) * rows));
  90. let art = '';
  91. for (let r = 0; r < rows; r++) {
  92. for (let c = 0; c < cols; c++) {
  93. art += (r===0 || r===rows-1 || c===0 || c===cols-1) ? '#' : ' ';
  94. }
  95. art += '\n';
  96. }
  97. asciiBox.textContent = art;
  98. }
  99. // initial
  100. calc();
  101. ratioSelect.addEventListener('change', calc);
  102. diagSlider.addEventListener('input', calc);
  103. </script>
  104. </body>
  105. </html>