简体   繁体   English

将imagesetthickness()过滤到PHP中的特定行

[英]Filtering imagesetthickness() to Specific line in PHP

The imagesetthickness() on the PHP will change the thickness of all lines on the image. PHP上的imagesetthickness()将更改图像上所有线条的粗细。 Is there any way to select what line to be associated with this function? 有什么办法选择与该功能关联的行? For Example in following image I would like to ONLY change the thickness of GREEN lines to 5. 用于以下实施例的图像我想的绿线厚度唯一的变化为5。

<?php
 $image = ImageCreate(130, 170);
 $white = ImageColorAllocate($image, 255, 255, 255);
 $black = ImageColorAllocate($image, 0, 0, 0);
 $green = ImageColorAllocate($image, 82, 128, 8);

 ImageFill($image, 0, 0, $white);

 ImageSetThickness ($image , 5);

 ImageLine($image,60,40,60,100,$black);
 ImageLine($image,25,25,100,25,$green);

 ImagePng($image, "flag.png");
 ImageDestroy($image);
 ?>

You just need to set the thickness to the desired value before calling imageline . 您只需要在调用imageline之前将厚度设置为所需的值即可。

<?php
 $image = ImageCreate(130, 170);
 $white = ImageColorAllocate($image, 255, 255, 255);
 $black = ImageColorAllocate($image, 0, 0, 0);
 $green = ImageColorAllocate($image, 82, 128, 8);

 ImageFill($image, 0, 0, $white);

 // set to 3 for the next call 
 ImageSetThickness ($image , 3);
 ImageLine($image,60,40,60,100,$black);

 // set to 5 for the next call
 ImageSetThickness ($image , 5);
 ImageLine($image,25,25,100,25,$green);

 // Set back to 3 for any future calls calls
 ImageSetThickness ($image , 3);

 ImagePng($image, "flag.png");
 ImageDestroy($image);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM