Add popper for custom distance

This commit is contained in:
bogo
2024-09-28 09:12:18 +02:00
parent fc6a6d7b9a
commit 88825efaeb
8 changed files with 38 additions and 17 deletions

8
app.py
View File

@@ -27,6 +27,8 @@ IPSC_TARGET_HEIGHT = 58
IPSC_STAGE_WIDTH = 322
IDPA_TARGET_HEIGHT = 78
POPPER_HEIGHT = 85
POPPER_WIDTH = 30
VALUES = {
"five_to_go": {
@@ -276,15 +278,15 @@ def generate_pdf_custom():
size = request.form.get('size')
target_type = request.form.get('target_type')
scale = distance / simulated_distance
print(distance,simulated_distance_meters, simulated_distance, scale)
original_target_height= IPSC_TARGET_HEIGHT if target_type == 'ipsc' else IDPA_TARGET_HEIGHT
original_target_height= (IPSC_TARGET_HEIGHT if target_type == 'ipsc' else IDPA_TARGET_HEIGHT if target_type == 'idpa' else POPPER_HEIGHT)
original_target_width= (IPSC_TARGET_WIDTH if target_type == 'ipsc' else IPSC_TARGET_WIDTH if target_type == 'idpa' else POPPER_WIDTH)
rendered_html = render_template(
'pdf_template_custom.html',
distance=distance,
size=size,
target_height=scale * original_target_height,
target_width=scale * IPSC_TARGET_WIDTH,
target_width=scale * original_target_width,
gap=scale * IPSC_GAP + scale * IPSC_TARGET_WIDTH,
target_type=target_type,
simulated_distance=simulated_distance_meters

View File

@@ -44,7 +44,7 @@
</a>
<a href="{{ url_for('custom') }}"
class="{{ 'shadow-inner shadow-blue-900' if current_url == url_for('custom') else '' }} bg-blue-500 text-white py-2 px-4 rounded-md hover:bg-blue-600 transition-colors">
Custom
{% trans %}Custom distance{% endtrans %}
</a>
</div>

View File

@@ -1,19 +1,27 @@
{% extends "base.html" %}
{% block title %}El Presidente{% endblock %}
{% block title %}{%trans%}Custom distance{%endtrans%}{% endblock %}
{% block content %}
<form class="" action="/generate-pdf-custom" method="post">
{% include 'setup.html' %}
<div class="mb-6 max-w-2xl mx-auto mt-4">
<h2>{%trans%}Simulated distance{%endtrans%} [m]</h2>
<input type="number" id="simulated_distance" name="simulated_distance" min="1" max="300" class="w-full p-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-400" required>
</div>
<div class="mb-6 max-w-2xl mx-auto">
<h2>{%trans%}Select the stage{%endtrans%}</h2>
<div class="mb-6 max-w-2xl mx-auto mt-4">
<h2>{%trans%}Simulated distance{%endtrans%} [m]</h2>
<input type="number" id="simulated_distance" name="simulated_distance" min="1" max="300" class="w-full p-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-400" required>
</div>
<h2>{%trans%}Select the target type{%endtrans%}</h2>
<div id="stage" class="grid grid-cols-1 gap-4">
<div>
<label for="popper">
<p>Popper</p>
{% with target_width=3, target_height=8.5 %}
{%include 'popper_svg.html'%}
{% endwith %}
<input type="radio" id="popper" name="target_type" value="popper" required>
</label>
</div>
<div>
<label for="ipsc">
<p>IPSC</p>

View File

@@ -63,11 +63,13 @@
<div class="page-break">
<div class="content">
{% with target_width=target_width, target_height=target_height %}
{%if target_type == 'ipsc' %}
{% if target_type == 'ipsc' %}
{%include 'ipsc_svg.html'%}
{%else%}
{% elif target_type == 'idpa' %}
{%include 'idpa_svg.html'%}
{%endif%}
{% else %}
{% include 'popper_svg.html'%}
{% endif%}
{% endwith %}
<br>
<div class="mounting-info">

View File

@@ -0,0 +1,3 @@
<svg style="display: block; margin: auto;" width="{{target_width}}cm" height="{{target_height}}cm" viewBox="0 0 300 850" xmlns="http://www.w3.org/2000/svg">
<path d="M0 150a1 1 0 11300 0 1 1 0 11-300 0zm53 114 194 0-22 586-150 0-22-586" fill="dodgerblue"/>
</svg>

After

Width:  |  Height:  |  Size: 267 B

View File

@@ -5,7 +5,7 @@
class="cursor-pointer border-2 border-transparent rounded-lg overflow-hidden transition-all hover:border-blue-400">
<img src="{{ url_for('static', filename='images/floor.webp') }}" alt="{%trans%}Distance from wall{%endtrans%}"
class="w-40 h-auto">
<input type="radio" id="floor" name="distance_type" value="floor" required>
<input type="radio" id="floor" name="distance_type" value="floor" required checked>
</label>
{% if current_url != url_for('custom') %}
<label for="wall"
@@ -29,7 +29,7 @@
class="cursor-pointer border-2 border-transparent rounded-lg overflow-hidden transition-all hover:border-blue-400">
<img src="{{ url_for('static', filename='images/a4.webp') }}" alt="A4 (210mm x 297mm)"
class="w-40 h-auto">
<input type="radio" id="a4" name="size" value="a4" required>
<input type="radio" id="a4" name="size" value="a4" required checked>
</label>
<label for="a3"
class="cursor-pointer border-2 border-transparent rounded-lg overflow-hidden transition-all hover:border-blue-400">

View File

@@ -83,4 +83,10 @@ msgid "Place target on"
msgstr "Umieść cel w odległości"
msgid "Target"
msgstr "Cel"
msgstr "Cel"
msgid "Custom distance"
msgstr "Dystans niestandardowy"
msgid "Select the target type"
msgstr "Wybierz rodzaj celu"