summaryrefslogtreecommitdiff
path: root/navit/layout.c
diff options
context:
space:
mode:
authorStefan Wildemann <metalstrolch@users.noreply.github.com>2022-01-01 14:12:44 +0100
committerGitHub <noreply@github.com>2022-01-01 14:12:44 +0100
commit17f1a6ec6aebbc51a67be6ac6064d231ce02a62e (patch)
treeade88ff515cba3763fc9ac00ec2f0a392ec32ba5 /navit/layout.c
parent13e550f93052ef6d51fcbde76cd6796a3cc6bb4e (diff)
downloadnavit-17f1a6ec6aebbc51a67be6ac6064d231ce02a62e.tar.gz
feature: graphics: allow spiked lines for cliff and embarkments (#1174)
* feature: graphics: allow spiked lines for cliff and embarkments This adds another drwing element to graphics system. It can produce lines with spikes as used for cliffs on maps. Additionally this adds embarlment support for map. * review fixes. Add changes requested by review, plus add paranoia check on xml parameter.
Diffstat (limited to 'navit/layout.c')
-rw-r--r--navit/layout.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/navit/layout.c b/navit/layout.c
index 0889fb52b..2300ab68d 100644
--- a/navit/layout.c
+++ b/navit/layout.c
@@ -399,6 +399,7 @@ int itemgra_add_attr(struct itemgra *itemgra, struct attr *attr) {
case attr_icon:
case attr_image:
case attr_arrows:
+ case attr_spikes:
itemgra->elements = g_list_append(itemgra->elements, attr->u.element);
return 1;
default:
@@ -446,6 +447,27 @@ static void element_set_arrows_width(struct element *e, struct attr **attrs) {
e->u.arrows.width=10;
}
+static void element_set_spikes_width(struct element *e, struct attr **attrs) {
+ struct attr *width;
+ width=attr_search(attrs, attr_width);
+ if (width)
+ e->u.spikes.width=width->u.num;
+ else
+ e->u.spikes.width=10;
+}
+
+static void element_set_spikes_distance(struct element *e, struct attr **attrs) {
+ struct attr *distance;
+ distance=attr_search(attrs, attr_distance);
+ if (distance) {
+ e->u.spikes.distance=distance->u.num;
+ /* paranoia check. We divide with that value */
+ if(e->u.spikes.distance < 1)
+ e->u.spikes.distance = 1;
+ } else
+ e->u.spikes.distance=10;
+}
+
static void element_set_polyline_width(struct element *e, struct attr **attrs) {
struct attr *width;
width=attr_search(attrs, attr_width);
@@ -651,6 +673,17 @@ arrows_new(struct attr *parent, struct attr **attrs) {
return (struct arrows *)e;
}
+struct spikes *
+spikes_new(struct attr *parent, struct attr **attrs) {
+ struct element *e;
+ e = g_malloc0(sizeof(*e));
+ e->type=element_spikes;
+ element_set_color(e, attrs);
+ element_set_spikes_width(e, attrs);
+ element_set_spikes_distance(e, attrs);
+ return (struct spikes *)e;
+}
+
int element_add_attr(struct element *e, struct attr *attr) {
switch (attr->type) {
case attr_coord: