输入数据的格式大概是这样的 (可调整), 其中 rgba 是三角形的填充颜色
x1 y1 x2 y2 x3 y3 rgba # 1st triangle
x1 y1 x2 y2 x3 y3 rgba # 2nd triangle
...
希望有一个现成的工具 (不限于 gnuplot) 能把这些三角形依次画出来,实现类似图层叠加的效果,输出到文件
在等到答案前我已经用其它方法手动实现了,C# 写这种程序真顺手啊
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
class Program
{
static void Main(string[] args)
{
// check argument
if (args.Length != 1) {
Console.WriteLine("Usage: ImagePainter {filename}");
return;
}
string filename = args[0];
// open data file
StreamReader file = new StreamReader(filename);
// init bitmap
Bitmap bitmap = new Bitmap(800, 800);
Graphics g = Graphics.FromImage(bitmap);
// read file
string line;
// draw triangles
while ((line = file.ReadLine()) != null) {
string[] fields = line.Trim().Split('\t');
double x1 = Convert.ToDouble(fields[0]);
double y1 = Convert.ToDouble(fields[1]);
double x2 = Convert.ToDouble(fields[2]);
double y2 = Convert.ToDouble(fields[3]);
double x3 = Convert.ToDouble(fields[4]);
double y3 = Convert.ToDouble(fields[5]);
double red = Convert.ToDouble(fields[6]);
double green = Convert.ToDouble(fields[7]);
double blue = Convert.ToDouble(fields[8]);
double alpha = Convert.ToDouble(fields[9]);
PointF[] points = {
new PointF(800 * (float)x1, 800 * (float)y1),
new PointF(800 * (float)x2, 800 * (float)y2),
new PointF(800 * (float)x3, 800 * (float)y3)
};
Color color = Color.FromArgb(
(int)(255 * alpha),
(int)(255 * red),
(int)(255 * green),
(int)(255 * blue);
g.FillPolygon(new SolidBrush(color), points);
}
bitmap.Save(filename + ".bmp");
}
}