[ease] [general] Math function cleanup
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] [general] Math function cleanup
- Date: Tue, 12 Oct 2010 14:27:29 +0000 (UTC)
commit d2e511d40594ab7b0061552a80b7678f16805f5c
Author: Nate Stedman <natesm gmail com>
Date: Tue Oct 12 09:52:35 2010 -0400
[general] Math function cleanup
ease-core/ease-utilities.vala | 15 ---------------
ease/ease-editor-embed.vala | 8 ++------
ease/ease-scrollable-embed.vala | 10 ++++++----
ease/ease-slide-actor.vala | 4 ++--
ease/ease-welcome-actor.vala | 16 ++++++++--------
ease/ease-welcome-window.vala | 4 ++--
6 files changed, 20 insertions(+), 37 deletions(-)
---
diff --git a/ease-core/ease-utilities.vala b/ease-core/ease-utilities.vala
index 11e5ae1..680e198 100644
--- a/ease-core/ease-utilities.vala
+++ b/ease-core/ease-utilities.vala
@@ -367,19 +367,4 @@ namespace Ease
var file = GLib.File.new_for_path(path);
return file.resolve_relative_path(".").get_path();
}
-
- public double dmax(double a, double b)
- {
- return a > b ? a : b;
- }
-
- public double dmin(double a, double b)
- {
- return a < b ? a : b;
- }
-
- public int roundd(double num)
- {
- return (int)(num - (int)num < 0.5 ? num : num + 1);
- }
}
diff --git a/ease/ease-editor-embed.vala b/ease/ease-editor-embed.vala
index c0f5409..948ee68 100644
--- a/ease/ease-editor-embed.vala
+++ b/ease/ease-editor-embed.vala
@@ -384,13 +384,9 @@ internal class Ease.EditorEmbed : ScrollableEmbed, UndoSource
slide_actor.set_scale_full(zoom, zoom, 0, 0);
- slide_actor.x = roundd(w < width
- ? width / 2 - w / 2
- : 0);
+ slide_actor.x = Math.roundf(w < width ? width / 2 - w / 2 : 0);
- slide_actor.y = roundd(h < height
- ? height / 2 - h / 2
- : 0);
+ slide_actor.y = Math.roundf(h < height ? height / 2 - h / 2 : 0);
if (selection_rectangle != null && selected != null)
{
diff --git a/ease/ease-scrollable-embed.vala b/ease/ease-scrollable-embed.vala
index 9692c8f..b489d43 100644
--- a/ease/ease-scrollable-embed.vala
+++ b/ease/ease-scrollable-embed.vala
@@ -73,6 +73,8 @@ internal class Ease.ScrollableEmbed : Gtk.HBox
v_adjust = new Gtk.Adjustment(0, 0, 1, 0.1, 0.1, 0.1);
v_scrollbar = new Gtk.VScrollbar(v_adjust);
z_adjust = new Gtk.Adjustment(0, 0, 1, 0.1, 0.1, 0.1);
+
+ debug("%f %f", v_adjust.value, v_adjust.upper);
// set up clutter actors
viewport = new GtkClutter.Viewport(h_adjust, v_adjust, z_adjust);
@@ -150,14 +152,14 @@ internal class Ease.ScrollableEmbed : Gtk.HBox
switch (event.direction)
{
case Gdk.ScrollDirection.UP:
- v_adjust.value = dmin(v_adjust.upper,
- dmax(v_adjust.lower,
+ v_adjust.value = Math.fmin(v_adjust.upper,
+ Math.fmax(v_adjust.lower,
v_adjust.value -
v_adjust.step_increment));
break;
case Gdk.ScrollDirection.DOWN:
- v_adjust.value = dmin(v_adjust.upper,
- dmax(v_adjust.lower,
+ v_adjust.value = Math.fmin(v_adjust.upper,
+ Math.fmax(v_adjust.lower,
v_adjust.value +
v_adjust.step_increment));
break;
diff --git a/ease/ease-slide-actor.vala b/ease/ease-slide-actor.vala
index bb5998d..a1c863e 100644
--- a/ease/ease-slide-actor.vala
+++ b/ease/ease-slide-actor.vala
@@ -456,7 +456,7 @@ internal class Ease.SlideActor : Clutter.Group
internal void transition(SlideActor new_slide,
Clutter.Group container)
{
- uint length = (uint)dmax(1, slide.transition_time * 1000);
+ uint length = (uint)Math.fmax(1, slide.transition_time * 1000);
animation_time = new Clutter.Timeline(length);
@@ -1685,7 +1685,7 @@ internal class Ease.SlideActor : Clutter.Group
*/
private static uint8 clamp_opacity(double o)
{
- return (uint8)(dmax(0, dmin(255, o)));
+ return (uint8)(Math.fmax(0, Math.fmin(255, o)));
}
}
diff --git a/ease/ease-welcome-actor.vala b/ease/ease-welcome-actor.vala
index d03a43e..5a1250c 100644
--- a/ease/ease-welcome-actor.vala
+++ b/ease/ease-welcome-actor.vala
@@ -174,19 +174,19 @@ internal class Ease.WelcomeActor : Clutter.Group
*/
internal void set_actor_size(float w, float h)
{
- rect.width = roundd(w) + RECT_B_W * 2;
- rect.height = roundd(h) + RECT_B_W * 2;
+ rect.width = Math.roundf(w) + RECT_B_W * 2;
+ rect.height = Math.roundf(h) + RECT_B_W * 2;
- hilight_rect.width = roundd(w) + HLRECT_W * 2;
- hilight_rect.height = roundd(h) + HLRECT_W * 2;
+ hilight_rect.width = Math.roundf(w) + HLRECT_W * 2;
+ hilight_rect.height = Math.roundf(h) + HLRECT_W * 2;
- text.x = roundd(w / 2 - text.width / 2);
- text.y = roundd(h + TEXT_OFFSET);
+ text.x = Math.roundf(w / 2 - text.width / 2);
+ text.y = Math.roundf(h + TEXT_OFFSET);
if (slide_actor != null)
{
- slide_actor.width = roundd(w);
- slide_actor.height = roundd(h);
+ slide_actor.width = Math.roundf(w);
+ slide_actor.height = Math.roundf(h);
}
}
diff --git a/ease/ease-welcome-window.vala b/ease/ease-welcome-window.vala
index 2d070fd..6833780 100644
--- a/ease/ease-welcome-window.vala
+++ b/ease/ease-welcome-window.vala
@@ -353,8 +353,8 @@ internal class Ease.WelcomeWindow : Gtk.Window
float x_pixels = x_origin + x_position *
(PREVIEW_PADDING + preview_width);
- float x_round = roundd(x_pixels);
- float y_round = roundd(y_pixels);
+ float x_round = Math.roundf(x_pixels);
+ float y_round = Math.roundf(y_pixels);
if (animate_resize)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]