Exemple #1
0
        /// <summary>A callback used when the graphic has been loaded and is ready for display.</summary>
        public void ImageReady(ImagePackage package)
        {
            if (!Image.Loaded())
            {
                return;
            }

            Element.OnLoaded("background-image");

            RequestLayout();

            int imageWidth  = Image.Width();
            int imageHeight = Image.Height();

            // Make sure offsets aren't bigger than the dimensions of a single image:

            if (RepeatX && OffsetX != null)
            {
                if (imageWidth == 0)
                {
                    OffsetX = null;
                }
                else
                {
                    OffsetX.PX = OffsetX.PX % imageWidth;
                }
            }

            if (RepeatY && OffsetY != null)
            {
                if (imageHeight == 0)
                {
                    OffsetY = null;
                }
                else
                {
                    OffsetY.PX = OffsetY.PX % imageHeight;
                }
            }

            if (Image != null && Filtering != FilterMode.Point && Image.Image != null)
            {
                Image.Image.filterMode = Filtering;
            }
        }
Exemple #2
0
        /// <summary>Applies the given image to the background.</summary>
        /// <param name="image">The image to use.</param>
        public void SetImage(Texture2D image)
        {
            Image = new ImagePackage(image);
            ImageReady(Image);
            ComputedStyle computed = Element.Style.Computed;

            if (!computed.FixedWidth)
            {
                // Set the width:
                computed.ChangeTagProperty("width", new Css.Value(Image.Width() + "px", Css.ValueType.Pixels));
            }

            if (!computed.FixedHeight)
            {
                // And the height too:
                computed.ChangeTagProperty("height", new Css.Value(Image.Height() + "px", Css.ValueType.Pixels));
            }

            Element.Document.Renderer.RequestLayout();
        }
        /// <summary>Called when an image is found for this character. Used by e.g. Emoji.</summary>
        /// <param name="package">The image that was found.</param>
        public void SetupImage(ImagePackage package)
        {
            if (package == null)
            {
                Image = null;
                return;
            }

            Image = package;

            // Great! We found this character somewhere else as an image:
            Width  = Image.Width();
            Height = Image.Height();

            // And apply delta width too:
            AdvanceWidth = Width;

            // Queue up a global layout.
            UI.document.Renderer.RequestLayout();
        }
		/// <summary>Applies the given image to the background.</summary>
		/// <param name="image">The image to use.</param>
		public void SetImage(Texture2D image){
			Image=new ImagePackage(image);
			ImageReady(Image);
			ComputedStyle computed=Element.Style.Computed;
			
			if(!computed.FixedWidth){
				// Set the width:
				computed.ChangeTagProperty("width",new Css.Value(Image.Width()+"px",Css.ValueType.Pixels));
			}
			
			if(!computed.FixedHeight){
				// And the height too:
				computed.ChangeTagProperty("height",new Css.Value(Image.Height()+"px",Css.ValueType.Pixels));
			}
			
			Element.Document.Renderer.RequestLayout();
		}