Hướng dẫn what is graphics php?
PHP provides many functions to draw lines, rectangles, polygons, arcs, ellipses and much more. The GD library is utilized for dynamic picture creation. In PHP, we can easily use the GD library to make GIF, PNG, or JPG pictures quickly from our code. So there is no need to write HTML and CSS code. We can easily handle this using the PHP programming language. Show
Nội dung chính
Nội dung chính
Nội dung chính
If you are unsure that you have the GD library, you can run phpinfo() to check that GD support is enabled. On the off chance that you don't have it, you can download it for free. Drawing LinesPHP provides the imageline() function to draw a line between the two given points.
Parameters$image- An image resource, this is returned by imagecreatetruecolor() function. It returns a boolean value, TRUE on success and FALSE on failure. Example: imageline()
In the above example, the ImageCreateTrueColor() function creates a new true color image. imagesavealpha() function sets a flag to retain full alpha channel information. imagecolorallocatealpha() function allocates a color for an image, i.e., transparent color, which is filled by imagefill() function. Output: ImageLine()Drawing RectanglesPHP provides imagefilledrectangle() function to draw a filled rectangle.
Parameters$image- An image
resource. This is returned by the imagecreatetruecolor() function. Example
In the above example, we allocate a color for the rectangle using imagecolorallocatealpha() function. Output: Draw RectangleDrawing PolygonsPHP provides ImagePolygon() function to draw polygon.
Parameters$image - An image resource, this is returned by imagecreatetruecolor() function. Example - imagepolygon()
OutputDrawing ArcsPHP provides ImageArc() function for drawing arcs.
Parameters$image - An image resource, this is returned by imagecreatetruecolor() function. Example - ImageArc()
OutputDrawing EllipsesPHP provides ImageEllipse() function to draw an ellipse.
Parameters$image - An image resource, this is returned by imagecreatetruecolor() function. Example - ImageEllipse()
Drawing Patterned LinesIn PHP, we can draw patterned lines with the help of ImageSetStyle() and ImageFilledRectangle() functions. The ImageSetStyle() function sets the style for line drawing.
Parameters$image - An image resource, this is returned by imagecreatetruecolor() function. Example - ImageSetStyle()
OutputRelated Articles How to add google reCAPTCHA v2 in registration form using PHP ◀ Previous Article What are graphics functions?Graphic functions is an exercise concerning the graphical recognition of functions of one real variable. The server will give you the graph of a function , whose expression will be hidden. What is graphics PHP?Graphics are one of the most compelling aspects of PHP. Equipped with a powerful GD graphics library, it can dynamically manipulate images. It can create GIFs, JPEGs and PNG files. Use of GD graphics library provides PHP programming with another major advantage. What is the function used to draw filled in Figure in PHP?PHP | imagefilledrectangle() Function The imagefilledrectangle() function is an inbuilt function in PHP which is used to create a filled rectangle. This function creates a rectangle filled with a given color in the image. The top left corner of the image is (0, 0). What are the features of image in PHP?GD and Image Functions ¶. gd_info — Retrieve information about the currently installed GD library.. getimagesize — Get the size of an image.. getimagesizefromstring — Get the size of an image from a string.. image_type_to_extension — Get file extension for image type.. |