From 45d9e8d57710bdd9d53fa7d11e1407077b31291b Mon Sep 17 00:00:00 2001 From: Pyro Nicampt <81565698+PyroNicampt@users.noreply.github.com> Date: Sat, 15 Mar 2025 18:11:47 -0500 Subject: [PATCH] Canvas rewrite -Full rewrite to use Canvas instead of SVG -Restructured backend --- config.js | 52 +++ index.html | 218 +-------- index.js | 1087 ++++++++++++------------------------------- js/bezierlib.js | 50 ++ js/mapdata.js | 573 +++++++++++++++++++++++ js/spritelib.js | 10 + js/utillib.js | 99 +++- legend.js | 151 +++--- mapSprites.svg | 282 +++++++++++ poi_dv.json | 106 +++++ style.css | 40 ++ terrains/dvrt.jpg | Bin 0 -> 1106466 bytes terrains/simple.jpg | Bin 0 -> 394867 bytes 13 files changed, 1612 insertions(+), 1056 deletions(-) create mode 100644 js/mapdata.js create mode 100644 js/spritelib.js create mode 100644 mapSprites.svg create mode 100644 terrains/dvrt.jpg create mode 100644 terrains/simple.jpg diff --git a/config.js b/config.js index 2797701..a0beadf 100644 --- a/config.js +++ b/config.js @@ -1,5 +1,6 @@ 'use strict'; import {Color} from './js/colorlib.js'; +import {SpriteBounds} from './js/spritelib.js'; export const gradeColors = { grade_flat: '#fff', @@ -39,4 +40,55 @@ export const sidingUsageMeanings = { LP:'Passenger Transfer', SP:'Passenger Car Storage', D:'Service & Repair', +} + +export const bezierGradeResolution = 80; +export const bezierLengthResolution = 80; +export const bezierCurvatureResolution = 80; +export const scrollZoomFactor = 1.25; +export const buttonZoomFactor = 1.5; + +export const minZoomLevel = 0.01; +export const maxZoomLevel = 60; +export const defaultMapPadding = 500; + +export const maxZoneLength = 700; + +/** How many pixels around the view is still considered "visible", beyond this and items are culled. */ +export const viewCullMargin = 60; + +export const tooltipHitzone = { + default: {radius:12}, + junction: {width:24, height:35}, +}; + +export const spriteBounds = { + unknown: new SpriteBounds(0,0,20,20), + junction: new SpriteBounds(0,20,20,20), + gradeArrow: new SpriteBounds(20,20,20,20), + gradeArrowDown: new SpriteBounds(40,20,20,20), + speed_1: new SpriteBounds(20,40,20,20), + speed_2: new SpriteBounds(40,40,20,20), + speed_3: new SpriteBounds(60,40,20,20), + speed_4: new SpriteBounds(20,60,20,20), + speed_5: new SpriteBounds(40,60,20,20), + speed_6: new SpriteBounds(60,60,20,20), + speed_7: new SpriteBounds(80,60,20,20), + speed_8: new SpriteBounds(100,60,20,20), + speed_9: new SpriteBounds(120,60,20,20), + speed_10: new SpriteBounds(140,60,20,20), + speed_12: new SpriteBounds(160,60,20,20), + office: new SpriteBounds(0,80,20,20), + office_military: new SpriteBounds(20,80,20,20), + office_museum: new SpriteBounds(40,80,20,20), + water: new SpriteBounds(0,100,20,20), + coal: new SpriteBounds(20,100,20,20), + landmark: new SpriteBounds(40,100,20,20), + shop: new SpriteBounds(60,100,20,20), + garage: new SpriteBounds(80,100,20,20), + demonstrator: new SpriteBounds(100,100,20,20), + service: new SpriteBounds(0,120,20,20), + service_repair: new SpriteBounds(20,120,20,20), + service_diesel: new SpriteBounds(40,120,20,20), + service_charger: new SpriteBounds(60,120,20,20), } \ No newline at end of file diff --git a/index.html b/index.html index d2809cf..cd96045 100644 --- a/index.html +++ b/index.html @@ -12,218 +12,11 @@ -