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:
parent
29e00e488b
commit
4c3c925c2c
|
|
@ -23,7 +23,7 @@ pub struct ShapeTool {
|
|||
}
|
||||
|
||||
pub struct ShapeOptions {
|
||||
vertices: u8,
|
||||
vertices: u32,
|
||||
}
|
||||
|
||||
impl Default for ShapeOptions {
|
||||
|
|
@ -53,7 +53,7 @@ pub enum ShapeToolMessage {
|
|||
#[remain::sorted]
|
||||
#[derive(PartialEq, Clone, Debug, Hash, Serialize, Deserialize)]
|
||||
pub enum ShapeOptionsUpdate {
|
||||
Vertices(u8),
|
||||
Vertices(u32),
|
||||
}
|
||||
|
||||
impl PropertyHolder for ShapeTool {
|
||||
|
|
@ -64,8 +64,8 @@ impl PropertyHolder for ShapeTool {
|
|||
value: Some(self.options.vertices as f64),
|
||||
is_integer: true,
|
||||
min: Some(3.),
|
||||
max: Some(256.),
|
||||
on_update: WidgetCallback::new(|number_input: &NumberInput| ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::Vertices(number_input.value.unwrap() as u8)).into()),
|
||||
max: Some(1000.),
|
||||
on_update: WidgetCallback::new(|number_input: &NumberInput| ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::Vertices(number_input.value.unwrap() as u32)).into()),
|
||||
..NumberInput::default()
|
||||
}))],
|
||||
}])
|
||||
|
|
@ -123,7 +123,7 @@ impl Default for ShapeToolFsmState {
|
|||
}
|
||||
#[derive(Clone, Debug, Default)]
|
||||
struct ShapeToolData {
|
||||
sides: u8,
|
||||
sides: u32,
|
||||
data: Resize,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ impl ShapeLayer {
|
|||
///
|
||||
/// # Panics
|
||||
/// 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};
|
||||
|
||||
fn unit_rotation(theta: f64) -> DVec2 {
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ pub enum Operation {
|
|||
path: Vec<LayerId>,
|
||||
insert_index: isize,
|
||||
transform: [f64; 6],
|
||||
sides: u8,
|
||||
sides: u32,
|
||||
style: style::PathStyle,
|
||||
},
|
||||
AddOverlayShape {
|
||||
|
|
|
|||
Loading…
Reference in New Issue