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)))
而不是
^{pr2}$xDDD
为了“节省”代码中的空间,您可以随时采用这种编码方式:
我已经使用它将近一年了,我对代码的可读性非常满意。在
Boo是一种带有静态类型的.Net语言。它使用CLR,因此您可以与其他.Net代码共享,包括与winforms和系统io以及其他熟悉的图书馆。它看起来很像python:在Boo中比较一下:
在C中
^{pr2}$Boo也是一个活跃的open source project
相关问题 更多 >
编程相关推荐