public static void WarpPath(GraphicsPath path, PointF[] destPoints, RectangleF srcRect, Matrix matrix = null, WarpMode warpMode = WarpMode.Perspective, float flatness = 0.25f)
        {
            if (path.PointCount == 0)
                return;

            path.Flatten(matrix, flatness);

            var pathData = path.PathData;
            var pnts = path.PathPoints;

            var srcPoints = new PointF[] { new PointF(srcRect.Left, srcRect.Top),
                new PointF(srcRect.Right, srcRect.Top),
                new PointF(srcRect.Left, srcRect.Bottom),
                new PointF(srcRect.Right, srcRect.Bottom) };

            var count = pnts.Length;
            float x1, y1;
            int i;

            if (warpMode == WarpMode.Perspective)
            {
                CalcProjectiveXformCoeffs(srcPoints, destPoints, out coeffs);

                for (i = 0; i < count; i++)
                {
                    x1 = pnts[i].X;
                    y1 = pnts[i].Y;

                    var factor = 1.0f / (coeffs[6] * x1 + coeffs[7] * y1 + 1.0f);
                    pnts[i].X = (float)(factor * (coeffs[0] * x1 + coeffs[1] * y1 + coeffs[2]));
                    pnts[i].Y = (float)(factor * (coeffs[3] * x1 + coeffs[4] * y1 + coeffs[5]));
                }
            }
            else
            {
                CalcBilinearXformCoeffs(srcPoints, destPoints, out coeffs);

                for (i = 0; i < count; i++)
                {
                    x1 = pnts[i].X;
                    y1 = pnts[i].Y;

                    pnts[i].X = (float)(coeffs[0] * x1 + coeffs[1] * y1 + coeffs[2] * x1 * y1 + coeffs[3]);
                    pnts[i].Y = (float)(coeffs[4] * x1 + coeffs[5] * y1 + coeffs[6] * x1 * y1 + coeffs[7]);
                }

            }

            GraphicsPath warpedPath = new GraphicsPath(pnts, pathData.Types);
            if (warpedPath != null)
            {
                FillMode fm = path.FillMode;
                path.Reset();
                path.FillMode = fm;

                path.AddPath(warpedPath, true);
                warpedPath.Dispose();
            }
        }
 internal static extern int GdipWarpPath(HandleRef path, HandleRef matrix, PointF *points, int count, float srcX, float srcY, float srcWidth, float srcHeight, WarpMode warpMode, float flatness);
        internal override void InternalDeserialize(NetIncomingMessage lidgrenMsg)
        {
            base.InternalDeserialize(lidgrenMsg);

            WarpMode                         = (WarpMode)lidgrenMsg.ReadInt32();
            GameMode                         = (GameMode)lidgrenMsg.ReadInt32();
            TerrainQuality                   = (TerrainQuality)lidgrenMsg.ReadInt32();
            AllowCheats                      = lidgrenMsg.ReadBoolean();
            AllowAdmin                       = lidgrenMsg.ReadBoolean();
            AllowSackKerbals                 = lidgrenMsg.ReadBoolean();
            AllowQuicksaves                  = lidgrenMsg.ReadBoolean();
            MaxNumberOfAsteroids             = lidgrenMsg.ReadInt32();
            ConsoleIdentifier                = lidgrenMsg.ReadString();
            GameDifficulty                   = (GameDifficulty)lidgrenMsg.ReadInt32();
            SafetyBubbleDistance             = lidgrenMsg.ReadFloat();
            MaxVesselParts                   = lidgrenMsg.ReadInt32();
            VesselUpdatesMsInterval          = lidgrenMsg.ReadInt32();
            SecondaryVesselUpdatesMsInterval = lidgrenMsg.ReadInt32();
            AllowOtherLaunchSites            = lidgrenMsg.ReadBoolean();
            AllowStockVessels                = lidgrenMsg.ReadBoolean();
            CanRevert                        = lidgrenMsg.ReadBoolean();
            AutoHireCrews                    = lidgrenMsg.ReadBoolean();
            BypassEntryPurchaseAfterResearch = lidgrenMsg.ReadBoolean();
            IndestructibleFacilities         = lidgrenMsg.ReadBoolean();
            MissingCrewsRespawn              = lidgrenMsg.ReadBoolean();
            ReentryHeatScale                 = lidgrenMsg.ReadFloat();
            ResourceAbundance                = lidgrenMsg.ReadFloat();
            FundsGainMultiplier              = lidgrenMsg.ReadFloat();
            FundsLossMultiplier              = lidgrenMsg.ReadFloat();
            RepGainMultiplier                = lidgrenMsg.ReadFloat();
            RepLossMultiplier                = lidgrenMsg.ReadFloat();
            RepLossDeclined                  = lidgrenMsg.ReadFloat();
            ScienceGainMultiplier            = lidgrenMsg.ReadFloat();
            StartingFunds                    = lidgrenMsg.ReadFloat();
            StartingReputation               = lidgrenMsg.ReadFloat();
            StartingScience                  = lidgrenMsg.ReadFloat();
            RespawnTimer                     = lidgrenMsg.ReadFloat();
            EnableCommNet                    = lidgrenMsg.ReadBoolean();
            EnableKerbalExperience           = lidgrenMsg.ReadBoolean();
            ImmediateLevelUp                 = lidgrenMsg.ReadBoolean();
            ResourceTransferObeyCrossfeed    = lidgrenMsg.ReadBoolean();
            BuildingImpactDamageMult         = lidgrenMsg.ReadFloat();
            PartUpgradesInCareerAndSandbox   = lidgrenMsg.ReadBoolean();
            RequireSignalForControl          = lidgrenMsg.ReadBoolean();
            DsnModifier                      = lidgrenMsg.ReadFloat();
            RangeModifier                    = lidgrenMsg.ReadFloat();
            OcclusionMultiplierVac           = lidgrenMsg.ReadFloat();
            OcclusionMultiplierAtm           = lidgrenMsg.ReadFloat();
            EnableGroundStations             = lidgrenMsg.ReadBoolean();
            PlasmaBlackout                   = lidgrenMsg.ReadBoolean();
            ActionGroupsAlways               = lidgrenMsg.ReadBoolean();
            GKerbalLimits                    = lidgrenMsg.ReadBoolean();
            GPartLimits                      = lidgrenMsg.ReadBoolean();
            PressurePartLimits               = lidgrenMsg.ReadBoolean();
            KerbalGToleranceMult             = lidgrenMsg.ReadFloat();
            AllowNegativeCurrency            = lidgrenMsg.ReadBoolean();
            MinScreenshotIntervalMs          = lidgrenMsg.ReadInt32();
            MaxScreenshotWidth               = lidgrenMsg.ReadInt32();
            MaxScreenshotHeight              = lidgrenMsg.ReadInt32();
            MinCraftLibraryRequestIntervalMs = lidgrenMsg.ReadInt32();
            PrintMotdInChat                  = lidgrenMsg.ReadBoolean();
        }
