Home Backend Development PHP Tutorial PHP uses GD library to draw a five-pointed star_PHP tutorial

PHP uses GD library to draw a five-pointed star_PHP tutorial

Jul 13, 2016 pm 05:53 PM
500 height imagecreatetruecolor php red width use

01 $width = 500;

02 $height = 500;

03

04 $im = imagecreatetruecolor($width, $height);

05

06 $red = imagecolorallocate($im, 230, 0, 0);

07 imagefill($im, 0, 0, $red);

08

09 $yellow = imagecolorallocate($im, 255, 255, 0);

10 

11 //Set the side length of the regular pentagon formed by drawing the five vertices of the five-pointed star

12 $b=100;

13 $pi=3.14/180;

14

15 $p1x = 150;

16 $p1y = 250;

17

18 $p2x = 150+(cos(36*$pi)*$b);

19 $p2y = 250-(sin(36*$pi)*$b);

20

21 $p3x = 150+(2*cos(36*$pi)*$b);

22 $p3y = 250;

23

24 $p4x = $p3x-sin(18*$pi)*$b;

25 $p4y = 250+cos(18*$pi)*$b;

26

27 $p5x = 150+sin(18*$pi)*$b;

28 $p5y = 250+cos(18*$pi)*$b;

29 

30 //Connect the corresponding points and draw lines

31 imageline($im, $p1x, $p1y, $p3x, $p3y, $yellow);

32 imageline($im, $p1x, $p1y, $p4x, $p4y, $yellow);

33

34 imageline($im, $p2x, $p2y, $p4x, $p4y, $yellow);

35 imageline($im, $p2x, $p2y, $p5x, $p5y, $yellow);

36

37 imageline($im, $p3x, $p3y, $p5x, $p5y, $yellow);

38

39 header('Content-Type:image/png');

40

41 imagepng($im);

42

43 imagedestroy($im);

44

45 ?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478005.htmlTechArticle01 $width = 500; 02 $height = 500; 03 04 $im = imagecreatetruecolor($width, $height ); 05 06 $red = imagecolorallocate($im, 230, 0, 0); 07 imagefill($im, 0, 0, $red); 08 09 $yellow...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the blockchain data analysis tools? What are the blockchain data analysis tools? Feb 21, 2025 pm 10:24 PM

The rapid development of blockchain technology has brought about the need for reliable and efficient analytical tools. These tools are essential to extract valuable insights from blockchain transactions in order to better understand and capitalize on their potential. This article will explore some of the leading blockchain data analysis tools on the market, including their capabilities, advantages and limitations. By understanding these tools, users can gain the necessary insights to maximize the possibilities of blockchain technology.

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Binance Launchpool No. 64 project analysis and price forecast: Can RedStone (RED) ignite the market? Binance Launchpool No. 64 project analysis and price forecast: Can RedStone (RED) ignite the market? Mar 03, 2025 pm 11:45 PM

Hello everyone, I am your old friend, a friend who talks to you about the crypto market in Binance Plaza all year round. Binance Launchpool recently launched the 64th phase project - RedStone (RED). As a multi-chain oracle project, it sparked a lot of discussion before it was launched. Today we will have an in-depth analysis of RED to see how its potential and how the price may go after it is launched. Binance Launchpool No. 64 project analysis and price forecast: Can RedStone (RED) ignite the market? Project background and core highlights RedStone (RED) is a multi-chain oracle platform focusing on decentralized finance (DeFi), with the goal of E

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

The track is cold, can the AI ​​Agent in the vertical field break the deadlock? The track is cold, can the AI ​​Agent in the vertical field break the deadlock? Mar 05, 2025 am 07:57 AM

Web3 Vertical AIAgent: Subvert tradition and reshape the industry landscape? This paper discusses the application differences of AIAgent in Web2 and Web3 and the future potential of Web3Agent. Web2 has been widely used to improve efficiency, covering sales, marketing and other fields, and has achieved significant economic benefits. Web3Agent combines blockchain technology to open up new application scenarios, especially in the DeFi field. It demonstrates potential beyond Web2Agent through token incentives, decentralized platforms and on-chain data analysis. Although Web3Agent is currently facing challenges, its unique advantages make it expected to compete with Web2 in the medium and long term, and even reshape the industry landscape. Web2AI

Vertical proxy: Application scenarios and interpretation of disruptive potential of encryption native proxy Vertical proxy: Application scenarios and interpretation of disruptive potential of encryption native proxy Mar 04, 2025 am 10:21 AM

Artificial intelligence agents (AIAgents) are rapidly integrating into daily operations of enterprises, from large companies to small businesses, almost all areas have begun to be used, including sales, marketing, finance, law, IT, project management, logistics, customer service and workflow automation. We are moving from an era of manual processing of data, performing repetitive tasks, and using Excel tables to an era of autonomous operation by AI agents around the clock, which not only improves efficiency but also significantly reduces costs. Application case of AI agents in Web2: YCombinator's Perspective Apten: A sales and marketing optimization tool combining AI and SMS technology. BildAI: A model that can read architectural blueprints,

Redstone/RED currency listing price forecast and detailed explanation of token economics Redstone/RED currency listing price forecast and detailed explanation of token economics Mar 03, 2025 pm 10:42 PM

This time, the Redstone token $RED will be launched on Binance Launchpool on Binance TGE! This is also the first time Binance has launched a pre-market trading limit mechanism! The first day limit is 200%, and the ban will be lifted after 3 days to avoid "the peak will be achieved when the market opens"! Launchpool mechanism introduces the BinanceLaunchpool participating in Redstone that needs to pledge designated tokens (BNB, USDC, FDUSD) activity period is 48 hours: 08:00 UTC on February 26, 2025 to 08:00 UTC on February 28, 2025 ending this pre-market daily limit rule: 18:00 on February 28, 2025

It is said that Citibank will provide cryptocurrency custody services in detail! Next step to issue stablecoins? It is said that Citibank will provide cryptocurrency custody services in detail! Next step to issue stablecoins? Mar 04, 2025 am 10:42 AM

According to The Information, Citigroup, the third largest asset-scale bank in the United States, is actively exploring the integration of cryptocurrency custody services into its business territory. It is reported that Citi's move originated from a pilot project launched in February 2024 that successfully demonstrated the feasibility of issuing and custodializing tokenized private equity funds on the blockchain network. Many banks have obtained digital asset custody licenses. At present, many banks have obtained digital asset custody service qualifications in different countries/regions. For example, BNY Mellon has been approved to provide digital asset custody services other than Bitcoin and Ethereum ETFs; Standard Chartered has established a foundation for digital asset custody in Dubai.

See all articles