Beispiel #1
0
        protected virtual void DrawChildren(DrawContext drawContext, float actualOpacity)
        {
            if (children.Count == 0)
            {
                return;
            }

#if DEBUG
            Box2?clipRegionDebug = null;
#endif
            using (ClipChildren ? DrawState.Clip(Bounds, Manager.Camera) : null)
            {
                foreach (var child in children)
                {
                    if (child.displayed)
                    {
                        child.Draw(drawContext, actualOpacity);
                    }
                }

#if DEBUG
                if (ClipChildren)
                {
                    clipRegionDebug = DrawState.GetClipRegion(Manager.Camera);
                }
#endif
            }
#if DEBUG
            if (clipRegionDebug.HasValue)
            {
                Manager.Skin.GetDrawable("debug_clipregion")?.Draw(drawContext, manager.Camera, clipRegionDebug.Value, 1);
            }
#endif
        }
Beispiel #2
0
        public void Draw(DrawContext drawContext, Camera camera, Box2 bounds, float opacity)
        {
            validate();

            var inverseScaling = 1 / scaling;
            var color          = Color.WithOpacity(opacity);

            var renderer   = DrawState.Prepare(drawContext.Get <SpriteRenderer>(), camera, RenderStates);
            var clipRegion = DrawState.GetClipRegion(camera) ?? new Box2(camera.ExtendedViewport.Left, camera.ExtendedViewport.Top, camera.ExtendedViewport.Right, camera.ExtendedViewport.Bottom);

            foreach (var layoutGlyph in textLayout.VisibleGlyphs)
            {
                var glyph    = layoutGlyph.Glyph;
                var position = layoutGlyph.Position;

                var y      = bounds.Top + position.Y * inverseScaling;
                var height = glyph.Height * inverseScaling;

                if (y > clipRegion.Bottom)// || y - height > bounds.Bottom)
                {
                    break;
                }

                if (y + height < clipRegion.Top)// || y < bounds.Top)
                {
                    continue;
                }

                var x     = bounds.Left + position.X * inverseScaling;
                var width = glyph.Width * inverseScaling;

                renderer.Draw(glyph.Texture, x, y, 0, 0, inverseScaling, inverseScaling, 0, color);
            }
        }