示例#1
0
        public override void _Ready()
        {
            sprite  = new Sprite();
            image   = new Image();
            texture = new ImageTexture();
            noise   = new OpenSimplexNoise()
            {
                Octaves = Octaves
            };

            var viewportSize = GetViewportRect().Size;

            imageSize = viewportSize / Factor;
            imageSize = new Vector2((int)imageSize.x, (int)imageSize.y);
            image.Create((int)imageSize.x, (int)imageSize.y, false, Image.Format.Rgba8);

            // Generate
            GenerateNoiseTexture();

            // Create texture
            texture.CreateFromImage(image);

            // Prepare sprite
            sprite.Texture  = texture;
            sprite.Position = viewportSize / 2;
            sprite.Scale    = new Vector2(Factor, Factor);
            AddChild(sprite);
        }
示例#2
0
        /**
         * Construct a new Surface from the given image resource
         */
        public Surface(string Resourcepath)
        {
            texture = TextureManager.Get(Resourcepath);
            texture.Ref();
            width = texture.ImageWidth;
            height = texture.ImageHeight;

            Left = 0;
            Top = 0;
            Right = texture.UVRight;
            Bottom = texture.UVBottom;
        }
示例#3
0
        /// <summary>Construct a new Surface from the given image resource</summary>
        public Surface(string Resourcepath)
        {
            texture = TextureManager.Get(Resourcepath);
            texture.Ref();
            width  = texture.ImageWidth;
            height = texture.ImageHeight;

            Left   = 0;
            Top    = 0;
            Right  = texture.UVRight;
            Bottom = texture.UVBottom;
        }
示例#4
0
        public Surface(Surface other)
        {
            texture = other.texture;
            texture.Ref();

            width = other.width;
            height = other.height;

            Left = other.Left;
            Top = other.Top;
            Right = other.Right;
            Bottom = other.Bottom;
        }
示例#5
0
        public Surface(string Resourcepath, float x, float y, float w, float h)
        {
            texture = TextureManager.Get(Resourcepath);
            texture.Ref();

            width = w;
            height = h;

            Left = x / texture.Width;
            Top = y / texture.Height;
            Right = (x+w) / texture.Width;
            Bottom = (y+h) / texture.Height;
        }
示例#6
0
        public Surface(Surface other)
        {
            texture = other.texture;
            texture.Ref();

            width  = other.width;
            height = other.height;

            Left   = other.Left;
            Top    = other.Top;
            Right  = other.Right;
            Bottom = other.Bottom;
        }
示例#7
0
        public Surface(string Resourcepath, float x, float y, float w, float h)
        {
            texture = TextureManager.Get(Resourcepath);
            texture.Ref();

            width  = w;
            height = h;

            Left   = x / texture.Width;
            Top    = y / texture.Height;
            Right  = (x + w) / texture.Width;
            Bottom = (y + h) / texture.Height;
        }
示例#8
0
 public void Dispose()
 {
     texture.UnRef();
     texture = null;
 }
示例#9
0
 public void Dispose()
 {
     texture.UnRef();
     texture = null;
 }