php — ��� ������� ������������ ��������� ImageFilledPolygon php?
� ���� ���� �������, ������� ��������� ����� ���������� �����������, ���������� imagecreatetruecolor ($ h, $ w); �� ����������� �������� �������, ���������� �������� � ���������, ��� ������. � ���������� php antialias (resource, boolean), � ��� ������� �������. � ���� ������ ������������, ��� ��� �� ��������������. ����� ���� ����� �����-������ �������� ����, ����� ������� ����� ��������? ���� �� ���������� �� ����������� http://www.php.net/manual/en/images/21009b70229598c6a80eef8b45bf282b-imagefilledpolygon.png �� ����������� php, ��� ������ ��, ��� � ���� � ����. ����� ����, ��� ������� ��� (�������� ����)? ������� ������� � ����������� ����.
-
2 2
- 22 ��� 2020 2020-03-22 02:30:39
- Lews Therin
2 ������
«trimbo» ������ � 2006 ���� �� php.net:
�� ��� �� ������ �������� ���������� ����������� ��������������, ����� ����� ������������� ������ ������������ � ���� �� ���������:
- 22 ��� 2020 2020-03-22 02:30:40
- Daryl
����� ������� ����� ��������, �� ������ ����������� ������� resizeimage � �������� �������� ��������.
���������� �������������
��� ����� ���������� �������������
������ ����� �����. ��� ����� ���������� ������������� �� canvas, ���� ���� ������� ������ ���� �.
���������� �������������
������������! ��� ���� ��������� ����� �������������, � � ������ ������ �����. ��������.
���������� �������������
���������� ��� ���������� ������������� ����������. (��� ��������� ����� 6 ��������) �������������.
���������� �������������
������������ � �� ��������, ������ �� ������� �����. � ���� ������: ���������� �����.
���������� �������������
� ���� ���� ������ �� n ��������. 3>n>11. Point points. � points �������� ���������� �����. ��.
��� ������������� ����� ������� �� onDraw() �.�. �� ��������� ������ ������ ����� �������. �.�. ��� �����, path, paint ������ ���� ���������������� ��� � onCreate(), � � onDraw() ������ �������� �� ���������.
� �������� ��� ������� ����� �������� �� ������ onTouchListener � � ��� ��� ������� ������ ����� ����� ������, �������� ���� ����� �������� � ����� ������ �� Path, � �������, ����� �� ���� ����� ���������� � �.�.
Imagefilledpolygon
Php �������
Php �������
imagefilledpolygon
(PHP 3, PHP 4, PHP 5)
imagefilledpolygon — Draw a filled polygon
Description
bool imagefilledpolygon ( resource image, array points, int num_points, int color )
imagefilledpolygon() creates a filled polygon in image image .
points is an array containing the x and y co-ordinates of the polygons vertices consecutively.
The parameter num_points is the total number of vertices, which must be larger than 3.
������ 1. imagefilledpolygon() example
|
User Contributed Notes
etnekor at tar dot hu
23-Jan-2006 12:18
There is a simple function to draw a filled point with a chosen radius and color.
������� PolyLine � ��������� Polygon
�� ���������� �������� ����� � ������� �� ������������� ���������� ���������������� ������ �����, ��������� ��������� MoveTo � LineTo. �� ���� ���������� ������ ������� (��������� ��� ���), ���� �� ����� ������� � ������� �������� PolyLine � Polygon. ����� �������, � ����� ������� ����� ����� ��������������?
��������� PolyLine ��������� ������� �����
? PolyLine � ���������, ������ ������� ����� �� ������, ���������� ������� ������ � ������� points. � PascalABC � PascalABC.Net ��� ��������� �������� ������� ��-�������.
������� �� ��������� PolyLine � PascalABC � PascalABC.Net, � ���� �������� �������.
PolyLine � PascalABC:
procedure PolyLine(var points: array[1..n] of Point; n: integer);
� ������ ������� �� n ������, ���������� ������� ������ � ������� a ��������� ���� Point, ���������� � ������� ������:
PolyLine � PascalABC.Net:
procedure PolyLine(points: array of Point);
� ������ ������� �� ������, ���������� ������� ������ � ������� points. �� ���� points � ��� ������������ ������, ��� �������� ����� �������������� ������ ������, � ��� Point ��������� �� ����� (��� ���������� ��� PascalABC.Net).
����� �����, ��� � PascalABC.Net ��������� PolyLine ����� ������ ���� �������� — ���������� ��� ������ ����� points (� ������� �� �������� PascalABC, ��� ���� ��� ������ �������� � ������ �������, ��� ���������� �����). ��� ����� �������, ��� � ������������ �������� ��������� ���������� � 0.
�������� ������ ������� ����� �� ������� ����� PolyLine � PascalABC:
�� ����� ������� ��� ������������� MoveTo(x, y) � LineTo(x, y):
� ����� ��������� ������� ���������� ���������:
�������� ������ ��� �� ���������, �� � PascalABC.Net:
�� �������� ������� ������� � ������� �� ������� ������� ���������� �������, ��������� ��������� Line ��� ���������� ����� �������. �������� ����� ������ ��� ������ ���������� ������� �� PascalABC.Net, �� ��� � �������������� ������������ PolyLine. ����������� � ����.
��������� ���������� ������� ������� ������ ���������� � ����� PascalABC.Net ����� �� �������:
��������� Polygon ��������� ��������������
? Polygon � ���������, ������ ��������� ������� � PascalABC � ����������� ������������� � PascalABC.Net �� ������, ���������� ������� ������ � ������� points.
Polygon � PascalABC:
procedure Polygon(var A: array[1..n] of Point; n: integer);
� ������ ��������� ������� �� n ������, ���������� ������� ������ � ������� a ��������� ���� Point. ����� Point — ��� ����� � PascalABC.
Polygon � PascalABC.Net:
procedure Polygon(points: array of Point);
� ������ ����������� �������������, ���������� ������ �������� ������ � ������� points. ����� points — ��� ������������ ������ ����� ���� Point, ������� ���� X, Y (���������� ����� � ����������� ����). Point � PascalABC.Net — ��� ���������� ��� ������ (�����������, �������), �� ���� �����, ��������� ������� �� �����.
����� ������� Polygon �� PolyLine? ������� ������ � ���, ��� � ������ � Polygon ������ ����� ���������� � ���������, � � ���������� �������� �� ������ ������� �����, � ��������� ������� � �������������. ����� �������� ����� �������� ������������ ��������� Polygon � PascalABC � PascalABC.Net ��� ��������� ���������������.
������������� � PascalABC
������ ����������� � PascalABC:
������ ����������� ��������������� � PascalABC:
������������� � PascalABC.Net
������ ����������� � PascalABC.Net:
������ ����������� ��������������� � PascalABC.Net:
����� �� ��������� ��������� ����������� � ����������� ���� � ������� ��������� SaveWindow � ���� � ������ «����������� ���������������.jpg» (���� ���� ����� ��������� � ��� �� �����, ���� �� ��������� ��� ������ ���������):
����������� �������������� � PascalABC.Net:
��������� �������� ���: ��� ������� � ����������� ���� ������ 2 ������� ���������� ����������� �������������� �� ��������� ����������� ������ �� 3 �� 30 (������ 16 ����). ����� ���������� ���������� ������ ����������� ��������������, � ����� �� ���� ������� ������� ������� ��� �������������� ��� ��������� ���������� �� 15 �������� (������ 20 — 28). ����� ������ ������������� (������ 32) � ��������� ��� ����������� (������ 35).
�������� ��������, ��� ���� ������� ������� � ����������� ����� (������� false �� ������ ����� repeat-until ������ �����, ������� �� ������� �� �����������), ������� ���������� ��� ����� ������ ������ ����. � ��� ������: ������ ��� ������� � ��� � ����� � ���������� ����� ���������� ����� ���� ����������� ���� «����������� ���������������-1.jpg» , «����������� ���������������-2.jpg» , «����������� ���������������-3.jpg» � �.�., � ���� ��� ����� �� ����� ��� �������, �� �� ���� �������. ��� ������� ����� ��������������� (�������� ������ �� �������� � ������������� ������-�����):
��� ����� ��� imagefilledpolygon
imagefilledpolygon — Draw a filled polygon
Description int imagefilledpolygon ( resource image, array points, int num_points, int color)
imagefilledpolygon() creates a filled polygon in image image . points is a PHP array containing the polygon’s vertices, ie. points[0] = x0, points[1] = y0, points[2] = x1, points[3] = y1, etc. num_points is the total number of vertices.
Example 1. imagefilledpolygon() example
40, // x1 1 => 50, // y1 2 => 20, // x2 3 => 240, // y2 4 => 60, // x3 5 => 60, // y3 6 => 240, // x4 7 => 20, // y4 8 => 50, // x5 9 => 40, // y5 10 => 10, // x6 11 => 10, // y6 ); // create image $im = imagecreate(250, 250); // some colors $bg = imagecolorallocate($im, 255, 255, 255); $blue = imagecolorallocate($im, 0, 0, 255); // draw a polygon imagefilledpolygon($im, $values, 6, $blue ); // flush image header(‘Content-type: image/png’); imagepng($im); imagedestroy($im); ?>
However, ImageFillPolygon supports only polygons with a maximum of 256 points, so be aware of such complicated polygons.
imagefilledpolygon
Draw a filled polygon ( PHP 4, PHP 5 )
Example 1010. imagefilledpolygon() example
// set up array of points for polygon
$values = array(
40 , 50 , // Point 1 (x, y)
20 , 240 , // Point 2 (x, y)
60 , 60 , // Point 3 (x, y)
240 , 20 , // Point 4 (x, y)
50 , 40 , // Point 5 (x, y)
10 , 10 // Point 6 (x, y)
);
// create image
$image = imagecreatetruecolor ( 250 , 250 );
// some colors
$bg = imagecolorallocate ( $image , 200 , 200 , 200 );
$blue = imagecolorallocate ( $image , 0 , 0 , 255 );
// draw a polygon
imagefilledpolygon ( $image , $values , 6 , $blue );
// flush image
header ( ‘Content-type: image/png’ );
imagepng ( $image );
imagedestroy ( $image );
?>
The above example will output something similar to:
php — ��� ������� ������������ ��������� ImageFilledPolygon php?
� ���� ���� �������, ������� ��������� ����� ���������� �����������, ���������� imagecreatetruecolor ($ h, $ w); �� ����������� �������� �������, ���������� �������� � ���������, ��� ������. � ���������� php antialias (resource, boolean), � ��� ������� �������. � ���� ������ ������������, ��� ��� �� ��������������. ����� ���� ����� �����-������ �������� ����, ����� ������� ����� ��������? ���� �� ���������� �� ����������� http://www.php.net/manual/en/images/21009b70229598c6a80eef8b45bf282b-imagefilledpolygon.png �� ����������� php, ��� ������ ��, ��� � ���� � ����. ����� ����, ��� ������� ��� (�������� ����)? ������� ������� � ����������� ����.
-
3 2
- 22 ��� 2020 2020-03-22 02:30:39
- Lews Therin
2 ������
«trimbo» ������ � 2006 ���� �� php.net:
�� ��� �� ������ �������� ���������� ����������� ��������������, ����� ����� ������������� ������ ������������ � ���� �� ���������:
- 22 ��� 2020 2020-03-22 02:30:40
- Daryl
����� ������� ����� ��������, �� ������ ����������� ������� resizeimage � �������� �������� ��������.
����� �����
� ����� ������� ����� ���������� ��������, ������� ������������ � ���� �� �����������, ��� � ����������, �� � � ������� �� ��� � ��������� ��������� ���������� �����������. ��� ��� �� ��� ������ �����, ��� ���������? � ����� �� �� ����-�� � ��� ���������?
� ������� ������� �� ��� ������� ����� ������ � ������ �����, ���-��������� ���������� ������������� �������������� �������� Deloitte, ���������������� ������ �� 25 000 �������� �� 45 ���. � ���������� ����������� �� ������ �������� ������������ �� ������� �������������� ����� ������ �� �� ������ �������, �������� ������� ����������������� ��� ������������ ������������ � �������������� �������� � ����������� �������� ��������.
� Details the Eclipse Integrated Development Environment (IDE) essential to streamlining your embedded development process
� Overview of the latest C/C++ Development toolkit
� Includes case studies of eclipse use including Monta Vista, LynuxWorks, and WindRiver
imagefilledpolygon
imagefilledpolygon — Draw a filled polygon
Описание
imagefilledpolygon() creates a filled polygon in the given image .
Список параметров
An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().
An array containing the x and y coordinates of the polygons vertices consecutively
Total number of vertices, which must be bigger than 3
A color identifier created with imagecolorallocate()
Возвращаемые значения
Возвращает TRUE в случае успешного завершения или FALSE в случае возникновения ошибки.
Примеры
Example#1 imagefilledpolygon() example
// set up array of points for polygon
$values = array(
40 , 50 , // Point 1 (x, y)
20 , 240 , // Point 2 (x, y)
60 , 60 , // Point 3 (x, y)
240 , 20 , // Point 4 (x, y)
50 , 40 , // Point 5 (x, y)
10 , 10 // Point 6 (x, y)
);
// create image
$image = imagecreatetruecolor ( 250 , 250 );
// some colors
$bg = imagecolorallocate ( $image , 200 , 200 , 200 );
$blue = imagecolorallocate ( $image , 0 , 0 , 255 );
// draw a polygon
imagefilledpolygon ( $image , $values , 6 , $blue );
// flush image
header ( ‘Content-type: image/png’ );
imagepng ( $image );
imagedestroy ( $image );
?>
� езультатом выполнения данного примера будет что-то подобное:
Draw a star using imagefilledpolygon (with diagram)
Is there a way with PHP GD to draw a star using imagefilledpolygon ?
Where would the points be plotted?
I believe it involves sine and cosine because.
How can I relate those points to the center using sine and cosine in GD?
3 Answers 3
yes. I suggest you read that manual entry you yourself supplied, as it tells you exactly what you need to do. It even gives an example of a 3-point star, and there’s even an example in the user notes of a 5-sided star.
It’s easy to calculate the points you need:
Before drawing shape, add DG Liabrary in php.in file. Here is the code:
Not the answer you’re looking for? Browse other questions tagged php geometry gd or ask your own question.
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo � 2020 Stack Exchange Inc; user contributions licensed under cc by-sa 4.0 with attribution required. rev 2020.11.12.35412