Boo是一种具有静态类型的 .Net 语言。它使用 CLR,因此您可以与其他 .Net 代码共享,包括 c#;它适用于 winforms 和 system.io 以及其他熟悉的库。它看起来很像 python:在 Boo 中比较这些:
internal class TileBytes:
public Size as int
public def constructor(size as int):
Size = size
public def Generate(tile as Tile) as (byte):
buffer as (byte) = array(byte, ((Size * Size) * 3))
for u in range(0, Size):
for v in range(0, Size):
pixelColor as Color32 = GetColor(tile, u, v)
bufferidx as int = (3 * ((u * Size) + v))
buffer[bufferidx] = pixelColor.r
buffer[(bufferidx + 1)] = pixelColor.g
buffer[(bufferidx + 2)] = pixelColor.b
return buffer
public def GetColor(tile as Tile, u as int, v as int) as Color32:
h as int = (0 if (v > (Size / 2.0)) else 2)
w as int = (0 if (u > (Size / 2.0)) else 1)
tc as TileCorner = ((h cast TileCorner) + w)
return tile[tc].GetPixel(v, (Size - (u + 1)))
在 C# 中对此
class TileBytes
{
public int Size;
public TileBytes(int size)
{
Size = size;
}
public byte[] Generate(Tile tile)
{
byte[] buffer = new byte[Size * Size * 3];
for (int u = 0; u < Size; u++)
{
for (int v = 0; v<Size; v++)
{
Color32 pixelColor = GetColor (tile, u, v);
int bufferidx = 3 * (( u * Size) + v);
buffer[bufferidx] = pixelColor.r;
buffer[bufferidx + 1] = pixelColor.g;
buffer[bufferidx + 2] = pixelColor.b;
}
}
return buffer;
}
public Color32 GetColor(Tile tile, int u, int v)
{
int h = v > Size / 2.0 ? 0 : 2;
int w = u > Size / 2.0 ? 0 : 1;
TileCorner tc = (TileCorner) h + w;
return tile[tc].GetPixel(v, Size - (u + 1));
}
}
Boo 也是一个活跃的开源项目