Skip to content
Snippets Groups Projects
Unverified Commit cb41455c authored by Matt Hall's avatar Matt Hall Committed by GitHub
Browse files

Merge pull request #84 from tatref/point

Add ObjectShape::Point for object layer
parents 50baa8b2 85269e0a
No related branches found
No related tags found
No related merge requests found
...@@ -817,6 +817,7 @@ pub enum ObjectShape { ...@@ -817,6 +817,7 @@ pub enum ObjectShape {
Ellipse { width: f32, height: f32 }, Ellipse { width: f32, height: f32 },
Polyline { points: Vec<(f32, f32)> }, Polyline { points: Vec<(f32, f32)> },
Polygon { points: Vec<(f32, f32)> }, Polygon { points: Vec<(f32, f32)> },
Point(f32, f32),
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone)]
...@@ -885,6 +886,10 @@ impl Object { ...@@ -885,6 +886,10 @@ impl Object {
shape = Some(Object::new_polygon(attrs)?); shape = Some(Object::new_polygon(attrs)?);
Ok(()) Ok(())
}, },
"point" => |_| {
shape = Some(Object::new_point(x, y)?);
Ok(())
},
"properties" => |_| { "properties" => |_| {
properties = parse_properties(parser)?; properties = parse_properties(parser)?;
Ok(()) Ok(())
...@@ -938,6 +943,10 @@ impl Object { ...@@ -938,6 +943,10 @@ impl Object {
Ok(ObjectShape::Polygon { points: points }) Ok(ObjectShape::Polygon { points: points })
} }
fn new_point(x: f32, y: f32) -> Result<ObjectShape, TiledError> {
Ok(ObjectShape::Point(x, y))
}
fn parse_points(s: String) -> Result<Vec<(f32, f32)>, TiledError> { fn parse_points(s: String) -> Result<Vec<(f32, f32)>, TiledError> {
let pairs = s.split(' '); let pairs = s.split(' ');
let mut points = Vec::new(); let mut points = Vec::new();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment