Skip to content

Commit 49aeb6e

Browse files
committed
tyutyu v0
1 parent 8b964d3 commit 49aeb6e

File tree

6 files changed

+194
-1
lines changed

6 files changed

+194
-1
lines changed

src/app/app-routing.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import { Routes, RouterModule } from '@angular/router';
44
import { HomeComponent } from './home';
55
import { LoginComponent } from './login';
66
import { AuthGuard } from './_helpers';
7+
import {TyutyuGeneratorComponent} from "@app/tyutyu/tyutyu-generator.component";
78

89
const routes: Routes = [
910
{ path: '', component: HomeComponent, canActivate: [AuthGuard] },
1011
{ path: 'login', component: LoginComponent },
12+
{ path: 'tyutyu', component: TyutyuGeneratorComponent },
1113

1214
// otherwise, redirect to home
1315
{ path: '**', redirectTo: '' }

src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {MatBadgeModule} from '@angular/material/badge';
3030
import {CheckinDialog} from '@app/home/ticket-dialog/checkin.dialog';
3131
import {MatAutocompleteModule} from '@angular/material/autocomplete';
3232
import {AppConfigService} from "@app/app-config.service";
33+
import {TyutyuGeneratorComponent} from "@app/tyutyu/tyutyu-generator.component";
3334

3435
export function loadAppConfig(configService: AppConfigService) {
3536
return () => configService.loadConfig();
@@ -69,7 +70,8 @@ export function loadAppConfig(configService: AppConfigService) {
6970
LoginComponent,
7071
VariationPipe,
7172
EditDialog,
72-
CheckinDialog
73+
CheckinDialog,
74+
TyutyuGeneratorComponent
7375
],
7476
providers: [
7577
{

src/app/tyutyu/Hermione-Regular.otf

8.44 KB
Binary file not shown.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<div class="container">
2+
<h2>Tyütyü Szöveg Generátor</h2>
3+
4+
<textarea [(ngModel)]="inputText" placeholder="Írj be egy szöveget..." (input)="formatText()"></textarea>
5+
6+
<!-- Hibaüzenet megjelenítése, ha van -->
7+
<div *ngIf="errorMessage" class="error-message">
8+
{{ errorMessage }}
9+
</div>
10+
11+
<div class="preview-container">
12+
<div class="preview">
13+
<div *ngFor="let line of formattedText" class="line">
14+
<div class="spacing" [style.width.px]="calculateSidePadding(calculateWidth(line)) * 10"></div>
15+
<span *ngFor="let char of line; let i = index" class="char"
16+
[ngStyle]="{'width.px': (letterWidths[char] || defaultWidth) * 10}">
17+
{{ char }}
18+
<span class="size">{{ letterWidths[char] || defaultWidth }} cm</span>
19+
</span>
20+
<div class="spacing" [style.width.px]="calculateSidePadding(calculateWidth(line)) * 10"></div>
21+
</div>
22+
</div>
23+
</div>
24+
25+
<div class="measurements">
26+
<h3>Méretek:</h3>
27+
<ul>
28+
<li *ngFor="let line of formattedText">
29+
"{{ line }}" - {{ calculateWidth(line) }} cm széles
30+
(Kétoldali térköz: {{ calculateSidePadding(calculateWidth(line)) }} cm)
31+
</li>
32+
<li>Sorok száma: {{ formattedText.length }}</li>
33+
<li>Betűk magassága: {{ letterHeight }} cm</li>
34+
<li>Sorok közötti távolság: {{ lineHeight }} cm</li>
35+
<li>Betűköz: {{ letterSpacing }} cm</li>
36+
<li>Szóköz: {{ wordSpacing }} cm</li>
37+
</ul>
38+
</div>
39+
</div>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
@font-face {
2+
font-family: 'Hermione';
3+
src: url('Hermione-Regular.otf') format('truetype');
4+
}
5+
6+
.container {
7+
max-width: 500px;
8+
margin: auto;
9+
font-family: Arial, sans-serif;
10+
text-align: center;
11+
12+
h2 {
13+
font-size: 1.5rem;
14+
}
15+
16+
textarea {
17+
width: 100%;
18+
height: 100px;
19+
font-size: 1.2rem;
20+
padding: 10px;
21+
margin-bottom: 15px;
22+
font-family: 'Hermione', sans-serif;
23+
text-transform: uppercase;
24+
white-space: pre-wrap;
25+
}
26+
27+
.error-message {
28+
background: red;
29+
color: white;
30+
padding: 10px;
31+
border-radius: 5px;
32+
font-weight: bold;
33+
margin-bottom: 10px;
34+
}
35+
36+
.preview-container {
37+
display: flex;
38+
justify-content: center;
39+
align-items: center;
40+
background: #fafafa;
41+
border: 2px solid #000;
42+
width: 500px;
43+
height: 350px;
44+
margin: auto;
45+
}
46+
47+
.measurements {
48+
margin-top: 15px;
49+
background: #f8f9fa;
50+
padding: 10px;
51+
border-radius: 5px;
52+
53+
ul {
54+
list-style: none;
55+
padding: 0;
56+
}
57+
58+
li {
59+
background: #ddd;
60+
padding: 5px;
61+
margin-bottom: 5px;
62+
}
63+
}
64+
}
65+
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-tyutyu-generator',
5+
templateUrl: './tyutyu-generator.component.html',
6+
styleUrls: ['./tyutyu-generator.component.scss']
7+
})
8+
export class TyutyuGeneratorComponent {
9+
inputText: string = '';
10+
formattedText: string[] = [];
11+
errorMessage: string | null = null; // Hibaüzenet tárolása
12+
13+
// Betűméretek (cm-ben), Excel alapján
14+
letterWidths: { [key: string]: number } = {
15+
'M': 6, 'W': 6, '.': 1, '…': 5, ';': 1, '"': 2, "'": 1, '(': 2, ')': 2, ':': 1
16+
};
17+
defaultWidth = 5; // Normál betűk szélessége
18+
wordSpacing = 4; // Szóköz távolsága
19+
letterSpacing = 1; // Betűk közötti távolság
20+
lineHeight = 2; // Sorok közötti távolság
21+
letterHeight = 10; // Betűk magassága
22+
maxCharsPerLine = 8;
23+
maxLines = 3;
24+
25+
constructor() {
26+
this.formatText();
27+
}
28+
29+
formatText(): void {
30+
let lines = this.inputText.toUpperCase().split('\n').map(line => line.trim()).filter(line => line.length > 0);
31+
32+
if (lines.length === 0) {
33+
this.formattedText = [];
34+
this.errorMessage = null;
35+
return;
36+
}
37+
38+
let autoWrappedLines: string[] = [];
39+
lines.forEach(line => {
40+
autoWrappedLines.push(...this.wrapLine(line));
41+
});
42+
43+
if (autoWrappedLines.length > this.maxLines) {
44+
this.errorMessage = `HIBA: A szöveg túl hosszú! Maximum ${this.maxLines} sor engedélyezett.`;
45+
this.formattedText = [];
46+
} else {
47+
this.errorMessage = null;
48+
this.formattedText = autoWrappedLines;
49+
}
50+
}
51+
52+
wrapLine(text: string): string[] {
53+
let words = text.split(' ');
54+
let lines: string[] = [];
55+
let currentLine = '';
56+
57+
words.forEach(word => {
58+
let testLine = currentLine ? `${currentLine} ${word}` : word;
59+
if (this.calculateWidth(testLine) <= this.maxCharsPerLine * this.defaultWidth) {
60+
currentLine = testLine;
61+
} else {
62+
if (lines.length < this.maxLines - 1) {
63+
lines.push(currentLine);
64+
currentLine = word;
65+
}
66+
}
67+
});
68+
69+
if (currentLine) lines.push(currentLine);
70+
return lines;
71+
}
72+
73+
calculateWidth(text: string): number {
74+
return text.split('').reduce((sum, char, index, arr) => {
75+
let charWidth = this.letterWidths[char] || this.defaultWidth;
76+
let extraSpace = (char === ' ') ? this.wordSpacing : (index < arr.length - 1 ? this.letterSpacing : 0);
77+
return sum + charWidth + extraSpace;
78+
}, 0);
79+
}
80+
81+
calculateSidePadding(width: number): number {
82+
let totalWidth = 50; // Tyütyü teljes szélessége cm-ben
83+
return (totalWidth - width) / 2; // Oldalsó térköz számítása
84+
}
85+
}

0 commit comments

Comments
 (0)