Fix polygon overflow (#644)

* changed polygon side to u32 + set max polygon side to 1000

* revert unnecessary change

* Include unwrap for vertices input
This commit is contained in:
Thomas Cheng 2022-05-20 16:40:01 -04:00 committed by Keavon Chambers
parent 29e00e488b
commit 4c3c925c2c
3 changed files with 7 additions and 7 deletions

View File

@ -23,7 +23,7 @@ pub struct ShapeTool {
} }
pub struct ShapeOptions { pub struct ShapeOptions {
vertices: u8, vertices: u32,
} }
impl Default for ShapeOptions { impl Default for ShapeOptions {
@ -53,7 +53,7 @@ pub enum ShapeToolMessage {
#[remain::sorted] #[remain::sorted]
#[derive(PartialEq, Clone, Debug, Hash, Serialize, Deserialize)] #[derive(PartialEq, Clone, Debug, Hash, Serialize, Deserialize)]
pub enum ShapeOptionsUpdate { pub enum ShapeOptionsUpdate {
Vertices(u8), Vertices(u32),
} }
impl PropertyHolder for ShapeTool { impl PropertyHolder for ShapeTool {
@ -64,8 +64,8 @@ impl PropertyHolder for ShapeTool {
value: Some(self.options.vertices as f64), value: Some(self.options.vertices as f64),
is_integer: true, is_integer: true,
min: Some(3.), min: Some(3.),
max: Some(256.), max: Some(1000.),
on_update: WidgetCallback::new(|number_input: &NumberInput| ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::Vertices(number_input.value.unwrap() as u8)).into()), on_update: WidgetCallback::new(|number_input: &NumberInput| ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::Vertices(number_input.value.unwrap() as u32)).into()),
..NumberInput::default() ..NumberInput::default()
}))], }))],
}]) }])
@ -123,7 +123,7 @@ impl Default for ShapeToolFsmState {
} }
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
struct ShapeToolData { struct ShapeToolData {
sides: u8, sides: u32,
data: Resize, data: Resize,
} }

View File

@ -105,7 +105,7 @@ impl ShapeLayer {
/// ///
/// # Panics /// # Panics
/// This function panics if `sides` is zero. /// This function panics if `sides` is zero.
pub fn ngon(sides: u8, style: PathStyle) -> Self { pub fn ngon(sides: u32, style: PathStyle) -> Self {
use std::f64::consts::{FRAC_PI_2, TAU}; use std::f64::consts::{FRAC_PI_2, TAU};
fn unit_rotation(theta: f64) -> DVec2 { fn unit_rotation(theta: f64) -> DVec2 {

View File

@ -95,7 +95,7 @@ pub enum Operation {
path: Vec<LayerId>, path: Vec<LayerId>,
insert_index: isize, insert_index: isize,
transform: [f64; 6], transform: [f64; 6],
sides: u8, sides: u32,
style: style::PathStyle, style: style::PathStyle,
}, },
AddOverlayShape { AddOverlayShape {