PHP:创建一个平滑的边缘,图像或字体? [英] PHP: creating a smooth edged circle, image or font?

查看:320
本文介绍了PHP:创建一个平滑的边缘,图像或字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我用过:

 <?php 
imagefilledellipse($ image,$ cx,$ cy,$ w,$ h,$ color);
?>

但讨厌它产生的粗糙边缘。所以我正在考虑制作或使用我将要输出的圆形字体:

 <?php 
imagettftext ($ image,$ size,$ angle,$ x,$ y,$ color,'fontfile.ttf',$ text);
?>

这样字体会产生一个光滑边缘的圆。我的问题是使字体大小匹配半径大小。

任何想法?或者,也许一个PHP的类,会产生圆滑的边缘将是伟大的!



谢谢。

解决方案

聪明的想法,我喜欢!

但是,也许这个PHP类已经做到了:用于PHP(GD)的Antialiased填充弧/椭圆


在很多情况下,网站需要动态创建的图像:饼图,圆角,菜单按钮等。这个列表是无止境的。 PHP,或者更确切的说是GD库,提供了椭圆弧和椭圆,但是没有反锯齿。因此,我写了一个PHP函数,用PHP轻松地呈现填充的抗锯齿椭圆弧或填充抗锯齿椭圆(以及圆..)。绘制这些填充弧线现在是一个单线。



I'm making a PHP image script that will create circles at a given radius.

I used:

<?php
imagefilledellipse ( $image, $cx, $cy, $w, $h, $color );
?>

but hate the rough edges it produces. So I was thinking of making or using a circle font that I will output using:

<?php
 imagettftext ( $image, $size, $angle, $x, $y, $color, 'fontfile.ttf', $text );
?>

So that the font will produce a circle that has a smooth edge. My problem is making the "font size" match the "radius size".

Any ideas? Or maybe a PHP class that will produce a smooth edge on a circle would be great!

Thank you.

解决方案

Clever idea, I like that!

But maybe this PHP class already does the trick: Antialiased filled Arcs/Ellipses for PHP (GD)

In many cases websites need dynamically created images: pie charts, rounded corners, menu buttons, etc. This list is endless. PHP, or more precisely the GD library, provides filled elliptical arcs and ellipses, but they are not antialiased. Therefore I have written a PHP function to render filled antialiased elliptical arcs or filled antialiased ellipses (as well as circles..) with PHP easily. Drawing these filled arcs is now a one-liner.

这篇关于PHP:创建一个平滑的边缘,图像或字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