Esempio n. 4
0
 public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode, float flatness)
 {
     Changed();
     gdiPath.Warp(destPoints, srcRect, matrix, warpMode, flatness);
 }
        public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode, float flatness)
        {
            if (destPoints.Length < 3)
                throw new ArgumentOutOfRangeException ("destPoints must contain 3 or 4 points");

            if (destPoints.Length == 3)
            {
                var destPoints1 = new PointF[4];
                destPoints1 [0] = destPoints [0];
                destPoints1 [1] = destPoints [1];
                destPoints1 [2] = destPoints [2];
                destPoints1 [3] = new PointF ((destPoints [1].X - destPoints [0].X) + destPoints [2].X,
                                              (destPoints [1].Y - destPoints [0].Y) + destPoints [2].Y);
                GeomTransformUtils.WarpPath (this, destPoints1, srcRect, matrix, warpMode, flatness);
            }
            else
            {
                GeomTransformUtils.WarpPath (this, destPoints, srcRect, matrix, warpMode, flatness);
            }
        }
Esempio n. 6
0
        public static Bitmap Generate(string key)
        {
            Bitmap bmp = new Bitmap(200, 100);

            using (Graphics g = Graphics.FromImage(bmp))
            {
                Rectangle rct = new Rectangle(0, 0, bmp.Width, bmp.Height);

                Color backdropColor   = GenerateColor();
                Color foregroundColor = GenerateAlphaColor();
                Color fontForeColor   = GenerateColor();

                Color darkThemeColor = Color.FromArgb(54, 57, 63);
                int   tolerance      = 20;

                int rngR = _rng.Next(255 - fontForeColor.R);
                if (rngR < darkThemeColor.R + tolerance && rngR > darkThemeColor.R - tolerance)
                {
                    int spacing = 255 - rngR;
                    if (spacing > tolerance)
                    {
                        rngR += tolerance;
                    }
                    else if (spacing < tolerance)
                    {
                        rngR -= tolerance;
                    }
                }
                int rngG = _rng.Next(255 - fontForeColor.G);
                if (rngG < darkThemeColor.G + tolerance && rngG > darkThemeColor.G - tolerance)
                {
                    int spacing = 255 - rngG;
                    if (spacing > tolerance)
                    {
                        rngG += tolerance;
                    }
                    else if (spacing < tolerance)
                    {
                        rngG -= tolerance;
                    }
                }
                int rngB = _rng.Next(255 - fontForeColor.B);
                if (rngB < darkThemeColor.B + tolerance && rngB > darkThemeColor.B - tolerance)
                {
                    int spacing = 255 - rngB;
                    if (spacing > tolerance)
                    {
                        rngB += tolerance;
                    }
                    else if (spacing < tolerance)
                    {
                        rngB -= tolerance;
                    }
                }
                int distance = (rngR * rngR) + (rngG * rngG) + (rngB * rngB);
                int average  = (int)Math.Sqrt(distance / 3);

                int   fontBackR     = Math.Abs(fontForeColor.R - rngR);
                int   fontBackG     = Math.Abs(fontForeColor.G - rngG);
                int   fontBackB     = Math.Abs(fontForeColor.B - rngB);
                Color fontBackColor = Color.FromArgb(fontBackR, fontBackG, fontBackB);//GenerateColor();

                HatchStyle foregroundBrushStyle = GetRandomHatchStyle();
                Brush      foregroundBrush      = new HatchBrush(foregroundBrushStyle, fontForeColor, Color.Transparent);

                HatchStyle fontBrushStyle = GetRandomHatchStyle();
                Brush      fontBrush      = new HatchBrush(fontBrushStyle, fontForeColor, fontBackColor);



                //g.Clear(backdropColor);
                g.Clear(Color.Transparent);

                FontFamily family = FontFamily.GenericSansSerif;
                int        size   = GetRandomFontSize();
                Font       font   = new Font(family, size);

                Size  area          = g.MeasureString(key, font).ToSize();
                int   midPointHoriz = (bmp.Width / 2) - (area.Width / 2);
                int   midPointVert  = (bmp.Height / 2) - (area.Height / 2);
                Point center        = new Point(midPointHoriz, midPointVert);

                /*Bitmap text = new Bitmap(area.Width, area.Height);
                 * using (Graphics gr = Graphics.FromImage(text))
                 * {
                 *  gr.DrawString(key, font, fontBrush, 0, 0);
                 * }*/

                StringFormat format = new StringFormat();
                format.Alignment     = StringAlignment.Center;
                format.LineAlignment = StringAlignment.Center;
                GraphicsPath path = new GraphicsPath();
                path.AddString(key, family, (int)font.Style, size, rct, format);
                Pen    pen    = new Pen(fontBrush, _rng.Next(1, 72));
                Matrix matrix = new Matrix();

                WarpMode mode       = WarpMode.Perspective;
                PointF[] warpPoints = GetRandomWarpPoints(bmp.Size);
                matrix.Translate(0, 0);

                if (_rng.Next(0, 1) == 1)
                {
                    path.Widen(pen, matrix);
                }

                path.Warp(warpPoints, rct, matrix, mode, 0);

                //g.DrawImage(text, center);
                g.FillPath(fontBrush, path);
                g.FillRectangle(foregroundBrush, g.ClipBounds);
            }

            return(bmp);
        }
	public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, Matrix matrix, WarpMode warpMode, float flatness) {}
 public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode, float flatness)
 {
     throw new NotImplementedException();
 }
 public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, Matrix matrix, WarpMode warpMode, float flatness)
 {
 }
 public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode, float flatness)
 {
     if (destPoints == null)
         throw new ArgumentNullException(nameof(destPoints)); }
	public void Warp(PointF[] destPoints, RectangleF srcRect,
					 Matrix matrix, WarpMode warpMode, float flatness)
			{
				// TODO
			}
