예제 #1
0
        /// <summary>
        /// Draw text on surface
        /// </summary>
        /// <param name="face">Draw glyphs in <see cref="Face"/></param>
        /// <param name="pt">Size glyph in punkt</param>
        /// <param name="text">Text for drawing</param>
        /// <param name="color"><see cref="Color"/> of <see cref="Glyph"/></param>
        /// <param name="position">Position to draw on <see cref="Surface"/></param>
        /// <param name="origin">Origin of <see cref="Glyph"/></param>
        /// <param name="scale">Scale of <see cref="Glyph"/></param>
        /// <param name="angle">Rotation of <see cref="Glyph"/></param>
        /// <param name="verticalLayout"><see cref="Glyph"/> orientation</param>
        /// <exception cref="ArgumentNullException">parameter is null</exception>
        /// <exception cref="ArgumentException"><see cref="Face"/> handle is invalid</exception>
        /// <exception cref="ObjectDisposedException">Object disposed</exception>
        public void DrawText(Face face, float pt, string text, Color color, Point position, Point origin, Point scale, float angle, bool verticalLayout)
        {
            CheckDisposed();

            if (face == null)
            {
                throw new ArgumentNullException(nameof(face));
            }

            if (face.Object.IsInvalid)
            {
                throw new ArgumentException("face invalid", nameof(face));
            }

            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }

            if (color == null)
            {
                throw new ArgumentNullException(nameof(color));
            }

            if (text.Length != 0)
            {
                var unmanagedColor = new Import.Color
                {
                    red   = color.Red,
                    green = color.Green,
                    blue  = color.Blue,
                    alpha = color.Alpha
                };

                var unmanagedPosition = new Import.Point
                {
                    x = position.X,
                    y = position.Y
                };

                var unmanagedOrigin = new Import.Point
                {
                    x = origin.X,
                    y = origin.Y
                };

                var unmanagedScale = new Import.Point
                {
                    x = scale.X,
                    y = scale.Y
                };

                using (var unmanagedText = new StringHandle(text))
                {
                    Api.SurfaceDrawText(Object, face.Object, pt, unmanagedText, ref unmanagedColor, ref unmanagedPosition, ref unmanagedOrigin, ref unmanagedScale, angle, verticalLayout);
                }

                Object.CheckState();
            }
        }
예제 #2
0
        /// <summary>
        /// Set <see cref="Color"/> of pixel
        /// </summary>
        /// <param name="x">X position</param>
        /// <param name="y">Y position</param>
        /// <param name="color"><see cref="Color"/> of pixel</param>
        /// <exception cref="ObjectDisposedException">Object disposed</exception>
        public void SetPixel(int x, int y, Color color)
        {
            CheckDisposed();

            var unmanagedColor = new Import.Color
            {
                red   = color.Red,
                green = color.Green,
                blue  = color.Blue,
                alpha = color.Alpha
            };

            Api.SurfaceSetPixel(Object, x, y, ref unmanagedColor);
            Object.CheckState();
        }
