fix tranform bug

This commit is contained in:
bogo
2024-09-03 16:10:56 +02:00
parent e9cf44dd88
commit 31753a050a
2 changed files with 168 additions and 43 deletions

2
app.py
View File

@@ -185,7 +185,7 @@ def generate_pdf():
wall_length=wall_length,
box_position=box_position,
)
# return rendered_html
#return rendered_html
pdf_file = io.BytesIO()
HTML(string=rendered_html).write_pdf(pdf_file)

View File

@@ -10,52 +10,34 @@
size: {{ size }};
margin: 5mm;
}
body {
font-family: sans-serif;
margin-top: 0;
}
h1, h2 {
text-align: center;
margin-top: 20mm;
}
.page-break {
page-break-after: always;
}
.target {
margin: 0 auto;
background-color: dodgerblue;
position: absolute;
top: 0%;
left: 50%;
transform: translate(-50%, -50%);
}
.circle {
border-radius: 50%;
}
.post {
margin: auto;
background-color: black;
position: relative;
}
.elevator {
position: absolute;
bottom: 0;
left: 50%;
transform: translate(-50%, 0);
}
.stop-plate {
background-color: red !important;
}
.page-break {
page-break-after: always;
}
.content {
position: absolute;
bottom: 0;
left: 0;
right: 0;
}
.mounting-point {
height: 10mm;
width: 0.5mm;
@@ -66,8 +48,8 @@
.mounting-info {
font-size: xx-small;
color: #ccc;
text-align: center;
}
.preview {
position: relative;
display: block;
@@ -80,21 +62,26 @@
.preview-post {
position: absolute;
}
</style>
</head>
<body>
<div>
<div class="page-break">
<h1>Paper Challenge</h1>
<h2>{{ stage.split('_') | map('capitalize') | join(' ') }}</h2>
<div class="preview">
{% for target in preview_target_info %}
<div class="post preview-post {% if target.stop_plate %} stop-plate {% endif %}"
style="top: {{ 50 - target.post_height }}mm; left: {{ target.position + 3 }}mm; width: {{ target.post_width }}mm; height: {{ target.height }}mm;">
<div class="target {% if target.width == target.height %} circle {% endif %}"
style="width: {{ target.width }}mm; height: {{ target.height }}mm"></div>
style="width: {{ target.width }}mm; height: {{ target.height }}mm;
bottom: {{(target.height/2) }}mm;
right: {{ (target.post_width/2) - (target.width/2)}}mm;"></div>
</div>
{% endfor %}
</div>
<p>Minimalna długość ściany: {{ wall_length/10 }}cm</p>
<p>Odległość od ściany: {{ distance }}cm</p>
<p>Przygotowanie toru:</p>
@@ -109,20 +96,158 @@
</ul>
</div>
<div class="page-break"></div>
{% for target in target_info %}
<div class="page-break"></div>
<div class="elevator">
<div class="post {% if target.stop_plate %} stop-plate {% endif %}" style="width: {{ target.post_width }}mm; height: {{ target.post_height }}mm;">
<div class="target {% if target.width == target.height %} circle {% endif %}" style="width: {{ target.width }}mm; height: {{ target.height }}mm"></div>
{% for target in target_info %}
<div class="page-break">
<div class="content">
<div class="post {% if target.stop_plate %} stop-plate {% endif %}" style="width: {{ target.post_width }}mm; height: {{ target.post_height }}mm;">
<div class="target {% if target.width == target.height %} circle {% endif %}"
style="
width: {{ target.width }}mm;
height: {{ target.height }}mm;
bottom: {{ target.post_height - (target.height/2) }}mm;
right: {{ (target.post_width/2) - (target.width/2)}}mm;
">
</div>
</div>
{% if target.target == 't1' %}
<div class="mounting-info">punkt ZERO ({{ stage.split('_') | map('capitalize') | join(' ') }})</div>
{% else %}
<div class="mounting-info">{{ target.position / 10 }}cm from 0 point ({{ stage.split('_') | map('capitalize') | join(' ') }})</div>
{% endif %}
<div class="mounting-point"></div>
</div>
{% if target.target == 't1' %}
<div class="mounting-info">punkt ZERO ({{ stage.split('_') | map('capitalize') | join(' ') }})</div>
{% else %}
<div class="mounting-info">{{ target.position / 10 }}cm from 0 point ({{ stage.split('_') | map('capitalize') | join(' ') }})</div>
{% endif %}
<div class="mounting-point"></div>
</div>
{% endfor %}
</body>
</html>
{#<!doctype html>#}
{#<html lang="en">#}
{#<head>#}
{# <meta charset="UTF-8">#}
{# <meta name="viewport" content="width=device-width, initial-scale=1.0">#}
{# <title>Paper Challenge - {{ stage.split('_') | map('capitalize') | join(' ') }} - {{ distance }} cm#}
{# - {{ size|capitalize }}</title>#}
{# <style>#}
{# @page {#}
{# size: {{ size }};#}
{# margin: 5mm;#}
{# }#}
{##}
{# body {#}
{# font-family: sans-serif;#}
{# margin-top: 0;#}
{# }#}
{##}
{# h1, h2 {#}
{# text-align: center;#}
{# margin-top: 20mm;#}
{# }#}
{##}
{# .page-break {#}
{# page-break-after: always;#}
{# }#}
{##}
{# .target {#}
{# margin: 0 auto;#}
{# background-color: dodgerblue;#}
{# position: absolute;#}
{# top: 0%;#}
{# left: 50%;#}
{# transform: translate(-50%, -50%);#}
{##}
{# }#}
{##}
{# .circle {#}
{# border-radius: 50%;#}
{# }#}
{##}
{# .post {#}
{# margin: auto;#}
{# background-color: black;#}
{# position: relative;#}
{# }#}
{##}
{# .elevator {#}
{# position: absolute;#}
{# bottom: 0;#}
{# left: 50%;#}
{# transform: translate(-50%, 0);#}
{# }#}
{##}
{# .stop-plate {#}
{# background-color: red !important;#}
{# }#}
{##}
{# .mounting-point {#}
{# height: 10mm;#}
{# width: 0.5mm;#}
{# background-color: #ccc;#}
{# margin: auto;#}
{# }#}
{##}
{# .mounting-info {#}
{# font-size: xx-small;#}
{# color: #ccc;#}
{# }#}
{##}
{# .preview {#}
{# position: relative;#}
{# display: block;#}
{# border-bottom: solid 1px black;#}
{# border-top: solid 1px black;#}
{# width: 100%;#}
{# height: 75mm;#}
{# }#}
{##}
{# .preview-post {#}
{# position: absolute;#}
{# }#}
{# </style>#}
{#</head>#}
{#<body>#}
{#<div>#}
{# <h1>Paper Challenge</h1>#}
{# <h2>{{ stage.split('_') | map('capitalize') | join(' ') }}</h2>#}
{# <div class="preview">#}
{# {% for target in preview_target_info %}#}
{# <div class="post preview-post {% if target.stop_plate %} stop-plate {% endif %}"#}
{# style="top: {{ 50 - target.post_height }}mm; left: {{ target.position + 3 }}mm; width: {{ target.post_width }}mm; height: {{ target.height }}mm;">#}
{# <div class="target {% if target.width == target.height %} circle {% endif %}"#}
{# style="width: {{ target.width }}mm; height: {{ target.height }}mm"></div>#}
{# </div>#}
{# {% endfor %}#}
{# </div>#}
{# <p>Minimalna długość ściany: {{ wall_length/10 }}cm</p>#}
{# <p>Odległość od ściany: {{ distance }}cm</p>#}
{# <p>Przygotowanie toru:</p>#}
{# <ul>#}
{# <li>Umieść z lewej strony ściany pierwszy cel ze znacznikiem "punkt ZERO"</li>#}
{# <li>Wyznacz pole startowe {{ box_position }}cm od punktu "zero"</li>#}
{# <li>Upewnij się, że pole startowe znjaduje się w dogodnym miejscu, pomieszczenia, tak aby nic nie przeszkazdało#}
{# w swobodnym dobyciu i składaniu do celów na całej szerokości ściany#}
{# </li>#}
{# <li>W razie potrzeby dostosuj pierwszy cel wraz z punktem ZERO i powtórz dwa powyższe kroki</li>#}
{# <li>Umieść na ścianie pozostałe cele zgodnie z odległościami podanymi na znacznikach pozycji na dole każdego celu. Upewnij się, że wszystkie cele są umieszczone w jednej linii równoległej do podłoża</li>#}
{# </ul>#}
{##}
{#</div>#}
{# <div class="page-break"></div>#}
{#{% for target in target_info %}#}
{# <div class="page-break"></div>#}
{# <div class="elevator">#}
{# <div class="post {% if target.stop_plate %} stop-plate {% endif %}" style="width: {{ target.post_width }}mm; height: {{ target.post_height }}mm;">#}
{# <div class="target {% if target.width == target.height %} circle {% endif %}" style="width: {{ target.width }}mm; height: {{ target.height }}mm"></div>#}
{# </div>#}
{# {% if target.target == 't1' %}#}
{# <div class="mounting-info">punkt ZERO ({{ stage.split('_') | map('capitalize') | join(' ') }})</div>#}
{# {% else %}#}
{# <div class="mounting-info">{{ target.position / 10 }}cm from 0 point ({{ stage.split('_') | map('capitalize') | join(' ') }})</div>#}
{# {% endif %}#}
{# <div class="mounting-point"></div>#}
{# </div>#}
{#{% endfor %}#}
{#</body>#}
{#</html>#}