Skip to content

Commit

Permalink
Quantize input
Browse files Browse the repository at this point in the history
  • Loading branch information
sweavo committed Feb 19, 2020
1 parent 896ff1e commit f366d57
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Timeboxer/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ private double get_angle_from_vector(Point p)
}
}

// Round to nearest _granularity_
private int Quantize( int input, int granularity)
{
return granularity * (int)((input + (granularity / 2)) / granularity);
}

private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
Point mouse_at = e.Location;
Expand All @@ -185,9 +191,9 @@ private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
if (e.Button == MouseButtons.Right)
{
// Get angle through the mouse position
mouse_angle = get_angle_from_vector(mouse_at);
mouse_angle = Quantize( (int)get_angle_from_vector(mouse_at), 3);

double mouse_period = mouse_angle / 6.0;
double mouse_period = mouse_angle / 6.0 + (1.0/60.0);
alarm_time = DateTime.Now.AddMinutes(mouse_period);
}

Expand Down

0 comments on commit f366d57

Please sign in to comment.