Esempio n. 12
0
 public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode)
 {
     Changed();
     GdiPath.Warp(destPoints, srcRect, matrix, warpMode);
 }
Esempio n. 13
0
File: Paths.cs Progetto: misiek/foo
 public static extern GpStatus GdipWarpPath(GpPath path, GpMatrix matrix,
     GpPointF[] points, int count,
     float srcx, float srcy, float srcwidth, float srcheight,
     WarpMode warpMode, float flatness);
Esempio n. 14
0
		public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix,  WarpMode warpMode, float flatness)
		{
			throw new NotImplementedException();
		}
Esempio n. 15
0
 public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix,
                  WarpMode warpMode, float flatness)
 {
     if (destPoints == null)
         throw new ArgumentNullException("destPoints");
     
     IntPtr buf = SafeNativeMethods.Gdip.ConvertPointToMemory(destPoints);
     try {
         int status = SafeNativeMethods.Gdip.GdipWarpPath(new HandleRef(this, nativePath),
                                       new HandleRef(matrix, (matrix == null) ? IntPtr.Zero : matrix.nativeMatrix),
                                       new HandleRef(null, buf),
                                       destPoints.Length,
                                       srcRect.X,
                                       srcRect.Y,
                                       srcRect.Width,
                                       srcRect.Height,
                                       warpMode,
                                       flatness);
         if (status != SafeNativeMethods.Gdip.Ok)
             throw SafeNativeMethods.Gdip.StatusException(status);
     } finally {
         Marshal.FreeHGlobal(buf);
     }
 }
