x,1=>y - ako var $inputArray = array(); /** * Do some tasks before drawing (get max Y value - ako) **/ function startDrawing() { // ClickHeat needs the maximum Y value for some reason (haven't actually investigated.) // Get Y dimensions from source array // - ako $ys = array(); foreach ($this->inputArray as $coords) { $ys[]=$coords[1]; } // Get max Y value from new array. -ako $this->maxY = max($ys); return true; } /** * Find pixels coords and draw these on the current image * * @param integer $image Number of the image (to be used with $this->height) * @return boolean Success **/ function drawPixels($image) { foreach ($this->inputArray as $click) { $x = (int) $click[0]; $y = (int) ($click[1] - $image * $this->height); if ($x < 0 || $x >= $this->width) { continue; } /** Apply a calculus for the step, with increases the speed of rendering : step = 3, then pixel is drawn at x = 2 (center of a 3x3 square) */ $x -= $x % $this->step - $this->startStep; $y -= $y % $this->step - $this->startStep; /** Add 1 to the current color of this pixel (color which represents the sum of clicks on this pixel) */ $color = imagecolorat($this->image, $x, $y) + 1; imagesetpixel($this->image, $x, $y, $color); $this->maxClicks = max($this->maxClicks, $color); if ($image === 0) { /** Looking for the maximum height of click */ $this->maxY = max($y, $this->maxY); } } } /** * Do some cleaning or ending tasks (close database, reset array...) **/ function finishDrawing() { /** Close connection */ return true; } } ?>