public function saveComposite($filename) { // Measure the image and create an image 32x32 pixels wider than the source $ir = $this->img->measure(); $wi = Canvas::createTrueColor($ir->w + SPECTRUM_SIZE + 4, $ir->h + SPECTRUM_SIZE + 4); // Draw the image into the new working image offset by 32x32 puxels $srect = $this->img->measure(); $drect = $this->img->measure(); $drect->move(SPECTRUM_SIZE + 4, SPECTRUM_SIZE + 4); $this->img->draw($wi, $drect, $srect); $wi->drawLine(0, $drect->y - 2, $wi->width, $drect->y - 2, [255, 255, 255]); $wi->drawLine($drect->x - 2, 0, $drect->x - 2, $wi->height, [255, 255, 255]); $wi->drawFilledRect(0, 0, $drect->x - 4, $drect->y - 4, [64, 64, 64]); $this->drawSpectrumX($wi, $this->xbuckets, $drect); $this->drawSpectrumY($wi, $this->ybuckets, $drect); // Save the working image $wi->save($filename); }