mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 20:16:36 -04:00
Better field names for PaletteEntry.
This commit is contained in:
parent
92b7b6ad60
commit
0be654b006
@ -148,9 +148,9 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
|
||||
Color col = bmp.GetPixel(xx, yy);
|
||||
cur.r = col.R; cur.g = col.G; cur.b = col.B;
|
||||
cur.R = col.R; cur.G = col.G; cur.B = col.B;
|
||||
int position;
|
||||
cur.block = selector.BestMatch(cur, out position);
|
||||
cur.Block = selector.BestMatch(cur, out position);
|
||||
if (popType == 1 || popType == 3) {
|
||||
int threshold = popType == 1 ? 20 : 3;
|
||||
if (position <= threshold) {
|
||||
@ -165,8 +165,8 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
}
|
||||
|
||||
if (col.A < 20) cur.block = Block.air;
|
||||
p.level.UpdateBlock(p, (ushort)P.X, (ushort)P.Y, (ushort)P.Z, cur.block, 0);
|
||||
if (col.A < 20) cur.Block = Block.air;
|
||||
p.level.UpdateBlock(p, (ushort)P.X, (ushort)P.Y, (ushort)P.Z, cur.Block, 0);
|
||||
}
|
||||
|
||||
if (dArgs.name == "tempImage_" + p.name)
|
||||
|
@ -35,7 +35,7 @@ namespace MCGalaxy.Drawing {
|
||||
public void SetAvailableBlocks(PaletteEntry[] blocks) { }
|
||||
|
||||
public byte BestMatch(PaletteEntry cur, out int position) {
|
||||
int brightness = (cur.r + cur.g + cur.b) / 3; position = -1;
|
||||
int brightness = (cur.R + cur.G + cur.B) / 3; position = -1;
|
||||
if (brightness < (256 / 4))
|
||||
return Block.obsidian;
|
||||
else if (brightness >= (256 / 4) && brightness < (256 / 4) * 2)
|
||||
@ -58,15 +58,15 @@ namespace MCGalaxy.Drawing {
|
||||
int minimum = int.MaxValue; position = 0;
|
||||
for (int i = 0; i < palette.Length; i++) {
|
||||
PaletteEntry pixel = palette[i];
|
||||
int dist = (cur.r - pixel.r) * (cur.r - pixel.r)
|
||||
+ (cur.g - pixel.g) * (cur.g - pixel.g)
|
||||
+ (cur.b - pixel.b) * (cur.b - pixel.b);
|
||||
int dist = (cur.R - pixel.R) * (cur.R - pixel.R)
|
||||
+ (cur.G - pixel.G) * (cur.G - pixel.G)
|
||||
+ (cur.B - pixel.B) * (cur.B - pixel.B);
|
||||
|
||||
if (dist < minimum) {
|
||||
minimum = dist; position = i;
|
||||
}
|
||||
}
|
||||
return palette[position].block;
|
||||
return palette[position].Block;
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ namespace MCGalaxy.Drawing {
|
||||
|
||||
LabColor RgbToLab(PaletteEntry block) {
|
||||
// First convert RGB to CIE-XYZ
|
||||
double R = block.r / 255.0, G = block.g / 255.0, B = block.b / 255.0;
|
||||
double R = block.R / 255.0, G = block.G / 255.0, B = block.B / 255.0;
|
||||
if (R > 0.04045) R = Math.Pow((R + 0.055) / 1.055, 2.4);
|
||||
else R = R / 12.92;
|
||||
if (G > 0.04045) G = Math.Pow((G + 0.055) / 1.055, 2.4);
|
||||
@ -131,7 +131,7 @@ namespace MCGalaxy.Drawing {
|
||||
lab.L = 116 * Y - 16;
|
||||
lab.A = 500 * (X - Y);
|
||||
lab.B = 200 * (Y - Z);
|
||||
lab.Block = block.block;
|
||||
lab.Block = block.Block;
|
||||
return lab;
|
||||
}
|
||||
}
|
||||
|
@ -137,10 +137,10 @@ namespace MCGalaxy.Drawing {
|
||||
}
|
||||
|
||||
public struct PaletteEntry {
|
||||
public byte block, r, g, b;
|
||||
public byte R, G, B, Block;
|
||||
|
||||
public PaletteEntry(byte r, byte g, byte b, byte block) {
|
||||
this.r = r; this.g = g; this.b = b; this.block = block;
|
||||
R = r; G = g; B = b; Block = block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user