Revision: 2059
http://synfig.svn.sourceforge.net/synfig/?rev=2059&view=rev
Author: dooglus
Date: 2008-09-18 08:58:59 +0000 (Thu, 18 Sep 2008)
Log Message:
-----------
Use #defined constants for converting between different units.
Modified Paths:
--------------
synfig-core/trunk/src/synfig/distance.cpp
Modified: synfig-core/trunk/src/synfig/distance.cpp
===================================================================
--- synfig-core/trunk/src/synfig/distance.cpp 2008-09-17 20:27:17 UTC (rev
2058)
+++ synfig-core/trunk/src/synfig/distance.cpp 2008-09-18 08:58:59 UTC (rev
2059)
@@ -43,12 +43,16 @@
/* === M A C R O S ========================================================= */
-#define POINTS_PER_INCH (72.0)
+#define POINTS_PER_INCH (72.0)
+#define INCHES_PER_METER (39.3700787402)
+#define POINTS_PER_METER (POINTS_PER_INCH*INCHES_PER_METER)
+#define CENTIMETERS_PER_METER (100.0)
+#define MILLIMETERS_PER_METER (1000.0)
+#define METERS_PER_UNIT
(rend_desc.get_physical_w()/abs(rend_desc.get_tl()[0]-rend_desc.get_br()[0]))
+
/* === G L O B A L S ======================================================= */
-#define METERS_PER_UNIT
(rend_desc.get_physical_w()/abs(rend_desc.get_tl()[0]-rend_desc.get_br()[0]))
-
/* === P R O C E D U R E S ================================================= */
/* === M E T H O D S ======================================================= */
@@ -130,11 +134,11 @@
{
switch(system_)
{
- case SYSTEM_INCHES: return value_/39.3700787402;
- case SYSTEM_POINTS: return value_/POINTS_PER_INCH/39.3700787402;
- case SYSTEM_METERS: return value_;
- case SYSTEM_CENTIMETERS: return value_/100.0;
- case SYSTEM_MILLIMETERS: return value_/1000.0;
+ case SYSTEM_INCHES: return value_/INCHES_PER_METER;
+ case SYSTEM_POINTS: return value_/POINTS_PER_METER;
+ case SYSTEM_METERS: return value_;
+ case SYSTEM_CENTIMETERS: return value_/CENTIMETERS_PER_METER;
+ case SYSTEM_MILLIMETERS: return value_/MILLIMETERS_PER_METER;
default: throw BadSystem();
}
}
@@ -174,11 +178,11 @@
{
switch(target_system)
{
- case SYSTEM_INCHES: return x*39.3700787402;
- case SYSTEM_POINTS: return x*39.3700787402*POINTS_PER_INCH;
- case SYSTEM_METERS: return x;
- case SYSTEM_CENTIMETERS: return x*100.0;
- case SYSTEM_MILLIMETERS: return x*1000.0;
+ case SYSTEM_INCHES: return x*INCHES_PER_METER;
+ case SYSTEM_POINTS: return x*POINTS_PER_METER;
+ case SYSTEM_METERS: return x;
+ case SYSTEM_CENTIMETERS: return x*CENTIMETERS_PER_METER;
+ case SYSTEM_MILLIMETERS: return x*MILLIMETERS_PER_METER;
default: throw BadSystem();
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl