Add snowflake vertex shape

This commit is contained in:
Oleg Sh 2022-12-17 21:55:33 +02:00
parent 4eeb746d21
commit 0c26400c6c
14 changed files with 71 additions and 5 deletions

View File

@ -292,4 +292,6 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit</a>";
$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";
?>

View File

@ -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";
?>

View File

@ -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";
?>

View File

@ -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";
?>

View File

@ -292,4 +292,6 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit</a>";
$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";
?>

View File

@ -292,4 +292,6 @@ Tenemos traducciones en griego 🇬🇷.</a> <a href=\"https://github.com/UnickS
$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";
?>

View File

@ -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";
?>

View File

@ -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";
?>

View File

@ -292,4 +292,6 @@ Dodaliśmy polskie tłumaczenie, Patryk</a>";
$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";
?>

View File

@ -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";
?>

View File

@ -295,4 +295,5 @@
$g_lang["edge_list_wrong_format"] = "Неправильный формат списка рёбер";
$g_lang["fix_button"] = "исправить";
$g_lang["snowflake"] = "Снежинка";
?>

View File

@ -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";
?>

View File

@ -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;
}
}

View File

@ -11,7 +11,7 @@
<script src="<?= Root('i/js/dev/jquery-ui.js')?>"></script>
<script src="<?= Root('i/js/dev/jquery.feedback_me.js')?>"></script>
<script src="<?= Root("script/canvas2svg.js")?>" ></script>
<script src="<?= Root("script/example.js?v=68")?>" ></script>
<script src="<?= Root("script/example.js?v=69")?>" ></script>
<!-- Yandex.RTB -->
<script>window.yaContextCb=window.yaContextCb||[]</script>
@ -536,6 +536,7 @@
<option value="2"><?= L('triangle')?></option>
<option value="3"><?= L('pentagon')?></option>
<option value="5"><?= L('textbox')?></option>
<option value="6"><?= L('snowflake')?></option>
</select>
</div>
</div>