Commit 08779a1b by sn

einheiten

1 parent 365df977
......@@ -148,10 +148,10 @@ class D {
// self::new_echo("<br>______________________<br>", $param_print, $param_force);
self::printCurrentFunction($param_print,"<br>______________________<br>");
self::printCurrentFunction($param_print,"<br>______________________<br>", true);
// self::new_echo("<b>show(".$param_string.")</b>", $param_print, $param_force);
$string_show = "<br /><b>show(".$param_string.")</b><br />";
$string_show = "<br /><b>show(".$param_string.") -- </b><br />";
if(is_object($param_val) && get_class($param_val)=='DOMElement') {
D::showdomelement($param_val, $string_show.$param_string,$param_print, $param_force);
......
<?php
class mcUnityCalculator {
public static $UNITS = array(
'in' => array(
'mm' => 25.4,
'cm' => 2.54,
'in' => 1,
'pt' => 72,
'pc' => 6,
'px' => false,
)
);
/**
* transform $param_in_number $param_in_unit to $param_out_unit
*
* @param number $param_in_number
* @param string $param_in_unit
* @param string $param_out_unit
* @return number
*/
public static function to($param_in_number, $param_in_unit, $param_out_unit){
$inchNumber = mcUnityCalculator::toInch($param_in_number, $param_in_unit);
$outNumber = mcUnityCalculator::inchTo($inchNumber, $param_out_unit);
return $outNumber;
}
public static function calculateDpi($param_px_number, $param_number, $param_unit) {
$inch_outNumber = mcUnityCalculator::toInch($param_number, $param_unit);
$dpi = $param_px_number / $inch_outNumber;
return $dpi;
}
/**
*
* @param type $param_number - number in inch / zahl in zoll
* @param string $param_unit - mm / cm / in / pt / pc / px
* @return type
*/
private static function inchTo($param_number, $param_unit, $param_dpi=300) {
if(array_key_exists($param_unit, mcUnityCalculator::$UNITS['in'])) {
if($param_unit != 'px') {
return $param_number * mcUnityCalculator::$UNITS['in'][$param_unit];
} else {
return mcUnityCalculator::inchToPx($param_number, $param_dpi);
}
} else {
return Error::newError('falsche Einheit', '');
}
}
/**
*
* @param type $param_number - number in inch / zahl in zoll
* @param string $param_unit - mm / cm / in / pt / pc / px
* @return type
*/
private static function toInch($param_number, $param_unit, $param_dpi=300) {
if(array_key_exists($param_unit, mcUnityCalculator::$UNITS['in'])) {
if($param_unit != 'px') {
return $param_number / mcUnityCalculator::$UNITS['in'][$param_unit];
} else {
return mcUnityCalculator::pxToInch($param_number, $param_dpi);
}
} else {
return Error::newError('falsche Einheit', '');
}
}
// /**
// *
// * @param type $param_number
// * @param type $param_unit
// * @param type $param_dpi
// * @return type
// */
// public static function toPx($param_number, $param_unit, $param_dpi) {
// $inch = mcUnityCalculator::toInch($param_number, $param_unit);
// $px = mcUnityCalculator::inchToPx($inch, $param_dpi);
// return $px;
// }
private static function pxToInch($param_px, $param_dpi) {
return $param_px / $param_dpi;
}
private static function inchToPx($param_inch, $param_dpi) {
return $param_inch * $param_dpi;
}
}
?>
......@@ -65,6 +65,7 @@ class mcCairoSvg {
$inkscape_order = "cairosvg.sh $param_in_svg $param_out_pdf";
$shell_exec = shell_exec($inkscape_order);
D::show($shell_exec, $inkscape_order);
return $param_out_pdf;
}
......
......@@ -75,4 +75,6 @@ require_once $__PATH_to_mcClasses . 'mcPUIX/class_mcPUIX_CONFIG.inc.php';
require_once $__PATH_to_mcClasses . 'mcPUIX/class_mcPUIX_DOM.inc.php';
require_once $__PATH_to_mcClasses . 'mcPUIX/class_Converter.inc.php';
require_once $__PATH_to_mcClasses . 'class_mcUnityCalculator.inc.php';
?>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!