aboutsummaryrefslogtreecommitdiff
path: root/src/map/icon.rs
diff options
context:
space:
mode:
authorArne Dußin2020-12-21 01:22:15 +0100
committerArne Dußin2020-12-21 21:15:55 +0100
commitd7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4 (patch)
treee5633f4d3b18472922c943d759e9f58722ba4405 /src/map/icon.rs
parent48f321a80970ebeb8374072b1d2e0a4d297aa348 (diff)
downloadgraf_karto-d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4.tar.gz
graf_karto-d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4.zip
Add previously missing docs where appropriate
Diffstat (limited to 'src/map/icon.rs')
-rw-r--r--src/map/icon.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/map/icon.rs b/src/map/icon.rs
index f623c98..2e45486 100644
--- a/src/map/icon.rs
+++ b/src/map/icon.rs
@@ -1,3 +1,6 @@
+//! Icons are map elements that have a specific size and cannot be stretched. They are usually used
+//! as markers for specific places in the world.
+
use super::icon_renderer::IconRenderer;
use crate::colours::DEFAULT_COLOURS;
use crate::map::Mappable;
@@ -8,6 +11,7 @@ use serde::{Deserialize, Serialize};
use std::ops::{Deref, DerefMut};
use std::rc::Rc;
+/// The icon data necessary to create an Icon again.
#[derive(Clone, Serialize, Deserialize)]
pub struct IconData {
/// The id of the icon is the icons position in the currently loaded icon_data vector.
@@ -18,6 +22,7 @@ pub struct IconData {
pub rotation: f64,
}
+/// Describes an icon in the world and can be drawn.
#[derive(Clone)]
pub struct Icon {
data: IconData,
@@ -26,6 +31,8 @@ pub struct Icon {
}
impl Icon {
+ /// Create a new icon. Requires the icon renderer that is used to render this icon, as well as all
+ /// the information necessary to describe the icon itself.
pub fn new(id: usize, position: Vec2<f64>, rotation: f64, renderer: Rc<IconRenderer>) -> Self {
Self::from_data(
IconData {
@@ -37,6 +44,7 @@ impl Icon {
)
}
+ /// Like `new()`, but with the icon data bundled into the icon data type.
pub fn from_data(data: IconData, renderer: Rc<IconRenderer>) -> Self {
Self {
data,