Ejemplo n.º 1
0
 /**
  * Mirrors the image horizontally.
  * Uses an affine transformation matrix to mirror the image.
  *
  * 123 -> 321
  *
  * @return void
  */
 function mirror()
 {
     $outputSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, $this->img_x, $this->img_y);
     $outputContext = cairo_create($outputSurface);
     //                            xx, yx, xy, yy, x0, y0
     $matrix = cairo_matrix_create(-1, 0, 0, 1, $this->img_x, 0);
     cairo_set_matrix($outputContext, $matrix);
     cairo_set_source_surface($outputContext, $this->surface, 0, 0);
     cairo_paint($outputContext);
     cairo_destroy($outputContext);
     cairo_surface_destroy($this->surface);
     $this->surface = $outputSurface;
 }
Ejemplo n.º 2
0
 /**
  * 画像を合成
  *
  * 画像ファイル(PNG)を合成します。
  *
  * @param string $file  ファイル名
  * @param int    $x     X座標
  * @param int    $y     Y座標
  * @param float  $alpha アルファブレンディング(0..1)
  *
  * @return void
  */
 public function addImage($file, $x = 0, $y = 0, $alpha = 1.0)
 {
     $file = $this->loadRemoteFile($file);
     $surfce = cairo_image_surface_create_from_png($file);
     cairo_set_source_surface($this->image, $surfce, $x, $y);
     cairo_paint_with_alpha($this->image, $alpha);
 }