PHP uses GD library to draw Pentagram _php tutorial

Source: Internet
Author: User
$width = 500;

$height = 500;

03

$im = Imagecreatetruecolor ($width, $height);

05

$red = Imagecolorallocate ($im, 230, 0, 0);

Imagefill ($im, 0, 0, $red);

08

$yellow = Imagecolorallocate ($im, 255, 255, 0);

10

11//Set the edge length of the positive Pentagon formed by the five vertices that draw the pentagram

$b = 100;

$pi =3.14/180;

14

$p 1x = 150;

$p 1y = 250;

17

$p 2x = 150+ (cos (36* $pi) * $b);

$p 2y = 250-(sin (36* $pi) * $b);

20

$p 3x = 150+ (2*cos (36* $pi) * $b);

$p 3y = 250;

23

$p 4x = $p 3x-sin (18* $pi) * $b;

$p 4y = 250+cos (18* $pi) * $b;

26

$p 5x = 150+sin (18* $pi) * $b;

$p 5y = 250+cos (18* $pi) * $b;

29

30//Connect the corresponding point draw line

Imageline ($im, $p 1x, $p 1y, $p 3x, $p 3y, $yellow);

Imageline ($im, $p 1x, $p 1y, $p 4x, $p 4y, $yellow);

33

Imageline ($im, $p 2x, $p 2y, $p 4x, $p 4y, $yellow);

Imageline ($im, $p 2x, $p 2y, $p 5x, $p 5y, $yellow);

36

Panax Notoginseng imageline ($im, $p 3x, $p 3y, $p 5x, $p 5y, $yellow);

38

(' Content-type:image/png ');

40

Imagepng ($im);

42

Imagedestroy ($im);

44

?>

http://www.bkjia.com/PHPjc/478005.html www.bkjia.com true http://www.bkjia.com/PHPjc/478005.html techarticle the $width of the $height =; $im = Imagecreatetruecolor ($width, $height); $red = Imagecolorallocate ( $im, 230, 0, 0); Imagefill ($im, 0, 0, $red); $yellow ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.