naming and test

This commit is contained in:
grey-cat-1908 2024-03-17 10:23:40 +03:00
parent b37a992834
commit c8edbf0cb1
4 changed files with 31 additions and 13 deletions

View file

@ -7,13 +7,19 @@ import {ConnectedStation} from "./models/connectedStation.ts";
import {ExtraBranch} from "./models/extraBranch.ts"; import {ExtraBranch} from "./models/extraBranch.ts";
onMounted(() => { onMounted(() => {
let extraBranch1: ExtraBranch = new ExtraBranch("Таганско-Краснопресненская", "#800080", 2) let extraBranch1: ExtraBranch = new ExtraBranch( "#EF161E", 1)
let extraStation1: ConnectedStation = new ConnectedStation("Кузнецкий\nмост", extraBranch1) let extraStation1: ConnectedStation = new ConnectedStation("Библиотека\nимени Ленина", extraBranch1)
let station1: Station = new Station("Охотный ряд", false, [], 0) let extraBranch4: ExtraBranch = new ExtraBranch( "#00BFFF", 4)
let station2: Station = new Station("Лубянка", true, [extraStation1], 500) let extraStation4: ConnectedStation = new ConnectedStation("Александровский\nсад", extraBranch4)
let branch: Branch = new Branch('Best','#FF0000', 1, [station1, station2]) let extraBranch9: ExtraBranch = new ExtraBranch( "#999999", 9)
let extraStation9: ConnectedStation = new ConnectedStation("Боровицкая", extraBranch9)
let station1: Station = new Station("Смоленская", false, [], 0)
let station2: Station = new Station("Арбатская", true, [extraStation1, extraStation9, extraStation4], 500)
let branch: Branch = new Branch('Арбатско-Покровская линия','#0078BE', 3, [station1, station2])
let map: Map = new Map(branch) let map: Map = new Map(branch)
map.build() map.build()

View file

@ -1,16 +1,13 @@
interface ExtraBranchInterface { interface ExtraBranchInterface {
name: string;
color: string; color: string;
number: number; number: number;
} }
export class ExtraBranch implements ExtraBranchInterface { export class ExtraBranch implements ExtraBranchInterface {
name: string;
color: string; color: string;
number: number; number: number;
constructor(name: string, color: string, number: number) { constructor(color: string, number: number) {
this.name = name;
this.color = color; this.color = color;
this.number = number; this.number = number;
} }

View file

@ -65,12 +65,12 @@ export class Map implements MetroMap {
for (let i = 0; i < stations.length; i++) { for (let i = 0; i < stations.length; i++) {
let cx = last + stations[i].step; let cx = last + stations[i].step;
if (stations[i].connectedStations.length > 0) { if (stations[i].connectedStations.length > 0) {
this.draw.circle(50).fill('#f06').cx(cx).cy(yMax) this.draw.circle(50).fill(this.branch.color).cx(cx).cy(yMax)
this.draw.circle(25).fill('white').cx(cx).cy(yMax) this.draw.circle(25).fill('white').cx(cx).cy(yMax)
this.drawConnectedStations(stations[i].connectedStations, stations[i].up, cx, yMax); this.drawConnectedStations(stations[i].connectedStations, stations[i].up, cx, yMax);
} else { } else {
this.draw.rect(15, 50).fill('#f06').cx(cx).cy(yMax) this.draw.rect(15, 50).fill(this.branch.color).cx(cx).cy(yMax)
} }
let textPosition: number = this.getTextPosition(stations[i].up) let textPosition: number = this.getTextPosition(stations[i].up)
@ -87,11 +87,26 @@ export class Map implements MetroMap {
this.draw = this.draw.size(window.innerWidth, (window.innerHeight-50) / 2); this.draw = this.draw.size(window.innerWidth, (window.innerHeight-50) / 2);
this.draw.clear(); this.draw.clear();
this.draw.circle(50).fill(this.branch.color).cx(50).cy(50)
let text = this.draw.text(this.branch.number.toString()).font({ size: 35}).fill('#fff').cx(50).cy(50);
text.font({
family: 'Onest',
weight: '750',
})
let naming = this.draw.text(this.branch.name).font({ size: 35});
naming.cx(50 + 40 + (naming.bbox().width / 2)).cy(50);
naming.font({
family: 'Onest',
weight: '750',
})
const lineMax = window.innerWidth - 200; const lineMax = window.innerWidth - 200;
const yMax = (window.innerHeight-50) / 4; const yMax = (window.innerHeight-50) / 4;
let line = this.draw.line(200, yMax, lineMax, yMax) let line = this.draw.line(200, yMax, lineMax, yMax)
line.stroke({ color: '#f06', width: 16}) line.stroke({ color: this.branch.color, width: 16})
this.drawStations(this.branch.stations) this.drawStations(this.branch.stations)
} }

View file

@ -1 +1 @@
@import url('https://fonts.googleapis.com/css2?family=Onest:wght@100..900&display=swap'); @import url('https://fonts.googleapis.com/css2?family=Onest:wght@100..900&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap')