public LPaper(LTexture background, int x, int y):base(x, y, background.GetWidth(), background.GetHeight()) { this.customRendering = true; this.SetBackground(background); this.SetElastic(true); this.SetLocked(true); this.SetLayer(100); }
public SpriteSheet(LTexture img, int tw, int th, int s, int m) { this.width = img.GetWidth(); this.height = img.GetHeight(); this.target = img; this.tw = tw; this.th = th; this.margin = m; this.spacing = s; }
public LPad(int x, int y, LTexture b, LTexture f, LTexture d, float scale) : base(x, y, (int)(f.GetWidth() * scale), (int)(f.GetHeight() * scale)) { this.offsetX = 6 * scale; this.offsetY = 6 * scale; this.fore = f; this.back = b; this.dot = d; this.dotWidth = (int)(d.GetWidth() * scale); this.dotHeight = (int)(d.GetHeight() * scale); this.baseWidth = (int)(f.GetWidth() * scale); this.baseHeight = (int)(f.GetHeight() * scale); this.backWidth = (int)(b.GetWidth() * scale); this.backHeight = (int)(b.GetHeight() * scale); this.centerX = (baseWidth - dotWidth) / 2 + offsetX; this.centerY = (baseHeight - dotHeight) / 2 + offsetY; this.scale_pad = scale; }
public Picture(LTexture image, int x, int y) { if (image != null) { this.SetImage(image); this.width = image.GetWidth(); this.height = image.GetHeight(); } this.SetLocation(x, y); this.visible = true; }
public RainKernel(int n, int w, int h) { id = n; rain = XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "rain_" + n + ".png"); rainWidth = rain.GetWidth(); rainHeight = rain.GetHeight(); width = w; height = h; offsetX = 0; offsetY = (5 - n) * 30 + 75 + MathUtils.Random() * 15; }
public SnowKernel(int n, int w, int h) { snow = XNAConfig .LoadTex(LSystem.FRAMEWORK_IMG_NAME + "snow_" + n + ".png"); snowWidth = snow.GetWidth(); snowHeight = snow.GetHeight(); width = w; height = h; offsetX = 0; offsetY = n * 0.6f + 1.9f + MathUtils.Random() * 0.2f; speed = MathUtils.Random(); }
private void Init(LTexture tex2d, float limit, bool remove, float scale) { this.isVisible = true; this.expandLimit = limit; this.width = tex2d.GetWidth(); this.height = tex2d.GetHeight(); this.scaleWidth = (int) (width * scale); this.scaleHeight = (int) (height * scale); this.loopMaxCount = (MathUtils.Max(scaleWidth, scaleHeight) / 2) + 1; this.fractions = new float[(scaleWidth * scaleHeight) * maxElements]; this.exWidth = (int) (scaleWidth * expandLimit); this.exHeigth = (int) (scaleHeight * expandLimit); LImage image = tex2d.GetImage().ScaledInstance(scaleWidth, scaleHeight); Color[] pixels = image.GetPixels(); if (image != null) { image.Dispose(); image = null; } this.size = pixels.Length; this.pixmap = new LPixmapData(exWidth, exHeigth, true); int no = 0, idx = 0; int length = fractions.Length; float angle = 0; float speed = 0; System.Random random = LSystem.random; for (int y = 0; y < scaleHeight; y++) { for (int x = 0; x < scaleWidth; x++) { if (idx + maxElements < length) { no = y * scaleWidth + x; angle = random.Next(360); speed = 10f / random.Next(30); fractions[idx + 0] = x; fractions[idx + 1] = y; fractions[idx + 2] = (MathUtils.Cos(angle * MathUtils.PI / 180) * speed); fractions[idx + 3] = (MathUtils.Sin(angle * MathUtils.PI / 180) * speed); fractions[idx + 4] = (pixels[no].PackedValue == 0xff00 ? 0xffffff : pixels[no].PackedValue); fractions[idx + 5] = x / 6 + random.Next(10); idx += maxElements; } } } if (remove) { if (tex2d != null) { tex2d.Destroy(); tex2d = null; } } this.tmp = tex2d; this.StartUsePixelThread(); }
public PetalKernel(int n, int w, int h) { id = n; sakura = XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "sakura_" + n + ".png"); sakuraWidth = sakura.GetWidth(); sakuraHeight = sakura.GetHeight(); width = w; height = h; offsetX = 0; offsetY = n * 0.6f + 1.9f + MathUtils.Random() * 0.2f; speed = MathUtils.Random(); }
public SplitEffect(LTexture t, RectBox limit_0, int d) { this.texture = t; this.width = texture.GetWidth(); this.height = texture.GetHeight(); this.halfWidth = width / 2; this.halfHeight = height / 2; this.multiples = 2; this.direction = d; this.limit = limit_0; this.timer = new LTimer(10); this.visible = true; this.v1 = new Vector2f(); this.v2 = new Vector2f(); switch (direction) { case Config.UP: case Config.DOWN: special = true; { v1.Set(0, 0); v2.Set(halfWidth, 0); break; } case Config.TLEFT: case Config.TRIGHT: v1.Set(0, 0); v2.Set(halfWidth, 0); break; case Config.LEFT: case Config.RIGHT: special = true; { v1.Set(0, 0); v2.Set(0, halfHeight); break; } case Config.TUP: case Config.TDOWN: v1.Set(0, 0); v2.Set(0, halfHeight); break; } }
public LMessage(LTexture formImage, int x, int y, int width, int height):base(x, y, width, height) { this.animation = new Animation(); if (formImage == null) { this.SetBackground(new LTexture(width, height, true, Loon.Core.Graphics.Opengl.LTexture.Format.SPEED)); this.SetAlpha(0.3F); } else { this.SetBackground(formImage); if (width == -1) { width = formImage.GetWidth(); } if (height == -1) { height = formImage.GetHeight(); } } this.print = new Print(GetLocation(), messageFont, width, height); this.SetTipIcon(XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "creese.png")); this.totalDuration = 80; this.customRendering = true; this.SetWait(false); this.SetElastic(true); this.SetLocked(true); this.SetLayer(100); }
public void CreateUI(GLEx g) { if (!visible) { return; } image = animation.GetSpriteImage(); if (image == null) { return; } float width = (image.GetWidth() * scaleX); float height = (image.GetHeight() * scaleY); if (filterColor == null) { if (alpha > 0 && alpha < 1) { g.SetAlpha(alpha); } if (LTrans.TRANS_NONE == transform) { g.DrawTexture(image, X(), Y(), width, height, rotation); } else { g.DrawRegion(image, 0, 0, GetWidth(), GetHeight(), transform, X(), Y(), LGraphics.TOP | LGraphics.LEFT); } if (alpha > 0 && alpha < 1) { g.SetAlpha(1); } return; } else { if (alpha > 0 && alpha < 1) { g.SetAlpha(alpha); } if (LTrans.TRANS_NONE == transform) { g.DrawTexture(image, X(), Y(), width, height, rotation, filterColor); } else { g.DrawRegion(image, 0, 0, GetWidth(), GetHeight(), transform, X(), Y(), LGraphics.TOP | LGraphics.LEFT, filterColor); } if (alpha > 0 && alpha < 1) { g.SetAlpha(1); } return; } }
public void SetImage(LTexture img) { if (img != null || this.image != null) { bool sizeChanged = true; if (img != null && this.image != null && img.GetWidth() == this.image.GetWidth() && img.GetHeight() == this.image.GetHeight()) { sizeChanged = false; } if (image != null && image.GetParent() == null && image.IsChildAllClose()) { if (image != null) { image.Destroy(); image = null; } } this.image = img; if (sizeChanged) { this.boundingRect = null; this.SizeChanged(); } } }
public void SetCreeseIcon(LTexture icon) { if (this.creeseIcon != null) { creeseIcon.Destroy(); creeseIcon = null; } this.creeseIcon = icon; if (icon == null) { return; } this.iconWidth = icon.GetWidth(); }
public void SetImageUI(int index, LTexture imageUI) { if (imageUI != null) { this.width = imageUI.GetWidth(); this.height = imageUI.GetHeight(); } this.imageUI[index] = imageUI; }
public void SetBackground(LTexture background) { if (background == null) { return; } LTexture oldImage = this.background; if (oldImage != background && oldImage != null) { oldImage.Destroy(); oldImage = null; } this.background = background; this.SetAlpha(1.0F); this.width = background.GetWidth(); this.height = background.GetHeight(); if (this.width <= 0) { this.width = 1; } if (this.height <= 0) { this.height = 1; } }
public virtual void SetImage(LTexture image) { this.image = image; this.width = image.GetWidth(); this.height = image.GetHeight(); }
private void Load(string script) { string[] op = StringUtils.Split(script, "="); if (op.Length == 2) { string key = op[0].Trim(); string value_ren = op[1].Trim(); if ("path".Equals(key, StringComparison.InvariantCultureIgnoreCase)) { path = value_ren.Replace("\"", ""); if (texture != null) { texture.Destroy(); texture = null; } if (GLEx.Self != null) { texture = new LTexture(path); imageWidth = texture.GetWidth(); imageHeight = texture.GetHeight(); } } if ("imagewidth".Equals(key, StringComparison.InvariantCultureIgnoreCase)) { if (MathUtils.IsNan(value_ren)) { imageWidth = Int32.Parse(value_ren); } } else if ("alpha".Equals(key, StringComparison.InvariantCultureIgnoreCase)) { if (MathUtils.IsNan(value_ren)) { alpha = Single.Parse(value_ren, JavaRuntime.NumberFormat); } } else if ("angle".Equals(key, StringComparison.InvariantCultureIgnoreCase)) { if (MathUtils.IsNan(value_ren)) { angle = Single.Parse(value_ren, JavaRuntime.NumberFormat); } } else if ("color".Equals(key, StringComparison.InvariantCultureIgnoreCase)) { string[] p = StringUtils.Split(value_ren, ","); if (p.Length > 2 && p.Length < 5) { for (int i = 0; i < p.Length; i++) { p[i] = p[i].Replace("^[\\t ]*", "").Replace( "[\\t ]*$", ""); } if (p.Length == 3) { color = new LColor(Int32.Parse(p[0]), Int32.Parse(p[1]), Int32.Parse(p[2])); } if (p.Length == 4) { color = new LColor(Int32.Parse(p[0]), Int32.Parse(p[1]), Int32.Parse(p[2]), Int32.Parse(p[3])); } } } else if ("imageheight".Equals(key, StringComparison.InvariantCultureIgnoreCase)) { if (MathUtils.IsNan(value_ren)) imageHeight = Int32.Parse(value_ren); } else if ("width".Equals(key, StringComparison.InvariantCultureIgnoreCase)) { if (MathUtils.IsNan(value_ren)) { width = Int32.Parse(value_ren); } } else if ("height".Equals(key, StringComparison.InvariantCultureIgnoreCase)) { if (MathUtils.IsNan(value_ren)) { height = Int32.Parse(value_ren); } } else if ("time".Equals(key, StringComparison.InvariantCultureIgnoreCase)) { if (MathUtils.IsNan(value_ren)) { tmp_time = Int32.Parse(value_ren); } } else if ("pos".Equals(key, StringComparison.InvariantCultureIgnoreCase)) { string[] p_0 = StringUtils.Split(value_ren, ","); for (int i_1 = 0; i_1 < p_0.Length; i_1++) { p_0[i_1] = p_0[i_1].Replace("^[\\t ]*", "").Replace( "[\\t ]*$", ""); } switch (p_0.Length) { case 1: if (MathUtils.IsNan(p_0[0])) { CollectionUtils.Add(posxTmps, Int32.Parse(p_0[0])); CollectionUtils.Add(posyTmps, Int32.Parse(p_0[0])); CollectionUtils.Add(time, tmp_time); alltime += tmp_time; } break; case 2: if (MathUtils.IsNan(p_0[0]) && MathUtils.IsNan(p_0[1])) { CollectionUtils.Add(posxTmps, Int32.Parse(p_0[0])); CollectionUtils.Add(posyTmps, Int32.Parse(p_0[1])); CollectionUtils.Add(time, tmp_time); alltime += tmp_time; } break; } } } }
public void SetClickImage(LTexture on) { if (on == null) { return; } if (bitmap != null) { bitmap.Dispose(); } this.bitmap = new LTextureRegion(on); this.SetSize(on.GetWidth(), on.GetHeight()); }
public virtual void SetBackground(LTexture background) { if (background != null) { SetRepaintMode(SCREEN_BITMAP_REPAINT); LTexture screen = null; if (background.GetWidth() != GetWidth() || background.GetHeight() != GetHeight()) { screen = background.Scale(GetWidth(), GetHeight()); } else { screen = background; } LTexture tmp = currentScreen; currentScreen = screen; if (tmp != null) { tmp.Destroy(); tmp = null; } } else { SetRepaintMode(SCREEN_CANVAS_REPAINT); } }
public LButton(LTexture img, string text, int x, int y):this(img, text, img.GetWidth(), img.GetHeight(), x, y) { }
public virtual void SetImage(string fileName) { this.image = new LTexture(fileName); this.width = image.GetWidth(); this.height = image.GetHeight(); }
/** * 渲染纹理为指定状态 * * @param texture * @param x_src * @param y_src * @param width * @param height * @param transform * @param x_dst * @param y_dst * @param anchor * @param c */ public void DrawRegion(LTexture texture, int x_src, int y_src, int width, int height, int transform, int x_dst, int y_dst, int anchor, LColor c) { if (isClose || texture == null || texture.isClose) { return; } if (!texture.isLoaded) { texture.LoadTexture(); } if (x_src + width > texture.GetWidth() || y_src + height > texture.GetHeight() || width < 0 || height < 0 || x_src < 0 || y_src < 0) { throw new Exception("Area out of texture"); } int dW = width, dH = height; float rotate = 0; Direction dir = Direction.TRANS_NONE; switch (transform) { case TRANS_NONE: { break; } case TRANS_ROT90: { rotate = 90; dW = height; dH = width; break; } case TRANS_ROT180: { rotate = 180; break; } case TRANS_ROT270: { rotate = 270; dW = height; dH = width; break; } case TRANS_MIRROR: { dir = Direction.TRANS_MIRROR; break; } case TRANS_MIRROR_ROT90: { dir = Direction.TRANS_MIRROR; rotate = -90; dW = height; dH = width; break; } case TRANS_MIRROR_ROT180: { dir = Direction.TRANS_MIRROR; rotate = -180; break; } case TRANS_MIRROR_ROT270: { dir = Direction.TRANS_MIRROR; rotate = -270; dW = height; dH = width; break; } default: throw new Exception("Bad transform"); } bool badAnchor = false; if (anchor == 0) { anchor = LGraphics.TOP | LGraphics.LEFT; } if ((anchor & 0x7f) != anchor || (anchor & LGraphics.BASELINE) != 0) { badAnchor = true; } if ((anchor & LGraphics.TOP) != 0) { if ((anchor & (LGraphics.VCENTER | LGraphics.BOTTOM)) != 0) { badAnchor = true; } } else if ((anchor & LGraphics.BOTTOM) != 0) { if ((anchor & LGraphics.VCENTER) != 0) { badAnchor = true; } else { y_dst -= dH - 1; } } else if ((anchor & LGraphics.VCENTER) != 0) { y_dst -= (dH - 1) >> 1; } else { badAnchor = true; } if ((anchor & LGraphics.LEFT) != 0) { if ((anchor & (LGraphics.HCENTER | LGraphics.RIGHT)) != 0) { badAnchor = true; } } else if ((anchor & LGraphics.RIGHT) != 0) { if ((anchor & LGraphics.HCENTER) != 0) { badAnchor = true; } else { x_dst -= dW - 1; } } else if ((anchor & LGraphics.HCENTER) != 0) { x_dst -= (dW - 1) >> 1; } else { badAnchor = true; } if (badAnchor) { throw new Exception("Bad Anchor"); } DrawTexture(texture, x_dst, y_dst, width, height, x_src, y_src, x_src + width, y_src + height, c, rotate, null, dir); }
public LInfo(LTexture formImage, int x, int y) : this(formImage, x, y, formImage.GetWidth(), formImage.GetHeight()) { }
public TextureObject(float x, float y, LTexture tex2d):base(x, y, tex2d.GetWidth(), tex2d.GetHeight(), Animation.GetDefaultAnimation(tex2d), null) { }
public LInfo(LTexture formImage, int x, int y, int width, int height) : base(x, y, width, height) { fontSize = deffont.GetSize(); if (formImage == null) { this.SetBackground(new LTexture(width, height, true)); this.SetAlpha(0.3F); } else { this.SetBackground(formImage); if (width == -1) { width = formImage.GetWidth(); } if (height == -1) { height = formImage.GetHeight(); } } this.message_char_count = 0; this.message_x = new int[messageCountMax]; this.message_y = new int[messageCountMax]; this.locatePoint = new List<LocatePoint>(); this.flag = new FlagImage(this); this.customRendering = true; this.SetElastic(true); this.SetLayer(100); }
public CollisionMask(LTexture.Mask d) { Set(d, 0, 0, d.GetWidth(), d.GetHeight()); }
private void Load(LTexture image, int x, int y) { this.Load(image, x, y, image.GetWidth(), image.GetHeight(), LSystem.screenRect.width, LSystem.screenRect.height); }
public static LTexture[][] GetSplit2Textures(LTexture image, int width, int height) { if (image == null) { return null; } if (!image.IsLoaded()) { image.LoadTexture(); } int wlength = image.GetWidth() / width; int hlength = image.GetHeight() / height; LTexture[][] textures = (LTexture[][])CollectionUtils.XNA_CreateJaggedArray(typeof(LTexture), wlength, hlength); for (int y = 0; y < hlength; y++) { for (int x = 0; x < wlength; x++) { textures[x][y] = image.GetSubTexture((x * width), (y * height), width, height); } } return textures; }
public LTextureObject(LTexture texture, float x, float y) { this.texture = texture; this.x = x; this.y = y; this.width = texture.GetWidth(); this.height = texture.GetHeight(); this.visible = true; }
public static LTexture[] GetSplitTextures(LTexture image, int width, int height) { if (image == null) { return null; } if (!image.IsLoaded()) { image.LoadTexture(); } int frame = 0; int wlength = image.GetWidth() / width; int hlength = image.GetHeight() / height; int total = wlength * hlength; LTexture[] images = new LTexture[total]; for (int y = 0; y < hlength; y++) { for (int x = 0; x < wlength; x++) { images[frame] = image.GetSubTexture((x * width), (y * height), width, height); frame++; } } return images; }