Php - Create graphical image, Creating graphical image using php

Create graphical image

The below code can be used to create graphical image, it is a simple code code which is used used to create sample images

 
<?php
 $pic = imagecreatetruecolor(400,400); // for create canvas with 400 * 400 size
 
 $bluecol = 0;
 
 for ($i = -10; $i < 410; $i += 80) {
 for ($j = -10; $j < 410; $j += 80) {
 $brush = imagecreate(100,100); // for create brush (lines thickness)
 
 $brushtrans = imagecolorallocate($brush, 0, 0, 0); //forallocate color for brush
 imagecolortransparent($brush, $brushtrans); 

 for ($k = 1; $k < 18; ++$k) {
  $color = imagecolorallocate($brush, 255, $k * 15, $bluecol);// allocate different color for line's color
  imagefilledellipse($brush, $k * 2, $k * 2, 1, 1, $color); //for draw ellips (border only)
 }
 
 imagesetbrush($pic, $brush);
 imageellipse($pic, $i, $j, 50, 50, IMG_COLOR_BRUSHED);
 
 imagedestroy($brush); // free the brush memory
 }
 
 $bluecol += 40;
 }
 
 imagepng($pic,"myimage.png",9);// create png image(set image name and 9 indicates resolution for image)
 imagedestroy($pic); // free the memory
 ?> 

 <img src='myimage.png'/>

The topic on Php - Create graphical image is posted by - Math

Hope you have enjoyed, Php - Create graphical imageThanks for your time

Tech Bluff