Esempio n. 16
0
 public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode, float flatness)
 {
     throw null;
 }
Esempio n. 17
0
		public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode)
		{
                	Warp (destPoints, srcRect, matrix, warpMode, FlatnessDefault);
                }  		
 public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode, float flatness)
 {
     Changed();
     gdiPath.Warp(destPoints, srcRect, matrix, warpMode, flatness);
 }
Esempio n. 19
0
		public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix,  WarpMode warpMode, float flatness)
		{
			if (destPoints == null)
				throw new ArgumentNullException ("destPoints");

                	IntPtr m = (matrix == null) ? IntPtr.Zero : matrix.nativeMatrix;

                        Status s = GDIPlus.GdipWarpPath (nativePath, m, destPoints, destPoints.Length,
                                        srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, warpMode, flatness);

                        GDIPlus.CheckStatus (s);
                }
Esempio n. 20
0
 internal static extern Status GdipWarpPath (IntPtr path, IntPtr matrix,
                                             PointF [] points, int count,
                                             float srcx, float srcy, float srcwidth, float srcheight,
                                             WarpMode mode, float flatness);
Esempio n. 21
0
        public static void WarpPath(GraphicsPath path, PointF[] destPoints, RectangleF srcRect, Matrix matrix = null, WarpMode warpMode = WarpMode.Perspective, float flatness = 0.25f)
        {
            if (path.PointCount == 0)
            {
                return;
            }

            path.Flatten(matrix, flatness);

            var pathData = path.PathData;
            var pnts     = path.PathPoints;

            var srcPoints = new PointF[] { new PointF(srcRect.Left, srcRect.Top),
                                           new PointF(srcRect.Right, srcRect.Top),
                                           new PointF(srcRect.Left, srcRect.Bottom),
                                           new PointF(srcRect.Right, srcRect.Bottom) };

            var   count = pnts.Length;
            float x1, y1;
            int   i;

            if (warpMode == WarpMode.Perspective)
            {
                CalcProjectiveXformCoeffs(srcPoints, destPoints, out coeffs);

                for (i = 0; i < count; i++)
                {
                    x1 = pnts[i].X;
                    y1 = pnts[i].Y;

                    var factor = 1.0f / (coeffs[6] * x1 + coeffs[7] * y1 + 1.0f);
                    pnts[i].X = (float)(factor * (coeffs[0] * x1 + coeffs[1] * y1 + coeffs[2]));
                    pnts[i].Y = (float)(factor * (coeffs[3] * x1 + coeffs[4] * y1 + coeffs[5]));
                }
            }
            else
            {
                CalcBilinearXformCoeffs(srcPoints, destPoints, out coeffs);

                for (i = 0; i < count; i++)
                {
                    x1 = pnts[i].X;
                    y1 = pnts[i].Y;

                    pnts[i].X = (float)(coeffs[0] * x1 + coeffs[1] * y1 + coeffs[2] * x1 * y1 + coeffs[3]);
                    pnts[i].Y = (float)(coeffs[4] * x1 + coeffs[5] * y1 + coeffs[6] * x1 * y1 + coeffs[7]);
                }
            }

            GraphicsPath warpedPath = new GraphicsPath(pnts, pathData.Types);

            if (warpedPath != null)
            {
                FillMode fm = path.FillMode;
                path.Reset();
                path.FillMode = fm;

                path.AddPath(warpedPath, true);
                warpedPath.Dispose();
            }
        }
