public function add($color, $untilX) 
    {
        $samplesLeft = 
            (int)($untilX * $this->samplesPerPixel) - 
            $this->subPixelOffset - 
            $this->pixelOffset * $this->samplesPerPixel;

        // ColorUtils methods inlined for performance reasons
        $a = ($color) & 0xff;
        $r = ($color >> 24) & 0xff;
        $g = ($color >> 16) & 0xff;
        $b = ($color >> 8) & 0xff;
        
        // First partial pixel
        if ($this->subPixelOffset > 0) {
            $samples = $this->samplesPerPixel - $this->subPixelOffset;
            if ($samples > $samplesLeft) {
                $samples = $samplesLeft;
            }
            $samplesLeft -= $samples;

            $this->_add($samples, $a, $r, $g, $b);

            $this->subPixelOffset += $samples;
            if ($this->subPixelOffset == $this->samplesPerPixel) {
                $this->subPixelOffset = 0;
                $this->pixelOffset++;
            }
        }

        // Full pixels
        $fullPixels = (int)($samplesLeft / $this->samplesPerPixel);
        if ($fullPixels > 0) {
            for ($i = 0; $i < $fullPixels; $i++) {
                $this->_add($this->samplesPerPixel, $a, $r, $g, $b);
                $this->pixelOffset++;
            }

            $samplesLeft -= $fullPixels * $this->samplesPerPixel;
        }

        // Last partial pixel
        if ($samplesLeft > 0) {
            $this->_add($samplesLeft, $a, $r, $g, $b);

            $this->subPixelOffset += $samplesLeft;

            if ($this->subPixelOffset == $this->samplesPerPixel) {
                $this->subPixelOffset = 0;
                $this->pixelOffset++;
            }
        }
    }
public function add($color, $untilX) 
    {
        $samplesLeft = 
            (int)($untilX * $this->samplesPerPixel) - 
            $this->subPixelOffset - 
            $this->pixelOffset * $this->samplesPerPixel;

        // ColorUtils methods inlined for performance reasons
        $a = ($color) & 0xff;
        $r = ($color >> 24) & 0xff;
        $g = ($color >> 16) & 0xff;
        $b = ($color >> 8) & 0xff;
        
        // First partial pixel
        if ($this->subPixelOffset > 0) {
            $samples = $this->samplesPerPixel - $this->subPixelOffset;
            if ($samples > $samplesLeft) {
                $samples = $samplesLeft;
            }
            $samplesLeft -= $samples;

            $this->_add($samples, $a, $r, $g, $b);

            $this->subPixelOffset += $samples;
            if ($this->subPixelOffset == $this->samplesPerPixel) {
                $this->subPixelOffset = 0;
                $this->pixelOffset++;
            }
        }

        // Full pixels
        $fullPixels = (int)($samplesLeft / $this->samplesPerPixel);
        if ($fullPixels > 0) {
            for ($i = 0; $i < $fullPixels; $i++) {
                $this->_add($this->samplesPerPixel, $a, $r, $g, $b);
                $this->pixelOffset++;
            }

            $samplesLeft -= $fullPixels * $this->samplesPerPixel;
        }

        // Last partial pixel
        if ($samplesLeft > 0) {
            $this->_add($samplesLeft, $a, $r, $g, $b);

            $this->subPixelOffset += $samplesLeft;

            if ($this->subPixelOffset == $this->samplesPerPixel) {
                $this->subPixelOffset = 0;
                $this->pixelOffset++;
            }
        }
    }
public function add ( $ color , $ untilX ) { $ samplesLeft = ( int ) ( $ untilX * $ this -> samplesPerPixel ) - $ this -> subPixelOffset - $ this -> pixelOffset * $ this -> samplesPerPixel ; // ColorUtils methods inlined for performance reasons $ a = ( $ color ) & 0xff ; $ r = ( $ color >> 24 ) & 0xff ; $ g = ( $ color >> 16 ) & 0xff ; $ b = ( $ color >> 8 ) & 0xff ; // First partial pixel if ( $ this -> subPixelOffset > 0 ) { $ samples = $ this -> samplesPerPixel - $ this -> subPixelOffset ; if ( $ samples > $ samplesLeft ) { $ samples = $ samplesLeft ; } $ samplesLeft -= $ samples ; $ this -> _add ( $ samples , $ a , $ r , $ g , $ b ) ; $ this -> subPixelOffset += $ samples ; if ( $ this -> subPixelOffset == $ this -> samplesPerPixel ) { $ this -> subPixelOffset = 0 ; $ this -> pixelOffset ++ ; } } // Full pixels $ fullPixels = ( int ) ( $ samplesLeft / $ this -> samplesPerPixel ) ; if ( $ fullPixels > 0 ) { for ( $ i = 0 ; $ i < $ fullPixels ; $ i ++ ) { $ this -> _add ( $ this -> samplesPerPixel , $ a , $ r , $ g , $ b ) ; $ this -> pixelOffset ++ ; } $ samplesLeft -= $ fullPixels * $ this -> samplesPerPixel ; } // Last partial pixel if ( $ samplesLeft > 0 ) { $ this -> _add ( $ samplesLeft , $ a , $ r , $ g , $ b ) ; $ this -> subPixelOffset += $ samplesLeft ; if ( $ this -> subPixelOffset == $ this -> samplesPerPixel ) { $ this -> subPixelOffset = 0 ; $ this -> pixelOffset ++ ; } } }
Adds a color to the buffer up until the specified x index.

@param integer $color Color to write.
@param float $untilX Samples of the color will be added the buffer until
the cursor reaches this coordinate.
Adds a color to the buffer up until the specified x index .