From feefe1b0a612416b7ee9c289eb9bed306b0b7517 Mon Sep 17 00:00:00 2001 From: haraldhv Date: Sun, 25 Feb 2007 17:53:36 +0000 Subject: [PATCH] Changed sum formula --- lib/settings.cpp | 5 +++++ lib/state.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/settings.cpp b/lib/settings.cpp index 10b8874..ab9e089 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -4,4 +4,9 @@ Settings::Settings( void ) { colorThreshold[0] = 100; colorThreshold[1] = 1000; + + ul.x = bl.x = ul.y = ur.y = 30; + ur.x = br.x = 610; + br.y = bl.y = 450; + } diff --git a/lib/state.cpp b/lib/state.cpp index 0d7c53a..a970b6f 100644 --- a/lib/state.cpp +++ b/lib/state.cpp @@ -42,16 +42,16 @@ State State::generateState (SDL_Surface *boardImg, Settings settings) int i, j, x, y, r, sum; point p; r = 10; //what kind of magic number is this? - for (i = 0; i < size; i++) { - for (j = 0; j < size; j++) { //for all points: + for (i = 0; i < size; ++i) { + for (j = 0; j < size; ++j) { //for all points: p = positionPoint(i, j, settings); //retrieve the estimated point sum = 0; //TODO: this loop should be placed into its own function! - for (y = p.y-r; y < p.y+r; y++) { - for (x = p.x-r; x < p.x+r; x++) { //for -20 to 20 around the point + for (y = p.y-r; y < p.y+r; ++y) { + for (x = p.x-r; x < p.x+r; ++x) { //for -10 to 10 around the point uint32_t px = PX(boardImg, x, y); - sum += (1024 -PXR(px) - PXG(px) + PXB(px)); //sum up the colors + sum += (PXR(px) + PXG(px) + PXB(px)); //sum up the colors } } sum/=400;