也许有人可以帮助我,因为我被困在这里。所以我有 zem.png 大小为 560x225 的图像。它具有透明背景。我需要用 gd 库从 x,y 到 x1,x2 画线(我需要画 5-7 条线,但如果能得到一个如何画一条线的简单例子就完美了)。
这是我的透明图像的创建方式:
// Kuriame paveiksleli pasinaudodami GD library keliams tarp miestu pavaizduoti
$im = imagecreatetruecolor(560, 225);
$red = imagecolorallocate($im, 255, 0, 0);
$black = imagecolorallocate($im, 0, 0, 0);
// Make the background transparent
imagecolortransparent($im, $black);
// Issaugome paveiksleli
imagepng($im, './zem.png');
imagedestroy($im);
创建此图像后,我将其用作表格或 div 的背景图像。我的桌子 ir div 被分成 x - 35 个块,y 25 个块。
我选择了 4 个点或 4 个块来放置其他图像,这就是我生成这些 rondom 块的方式:
$x = rand(1, 35);
$y = rand(1, 25);
$x2 = rand(1, 35);
$y2 = rand(1, 25);
$x3 = rand(1, 35);
$y3 = rand(1, 25);
$x4 = rand(1, 35);
$y4 = rand(1, 25);
单个块大小为 16x9。而且我需要从每个生成的块到其他块绘制一条线(作为代表城市的道路),所以我必须将我的 x (x2,x3..) 乘以 16 和我的 y 乘以 9 才能准确地知道线的正确坐标起点和终点。所以我这样做:
// Breziame kelius
$kordinate = $x * 16;
$kordinate2 = $y * 9;
$kordinate3 = $x2 * 16;
$kordinate4 = $y2 * 9;
好的,我现在有一条线的坐标。这就是我被困住的地方。我尝试了很多例子,人们预先创建了 funkcions 等。但我仍然无法使用 php gd 库画一条线。所以也许有人可以提出一些建议?要在图像创建代码中添加一些东西,或者只是将其删除并留下空白透明图像并打开它然后画一条线......