From 0c26400c6ca02ec4c9a672134eabb6e2c6914c69 Mon Sep 17 00:00:00 2001 From: Oleg Sh Date: Sat, 17 Dec 2022 21:55:33 +0200 Subject: [PATCH] Add snowflake vertex shape --- lang/bg/home.php | 2 ++ lang/ch/home.php | 2 ++ lang/de/home.php | 2 ++ lang/el/home.php | 2 ++ lang/en/home.php | 2 ++ lang/es/home.php | 2 ++ lang/fr/home.php | 2 ++ lang/nl/home.php | 2 ++ lang/pl/home.php | 2 ++ lang/pt/home.php | 2 ++ lang/ru/home.php | 3 ++- lang/sv/home.php | 2 ++ script/BaseVertexDrawer.js | 48 +++++++++++++++++++++++++++++++++++--- tpl/home.php | 3 ++- 14 files changed, 71 insertions(+), 5 deletions(-) diff --git a/lang/bg/home.php b/lang/bg/home.php index a7a5cf5..3f57f23 100644 --- a/lang/bg/home.php +++ b/lang/bg/home.php @@ -292,4 +292,6 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit"; $g_lang["bad_inc_pair_message"] = "Cannot create graph. Edge list has wrong format. Click \"fix\" button to fix edge list or \"help\" button to open help about format"; $g_lang["edge_list_wrong_format"] = "Edge list format is incorrect"; $g_lang["fix_button"] = "fix"; + + $g_lang["snowflake"] = "Snowflake"; ?> diff --git a/lang/ch/home.php b/lang/ch/home.php index e8394e6..2e14c69 100644 --- a/lang/ch/home.php +++ b/lang/ch/home.php @@ -292,4 +292,6 @@ $g_lang["bad_inc_pair_message"] = "Cannot create graph. Edge list has wrong format. Click \"fix\" button to fix edge list or \"help\" button to open help about format"; $g_lang["edge_list_wrong_format"] = "Edge list format is incorrect"; $g_lang["fix_button"] = "fix"; + + $g_lang["snowflake"] = "Snowflake"; ?> diff --git a/lang/de/home.php b/lang/de/home.php index 502d0c2..4fdc023 100644 --- a/lang/de/home.php +++ b/lang/de/home.php @@ -255,4 +255,6 @@ $g_lang["bad_inc_pair_message"] = "Cannot create graph. Edge list has wrong format. Click \"fix\" button to fix edge list or \"help\" button to open help about format"; $g_lang["edge_list_wrong_format"] = "Edge list format is incorrect"; $g_lang["fix_button"] = "fix"; + + $g_lang["snowflake"] = "Schneeflocke"; ?> diff --git a/lang/el/home.php b/lang/el/home.php index 0e375d7..7390d08 100644 --- a/lang/el/home.php +++ b/lang/el/home.php @@ -293,4 +293,6 @@ $g_lang["bad_inc_pair_message"] = "Cannot create graph. Edge list has wrong format. Click \"fix\" button to fix edge list or \"help\" button to open help about format"; $g_lang["edge_list_wrong_format"] = "Edge list format is incorrect"; $g_lang["fix_button"] = "fix"; + + $g_lang["snowflake"] = "Snowflake"; ?> diff --git a/lang/en/home.php b/lang/en/home.php index 02c238c..6c9e67e 100755 --- a/lang/en/home.php +++ b/lang/en/home.php @@ -292,4 +292,6 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit"; $g_lang["bad_inc_pair_message"] = "Cannot create graph. Edge list has wrong format. Click \"fix\" button to fix edge list or \"help\" button to open help about format"; $g_lang["edge_list_wrong_format"] = "Edge list format is incorrect"; $g_lang["fix_button"] = "fix"; + + $g_lang["snowflake"] = "Snowflake"; ?> diff --git a/lang/es/home.php b/lang/es/home.php index 8f599b7..8a2b97a 100755 --- a/lang/es/home.php +++ b/lang/es/home.php @@ -292,4 +292,6 @@ Tenemos traducciones en griego 🇬🇷. diff --git a/lang/fr/home.php b/lang/fr/home.php index 4737d67..9b91b6f 100644 --- a/lang/fr/home.php +++ b/lang/fr/home.php @@ -260,4 +260,6 @@ $g_lang["bad_inc_pair_message"] = "Cannot create graph. Edge list has wrong format. Click \"fix\" button to fix edge list or \"help\" button to open help about format"; $g_lang["edge_list_wrong_format"] = "Edge list format is incorrect"; $g_lang["fix_button"] = "fix"; + + $g_lang["snowflake"] = "Snowflake"; ?> diff --git a/lang/nl/home.php b/lang/nl/home.php index 7d9b717..410f49c 100644 --- a/lang/nl/home.php +++ b/lang/nl/home.php @@ -257,4 +257,6 @@ $g_lang["bad_inc_pair_message"] = "Cannot create graph. Edge list has wrong format. Click \"fix\" button to fix edge list or \"help\" button to open help about format"; $g_lang["edge_list_wrong_format"] = "Edge list format is incorrect"; $g_lang["fix_button"] = "fix"; + + $g_lang["snowflake"] = "Snowflake"; ?> diff --git a/lang/pl/home.php b/lang/pl/home.php index 1472d73..7df3a5e 100644 --- a/lang/pl/home.php +++ b/lang/pl/home.php @@ -292,4 +292,6 @@ Dodaliśmy polskie tłumaczenie, Patryk"; $g_lang["bad_inc_pair_message"] = "Nie można stworzyć grafu. Lista krawędzi ma zły format. Kliknij \"fix\" przycisk,a= aby naprawić listę krawędzi lub \"help\" przycisk aby otworzyć stronę z pomocą dotyczącą formatu pliku"; $g_lang["edge_list_wrong_format"] = "Format listy krawędzi jest niepoprawny"; $g_lang["fix_button"] = "Napraw"; + + $g_lang["snowflake"] = "Snowflake"; ?> diff --git a/lang/pt/home.php b/lang/pt/home.php index b148916..2a25a3e 100644 --- a/lang/pt/home.php +++ b/lang/pt/home.php @@ -258,4 +258,6 @@ $g_lang["bad_inc_pair_message"] = "Cannot create graph. Edge list has wrong format. Click \"fix\" button to fix edge list or \"help\" button to open help about format"; $g_lang["edge_list_wrong_format"] = "Edge list format is incorrect"; $g_lang["fix_button"] = "fix"; + + $g_lang["snowflake"] = "Snowflake"; ?> diff --git a/lang/ru/home.php b/lang/ru/home.php index ea3834a..1e936a9 100755 --- a/lang/ru/home.php +++ b/lang/ru/home.php @@ -294,5 +294,6 @@ $g_lang["bad_inc_pair_message"] = "Ошибка создания графа. Список рёбер имеет неправильный формат. Нажимте кнопку \"исправить\" чтобы исправить список или кнопку \"справка\" чтобы открыть справку о формате"; $g_lang["edge_list_wrong_format"] = "Неправильный формат списка рёбер"; $g_lang["fix_button"] = "исправить"; - + + $g_lang["snowflake"] = "Снежинка"; ?> diff --git a/lang/sv/home.php b/lang/sv/home.php index bd7b1ff..4d832de 100644 --- a/lang/sv/home.php +++ b/lang/sv/home.php @@ -254,4 +254,6 @@ $g_lang["bad_inc_pair_message"] = "Cannot create graph. Edge list has wrong format. Click \"fix\" button to fix edge list or \"help\" button to open help about format"; $g_lang["edge_list_wrong_format"] = "Edge list format is incorrect"; $g_lang["fix_button"] = "fix"; + + $g_lang["snowflake"] = "Snowflake"; ?> diff --git a/script/BaseVertexDrawer.js b/script/BaseVertexDrawer.js index 7aa2a38..d8d4324 100644 --- a/script/BaseVertexDrawer.js +++ b/script/BaseVertexDrawer.js @@ -11,7 +11,8 @@ const VertexCircleShape = 0, VertexTriangleShape = 2, VertexPentagonShape = 3, VertexHomeShape = 4, - VertextTextboxShape = 5; + VertexTextboxShape = 5; + VertexSnowflakeShape = 6; // Common text position const CommonTextCenter = 0, @@ -88,6 +89,44 @@ function GetTextboxPoints(diameter, text) return res; } +function GetShowflakePoints(diameter) +{ + var res = []; + + var superSmallRadius = diameter * 0.8 / 2; + var smallRadius = diameter * 0.95 / 2; + var bigRadius = diameter * 1.5 / 2; + let angel = 8; + + res.push(new Point(superSmallRadius, 0).rotate(new Point(0, 0), - angel)); + res.push(new Point(smallRadius, 0)); + res.push(new Point(superSmallRadius, 0).rotate(new Point(0, 0), angel)); + res.push(new Point(bigRadius, 0).rotate(new Point(0, 0), 30)); + res.push(new Point(superSmallRadius, 0).rotate(new Point(0, 0), 60 - angel)); + res.push(new Point(smallRadius, 0).rotate(new Point(0, 0), 60)); + res.push(new Point(superSmallRadius, 0).rotate(new Point(0, 0), 60 + angel)); + res.push(new Point(bigRadius, 0).rotate(new Point(0, 0), 30 + 60)); + res.push(new Point(superSmallRadius, 0).rotate(new Point(0, 0), 60 + 60 - angel)); + res.push(new Point(smallRadius, 0).rotate(new Point(0, 0), 60 + 60)); + res.push(new Point(superSmallRadius, 0).rotate(new Point(0, 0), 60 + 60 + angel)); + res.push(new Point(bigRadius, 0).rotate(new Point(0, 0), 30 + 60 + 60)); + res.push(new Point(superSmallRadius, 0).rotate(new Point(0, 0), 60 + 60 + 60 - angel)); + res.push(new Point(smallRadius, 0).rotate(new Point(0, 0), 60 + 60 + 60)); + res.push(new Point(superSmallRadius, 0).rotate(new Point(0, 0), 60 + 60 + 60 + angel)); + + res.push(new Point(bigRadius, 0).rotate(new Point(0, 0), 30 + 60 + 60 + 60)); + res.push(new Point(superSmallRadius, 0).rotate(new Point(0, 0), 60 + 60 + 60 + 60 - angel)); + res.push(new Point(smallRadius, 0).rotate(new Point(0, 0), 60 + 60 + 60 + 60)); + res.push(new Point(superSmallRadius, 0).rotate(new Point(0, 0), 60 + 60 + 60 + 60 + angel)); + res.push(new Point(bigRadius, 0).rotate(new Point(0, 0), 30 + 60 + 60 + 60 + 60)); + res.push(new Point(superSmallRadius, 0).rotate(new Point(0, 0), 60 + 60 + 60 + 60 + 60 - angel)); + res.push(new Point(smallRadius, 0).rotate(new Point(0, 0), 60 + 60 + 60 + 60 + 60)); + res.push(new Point(superSmallRadius, 0).rotate(new Point(0, 0), 60 + 60 + 60 + 60 + 60 + angel)); + res.push(new Point(bigRadius, 0).rotate(new Point(0, 0), 30 + 60 + 60 + 60 + 60 + 60)); + + return res; +} + function GetPointsForShape(shape, diameter, text=null) { switch (parseInt(shape)) @@ -95,7 +134,8 @@ function GetPointsForShape(shape, diameter, text=null) case VertexSquareShape: return GetSquarePoints(diameter); break; case VertexTriangleShape: return GetTrianglePoints(diameter); break; case VertexPentagonShape: return GetPentagonPoints(diameter); break; - case VertextTextboxShape: return GetTextboxPoints(diameter, text); break; + case VertexTextboxShape: return GetTextboxPoints(diameter, text); break; + case VertexSnowflakeShape: return GetShowflakePoints(diameter); break; default: return null; break; } } @@ -107,7 +147,9 @@ function GetSizeForShape(shape, diameter) case VertexSquareShape: return diameter; break; case VertexTriangleShape: return diameter * 1.5; break; case VertexPentagonShape: return diameter * 1.2; break; - case VertextTextboxShape: return diameter; break; + case VertexTextboxShape: return diameter; break; + case VertexSnowflakeShape: return diameter * 1.5; break; + default: return diameter; break; } } diff --git a/tpl/home.php b/tpl/home.php index 087e154..2eb4d3a 100755 --- a/tpl/home.php +++ b/tpl/home.php @@ -11,7 +11,7 @@ - + @@ -536,6 +536,7 @@ +