1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- use std::fmt::Debug;
- use binrw::{BinRead, BinWrite};
- use diff::Diff;
- use crate::{
- field_of::FieldOf,
- types::{Field, ObjectType, Point, F64, U32},
- };
- use super::{ObjectCore, Translate};
- #[cfg_attr(feature = "default-debug", derive(Debug))]
- #[derive(BinRead, BinWrite, Clone, Diff, PartialEq)]
- #[diff(attr(
- #[derive(Debug, PartialEq)]
- ))]
- pub struct Ellipse {
- pub core: ObjectCore,
- #[brw(magic(8u32))] // Number of following fields in struct
- pub clockwise: U32,
- pub corner_a: FieldOf<Point>,
- pub corner_b: FieldOf<Point>,
- pub start_angle: F64, // Radians
- pub end_angle: F64, // Radians
- pub _unknown_1: [Field; 2],
- pub open_curve: U32,
- }
- // Custom Debug implementation to only print known fields
- #[cfg(not(feature = "default-debug"))]
- impl Debug for Ellipse {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- f.debug_struct("Ellipse")
- .field("core", &self.core)
- .field("clockwise", &self.clockwise)
- .field("corner_a", &self.corner_a)
- .field("corner_b", &self.corner_b)
- .field("start_angle", &self.start_angle)
- .field("end_angle", &self.end_angle)
- .field("open_curve", &self.open_curve)
- .finish()
- }
- }
- impl Default for Ellipse {
- fn default() -> Self {
- Self {
- core: ObjectCore::default(ObjectType::Ellipse),
- clockwise: 0.into(),
- corner_a: Point { x: 0.0, y: 0.0 }.into(),
- corner_b: Point { x: 0.0, y: 0.0 }.into(),
- start_angle: 0.0.into(),
- end_angle: 0.0.into(),
- _unknown_1: [
- vec![0, 0, 0, 0].into(), // 0_u32
- vec![
- 0, 0, 0, 0, 0, 0, 240, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 63,
- ] // ???
- .into(),
- ],
- open_curve: 0.into(),
- }
- }
- }
- impl Translate for Ellipse {
- fn translate(&mut self, origin: Option<Point>, z: Option<f64>) {
- self.core.translate(origin, z);
- origin.map(|origin| {
- *self.corner_a += origin;
- *self.corner_b += origin;
- });
- }
- }
|