예제 #3
0
        /// <summary>
        /// Draw glyph on surface to viewport
        /// </summary>
        /// <param name="glyph">Draw <see cref="Glyph"/></param>
        /// <param name="color"><see cref="Color"/> of <see cref="Glyph"/></param>
        /// <param name="position">Position to draw on <see cref="Surface"/></param>
        /// <param name="viewport">Viewport for glyph</param>
        /// <param name="origin">Origin of <see cref="Glyph"/></param>
        /// <param name="angle">Rotation of <see cref="Glyph"/></param>
        /// <param name="fitToViewport">Fit glyph to viewport without bearing</param>
        /// <exception cref="ArgumentNullException">parameter is null</exception>
        /// <exception cref="ArgumentException">glyph handle is invalid</exception>
        /// <exception cref="ObjectDisposedException">Object disposed</exception>
        public void DrawGlyphViewport(Glyph glyph, Color color, Point position, Point viewport, Point origin, float angle, bool fitToViewport)
        {
            CheckDisposed();

            if (glyph == null)
            {
                throw new ArgumentNullException(nameof(glyph));
            }

            if (glyph.Object.IsInvalid)
            {
                throw new ArgumentException("glyph invalid", nameof(glyph));
            }

            if (color == null)
            {
                throw new ArgumentNullException(nameof(color));
            }

            var unmanagedColor = new Import.Color
            {
                red   = color.Red,
                green = color.Green,
                blue  = color.Blue,
                alpha = color.Alpha
            };

            var unmanagedPosition = new Import.Point
            {
                x = position.X,
                y = position.Y
            };

            var unmanagedViewport = new Import.Point
            {
                x = viewport.X,
                y = viewport.Y
            };

            var unmanagedOrigin = new Import.Point
            {
                x = origin.X,
                y = origin.Y
            };

            Api.SurfaceDrawGlyphViewport(Object, glyph.Object, ref unmanagedColor, ref unmanagedPosition, ref unmanagedViewport, ref unmanagedOrigin, angle, fitToViewport);
            Object.CheckState();
        }
예제 #4
0
        /// <summary>
        /// Draw glyph on surface
        /// </summary>
        /// <param name="glyph">Draw <see cref="Glyph"/></param>
        /// <param name="color"><see cref="Color"/> of <see cref="Glyph"/></param>
        /// <param name="transform"><see cref="Transform"/> on <see cref="Glyph"/></param>
        /// <exception cref="ArgumentNullException">parameter is null</exception>
        /// <exception cref="ArgumentException">glyph and/or transform handle is invalid</exception>
        /// <exception cref="ObjectDisposedException">Object disposed</exception>
        public void DrawGlyphTransform(Glyph glyph, Color color, Transform transform)
        {
            CheckDisposed();

            if (glyph == null)
            {
                throw new ArgumentNullException(nameof(glyph));
            }

            if (glyph.Object.IsInvalid)
            {
                throw new ArgumentException("glyph invalid", nameof(glyph));
            }

            if (transform == null)
            {
                throw new ArgumentNullException(nameof(transform));
            }

            if (transform.Object.IsInvalid)
            {
                throw new ArgumentException("transform invalid", nameof(transform));
            }

            if (color == null)
            {
                throw new ArgumentNullException(nameof(color));
            }

            var unmanagedColor = new Import.Color
            {
                red   = color.Red,
                green = color.Green,
                blue  = color.Blue,
                alpha = color.Alpha
            };

            Api.SurfaceDrawGlyphTransform(Object, glyph.Object, ref unmanagedColor, transform.Object);
            Object.CheckState();
        }
예제 #5
0
        /// <summary>
        /// Fills the surface with a solid color.
        /// </summary>
        /// <param name="x">Starting horizontal position to fill</param>
        /// <param name="y">Starting vertical position to fill</param>
        /// <param name="width">Width to fill</param>
        /// <param name="height">Height to fill</param>
        /// <param name="color">Solid color to fill</param>
        /// <exception cref="ArgumentOutOfRangeException">Width and height can not be negative</exception>
        /// <exception cref="ArgumentNullException">Color is null</exception>
        /// <exception cref="ObjectDisposedException">Object disposed</exception>
        public void Fill(int x, int y, int width, int height, Color color)
        {
            CheckDisposed();

            if (x < 0)
            {
                x = 0;
            }

            if (y < 0)
            {
                y = 0;
            }

            if (width < 0)
            {
                new ArgumentOutOfRangeException(nameof(width), "Width can not be negative");
            }

            if (height < 0)
            {
                new ArgumentOutOfRangeException(nameof(height), "Height can not be negative");
            }

            if (color == null)
            {
                new ArgumentNullException(nameof(color), "Color is null");
            }

            var unmanagedColor = new Import.Color
            {
                red   = color.Red,
                green = color.Green,
                blue  = color.Blue,
                alpha = color.Alpha
            };

            Api.SurfaceFill(Object, (uint)x, (uint)y, (uint)width, (uint)height, ref unmanagedColor);
            Object.CheckState();
        }