0.0, 'y'=>0.0), array('x'=>90.0, 'y'=>0.0), array('x'=>90.0, 'y'=>90.0), array('x'=>0.0, 'y'=>90.0)); $copy = $points; convertPixelPointsToPercent($copy, 640, 480); check('small pixel zone is left alone without force', $copy[1]['x'], 90.0); $copy = $points; check('forced conversion reports pixels', convertPixelPointsToPercent($copy, 640, 480, true), true); check('small pixel zone x converted', $copy[1]['x'], 14.06); check('small pixel zone y converted', $copy[2]['y'], 18.75); // 90x90 px of 640x480 is 8100 px; a threshold of 50 px is 0.62% $zone = array('MinAlarmPixels'=>'50', 'MaxAlarmPixels'=>null, 'MinFilterPixels'=>'', 'MinBlobPixels'=>'8100'); convertZoneThresholdsToPercent($zone, 8100, true); check('legacy pixel threshold of 50 becomes a percentage', $zone['MinAlarmPixels'], 0.62); check('legacy null threshold stays null', $zone['MaxAlarmPixels'], null); check('legacy empty threshold stays empty', $zone['MinFilterPixels'], ''); check('legacy threshold of the whole area is 100', (float)$zone['MinBlobPixels'], 100.0); $zone = array('MinAlarmPixels'=>'50', 'MaxAlarmPixels'=>'200'); convertZoneThresholdsToPercent($zone, 8100, false); check('percent zone keeps a threshold of 50', $zone['MinAlarmPixels'], '50'); check('percent zone converts a stray pixel count', $zone['MaxAlarmPixels'], 2.47); echo "\n$passes passed, $failures failed\n"; exit($failures ? 1 : 0);