/// <summary> /// ����һ��RMVX��ʽ���α� /// </summary> /// /// <returns></returns> public static LTexture MakeCursor(int w, int h) { LPixmap cursor = new LPixmap(w, h, true); cursor.SetColor(0, 0, 0, 255); cursor.FillRect(0, 0, w, h); cursor.SetColor(255, 255, 255, 255); cursor.FillRect(1, 1, w - 2, h - 2); cursor.SetColor(0, 0, 0, 255); cursor.FillRect(4, 4, w - 8, h - 8); cursor.SetColor(0, 0, 0, 255); cursor.FillRect(w / 4, 0, w / 2, h); cursor.SetColor(0, 0, 0, 255); cursor.FillRect(0, h / 4, w, h / 2); Color[] basePixels = cursor.GetData(); int length = basePixels.Length; Color c = Color.Black; for (int i = 0; i < length; i++) { if (c.Equals(basePixels[i])) { basePixels[i].PackedValue = LSystem.TRANSPARENT; } } cursor.SetData(basePixels); return cursor.Texture; }
/// <summary> /// 绘制一个RMVX样式的游标 /// </summary> /// /// <returns></returns> public static LTexture MakeCursor(int w, int h) { LPixmap cursor = new LPixmap(w, h, true); cursor.SetColor(0, 0, 0, 255); cursor.FillRect(0, 0, w, h); cursor.SetColor(255, 255, 255, 255); cursor.FillRect(1, 1, w - 2, h - 2); cursor.SetColor(0, 0, 0, 255); cursor.FillRect(4, 4, w - 8, h - 8); cursor.SetColor(0, 0, 0, 255); cursor.FillRect(w / 4, 0, w / 2, h); cursor.SetColor(0, 0, 0, 255); cursor.FillRect(0, h / 4, w, h / 2); Color[] basePixels = cursor.GetData(); int length = basePixels.Length; Color c = Color.Black; for (int i = 0; i < length; i++) { if (c.Equals(basePixels[i])) { basePixels[i].PackedValue = LSystem.TRANSPARENT; } } cursor.SetData(basePixels); return(cursor.Texture); }
public static LTexture CreateTexture(int width, int height, LColor c) { LPixmap image = new LPixmap(width, height, false); image.SetColor(c); image.FillRect(0, 0, width, height); return(image.Texture); }
/// <summary> /// ˳ÐòΪ±³¾°£¬Ç°¾°£¬Öо° /// </summary> /// /// <param name="c1"></param> /// <param name="c2"></param> /// <param name="c3"></param> /// <returns></returns> public LTexture LoadBarColor(Color c1, Color c2, Color c3) { if (colors.Count > 10) { lock (colors) { foreach (LTexture tex2d in colors.Values) { if (tex2d != null) { tex2d.Destroy(); } } colors.Clear(); } } int hash = 1; hash = LSystem.Unite(hash, c1.PackedValue); hash = LSystem.Unite(hash, c2.PackedValue); hash = LSystem.Unite(hash, c3.PackedValue); LTexture texture_0 = null; lock (colors) { texture_0 = (LTexture)CollectionUtils.Get(colors, hash); } if (texture_0 == null) { LPixmap image = new LPixmap(8, 8, true); image.SetColor(c1); image.FillRect(0, 0, 4, 4); image.SetColor(c2); image.FillRect(4, 0, 4, 4); image.SetColor(c3); image.FillRect(0, 4, 4, 4); image.Dispose(); texture_0 = image.Texture; CollectionUtils.Put(colors, hash, texture_0); } return(this.texture = texture_0); }
public void DrawWidth(GLEx g, int x, int y) { try { if (drawTexWidth == null) { LPixmap img = new LPixmap(width, height, true); for (int i = 0; i < width; i++) { img.SetColor( (byte)((start.R * (width - i)) / width + (end.R * i) / width), (byte)((start.G * (width - i)) / width + (end.G * i) / width), (byte)((start.B * (width - i)) / width + (end.B * i) / width), (byte)alpha); img.DrawLine(i, 0, i, height); } drawTexWidth = img.Texture; } g.DrawTexture(drawTexWidth, x, y); } catch { for (int i = 0; i < width; i++) { g.SetColor( (byte)((start.R * (width - i)) / width + (end.R * i) / width), (byte)((start.G * (width - i)) / width + (end.G * i) / width), (byte)((start.B * (width - i)) / width + (end.B * i) / width), (byte)alpha); g.DrawLine(i + x, y, i + x, y + height); } } }
public void DrawHeight(GLEx g, int x, int y) { try { if (drawTexHeight == null) { LPixmap img = new LPixmap(width, height, true); for (int i = 0; i < height; i++) { img.SetColor((byte)( (start.R * (height - i)) / height + (end.R * i) / height), (byte)((start.G * (height - i)) / height + (end.G * i) / height), (byte)((start.B * (height - i)) / height + (end.B * i) / height), (byte)(alpha)); img.DrawLine(0, i, width, i); } drawTexHeight = img.Texture; } g.DrawTexture(drawTexHeight, x, y); } catch { for (int i = 0; i < height; i++) { g.SetColor( (byte)((start.R * (height - i)) / height + (end.R * i) / height), (byte)((start.G * (height - i)) / height + (end.G * i) / height), (byte)((start.B * (height - i)) / height + (end.B * i) / height), (byte)alpha); g.DrawLine(x, i + y, x + width, i + y); } } }
public void DrawHeight(LPixmap g, int x, int y) { try { if (drawImgHeight == null) { drawImgHeight = new LPixmap(width, height, true); for (int i = 0; i < height; i++) { drawImgHeight.SetColor( (byte)((start.R * (height - i)) / height + (end.R * i) / height), (byte)((start.G * (height - i)) / height + (end.G * i) / height), (byte)((start.B * (height - i)) / height + (end.B * i) / height), (byte)alpha); drawImgHeight.DrawLine(0, i, width, i); } } g.DrawPixmap(drawImgHeight, x, y); } catch { for (int i = 0; i < height; i++) { g.SetColor((byte)( (start.R * (height - i)) / height + (end.R * i) / height), (byte)((start.G * (height - i)) / height + (end.G * i) / height), (byte)((start.B * (height - i)) / height + (end.B * i) / height), (byte)alpha); g.DrawLine(x, i + y, x + width, i + y); } } }
public void DrawWidth(LPixmap g, int x, int y) { try { if (drawImgWidth == null) { drawImgWidth = new LPixmap(width, height, true); for (int i = 0; i < width; i++) { drawImgWidth.SetColor( (byte)((start.R * (width - i)) / width + (end.R * i) / width), (byte)((start.G * (width - i)) / width + (end.G * i) / width), (byte)((start.B * (width - i)) / width + (end.B * i) / width), (byte)alpha); drawImgWidth.DrawLine(i, 0, i, height); } } g.DrawPixmap(drawImgWidth, x, y); } catch { for (int i = 0; i < width; i++) { g.SetColor( (byte)((start.R * (width - i)) / width + (end.R * i) / width), (byte)((start.G * (width - i)) / width + (end.G * i) / width), (byte)((start.B * (width - i)) / width + (end.B * i) / width), (byte)alpha); g.DrawLine(i + x, y, i + x, y + height); } } }
public static LTexture CreateTexture(int width, int height, LColor c) { LPixmap image = new LPixmap(width, height, false); image.SetColor(c); image.FillRect(0, 0, width, height); return image.Texture; }
/// <summary> /// ˳��Ϊ������ǰ�����о� /// </summary> /// /// <param name="c1"></param> /// <param name="c2"></param> /// <param name="c3"></param> /// <returns></returns> public LTexture LoadBarColor(Color c1, Color c2, Color c3) { if (colors.Count > 10) { lock (colors) { foreach (LTexture tex2d in colors.Values) { if (tex2d != null) { tex2d.Destroy(); } } colors.Clear(); } } int hash = 1; hash = LSystem.Unite(hash, c1.PackedValue); hash = LSystem.Unite(hash, c2.PackedValue); hash = LSystem.Unite(hash, c3.PackedValue); LTexture texture_0 = null; lock (colors) { texture_0 = (LTexture)CollectionUtils.Get(colors, hash); } if (texture_0 == null) { LPixmap image = new LPixmap(8, 8, true); image.SetColor(c1); image.FillRect(0, 0, 4, 4); image.SetColor(c2); image.FillRect(4, 0, 4, 4); image.SetColor(c3); image.FillRect(0, 4, 4, 4); image.Dispose(); texture_0 = image.Texture; CollectionUtils.Put(colors, hash, texture_0); } return (this.texture = texture_0); }