Add TS-2, layout fixes

This commit is contained in:
bogo
2024-09-30 13:42:48 +02:00
parent 88825efaeb
commit 567f38007f
9 changed files with 54 additions and 15 deletions

18
app.py
View File

@@ -22,13 +22,16 @@ SHOOTOFF_GAP = 100
IPSC_DISTANCE = 914
IPSC_GAP = 92
IPSC_TARGET_WIDTH = 46
IPSC_TARGET_WIDTH = 45
IPSC_TARGET_HEIGHT = 58
IPSC_STAGE_WIDTH = 322
IDPA_TARGET_HEIGHT = 78
IDPA_TARGET_WIDTH = 46
POPPER_HEIGHT = 85
POPPER_WIDTH = 30
TS2_HEIGHT = 50
TS2_WIDTH = 50
VALUES = {
"five_to_go": {
@@ -245,6 +248,7 @@ def generate_pdf_ipsc():
box_position = target_line / 2
preview_margin=(preview_size - 3*(preview_scale * IPSC_TARGET_WIDTH))/2
original_target_height= IPSC_TARGET_HEIGHT if target_type == 'ipsc' else IDPA_TARGET_HEIGHT
original_target_width= IPSC_TARGET_WIDTH if target_type == 'ipsc' else IDPA_TARGET_WIDTH
rendered_html = render_template(
'pdf_template_ipsc.html',
@@ -255,7 +259,7 @@ def generate_pdf_ipsc():
target_width=scale * IPSC_TARGET_WIDTH,
gap=scale * IPSC_GAP + scale * IPSC_TARGET_WIDTH,
preview_target_height=preview_scale * original_target_height,
preview_target_width=preview_scale * IPSC_TARGET_WIDTH,
preview_target_width=preview_scale * original_target_width,
preview_margin=preview_margin,
preview_gap=preview_scale * IPSC_GAP + preview_margin,
box_position=box_position,
@@ -278,8 +282,12 @@ def generate_pdf_custom():
size = request.form.get('size')
target_type = request.form.get('target_type')
scale = distance / simulated_distance
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)
original_target_height, original_target_width = {
'ipsc': (IPSC_TARGET_HEIGHT, IPSC_TARGET_WIDTH),
'idpa': (IDPA_TARGET_HEIGHT, IDPA_TARGET_WIDTH),
'ts2': (TS2_HEIGHT, TS2_WIDTH),
'popper': (POPPER_HEIGHT, POPPER_WIDTH),
}[target_type]
rendered_html = render_template(
'pdf_template_custom.html',
@@ -287,7 +295,7 @@ def generate_pdf_custom():
size=size,
target_height=scale * original_target_height,
target_width=scale * original_target_width,
gap=scale * IPSC_GAP + scale * IPSC_TARGET_WIDTH,
gap=scale * IPSC_GAP + scale * original_target_width,
target_type=target_type,
simulated_distance=simulated_distance_meters
)

View File

@@ -29,7 +29,7 @@
<div class="max-w-4xl mx-auto p-6 bg-white shadow-md rounded-lg mt-10">
<h1 class="text-2xl font-bold mb-6 text-center text-gray-700">Steel Training</h1>
<h2 class="my-10 mx-auto text-center font-bold text-xl">{% trans %}Generate stage for{% endtrans %} {% block title %}{% endblock %}</h2>
<div class="flex justify-center gap-6">
<div class="flex flex-col md:flex-row justify-center gap-6 md:gap-3">
<a href="{{ url_for('index') }}"
class="{{ 'shadow-inner shadow-blue-900' if current_url == url_for('index') else '' }} bg-blue-500 text-white py-2 px-4 rounded-md hover:bg-blue-600 transition-colors">
Steel Challenge
@@ -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">
{% trans %}Custom distance{% endtrans %}
{% trans %}Custom{% endtrans %}
</a>
</div>

View File

@@ -1,5 +1,5 @@
{% extends "base.html" %}
{% block title %}{%trans%}Custom distance{%endtrans%}{% endblock %}
{% block title %}{%trans%}Custom{%endtrans%}{% endblock %}
{% block content %}
@@ -13,6 +13,15 @@
<h2>{%trans%}Select the target type{%endtrans%}</h2>
<div id="stage" class="grid grid-cols-1 gap-4">
<div>
<label for="ts2">
<p>TS-2</p>
{% with target_width=5, target_height=5 %}
{%include 'ts2_svg.html'%}
{% endwith %}
<input type="radio" id="ts2" name="target_type" value="ts2" required>
</label>
</div>
<div>
<label for="popper">
<p>Popper</p>

View File

@@ -67,6 +67,8 @@
{%include 'ipsc_svg.html'%}
{% elif target_type == 'idpa' %}
{%include 'idpa_svg.html'%}
{% elif target_type == 'ts2' %}
{%include 'ts2_svg.html'%}
{% else %}
{% include 'popper_svg.html'%}
{% endif%}

View File

@@ -28,13 +28,13 @@
<label for="a4"
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">
class="w-24 h-auto">
<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">
<img src="{{ url_for('static', filename='images/a3.webp') }}" alt="A3 (297mm x 420mm)"
class="w-40 h-auto">
class="w-24 h-auto">
<input type="radio" id="a3" name="size" value="a3" required>
</label>
</div>

View File

@@ -6,9 +6,11 @@
<div class="mb-6 max-w-2xl mx-auto">
<h2>Shootoff</h2>
<div class="mb-6 max-w-2xl mx-auto mt-4">
<div>
<label for="shootoff">
<img src="{{ url_for('static', filename='images/shootoff.webp') }}" alt="Shootoff">
<input type="radio" id="shootoff" name="stage" value="shootoff" required checked>
</label>
</div>
</div>

18
templates/ts2_svg.html Normal file
View File

@@ -0,0 +1,18 @@
<svg style="display: block; margin: auto;" width="{{target_width}}cm" height="{{target_height}}cm" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
<path d="
m0 250a1 1 0 11500 0 1 1 0 11-500 0
m25 0a1 1 0 11450 0 1 1 0 11-450 0
m25 0a1 1 0 11400 0 1 1 0 11-400 0
m25 0a1 1 0 11350 0 1 1 0 11-350 0
m25 0a1 1 0 11300 0 1 1 0 11-300 0
m25 0a1 1 0 11250 0 1 1 0 11-250 0
" fill="white" stroke="black" stroke-width="0.5"/>
<path d="
m150 250a1 1 0 11200 0 1 1 0 11-200 0
m25 0a1 1 0 11150 0 1 1 0 11-150 0
m25 0a1 1 0 11100 0 1 1 0 11-100 0
m25 0a1 1 0 1150 0 1 1 0 11-50 0
m12.5 0a1 1 0 1125 0 1 1 0 11-25 0
" fill="black" stroke="white" stroke-width="0.5"/>
</svg>

After

Width:  |  Height:  |  Size: 781 B

View File

@@ -85,8 +85,8 @@ msgstr "Umieść cel w odległości"
msgid "Target"
msgstr "Cel"
msgid "Custom distance"
msgstr "Dystans niestandardowy"
msgid "Custom"
msgstr "Niestandardowy"
msgid "Select the target type"
msgstr "Wybierz rodzaj celu"