Esempio n. 22
0
 public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode)
 {
     Warp (destPoints, srcRect, matrix, WarpMode.Perspective, 0.25f);
 }
Esempio n. 23
0
File: Paths.cs Progetto: mitice/foo
 GdipWarpPath(GpPath path, GpMatrix matrix,
              GpPointF[] points, int count,
              float srcx, float srcy, float srcwidth, float srcheight,
              WarpMode warpMode, float flatness);
Esempio n. 24
0
GdipWarpPath(GpPath path, GpMatrix matrix,
            GpPointF[] points, int count,
            float srcx, float srcy, float srcwidth, float srcheight,
            WarpMode warpMode, float flatness);
Esempio n. 25
0
 // ====================================================================
 // Sets the warp mode for the image generation
 // ====================================================================
 private void SetWarpMode(string warp)
 {
     try
     {
         this._warpMode = (WarpMode)Enum.Parse(typeof(WarpMode), warp);
     }
     catch (Exception)
     {
         this._warpMode = WarpMode.Perspective;
     }
 }
Esempio n. 26
0
            internal static partial int GdipWarpPath(
#if NET7_0_OR_GREATER
                [MarshalUsing(typeof(HandleRefMarshaller))]
#endif
                HandleRef path,
#if NET7_0_OR_GREATER
                [MarshalUsing(typeof(HandleRefMarshaller))]
#endif
                HandleRef matrix, PointF *points, int count, float srcX, float srcY, float srcWidth, float srcHeight, WarpMode warpMode, float flatness);
Esempio n. 27
0
 internal static extern int GdipWarpPath(HandleRef path, HandleRef matrix, HandleRef points, int count,
                                         float srcX, float srcY, float srcWidth, float srcHeight,
                                         WarpMode warpMode, float flatness);
Esempio n. 28
0
 public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode)
 {
     Warp(destPoints, srcRect, matrix, warpMode, FlatnessDefault);
 }
Esempio n. 29
0
        // Once this is called, the resultant path is made of line segments and
        // the original path information is lost.  When matrix is null, the 
        // identity matrix is assumed.

        public GpStatus Warp(GpPointF[] destPoints,
                GpRectF srcRect,
                Matrix matrix,
                WarpMode warpMode,
                float flatness)
        {
            GpMatrix nativeMatrix = new GpMatrix();
            if (matrix != null)
                nativeMatrix = matrix.nativeMatrix;

            return SetStatus(NativeMethods.GdipWarpPath(
                                            nativePath,
                                            nativeMatrix,
                                            destPoints,
                                            destPoints.Length,
                                            srcRect.X,
                                            srcRect.Y,
                                            srcRect.Width,
                                            srcRect.Height,
                                            warpMode,
                                            flatness));
        }
Esempio n. 30
0
 public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode)
 {
     Warp(destPoints, srcRect, matrix, warpMode, 0.25f);
 }
Esempio n. 31
0
		public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode)
		{
			Warp (destPoints, srcRect, matrix, warpMode, 1.0f / 4.0f);
		}