FillEllipse() 공개 메소드

public FillEllipse ( Brush brush, RectangleF rect ) : void
brush Brush
rect RectangleF
리턴 void
예제 #1
1
        public static void RepertoryImage(Graphics drawDestination)
        {
            StringFormat itemStringFormat = new StringFormat();
            RectangleF itemBox = new RectangleF(10, 30, 42, 10);
            RectangleF itemBox2 = new RectangleF(60, 48, 10, 10);
            itemStringFormat.Alignment = StringAlignment.Center;
            itemStringFormat.LineAlignment = StringAlignment.Far;
            drawDestination.DrawLine(Pens.LightGray,10,10,10,70);
            if (mMscStyle == MscStyle.SDL){
                PointF[] capPolygon = new PointF[3];
                capPolygon[0] = new PointF(61, 40);
                capPolygon[1] = new PointF(53, 44);
                capPolygon[2] = new PointF(53, 36);
                drawDestination.FillPolygon(Brushes.Black,capPolygon);
                drawDestination.DrawString("Lost",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
                drawDestination.DrawString("g",new Font("Arial",8),Brushes.Black,itemBox2,itemStringFormat);
                drawDestination.DrawLine(Pens.Black,10, 40, 60,40);
                drawDestination.FillEllipse(Brushes.Black, new RectangleF(60,35, 10,10));
            }
            else if(mMscStyle == MscStyle.UML2){

                drawDestination.DrawString("Lost",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
                drawDestination.DrawString("g",new Font("Arial",8),Brushes.Black,itemBox2,itemStringFormat);
                drawDestination.DrawLine(Pens.Black,10, 40, 60,40);
                drawDestination.DrawLine(Pens.Black,60, 40, 54,43);
                drawDestination.DrawLine(Pens.Black,60, 40, 54,37);
                drawDestination.FillEllipse(Brushes.Black, new RectangleF(60,35, 10,10));

            }
            itemStringFormat.Dispose();
        }
        public static void FillPill(Brush b, RectangleF rect, Graphics g)
        {
            if (rect.Width > rect.Height)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.FillEllipse(b, new RectangleF(rect.Left, rect.Top, rect.Height, rect.Height));
                g.FillEllipse(b, new RectangleF(rect.Left + rect.Width - rect.Height, rect.Top, rect.Height, rect.Height));

                var w = rect.Width - rect.Height;
                var l = rect.Left + ((rect.Height) / 2);
                g.FillRectangle(b, new RectangleF(l, rect.Top, w, rect.Height));
                g.SmoothingMode = SmoothingMode.Default;
            }
            else if (rect.Width < rect.Height)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.FillEllipse(b, new RectangleF(rect.Left, rect.Top, rect.Width, rect.Width));
                g.FillEllipse(b, new RectangleF(rect.Left, rect.Top + rect.Height - rect.Width, rect.Width, rect.Width));

                var t = rect.Top + (rect.Width / 2);
                var h = rect.Height - rect.Width;
                g.FillRectangle(b, new RectangleF(rect.Left, t, rect.Width, h));
                g.SmoothingMode = SmoothingMode.Default;
            }
            else if (rect.Width == rect.Height)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.FillEllipse(b, rect);
                g.SmoothingMode = SmoothingMode.Default;
            }
        }
예제 #3
0
 public static void RepertoryImage(Graphics drawDestination)
 {
     StringFormat itemStringFormat = new StringFormat();
     RectangleF itemBox = new RectangleF(15, 30, 50, 20);
     itemStringFormat.Alignment = StringAlignment.Center;
     itemStringFormat.LineAlignment = StringAlignment.Center;
     drawDestination.DrawLine(Pens.LightGray,40,10,40,70);
     if (mMscStyle == MscStyle.SDL){
         PointF[] statePolygon = new PointF[6];
         statePolygon[0] = new PointF(5,40);
         statePolygon[1] = new PointF(15,30);
         statePolygon[2] = new PointF(65,30);
         statePolygon[3] = new PointF(75,40);
         statePolygon[4] = new PointF(65,50);
         statePolygon[5] = new PointF(15,50);
         drawDestination.FillPolygon(Brushes.White,statePolygon);
         drawDestination.DrawString("State",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
         drawDestination.DrawPolygon(Pens.Black,statePolygon);
     }
     else if(mMscStyle == MscStyle.UML2){
             drawDestination.FillRectangle(Brushes.White,itemBox);
             drawDestination.FillEllipse(Brushes.White,5,30,20,20);
             drawDestination.FillEllipse(Brushes.White,55,30,20,20);
             drawDestination.DrawLine(Pens.Black,15,30,65,30);
             drawDestination.DrawLine(Pens.Black,15,50,65,50);
             drawDestination.DrawArc(Pens.Black,5,30,20,20,90,180);
             drawDestination.DrawArc(Pens.Black,55,30,20,20,270,180);
             drawDestination.DrawString("State",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
     }
     itemStringFormat.Dispose();
 }
		public void Draw(Graphics g, Size mapSize)
		{
			bool drawSquares = false;
			var galaxyMap = GalaxyMap.Instance;
			var galaxy = galaxyMap.Galaxy;
			var faction = galaxy.GetFaction(Planet);
			var color = faction != null ? faction.Color : Color.White;
			using (var brush = new SolidBrush(color)) {
				var x1 = (int)(Position.X*mapSize.Width - PlanetSize/2);
				var y1 = (int)(Position.Y*mapSize.Height - PlanetSize/2);

             
                g.FillEllipse(Brushes.Black, x1 - OutlineSize, y1 - OutlineSize, PlanetSize + OutlineSize * 2, PlanetSize + OutlineSize * 2);
				g.FillEllipse(brush, x1, y1, PlanetSize, PlanetSize);

                

				if (drawSquares) {
					g.SmoothingMode = SmoothingMode.None;
					g.InterpolationMode = InterpolationMode.NearestNeighbor;

					Faction attackFaction;
					var found = galaxyMap.AttackablePlanetIDs.TryGetValue(Planet.ID, out attackFaction);
					if (found) {
						g.DrawRectangle(new Pen(attackFaction.Color, 3), x1, y1, PlanetSize, PlanetSize);
					}

					if (galaxyMap.ClaimablePlanetIDs.Contains(Planet.ID)) {
						g.DrawRectangle(new Pen(Color.Purple, 3), x1, y1, PlanetSize, PlanetSize);
					}
					g.SmoothingMode = SmoothingMode.AntiAlias;
					g.InterpolationMode = InterpolationMode.HighQualityBicubic;
				}
			}
		}
        /// <summary>
        /// Overridden. Draws the content of the QTabButton button, here the extra CloseButton is painted.
        /// </summary>
        protected override void DrawTabButtonContent(QTabButton button, QTabButtonConfiguration buttonConfiguration, string text, Icon icon, Color replaceColor, Color replaceColorWith, Color textColor, Font font, Rectangle bounds, Graphics graphics)
        {
            //First call the base.
            base.DrawTabButtonContent(button, buttonConfiguration, text, icon, replaceColor, replaceColorWith, textColor, font, bounds, graphics);

            //Get the QTabCloseButton.
            QTabCloseButton tmp_oButton = button.Control.Tag as QTabCloseButton;

            if (tmp_oButton != null)
            {
                //Set the bounds.
                tmp_oButton.Bounds = new Rectangle(bounds.Right + 2, bounds.Top + 3, 10, 11);

                //Determine its state and draw an Ellipse and a Cross image.
                if ((tmp_oButton.IsPressed) && (tmp_oButton.IsHot))
                {
                    graphics.FillEllipse(Brushes.DarkRed, new QPadding(2, 2, 1, 1).InflateRectangleWithPadding(tmp_oButton.Bounds, true, true));
                    QControlPaint.DrawImage(QTabCloseButton.CloseMask, Color.Red, Color.White, QImageAlign.Centered, tmp_oButton.Bounds, QTabCloseButton.CloseMask.Size, graphics);
                }
                else if (tmp_oButton.IsHot)
                {
                    graphics.FillEllipse(Brushes.Red, new QPadding(2,2,1,1).InflateRectangleWithPadding(tmp_oButton.Bounds, true, true));
                    QControlPaint.DrawImage(QTabCloseButton.CloseMask, Color.Red, Color.White, QImageAlign.Centered, tmp_oButton.Bounds, QTabCloseButton.CloseMask.Size, graphics);
                }
                else
                {
                    QControlPaint.DrawImage(QTabCloseButton.CloseMask, Color.Red, Color.FromArgb(50,50,50), QImageAlign.Centered, tmp_oButton.Bounds, QTabCloseButton.CloseMask.Size, graphics);
                }

            }

        }
예제 #6
0
        internal override void Render(Graphics graphics, SizeF minimumSize, PointF location)
        {
            var size = Measure(graphics);
            size.Width = Math.Max(minimumSize.Width, size.Width);
            size.Height = Math.Max(minimumSize.Height, size.Height);

            Brush incomingSignalColor = Brushes.LightSteelBlue;
            Brush ownSignalColor = Brushes.LightSteelBlue;

            if (m_signal.IsIncomingRised())
            {
                incomingSignalColor = Brushes.LimeGreen;
            }

            if (m_signal.IsDropped())
            {
                ownSignalColor = Brushes.Tomato;
            }
            if (m_signal.IsRised())
            {
                ownSignalColor = Brushes.LimeGreen;
            }

            graphics.FillEllipse(incomingSignalColor, location.X + SIGNAL_OFFSET, location.Y + SIGNAL_OFFSET, SIGNAL_SIZE, SIGNAL_SIZE);
            graphics.DrawEllipse(Pens.DimGray, location.X + SIGNAL_OFFSET, location.Y + SIGNAL_OFFSET, SIGNAL_SIZE, SIGNAL_SIZE);

            graphics.FillEllipse(ownSignalColor, location.X + 2 * SIGNAL_OFFSET + SIGNAL_SIZE, location.Y + SIGNAL_OFFSET, SIGNAL_SIZE, SIGNAL_SIZE);
            graphics.DrawEllipse(Pens.DimGray, location.X + 2 * SIGNAL_OFFSET + SIGNAL_SIZE, location.Y + SIGNAL_OFFSET, SIGNAL_SIZE, SIGNAL_SIZE);

            graphics.DrawString(this.Text, SystemFonts.MenuFont, Brushes.Black, new RectangleF(location, size), GraphConstants.RightTextStringFormat);
        }
예제 #7
0
        public override void drawnShap(Graphics pe)
        {
            Brush CurrentBrush = initBrush();
            if (this.State.Shift1 == true)
            {
                calcShift();

                findSecondPointWhenShift();

                pe.DrawEllipse(new Pen(State.CurrentColor, State.LineWidth), State.StartPoint.X, State.StartPoint.Y, State.Width1, State.Width1);
                if (State.IsBrushFill == true)
                {
                    pe.FillEllipse(CurrentBrush, State.StartPoint.X, State.StartPoint.Y, State.Width1, State.Width1);
                }
            }
            else
            {
                calcHeightWidth();
                pe.DrawEllipse(new Pen(State.CurrentColor, State.LineWidth), State.StartPoint.X, State.StartPoint.Y, State.Width1, State.Height1);

                if (State.IsBrushFill == true)
                {
                    pe.FillEllipse(CurrentBrush, State.StartPoint.X, State.StartPoint.Y, State.Width1, State.Height1);
                }
            }


        }
    /// <summary>
    /// Draws a breakpoint icon in the margin.
    /// </summary>
    /// <param name="g">The <see cref="Graphics"/> context.</param>
    /// <param name="rectangle">The bounding rectangle.</param>
    /// <param name="isEnabled"><c>true</c> if enabled..</param>
    /// <param name="willBeHit"><c>true</c> if it will be hit.</param>
    public static void DrawBreakpoint(Graphics g, Rectangle rectangle, bool isEnabled, bool willBeHit)
    {
      int diameter = Math.Min(rectangle.Width - 4, rectangle.Height);
      Rectangle rect = new Rectangle(2, rectangle.Y + (rectangle.Height - diameter) / 2, diameter, diameter);

      using (GraphicsPath path = new GraphicsPath())
      {
        path.AddEllipse(rect);
        using (PathGradientBrush pthGrBrush = new PathGradientBrush(path))
        {
          pthGrBrush.CenterPoint = new PointF(rect.Left + rect.Width / 3, rect.Top + rect.Height / 3);
          pthGrBrush.CenterColor = Color.MistyRose;
          Color[] colors = { willBeHit ? Color.Firebrick : Color.Olive };
          pthGrBrush.SurroundColors = colors;

          if (isEnabled)
          {
            g.FillEllipse(pthGrBrush, rect);
          }
          else
          {
            g.FillEllipse(SystemBrushes.Control, rect);
            using (Pen pen = new Pen(pthGrBrush))
            {
              g.DrawEllipse(pen, new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2));
            }
          }
        }
      }
    }
예제 #9
0
        public override void Draw(Graphics g)
        {
            RectangleF rect = rectComponent.TopLeftCorner.CloneAndAdd(0, offSet).MakeRectangleFTill(rectComponent.BottomRightCorner.CloneAndAdd(0, -offSet));
            RectangleF upperRect = rectComponent.TopLeftCorner.MakeRectangleFTill(rectComponent.TopLeftCorner.CloneAndAdd(rectComponent.Width, 2 * offSet));
            RectangleF lowerRect = rectComponent.BottomRightCorner.CloneAndAdd(-rectComponent.Width, -2 * offSet).MakeRectangleFTill(rectComponent.BottomRightCorner);

            using (LinearGradientBrush brush =
                new LinearGradientBrush(rect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
            {
                g.FillRectangle(brush, rect);
                g.DrawRectangle(ViewFactory.BorderPen, rect.X, rect.Y, rect.Width, rect.Height);
            }


            using (LinearGradientBrush brush =
                new LinearGradientBrush(upperRect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
            {
                g.FillEllipse(brush, upperRect);
                g.DrawEllipse(ViewFactory.BorderPen, upperRect.X, upperRect.Y, upperRect.Width, upperRect.Height);
            }

            using (LinearGradientBrush brush =
                new LinearGradientBrush(lowerRect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
            {
                g.FillEllipse(brush, lowerRect);
                g.DrawArc(ViewFactory.BorderPen, lowerRect, 0, 180);
            }
            base.Draw(g);
        }
예제 #10
0
		public override void Draw(Graphics aGfx,int alWorldX,int alWorldY ,eEditMode mMode, bool abSelected)
		{
			Color Col;
			
			if(mMode == eEditMode.Lights)
			{
				Col = abSelected?Color.FromArgb(80,255,80):Color.FromArgb(255,0,255);
				
				SolidBrush CenterBrush = new SolidBrush(Col);
				aGfx.FillEllipse(CenterBrush,mlX-10-alWorldX,mlY-10-alWorldY,
					20,20);
				CenterBrush.Dispose();
			}
			else
			{
				Col = Color.Gray;
				SolidBrush CenterBrush = new SolidBrush(Col);
				aGfx.FillEllipse(CenterBrush,mlX-3-alWorldX,mlY-3-alWorldY,
					6,6);
				CenterBrush.Dispose();
			}


            Pen OuterPen = new Pen(Col);
			aGfx.DrawEllipse(OuterPen,mlX-mfRadius-alWorldX,mlY-mfRadius-alWorldY,
							mfRadius*2,mfRadius*2);
			OuterPen.Dispose();
		}
예제 #11
0
 /// <summary>
 /// Draw a Vertex
 /// </summary>
 public static void DrawEdge(Graphics g, IEdge e, PointF pSource, PointF pTarget, bool highLight = false)
 {
     var ps = pSource;
     var pt = pTarget;
     g.DrawLine(highLight ? penHighLight : penEdge, ps, pt);
     g.FillEllipse(highLight ? brushHighLight : brushEdgePoint, (pt.X + ps.X) / 2 - 2, (pt.Y + ps.Y) / 2 - 2, 4, 4);
     g.FillEllipse(highLight ? brushHighLight : brushEdgePoint, (pt.X * 2 + 3 * ps.X) / 5 - 4, (pt.Y * 2 + ps.Y * 3) / 5 - 4, 8, 8);
 }
예제 #12
0
 private void DrawRoundRect(Graphics g, Brush br, Rectangle area)
 {
     int rd = 8;
     g.FillEllipse(br, area.X, area.Y, rd * 2, rd * 2);
     g.FillEllipse(br, area.X, area.Y + area.Height - rd * 2, rd * 2, rd * 2);
     g.FillEllipse(br, area.X + area.Width - rd * 2, area.Y, rd * 2, rd * 2);
     g.FillEllipse(br, area.X + area.Width - rd * 2, area.Y + area.Height - rd * 2, rd * 2, rd * 2);
     g.FillRectangle(br, area.X , area.Y + rd, area.Width+1, area.Height - rd*2);
     g.FillRectangle(br, area.X + rd, area.Y, area.Width - rd * 2, area.Height+1);
 }
예제 #13
0
파일: Vertex.cs 프로젝트: flufferok/OOP
 public override void Draw(Graphics g, string str)
 {
     switch(str)
     {
         case "XY": g.FillEllipse(new SolidBrush(Color.Black), _x, g.VisibleClipBounds.Height - _y, 6, 6); break;
         case "XZ": g.FillEllipse(new SolidBrush(Color.Black), _x, g.VisibleClipBounds.Height - _z, 6, 6); break;
         case "YZ": g.FillEllipse(new SolidBrush(Color.Black), _y, g.VisibleClipBounds.Height - _z, 6, 6); break;
         default: break;
     }
 }
예제 #14
0
파일: Box.cs 프로젝트: RyanCccc/Checker_AI
 public void draw(Graphics g)
 {
     Pen p = new Pen(Brushes.Black, 3);
     g.DrawLine(p, new Point( Width / 2-1,0),new Point( Width / 2-1,Height));
     g.DrawLine(p, new Point(0, Height/2-1), new Point(Width, Height/2-1));
     if (hasCheck==1)
         g.FillEllipse(Brushes.Black, new Rectangle(0, 0, 25, 25));
     else if(hasCheck==2)
         g.FillEllipse(Brushes.White, new Rectangle(0, 0, 25, 25));
 }
예제 #15
0
파일: Circle.cs 프로젝트: Ring-r/sandbox
        public void Draw(Graphics g)
        {
            float r = this.r / 4;

            float d = (float)Math.Sqrt(this.vx * this.vx + this.vy * this.vy);
            if (d != 0.0f) {
                float vx = this.vx / d;
                float vy = this.vy / d;
                float vx_ = vy;
                float vy_ = -vx;

                PointF[] points = new PointF[3];
                points[0] = new PointF(this.px + this.r * vx_, this.py + this.r * vy_);
                points[1] = new PointF(this.px + 3 * this.r / 2 * vx, this.py + 3 * this.r / 2 * vy);
                points[2] = new PointF(this.px - this.r * vx_, this.py - this.r * vy_);
                Brush brush = new SolidBrush(Color.FromArgb(150, Color.Blue));
                g.FillPolygon(brush, points);

                float x;
                float y;

                float rFoot = this.r - r / 2;
                float rHand = 2 * r;
                float koef = (float)Math.Sin(this.t / rFoot * (float)Math.PI);
                float dFoot = rFoot * koef;
                float dHand = rHand * koef;

                x = this.px + vx_ * (this.r - r) + dHand * vx;
                y = this.py + vy_ * (this.r - r) + dHand * vy;
                g.FillEllipse(this.brush, x - r, y - r, 2 * r, 2 * r);
                g.DrawEllipse(this.pen, x - r, y - r, 2 * r, 2 * r);

                x = this.px + vx_ * r - dFoot * vx;
                y = this.py + vy_ * r - dFoot * vy;
                g.FillEllipse(this.brush, x - r, y - r, 2 * r, 2 * r);
                g.DrawEllipse(this.pen, x - r, y - r, 2 * r, 2 * r);

                x = this.px - vx_ * (this.r - r) - dHand * vx;
                y = this.py - vy_ * (this.r - r) - dHand * vy;
                g.FillEllipse(this.brush, x - r, y - r, 2 * r, 2 * r);
                g.DrawEllipse(this.pen, x - r, y - r, 2 * r, 2 * r);

                x = this.px - vx_ * r + dFoot * vx;
                y = this.py - vy_ * r + dFoot * vy;
                g.FillEllipse(this.brush, x - r, y - r, 2 * r, 2 * r);
                g.DrawEllipse(this.pen, x - r, y - r, 2 * r, 2 * r);

                this.t += d;
            } else {
                this.t = 0.0f;
            }

            g.FillEllipse(this.brush, this.px - this.r, this.py - this.r, 2 * this.r, 2 * this.r);
            g.DrawEllipse(this.pen, this.px - this.r, this.py - this.r, 2 * this.r, 2 * this.r);
        }
예제 #16
0
        public void drawSelf(Graphics g, Pen p)
        {
            int origin = (size / 2);

            if (selected)
            {
                g.FillEllipse(new SolidBrush(Color.FromArgb(64, 255, 255, 255)), position.X + origin, position.Y + origin, size, size);

            }
            g.DrawEllipse(p, position.X, position.Y, size, size);
            g.FillEllipse(Brushes.Red, position.X + origin + (origin /2), position.Y + origin + (origin / 2), size / 2, size / 2);
        }
예제 #17
0
        public void Draw(Graphics g)
        {
            // Head
            g.FillEllipse(mBrush, mListenerPos.x - SIZE, mListenerPos.y - SIZE, SIZE*2, SIZE*2);

            // Nose
            g.FillEllipse(mBrush, mListenerPos.x - SIZE/2, mListenerPos.y - SIZE - 5, SIZE, SIZE);

            // Ears
            g.FillEllipse(mBrush, mListenerPos.x - SIZE - 5, mListenerPos.y - SIZE/2, SIZE, SIZE);
            g.FillEllipse(mBrush, mListenerPos.x + SIZE - 10, mListenerPos.y - SIZE/2, SIZE, SIZE);
        }
예제 #18
0
        public void Draw(Graphics g)
        {
            if (StartPos != Point.Empty)
            {
                if (blink)
                    g.FillEllipse(Brushes.Red, StartPos.X, StartPos.Y, 10, 10);
                else
                    g.FillEllipse(Brushes.Blue, StartPos.X, StartPos.Y, 10, 10);

                blink = !blink;
            }
        }
예제 #19
0
        private void drawCircle()
        {
            bmp = new Bitmap((int)pbWIDTH, (int)pbHEIGHT);
            Pen pen = new Pen(Brushes.Black, width_pen);
            g = Graphics.FromImage(bmp);
            if (stan==0) g.FillEllipse(Brushes.White, (int)((pbHEIGHT - pbHEIGHT / 1.15) / 2), (int)((pbHEIGHT - pbHEIGHT / 1.15) / 2), (int)(pbHEIGHT / 1.15), (int)(pbWIDTH / 1.15));
            if (stan == 1) g.FillEllipse(Brushes.LightGreen, (int)((pbHEIGHT - pbHEIGHT / 1.15) / 2), (int)((pbHEIGHT - pbHEIGHT / 1.15) / 2), (int)(pbHEIGHT / 1.15), (int)(pbWIDTH / 1.15));
            if (stan == 2) g.FillEllipse(Brushes.Red, (int)((pbHEIGHT - pbHEIGHT / 1.15) / 2), (int)((pbHEIGHT - pbHEIGHT / 1.15) / 2), (int)(pbHEIGHT / 1.15), (int)(pbWIDTH / 1.15));

            g.DrawEllipse(pen, (int)((pbHEIGHT - pbHEIGHT/1.15)/2), (int)((pbHEIGHT - pbHEIGHT / 1.15) / 2), (int)(pbHEIGHT/1.15), (int)(pbWIDTH/1.15));
            g.DrawString("Pompa", new Font("Arial", 10), Brushes.Black, pbWIDTH / 4.7F, pbHEIGHT / 2.8F);
            
        }
예제 #20
0
        public void Draw(Graphics grafico)
        {
            Pen p = new Pen(Color.Black);

            grafico.DrawEllipse(p,r1);
            grafico.FillEllipse(brs[0],r1);
            grafico.DrawEllipse(p,r2);
            grafico.FillEllipse(brs[1],r2);
            grafico.DrawEllipse(p,r3);
            grafico.FillEllipse(brs[2],r3);
            grafico.DrawEllipse(p,r4);
            grafico.FillEllipse(brs[3],r4);
        }
예제 #21
0
파일: Form1.cs 프로젝트: j0eyWh/DrawApp
 //Get circle
 public void GetCircle(Point center, int radius, Pen borderPen, Pen mainPen, Graphics graph)
 {
     Rectangle rect = new Rectangle(center.X - radius / 2, center.Y - radius / 2, radius, radius);
     if (borderPen.Width == 0)
     {
         graph.FillEllipse(mainPen.Brush, rect);
     }
     else
     {
         graph.FillEllipse(mainPen.Brush, rect);
         graph.DrawEllipse(borderPen, rect);
     }
 }
예제 #22
0
 public void render(Graphics g)
 {
     for (int i = 0; i < gObjects.Length; i++)
         g.FillEllipse(Brushes.Blue,
             gObjects[i].Position.X - (gObjects[i].Mass * Params.gBodyDrawScale) / 2,
             gObjects[i].Position.Y - (gObjects[i].Mass * Params.gBodyDrawScale) / 2,
             gObjects[i].Mass * Params.gBodyDrawScale,
             gObjects[i].Mass * Params.gBodyDrawScale);
     g.FillEllipse(Brushes.Green, startPos.X - 5, startPos.Y - 5, 10, 10);
     g.FillEllipse(Brushes.Red, goal.X - 5, goal.Y - 5, 10, 10);
     for (int i = 0; i < ships.Count; i++)
         g.FillRectangle(Brushes.Black, ships[i].X - 2, ships[i].Y - 2, 4, 4);
 }
예제 #23
0
        public void Draw(Graphics g)
        {
            g.FillEllipse(Brushes.Blue, hotspotRect);

            //Getting how big the progress circle will be
            int fillWidth = (hotspotRect.Width / 100) * percentFill;
            int fillHeight = (hotspotRect.Width / 100) * percentFill;

            //Make the progress circle centered to the hotspot rectangle
            int xPos = (hotspotRect.Width - fillWidth) / 2;
            int yPos = (hotspotRect.Width - fillHeight) / 2;
            g.FillEllipse(Brushes.Red, xPos, yPos, fillWidth, fillHeight);
        }
예제 #24
0
 public override void Draw(Graphics g)
 {
     if (MyState)
     {
         g.FillEllipse(Brushes.Red, pos.X, pos.Y, box.Width, box.Height);
         g.DrawString(this.text, this.font, Brushes.Black, pos.X + 2 , pos.Y + 3 );
     }
     else
     {
         g.FillEllipse(Brushes.Black, pos.X, pos.Y, box.Width, box.Height);
         g.DrawString(this.text, this.font, Brushes.White, pos.X + 2 , pos.Y + 3);
     }
 }
예제 #25
0
        public override void Draw(Graphics gfx)
        {
            if (Enabled)
                gfx.DrawEllipse(new Pen(Color.Gray, 0.025f), point.X - 0.1f, point.Y - 0.1f, 0.2f, 0.2f);

            gfx.FillEllipse(Highlighted ? Brushes.Purple : Brushes.Black, point.X - size / 2, point.Y - size / 2, size, size);

            if (size >= 0.05)
            {
                //draw larger cities with a red center circle
                float centerSize = size / 2;
                gfx.FillEllipse(Brushes.DarkRed, point.X - centerSize / 2, point.Y - centerSize / 2, centerSize, centerSize);
            }
        }
예제 #26
0
 public void draw(Graphics g, Light color)
 {
     if (color == Light.GREEN) {
         topLight = new SolidBrush(Color.Green);
         buttomLight = new SolidBrush(Color.Gray);
     } else {
         topLight = new SolidBrush(Color.Gray);
         buttomLight = new SolidBrush(Color.Red);
     }
     g.FillRectangle(back, new Rectangle(40, 10, 70, 130));
     g.FillRectangle(back, new Rectangle(70, 130, 10, 200));
     g.FillEllipse(topLight, new Rectangle(50, 20, 50, 50));
     g.FillEllipse(buttomLight, new Rectangle(50, 80, 50, 50));
 }
예제 #27
0
파일: LetterCircle.cs 프로젝트: AtanasK/VP
 public void Draw(Graphics g)
 {
     if (IsHit)
     {
         g.FillEllipse(Brushes.Red, Center.X - RADIUS, Center.Y - RADIUS, RADIUS * 2, RADIUS * 2);
     }
     else
     {
         g.FillEllipse(Brushes.LightGreen, Center.X - RADIUS, Center.Y - RADIUS, RADIUS * 2, RADIUS * 2);
     }
     Font f = new Font("Arial", 24);
     g.DrawString(string.Format("{0}", Letter), f, Brushes.Black, Center.X - 15, Center.Y - 15);
     f.Dispose();
 }
예제 #28
0
        // for version 2.0, ignore newBrush and speed, use them in version 2.1
        public void Draw(Graphics g)
        {
            if (width > height)     // going horizontal
            {
                g.FillRectangle(myBrush, x, y, width, height);
                g.FillRectangle(Brushes.DarkBlue, x + 4, y - 2, 5, 3);  // window
                g.FillEllipse(Brushes.Black, x + 3, y + 4, 4, 5);       // left tire
                g.FillEllipse(Brushes.Black, x + width - 7, y + 4, 4, 5);   // right tire
            }

            else if (width < height)     // going horizontal
            {
                g.FillRectangle(myBrush, x, y, width, height);
                g.FillRectangle(Brushes.DarkBlue, x + 4, y - 2, 5, 3);  // window
                g.FillEllipse(Brushes.Black, x + 3, y + 4, 4, 5);       // left tire
                g.FillEllipse(Brushes.Black, x + width - 7, y + 4, 4, 5);   // right tire
            }

            else                    // going vertical
            {
                g.FillRectangle(myBrush, x, y, width, height);
                g.FillRectangle(Brushes.DarkBlue, x + 4, y - 2, 5, 3);  // window
                g.FillEllipse(Brushes.Black, x + 3, y + 4, 4, 5);       // left tire
                g.FillEllipse(Brushes.Black, x + width - 7, y + 4, 4, 5);   // right tire
                g.FillEllipse(Brushes.Black, x + 3, y + 4, 4, 5);       // left tire
                g.FillEllipse(Brushes.Black, x + width - 7, y + 4, -4, -5);   // right tire

            }
        }
예제 #29
0
파일: Number.cs 프로젝트: AtanasK/VP
 public void Draw(Graphics g)
 {
     if (TimeAlive <= 2)
     {
         g.FillEllipse(Brushes.Red, Center.X - RADIUS, Center.Y - RADIUS, RADIUS * 2, RADIUS * 2);
     }
     else
     {
         g.FillEllipse(Brushes.Aqua, Center.X - RADIUS, Center.Y - RADIUS, RADIUS * 2, RADIUS * 2);
     }
     Font f = new Font("Arial", 24);
     g.DrawString(string.Format("{0}", Digit), f, Brushes.Black, Center.X - 15, Center.Y - 15);
     f.Dispose();
 }
예제 #30
0
        public override void DrawSelf(Graphics gfx, Pen pen)
        {
            if (Center == Target)
            {
                gfx.FillEllipse(Brushes.Gainsboro, Center.X - (Width / 2), Center.Y - Height / 2, Width, Height);
            }
            else
            {
                //PointF a = new PointF(Center.X + 3, Center.Y);
                //PointF b = new PointF(Center.X + 3, Center.Y + 3);
                //PointF c = new PointF(Center.X - 3, Center.Y - 3);

                gfx.FillEllipse(Brushes.Black, Center.X - 2, Center.Y - 2, 4, 4);
            }
        }
예제 #31
0
파일: Spray.cs 프로젝트: ishkang/Gorgon
        /// <summary>
        /// Function to randomly "spray" a point on the surface.
        /// </summary>
        /// <param name="point">Origin point for the spray.</param>
        public void SprayPoint(Point point)
        {
            var randomArea = new Point(GorgonRandom.RandomInt32(-10, 10), GorgonRandom.RandomInt32(-10, 10));

            _graphics.FillEllipse(_brushes[GorgonRandom.RandomInt32(0, _brushes.Length - 1)], new Rectangle(point.X + randomArea.X, point.Y + randomArea.Y, 10, 10));
        }
예제 #32
0
        public static Icon GetIcon(string text, string originalIcon)
        {
            Size      bitmapSize = new Size(32, 32);
            float     fontSize   = 20;
            string    fontFamily = "Arial";
            FontStyle fontStyle  = FontStyle.Bold;
            float     offset     = 0;

            Bitmap bitmap = new Bitmap(bitmapSize.Width, bitmapSize.Height);

            System.Drawing.Font       drawFont         = new System.Drawing.Font(fontFamily, fontSize, fontStyle);
            System.Drawing.SolidBrush drawEllipseBrush = new System.Drawing.SolidBrush(ColorTranslator.FromHtml("#ffba09"));

            System.Drawing.SolidBrush drawCountBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

            System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);

            graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;

            if (!string.IsNullOrEmpty(originalIcon))
            {
                graphics.DrawIcon(new Icon(originalIcon), 0, 0);
            }

            float  ratioOfEllipseToBitmap = 0.8f;
            SizeF  ellipseSize            = new SizeF(bitmap.Width * ratioOfEllipseToBitmap, bitmap.Width * ratioOfEllipseToBitmap);
            PointF ellipseLocation        = new PointF(bitmap.Width - ellipseSize.Width, 0);

            RectangleF ellipseRectangle = new RectangleF(ellipseLocation, ellipseSize);

            graphics.FillEllipse(drawEllipseBrush, ellipseRectangle);

            int[,] pixelOne = PixelNumbers.pixelOne;

            int xOffset = (int)ellipseLocation.X + (int)(ellipseSize.Width / 2) - 2;
            int yOffset = (int)ellipseLocation.Y + (int)(ellipseSize.Height / 2) - 2;

            for (int i = 0; i < pixelOne.GetLength(0); i++)
            {
                bitmap.SetPixel(pixelOne[i, 0] + xOffset, pixelOne[i, 1] + yOffset, Color.Black);
            }

            float height = graphics.MeasureString(text, drawFont).Height;

            while (height >= ellipseSize.Height)
            {
                drawFont = new System.Drawing.Font(fontFamily, drawFont.Size - 0.01f, fontStyle);
                height   = graphics.MeasureString(text, drawFont).Height;
            }

            double halfLength = Math.Sqrt(ellipseSize.Width * 0.5 * ellipseSize.Width * 0.5 - height * 0.5 * height * 0.5);

            while (halfLength * 2 < graphics.MeasureString(text, drawFont).Width)
            {
                drawFont   = new System.Drawing.Font(fontFamily, drawFont.Size - 0.01f, fontStyle);
                height     = graphics.MeasureString(text, drawFont).Height;
                halfLength = Math.Sqrt(ellipseSize.Width * 0.5 * ellipseSize.Width * 0.5 - height * height * 0.25);
            }

            StringFormat stringFormat = new StringFormat();

            stringFormat.Alignment     = StringAlignment.Center;
            stringFormat.LineAlignment = StringAlignment.Center;

            RectangleF textRectangle = new RectangleF((float)(bitmapSize.Width - ellipseSize.Width * 0.5 - halfLength), (float)(ellipseSize.Height * 0.5 - height * 0.5), (float)(2 * halfLength), height + offset);

            Icon createdIcon = Icon.FromHandle(bitmap.GetHicon());

            drawFont.Dispose();
            drawEllipseBrush.Dispose();
            drawCountBrush.Dispose();
            graphics.Dispose();
            bitmap.Dispose();

            return(createdIcon);
        }
예제 #33
0
 public void FillEllipse(ARGB argb, Box bounds)
 {
     using (var brush = new SolidBrush(argb.ToColor()))
         _graphics.FillEllipse(brush, bounds.ToRectangleF());
 }
예제 #34
0
        // ====================================================================
        // Creates the bitmap image.
        // ====================================================================
        private void GenerateImage()
        {
            // Create a new 32-bit bitmap image.
            Bitmap bitmap = new Bitmap(this.width, this.height, PixelFormat.Format32bppArgb);

            // Create a graphics object for drawing.
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);
            g.SmoothingMode = SmoothingMode.AntiAlias;
            Rectangle rect = new Rectangle(0, 0, this.width, this.height);

            // Fill in the background.
            HatchBrush hatchBrush = new HatchBrush(HatchStyle.SmallConfetti, _DotColor, _BGColor);

            g.FillRectangle(hatchBrush, rect);

            // Set up the text font.
            SizeF size;
            float fontSize = rect.Height + 1;
            Font  font;

            // Adjust the font size until the text fits within the image.
            do
            {
                fontSize--;
                font = new Font(this.familyName, fontSize, FontStyle.Bold);
                size = g.MeasureString(this.text, font);
            } while (size.Width > rect.Width);

            // Set up the text format.
            StringFormat format = new StringFormat();

            format.Alignment     = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;

            // Create a path using the text and warp it randomly.
            GraphicsPath path = new GraphicsPath();

            path.AddString(this.text, font.FontFamily, (int)font.Style, font.Size, rect, format);

            float v = 0F;

            switch (_WarpStrength)
            {
            case WarpStrength.Light:
                v = 4F;
                break;

            case WarpStrength.Normal:
                v = 3.8F;
                break;

            case WarpStrength.Strong:
                v = 3.7F;
                break;
            }
            PointF[] points =
            {
                new PointF(this.random.Next(rect.Width) / v,              this.random.Next(rect.Height) / v),
                new PointF(rect.Width - this.random.Next(rect.Width) / v, this.random.Next(rect.Height) / v),
                new PointF(this.random.Next(rect.Width) / v,              rect.Height - this.random.Next(rect.Height) / v),
                new PointF(rect.Width - this.random.Next(rect.Width) / v, rect.Height - this.random.Next(rect.Height) / v)
            };
            Matrix matrix = new Matrix();

            matrix.Translate(0F, 0F);
            path.Warp(points, rect, matrix, WarpMode.Perspective, 0F);

            // Draw the text.
            hatchBrush = new HatchBrush(HatchStyle.LargeConfetti, _TextDistortioncolor, _FontColor);
            g.FillPath(hatchBrush, path);

            // Add some random noise.
            int m = Math.Max(rect.Width, rect.Height);

            for (int i = 0; i < (int)(rect.Width * rect.Height / 30F); i++)
            {
                int x = this.random.Next(rect.Width);
                int y = this.random.Next(rect.Height);
                int w = this.random.Next(m / 50);
                int h = this.random.Next(m / 50);
                g.FillEllipse(hatchBrush, x, y, w, h);
            }

            g.DrawRectangle(new Pen(new SolidBrush(Color.Black), 2), 0, 0, width - 1, height - 1);

            // Clean up.
            font.Dispose();
            hatchBrush.Dispose();
            g.Dispose();

            // Set the image.
            this.image = bitmap;
        }
예제 #35
0
        private void Form1_Click(object sender, EventArgs e)
        {
            if (run)
            {
                return;
            }
            run = true;
            //read x, y horizon
            int x = Int32.Parse(MousePosition.X.ToString()) - Int32.Parse(this.Location.X.ToString());
            int y = Int32.Parse(MousePosition.Y.ToString()) - Int32.Parse(this.Location.Y.ToString());

            //check in (if out then ignore)
            if (x > 655 || y > 699)
            {
                return;
            }

            //check position is available
            setx = (x - 1) / 35;
            sety = (y - 48) / 35;
            if (map[setx, sety] == '0')
            {
                if (turn == '1')
                {
                    map[setx, sety] = '1';
                    turn            = '2';
                    g.FillEllipse(Brushes.Black, new Rectangle(10 + setx * 35 - 16, 35 + sety * 35 - 16, 32, 32));
                    finish_check();

                    //do it except list
                    try
                    {
                        list.Remove(point[setx, sety]);
                    }catch (Exception ex) { }
                    try
                    {
                        for (int i = 0; i < 5; i++)
                        {
                            for (int j = 0; j < 5; j++)
                            {
                                if ((setx - 2 + i < 19) && (setx - 2 + i >= 0) && (sety - 2 + j >= 0) && (sety - 2 + j < 19) && (map[setx - 2 + i, sety - 2 + j] == '0') && (!list.Contains(point[setx - 2 + i, sety - 2 + j])))
                                {
                                    list.Add(point[setx - 2 + i, sety - 2 + j]);
                                }
                            }
                        }
                    }
                    catch (Exception ex) { }
                    if (option)
                    {
                        run = false;
                        do_it();  //alphago
                        finish_check();
                    }
                }
                else if (turn == '2')
                {
                    map[setx, sety] = '2';
                    turn            = '1';
                    g.FillEllipse(Brushes.White, new Rectangle(10 + setx * 35 - 16, 35 + sety * 35 - 16, 32, 32));
                    finish_check();
                }
            }

            run = false;
        }
예제 #36
0
        public override void Draw(System.Drawing.Graphics gr)
        {
            Brush brush = new SolidBrush(Color);

            gr.FillEllipse(brush, GlobalPos.X - Radius, GlobalPos.Y - Radius, 2 * Radius, 2 * Radius);
        }
        private void _drawCircle(System.Drawing.Graphics g, Brush brush, float x, float y, float radius)
        {
            float size = radius * 2;

            g.FillEllipse(brush, x - radius, y - radius, size, size);
        }
예제 #38
0
 public void sterg(System.Drawing.Graphics zona_des, System.Drawing.Brush rad, int pozx, int pozy, int diam)
 {
     zona_des.FillEllipse(rad, x0 + 1, y0 + 1, d - 1, d - 1);
 }
예제 #39
0
        public override void Draw(System.Drawing.Graphics graphics)
        {
            Brush brush = new SolidBrush(Color);

            graphics.FillEllipse(brush, X - radius, Y - radius, 2 * radius, 2 * radius);
        }
예제 #40
0
 public static Node drawNode(System.Drawing.Graphics pg, Point p, Color c)
 {
     brush = new SolidBrush(c);
     pg.FillEllipse(brush, new Rectangle(p, new Size(Form1.nodeW, Form1.nodeH)));
     return(new Node(p, c));
 }
예제 #41
0
        // la partie la fun : le dessin de l'horloge
        private void timer2_Tick(object sender, System.EventArgs e)
        {
            double osx, osy, sx, sy;
            double omx, omy, mmx, mmy;
            double ohx, ohy, hx, hy;
            double curSec, curMin, curHour;

            // declaration de l'objet qui sert à dessiner
            System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.GhostWhite);

            // declaration de l'objet qui sert à définir la brosse de remplissage
            System.Drawing.Brush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

            // declaration de l'objet dans lequel on peut dessiner. Ici, l'objet corespond
            // au format de la picturebox
            System.Drawing.Graphics formGraphics = pictureBox1.CreateGraphics();

            // c'est pour que le dessin soit antialiasé.
            // Commentez la ligne suivante pour voir le rendu sans ça, c'est... édifiant !
            formGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            // Seconde courante
            curSec = (double)DateTime.Now.Second;

            // Minute courante + l'équivalent en base 10 des secondes courantes
            // Cette petite astuce permet d'avoir un mouvement "smoothé" de l'aiguille
            // car plus précis que de minute en minute
            curMin = (double)DateTime.Now.Minute + (curSec / 60.0);

            // Heure courante, avec la même astuce qu'utilisée pour les minutes
            curHour = (double)DateTime.Now.Hour + (curMin / 60.0);

            /* Un peu de math !
             * sur le cercle trigo (rayon 1) : x = cos, y = sin
             * donc si on multiplie les coordonnées par le mm nombre N, on obtient
             * un cercle de rayon N (logique non ?!)
             * Exple : pour tracer point à point un cercle de rayon 10, on aurait (code faux car en degrés, mais plus facile à comprendre)
             *              for (int i=0; i<360; i++)
             *              {
             *                      x = cos(i) * 10;
             *                      y = sin(i) * 10;
             *                      dessinepoint(x, y)
             *              }
             * Il suffit ensuite d'ajouter les coordonnées du centre du cercle pour effectuer
             * une simple translation de repère
             * Pour résumer :
             *                      x = cos(angle)*rayon + origineX
             *                      y = sin(angle)*rayon + origineY
             *
             * A partir de ces éléments, rien n'est plus facile de déterminer une position sur un cercle
             * lorsqu'on connait l'angle
             */

            // On a précalculé l'angle que représente une seconde, on le multiplie
            // donc par le nombre de secondes. On y retire PI/2 (90°) pour que
            // ca tourne dans le bon sens : Le sens trigo est inverse au sens des aiguilles !
            sx = Math.Cos((uSec * curSec) - HalfPi) * 50 + (double)CenterX;
            sy = Math.Sin((uSec * curSec) - HalfPi) * 50 + (double)CenterY;

            // Ici c'est le calcul de l'origine de la trotteuse qui n'est pas au
            // centre de l'image mais 30 pixels plus loin (on ne retire pas pi/2
            // mais on le rajoute car il est bien de l'autre coté de l'origine du repere
            osx = Math.Cos((uSec * curSec) + HalfPi) * 20 + (double)CenterX;
            osy = Math.Sin((uSec * curSec) + HalfPi) * 20 + (double)CenterY;

            //calcul des minutes
            mmx = Math.Cos((uSec * curMin) - HalfPi) * 40 + (double)CenterX;
            mmy = Math.Sin((uSec * curMin) - HalfPi) * 40 + (double)CenterY;
            omx = Math.Cos((uSec * curMin) + HalfPi) * 20 + (double)CenterX;
            omy = Math.Sin((uSec * curMin) + HalfPi) * 20 + (double)CenterY;

            // idem mais avec l'angle representant 1 heure
            hx  = Math.Cos((uHour * curHour) - HalfPi) * 45 + (double)CenterX;
            hy  = Math.Sin((uHour * curHour) - HalfPi) * 45 + (double)CenterY;
            ohx = Math.Cos((uHour * curHour) + HalfPi) * 20 + (double)CenterX;
            ohy = Math.Sin((uHour * curHour) + HalfPi) * 20 + (double)CenterY;

            // le padleft sert à forcer l'affichage de la valeur sur 2 digits
            // par exple : 11:1:8 devient 11:01:08 ce qui est + esthétique :)
            label1.Text = DateTime.Now.Hour.ToString().PadLeft(2, '0') + ":" +
                          DateTime.Now.Minute.ToString().PadLeft(2, '0') + ":" +
                          DateTime.Now.Second.ToString().PadLeft(2, '0');

            /* C'est ici qu'on dessine
             * on commence par l'image de fond qui va tout ecraser (le clear fait scintiller c'est génant)
             * ensuite dans l'ordre dans lequel on veut que les aiguilles se surperposent.
             * En général, on commence par la trotteuse, ensuite celle des minutes et enfin pour les heures
             */
            // j'ai effectivement mis l'image de fond en background de ma forme
            // on pourrait tout aussi bien la mettre dans une imagelist
            formGraphics.DrawImage(this.BackgroundImage, pictureBox1.Bounds);

            // Définition de la couleur d'ecriture, largeur
            myPen.Color = System.Drawing.Color.White;
            myPen.Width = 3;
            // minute
            formGraphics.DrawLine(myPen, (int)omx, (int)omy, (int)mmx, (int)mmy);
            // heure
            formGraphics.DrawLine(myPen, (int)ohx, (int)ohy, (int)hx, (int)hy);

            // Petit bonus, j'ai dessiné un petit cercle pour le centre
            myPen.Width = 2;
            myPen.Color = System.Drawing.Color.White;
            formGraphics.FillEllipse(myBrush, CenterX - 4, CenterY - 4, 8, 8);

            // c'est pour le contour ^_^
            formGraphics.DrawEllipse(myPen, CenterX - 4, CenterY - 4, 8, 8);

            // la trotteuse
            // Définition de la couleur d'ecriture, largeur
            myPen.Color = System.Drawing.Color.LightSkyBlue;
            myPen.Width = 2;            //2
            formGraphics.DrawLine(myPen, (int)CenterX, (int)CenterY, (int)sx, (int)sy);
            formGraphics.DrawLine(myPen, (int)osx, (int)osy, (int)CenterX, (int)CenterY);
        }
예제 #42
0
        private void RenderOrbit(Orbit orbit, float origin, float scale, System.Drawing.Graphics graphics, SolidBrush brush, int number = 0)
        {
            if (orbit == null)
            {
                return;
            }
            if (orbit.Orbiters != null)
            {
                // Check each orbiting object.
                foreach (var orbiter in orbit.Orbiters)
                {
                    var localOrigin = origin;
                    // We can only really draw something useful if we have a radius...
                    if (orbiter.OrbitRadius != null)
                    {
                        // Figure out max radius of children.
                        var maxOrbit = scale * GetMaxRadius(orbiter.Moons);

                        // Draw actual stuff at max bounds.
                        localOrigin += orbiter.OrbitRadius.High * scale;
                        var orbiterFactory = FactoryManager.GetFactory(orbiter.Name) as PlanetFactory;
                        if (orbiterFactory != null)
                        {
                            brush.Color = System.Drawing.Color.FromArgb(150, orbiterFactory.SurfaceTint.R,
                                                                        orbiterFactory.SurfaceTint.G,
                                                                        orbiterFactory.SurfaceTint.B);
                            if (orbiterFactory.Radius != null)
                            {
                                var diameter = orbiterFactory.Radius.Low * scale * 2;
                                graphics.FillEllipse(brush, localOrigin - diameter / 2f, pbPreview.Image.Height / 2f - diameter / 2f, diameter, diameter);
                                diameter = orbiterFactory.Radius.High * scale * 2;
                                graphics.FillEllipse(brush, localOrigin - diameter / 2f, pbPreview.Image.Height / 2f - diameter / 2f, diameter, diameter);

                                maxOrbit = Math.Max(maxOrbit, orbiterFactory.Radius.High * scale);
                            }
                        }

                        // Half the interval of variance we have for our radius.
                        var halfVariance = scale * (orbiter.OrbitRadius.High - orbiter.OrbitRadius.Low) / 2f;

                        // Add it to the max orbit to get the overall maximum possible
                        // when rendering a circle with its center in the middle of the
                        // variance interval. (and times two for width/height)
                        maxOrbit = (maxOrbit + halfVariance) * 2;

                        // Show the indicator of the maximum bounds for this orbiter.
                        brush.Color = System.Drawing.Color.FromArgb(20, 255, 165, 0);
                        graphics.FillEllipse(brush, origin + scale * orbiter.OrbitRadius.Low + halfVariance - maxOrbit / 2f, pbPreview.Image.Height / 2f - maxOrbit / 2f, maxOrbit, maxOrbit);

                        // Draw own orbit.
                        var color = OrbitColors[number % OrbitColors.Length];
                        using (var p = new Pen(System.Drawing.Color.FromArgb(210, color.R, color.G, color.B)))
                        {
                            float orbitX, orbitY;

                            var eccentricity = orbiter.Eccentricity.Low;
                            Orbiter.ComputeRadii(orbiter.OrbitRadius.High * scale, eccentricity, out orbitX, out orbitY);
                            graphics.DrawEllipse(p, origin - orbitX + orbitX * eccentricity, pbPreview.Image.Height / 2f - orbitY, orbitX * 2, orbitY * 2);

                            p.Color = System.Drawing.Color.FromArgb(110, color.R, color.G, color.B);

                            eccentricity = orbiter.Eccentricity.High;
                            Orbiter.ComputeRadii(orbiter.OrbitRadius.Low * scale, eccentricity, out orbitX, out orbitY);
                            graphics.DrawEllipse(p, origin - orbitX + orbitX * eccentricity, pbPreview.Image.Height / 2f - orbitY, orbitX * 2, orbitY * 2);
                        }
                    }

                    // Render children.
                    RenderOrbit(orbiter.Moons, localOrigin, scale, graphics, brush, ++number);
                }
            }
        }
예제 #43
0
 public static Node drawNode(System.Drawing.Graphics pg, Point pt, LinearGradientBrush lgb)
 {
     pg.FillEllipse(lgb, new Rectangle(pt, new Size(Form1.nodeW, Form1.nodeH)));
     return(new Node(pt, Color.Gray));
 }
예제 #44
0
        public void DrawPoint(Point p)
        {
            int x, y;

            IDs       += p.ID + ";";
            X         += p.X + ";";
            Y         += p.Y + ";";
            xSec      += p.Xsec + ";";
            ySec      += p.Ysec + ";";
            networkID += p.NetworkID + ";";
            gps       += p.gps + ";";

            if (p.NetworkID == 1)
            {
                x = (int)Math.Round(p.X);
                y = (int)Math.Round(p.Y);
            }
            else
            {
                x = (int)Math.Round(p.Xsec);
                y = (int)Math.Round(p.Ysec);
            }

            /*
             * x = (int)p.X;
             * y = (int)p.Y;
             */
            x  = x * Magnify + Xoffset;
            x -= Magnify / 4;
            y  = y * Magnify + Yoffset;
            y -= Magnify / 4;

            Rectangle rectangle = new System.Drawing.Rectangle(x, y, Magnify / 2, Magnify / 2);

            if (p.NetworkID == 1)
            {
                graphics.DrawEllipse(System.Drawing.Pens.Black, rectangle);
                graphics.FillEllipse(Brushes.Black, x, y, Magnify / 2, Magnify / 2);
                graphics.DrawEllipse(System.Drawing.Pens.Black, rectangle);
            }
            else if (p.NetworkID == 2)
            {
                graphics.DrawEllipse(System.Drawing.Pens.Blue, rectangle);
                graphics.FillEllipse(Brushes.Blue, x, y, Magnify / 2, Magnify / 2);
                graphics.DrawEllipse(System.Drawing.Pens.Blue, rectangle);
            }
            else if (p.NetworkID == 3)
            {
                graphics.DrawEllipse(System.Drawing.Pens.Red, rectangle);
                graphics.FillEllipse(Brushes.Red, x, y, Magnify / 2, Magnify / 2);
                graphics.DrawEllipse(System.Drawing.Pens.Red, rectangle);
            }
            else if (p.NetworkID == 4)
            {
                graphics.DrawEllipse(System.Drawing.Pens.Green, rectangle);
                graphics.FillEllipse(Brushes.Green, x, y, Magnify / 2, Magnify / 2);
                graphics.DrawEllipse(System.Drawing.Pens.Green, rectangle);
            }


            Font       drawFont  = new Font("Arial", Magnify + 5);
            SolidBrush drawBrush = new SolidBrush(Color.Black);
            string     temp      = Math.Round(p.X, 0) + ";" + Math.Round(p.Y, 0);

            graphics.DrawString(temp, drawFont, drawBrush, x + 10, y - 2);
            graphics.DrawString("X      Y", drawFont, drawBrush, 100, 100);
        }
예제 #45
0
 public void sterg(System.Drawing.Graphics zona_des, System.Drawing.Brush rad)
 {
     zona_des.FillEllipse(rad, x0 + 1, y0 + 1, r0 - 1, r0 - 1);
 }
예제 #46
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            Pen       p    = new Pen(Color.Black, 20);
            Rectangle main = new Rectangle(10, 10, 769, 501);

            g.DrawRectangle(p, main);
            SolidBrush brush = new SolidBrush(Color.Blue);

            g.FillRectangle(brush, main);
            p     = new Pen(Color.White, 1);
            brush = new SolidBrush(Color.White);
            Rectangle[] ell =
            {
                new Rectangle(60,   60, 40, 40),
                new Rectangle(520, 300, 40, 40),
                new Rectangle(705, 440, 40, 40),
                new Rectangle(725, 200, 40, 40),
                new Rectangle(320,  20, 40, 40),
                new Rectangle(460,  80, 40, 40),
                new Rectangle(320, 360, 40, 40),
                new Rectangle(100, 400, 40, 40),
            };
            for (int i = 0; i < ell.Length; ++i)
            {
                g.FillEllipse(brush, ell[i]);
            }
            Point[] arr1 =
            {
                new Point(220, 180),
                new Point(160, 120),
                new Point(100, 180),
            };
            p     = new Pen(Color.Red, 10);
            brush = new SolidBrush(Color.Red);
            g.FillPolygon(brush, arr1);
            Point[] arr2 =
            {
                new Point(100, 140),
                new Point(220, 140),
                new Point(160, 200),
            };
            g.FillPolygon(brush, arr2);
            Point[] arr3 =
            {
                new Point(240, 320),
                new Point(200, 360),
                new Point(280, 360),
            };
            g.FillPolygon(brush, arr3);
            Point[] arr4 =
            {
                new Point(200, 340),
                new Point(280, 340),
                new Point(240, 380),
            };
            g.FillPolygon(brush, arr4);
            Point[] arr5 =
            {
                new Point(540, 120),
                new Point(520, 160),
                new Point(560, 160),
            };
            g.FillPolygon(brush, arr5);
            Point[] arr6 =
            {
                new Point(520, 140),
                new Point(560, 140),
                new Point(540, 180),
            };
            g.FillPolygon(brush, arr6);
            Point[] arr7 =
            {
                new Point(500, 380),
                new Point(440, 440),
                new Point(560, 440),
            };
            g.FillPolygon(brush, arr7);
            Point[] arr8 =
            {
                new Point(440, 400),
                new Point(560, 400),
                new Point(500, 460),
            };
            g.FillPolygon(brush, arr8);
            Point[] mn =
            {
                new Point(380, 200),
                new Point(420, 220),
                new Point(420, 280),
                new Point(380, 300),
                new Point(340, 280),
                new Point(340, 220),
            };
            p     = new Pen(Color.Yellow, 10);
            brush = new SolidBrush(Color.Yellow);
            g.DrawPolygon(p, mn);
            g.FillPolygon(brush, mn);
            Point[] str =
            {
                new Point(380, 220),
                new Point(400, 240),
                new Point(390, 240),
                new Point(390, 260),
                new Point(370, 260),
                new Point(370, 240),
                new Point(360, 240),
            };
            p     = new Pen(Color.Green, 10);
            brush = new SolidBrush(Color.Green);
            g.DrawPolygon(p, str);
            g.FillPolygon(brush, str);
            button1.Visible = false;
            Rectangle r = new Rectangle(340, 420, 75, 40);

            p     = new Pen(Color.Blue, 10);
            brush = new SolidBrush(Color.Black);
            g.DrawRectangle(p, r);
            g.FillRectangle(brush, r);
        }
예제 #47
0
        //
        // CREATE ROUTE MAP
        //
        /// <summary>Creates and returns the route map as Bitmap.</summary>
        /// <returns>The route map.</returns>
        /// <param name="Width">The width of the bitmap to create.</param>
        /// <param name="Height">The height of the bitmap to create.</param>
        /// <param name="inGame"><c>true</c> = bitmap for in-game overlay | <c>false</c> = for standard window.</param>
        internal static Bitmap CreateRouteMap(int Width, int Height, bool inGame)
        {
            int n, n0, n1;

            RouteRange(out n, out n0, out n1);
            // find dimensions
            double x0 = double.PositiveInfinity, z0 = double.PositiveInfinity;
            double x1 = double.NegativeInfinity, z1 = double.NegativeInfinity;

            for (int i = n0; i <= n1; i++)
            {
                double x = Program.CurrentRoute.Tracks[0].Elements[i].WorldPosition.X;
                double z = Program.CurrentRoute.Tracks[0].Elements[i].WorldPosition.Z;
                if (x < x0)
                {
                    x0 = x;
                }
                if (x > x1)
                {
                    x1 = x;
                }
                if (z < z0)
                {
                    z0 = z;
                }
                if (z > z1)
                {
                    z1 = z;
                }
            }
            // avoid 0 or negative height or width
            if (x0 >= x1 - 1.0)
            {
                x0 = x1 - 1.0;
            }
            if (z0 >= z1 - 1.0)
            {
                z0 = z1 - 1.0;
            }
            // remember area occupied so far
            double xMin, xMax, zMin, zMax;                              // used to track the bitmap area actually occupied by drawings

            xMin = x0;
            xMax = x1;
            zMin = z1;                                                                          // bitmap z goes down, while world z goes up
            zMax = z0;
            // fit route w/h ratio in image w/h ratio
            double wrh = (double)Width / (double)Height;

            if ((x1 - x0) / (z1 - z0) <= wrh)                           // if route ratio is taller than bitmap ratio
            {
                double dx = 0.5 * (z1 - z0) * wrh;                      //	scale (half of) x range as much as (half of) z range
                double px = 0.5 * (x0 + x1);                            //	x range mid point
                x0 = px - dx;                                           //	centre scaled x range around mid point
                x1 = px + dx;
            }
            else                                                                                // if route ratio is wider than bitmap ratio
            {                                                                                   //	do the opposite (scale z range on x)
                double dz = 0.5 * (x1 - x0) / wrh;
                double pz = 0.5 * (z0 + z1);
                z0 = pz - dz;
                z1 = pz + dz;
            }
            double ox = LeftPad, oy = TopPad;
            double w = (double)(Width - (LeftPad + RightPad));
            double h = (double)(Height - (TopPad + BottomPad));
            // horizontal and vertical scales
            double xd = w / (x1 - x0);
            double zd = h / (z1 - z0);

            // convert bitmap occupied area from world to bitmap coordinates
            xMin = ox + (xMin - x0) * xd;
            xMax = ox + (xMax - x0) * xd;
            zMin = oy + (z0 - zMin) * zd + h;
            zMax = oy + (z0 - zMax) * zd + h;
            // create bitmap
            int    mode = inGame ? 1 : 0;
            Bitmap b    = new Bitmap(Width, Height, inGame ? System.Drawing.Imaging.PixelFormat.Format32bppArgb
                                : System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(b);
            g.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            g.Clear(mapColors[mode].background);

            // ROUTE PATH
            {
                int  start = 0;
                bool atc   = false;
                n = n1 - n0 + 1;
                PointF[] p = new PointF[n];
                for (int i = 0; i < n; i++)
                {
                    double x = Program.CurrentRoute.Tracks[0].Elements[i + n0].WorldPosition.X;
                    double z = Program.CurrentRoute.Tracks[0].Elements[i + n0].WorldPosition.Z;
                    x    = ox + (x - x0) * xd;
                    z    = oy + (z0 - z) * zd + h;
                    p[i] = new PointF((float)x, (float)z);
                    // ATS / ATC
                    // for each track element, look for a StationStartEvent
                    for (int j = 0; j < Program.CurrentRoute.Tracks[0].Elements[i + n0].Events.Length; j++)
                    {
                        if (Program.CurrentRoute.Tracks[0].Elements[i + n0].Events[j] is StationStartEvent)
                        {
                            StationStartEvent e =
                                (StationStartEvent)Program.CurrentRoute.Tracks[0].Elements[i + n0].Events[j];
                            // if StationStartEvent found, look for a change in ATS/ATC control;
                            // if there is a change, draw all previous track elements
                            // with colour for the previous control state
                            if (Program.CurrentRoute.Stations[e.StationIndex].SafetySystem == SafetySystem.Atc)
                            {
                                if (!atc)
                                {
                                    atc = true;
                                    if (i - start - 1 > 0)
                                    {
                                        g.DrawCurve(mapColors[mode].normalMap, p, start, i - start - 1);
                                    }
                                    start = i;
                                }
                            }
                            else
                            {
                                if (atc)
                                {
                                    atc = false;
                                    if (i - start - 1 > 0)
                                    {
                                        g.DrawCurve(mapColors[mode].atcMap, p, start, i - start - 1);
                                    }
                                    start = i;
                                }
                            }
                            break;
                        }
                    }
                }
                // draw all remaining track element not drawn yet
                DrawSegmentedCurve(g, atc ? mapColors[mode].atcMap : mapColors[mode].normalMap, p, start, n - start - 1);
            }

            // STATION ICONS
            for (int i = n0; i <= n1; i++)
            {
                for (int j = 0; j < Program.CurrentRoute.Tracks[0].Elements[i].Events.Length; j++)
                {
                    if (Program.CurrentRoute.Tracks[0].Elements[i].Events[j] is StationStartEvent)
                    {
                        StationStartEvent e = (StationStartEvent)Program.CurrentRoute.Tracks[0].Elements[i].Events[j];
                        if (Program.CurrentRoute.Stations[e.StationIndex].Name != string.Empty)
                        {
                            double x = Program.CurrentRoute.Tracks[0].Elements[i].WorldPosition.X;
                            double y = Program.CurrentRoute.Tracks[0].Elements[i].WorldPosition.Z;
                            x = ox + (x - x0) * xd;
                            y = oy + (z0 - y) * zd + h;
                            // station circle
                            RectangleF r = new RectangleF((float)x - StationRadius, (float)y - StationRadius,
                                                          StationDiameter, StationDiameter);
                            bool q = Program.CurrentRoute.Stations[e.StationIndex].PlayerStops();
                            g.FillEllipse(q ? mapColors[mode].actStatnFill : mapColors[mode].inactStatnFill, r);
                            g.DrawEllipse(q ? mapColors[mode].actStatnBrdr : mapColors[mode].inactStatnBrdr, r);
                            // adjust bitmap occupied area
                            if (r.Left < xMin)
                            {
                                xMin = r.Left;
                            }
                            if (r.Top < zMin)
                            {
                                zMin = r.Top;
                            }
                            if (r.Right > xMax)
                            {
                                xMax = r.Right;
                            }
                            if (r.Bottom > zMax)
                            {
                                zMax = r.Bottom;
                            }
                        }
                    }
                }
            }

            // STATION NAMES
            {
                double wh = w * h;
                Font   f  = new Font(FontFamily.GenericSansSerif, wh < 65536.0 ? 9.0f : 10.0f, GraphicsUnit.Pixel);
                for (int i = n0; i <= n1; i++)
                {
                    for (int j = 0; j < Program.CurrentRoute.Tracks[0].Elements[i].Events.Length; j++)
                    {
                        if (Program.CurrentRoute.Tracks[0].Elements[i].Events[j] is StationStartEvent)
                        {
                            StationStartEvent e = (StationStartEvent)Program.CurrentRoute.Tracks[0].Elements[i].Events[j];
                            if (Program.CurrentRoute.Stations[e.StationIndex].Name != string.Empty)
                            {
                                double x = Program.CurrentRoute.Tracks[0].Elements[i].WorldPosition.X;
                                double y = Program.CurrentRoute.Tracks[0].Elements[i].WorldPosition.Z;
                                x = ox + (x - x0) * xd;
                                y = oy + (z0 - y) * zd + h;
                                bool   stop = Program.CurrentRoute.Stations[e.StationIndex].PlayerStops();
                                string t = Program.CurrentRoute.Stations[e.StationIndex].Name;
                                SizeF  m = g.MeasureString(t, f, Width, StringFormat.GenericDefault);
                                double sx = Program.CurrentRoute.Tracks[0].Elements[i].WorldSide.X;
                                double sz = Program.CurrentRoute.Tracks[0].Elements[i].WorldSide.Z;
                                double xt, yt;
                                if (Math.Sign(sx) == Math.Sign(sz))
                                {
                                    // descending
                                    bool o = (x - ox) * (h - y) <= (w - x) * (y - oy);
                                    if (o)
                                    {
                                        // up-right
                                        xt = x + StationTextPad;
                                        yt = y - StationTextPad - m.Height;
                                    }
                                    else
                                    {
                                        // down-left
                                        xt = x - StationTextPad - m.Width;
                                        yt = y + StationTextPad;
                                    }
                                }
                                else
                                {
                                    // ascending
                                    bool o = (h - y) * (w - x) <= (x - ox) * (y - oy);
                                    if (o)
                                    {
                                        // up-left
                                        xt = x - StationTextPad - m.Width;
                                        yt = y - StationTextPad - m.Height;
                                    }
                                    else
                                    {
                                        // down-right
                                        xt = x + StationTextPad;
                                        yt = y + StationTextPad;
                                    }
                                }
                                // constrain text within bitmap edges (taking into account also paddings)
                                if (xt < ox)
                                {
                                    xt = ox;
                                }
                                else if (xt + m.Width > w)
                                {
                                    xt = w - m.Width;
                                }
                                if (yt < oy)
                                {
                                    yt = oy;
                                }
                                else if (yt + m.Height > h)
                                {
                                    yt = h - m.Height;
                                }
                                RectangleF r = new RectangleF((float)xt - 1.0f, (float)yt - 1.0f, m.Width + 2.0f, m.Height + 2.0f);
                                g.FillRectangle(stop ? mapColors[mode].actNameFill : mapColors[mode].inactNameFill,
                                                r.Left, r.Top, r.Width, r.Height);
                                g.DrawRectangle(stop ? mapColors[mode].actNameBrdr : mapColors[mode].inactNameBrdr,
                                                r.Left, r.Top, r.Width, r.Height);
                                g.DrawString(t, f, stop ? mapColors[mode].actNameText : mapColors[mode].inactNameText,
                                             (float)xt, (float)yt);
                                // adjust bitmap occupied area
                                if (r.Left < xMin)
                                {
                                    xMin = r.Left;
                                }
                                if (r.Top < zMin)
                                {
                                    zMin = r.Top;
                                }
                                if (r.Right > xMax)
                                {
                                    xMax = r.Right;
                                }
                                if (r.Bottom > zMax)
                                {
                                    zMax = r.Bottom;
                                }
                            }
                        }
                    }
                }
            }
            // if in-game, trim unused parts of the bitmap
            if (inGame)
            {
                xMin -= LeftPad;
                xMax += RightPad;
                zMin -= TopPad;
                zMax += BottomPad;
                if (xMin < 0)
                {
                    xMin = 0;
                }
                if (xMax >= Width)
                {
                    xMax = Width - 1;
                }
                if (zMin < 0)
                {
                    zMin = 0;
                }
                if (zMax >= Height)
                {
                    zMax = Height - 1;
                }
                Bitmap nb = new Bitmap((int)(xMax - xMin + 1.0), (int)(zMax - zMin + 1.0));                     // round up
                g = System.Drawing.Graphics.FromImage(nb);
                g.DrawImage(b, (int)-xMin, (int)-zMin);                                                         // round down
                // set total bitmap world X and Z ranges from bitmap ranges
                lastRouteMinX = (int)((xMin - ox) / xd + x0);
                lastRouteMaxX = (int)((xMax - ox) / xd + x0);
                lastRouteMinZ = (int)(z0 - (zMax - oy - h) / zd);
                lastRouteMaxZ = (int)(z0 - (zMin - oy - h) / zd);
                return(nb);
            }
            //set total bitmap X and Z ranges
            lastRouteMinX = (int)(x0 - ox * (x1 - x0) / w);
            lastRouteMaxX = (int)(x1 + (Width - w - ox) * (x1 - x0) / w);
            lastRouteMinZ = (int)(z0 - oy * (z1 - z0) / h);
            lastRouteMaxZ = (int)(z1 + (Height - h - oy) * (z1 - z0) / h);
            return(b);
        }
예제 #48
0
 internal void Draw(System.Drawing.Graphics g)
 {
     g.FillEllipse(Brushes.Blue, this.Rectangle());
 }
예제 #49
0
        /// <summary>
        /// 現在のデータ点のバッファの描画を行います
        /// </summary>
        public void flush()
        {
            if (mIndex < 2)
            {
                // データ点が少ないのでflushする意味なし
                return;
            }
            if (mGraphType == TYPE_LINEAR)
            {
                // 塗りつぶし
                if (mFill)
                {
                    setPointData(mIndex, mLastX, mBaseLineY);
                    setPointData(mIndex + 1, mFirstX, mBaseLineY);

                    mGraphics.FillPolygon(getFillBrush(), mPoints);
                }

                // 線を描く
                if (mLine)
                {
                    for (int i = mIndex - 1; i < BUFLEN; i++)
                    {
                        setPointData(i, mLastX, mLastY);
                    }
                    mGraphics.DrawLines(getLinePen(), mPoints);
                }

                // ドットを描く
                if (mDot != DOTMODE_NO)
                {
                    // ここでは第mIndex - 1番目のドットまでを描いて、mIndex - 1番目のデータは第0番目にコピーし,次のflushで描く
                    for (int i = 0; i < mIndex - 1; i++)
                    {
                        System.Drawing.Point p = mPoints[i];
                        if (mDotType == DOT_CIRCLE)
                        {
                            mGraphics.FillEllipse(getDotBrush(), p.X - mDotSize, p.Y - mDotSize, mDotWidth, mDotWidth);
                        }
                        else if (mDotType == DOT_RECT)
                        {
                            mGraphics.FillRectangle(getDotBrush(), p.X - mDotSize, p.Y - mDotSize, mDotWidth, mDotWidth);
                        }
                    }
                }

                // 次の描画に備える
                setPointData(0, mLastX, mLastY);
                mFirstX = mLastX;
                mIndex  = 1;
            }
            else if (mGraphType == TYPE_STEP)
            {
                if (mFill)
                {
                    // 塗りつぶし用の枠を追加
                    setPointData(mIndex - 1, mLastX, mBaseLineY);
                    setPointData(mIndex, mFirstX, mBaseLineY);
                    for (int i = mIndex + 1; i < BUFLEN; i++)
                    {
                        setPointData(i, mFirstX, mBaseLineY);
                    }

                    // 塗りつぶし
                    mGraphics.FillPolygon(getFillBrush(), mPoints);
                }

                if (mLine)
                {
                    // 線を描く
                    for (int i = mIndex - 1; i < BUFLEN; i++)
                    {
                        setPointData(i, mLastX, mLastY);
                    }
                    mGraphics.DrawLines(getLinePen(), mPoints);
                }

                if (mDot != DOTMODE_NO)
                {
                    // データ点を描く
                    SolidBrush brs = getDotBrush();
                    Color      c   = brs.Color;
                    for (int i = 0; i < mIndex; i += 2)
                    {
                        Point p     = mPoints[i];
                        int   px    = p.X;
                        int   alpha = (mDot == DOTMODE_NEAR) ? getAlpha(px) : 255;
                        if (alpha <= 0)
                        {
                            continue;
                        }
                        brs.Color = Color.FromArgb(alpha, c);
                        if (mDotType == DOT_CIRCLE)
                        {
                            mGraphics.FillEllipse(brs, p.X - mDotSize, p.Y - mDotSize, mDotWidth, mDotWidth);
                        }
                        else
                        {
                            mGraphics.FillRectangle(brs, p.X - mDotSize, p.Y - mDotSize, mDotWidth, mDotWidth);
                        }
                    }
                    brs.Color = Color.FromArgb(255, c);
                }

                // 次の描画に備える
                setPointData(0, mLastX, mLastY);
                mFirstX = mLastX;
                mIndex  = 1;
            }
        }
예제 #50
0
        public void Draw(Matrix preobr, Graphics g, int dataPointCount, bool withMarkers)
        {
            Point[,] points = new Point[b1.DrawingPoints.Length, b1.DrawingPoints.Length];
            BezierCurve tempb1, tempb2, tempb3, tempb4;

            tempb1 = preobr * b1;
            tempb2 = preobr * b2;
            tempb3 = preobr * b3;
            tempb4 = preobr * b4;

            Pen pen = new Pen(Color.AliceBlue, 1f);

            double dt = 1f / (tempb1.DrawingPoints.Length - 2);

            for (int i = 0; i < tempb1.DrawingPoints.Length; i++)
            {
                for (int j = 0; j < tempb1.DrawingPoints.Length; j++)
                {
                    double t1 = i * dt;
                    double t2 = j * dt;

                    Point c0 = b2.B(t2) * (1 - t1) + b1.B(t2) * t1;
                    Point c1 = b3.B(t1) * (1 - t2) + b4.B(t1) * t2;
                    Point c2 = (b3.B(0) * (1 - t1) + b1.B(0) * t1) * (1 - t2) + (b4.B(0) * (1 - t1) + b1.B(1) * t1) * t2;

                    double x = c0.x + c1.x - c2.x;
                    double y = c0.y + c1.y - c2.y;
                    double z = c0.z + c1.z - c2.z;
                    points[i, j] = new Point(x, y, z, 1);
                }
            }

            for (int i = 0; i < tempb1.DrawingPoints.Length - 1; i++)
            {
                for (int j = 0; j < tempb1.DrawingPoints.Length - 2; j++)
                {
                    Point point1 = preobr * points[i, j];
                    Point point2 = preobr * points[i, j + 1];
                    g.DrawLine(pen, (int)point1.x, (int)point1.y, (int)point2.x, (int)point2.y);
                }
            }


            b1.Draw(preobr, g);
            b2.Draw(preobr, g);
            b3.Draw(preobr, g);
            b4.Draw(preobr, g);

            if (withMarkers)
            {
                b1.DrawMarkers(preobr, g);
                b2.DrawMarkers(preobr, g);
                b3.DrawMarkers(preobr, g);
                b4.DrawMarkers(preobr, g);

                if (dataPointCount != 12)
                {
                    RectangleF rectangle = new RectangleF();

                    if (dataPointCount < 3)
                    {
                        rectangle = new RectangleF((int)tempb1.DataPoints[dataPointCount].x - 5, (int)tempb1.DataPoints[dataPointCount].y - 5, (float)10, (float)10);
                    }
                    if (dataPointCount > 2 && dataPointCount < 6)
                    {
                        rectangle = new RectangleF((int)tempb2.DataPoints[dataPointCount - 3].x - 5, (int)tempb2.DataPoints[dataPointCount - 3].y - 5, (float)10, (float)10);
                    }
                    if (dataPointCount > 5 && dataPointCount < 9)
                    {
                        rectangle = new RectangleF((int)tempb3.DataPoints[dataPointCount - 6].x - 5, (int)tempb3.DataPoints[dataPointCount - 6].y - 5, (float)10, (float)10);
                    }
                    if (dataPointCount > 8 && dataPointCount < 12)
                    {
                        rectangle = new RectangleF((int)tempb4.DataPoints[dataPointCount - 9].x - 5, (int)tempb4.DataPoints[dataPointCount - 9].y - 5, (float)10, (float)10);
                    }
                    g.FillEllipse(Brushes.Yellow, rectangle);
                }
            }
        }
예제 #51
0
파일: GameForm.cs 프로젝트: mackvv/Snake
        //draws screen
        private void DrawIt(int x, int y)
        {
            //creates graphic screen in picture box
            System.Drawing.Graphics graphics = pbGame.CreateGraphics();
            //clears screen
            graphics.Clear(Color.Pink);

            //holds values until assigned to lastX, lastY
            int currentX;
            int currentY;


            //postions snake
            for (int i = 1; i < snakeLength; i++)
            {
                //if head
                if (i == 1)
                {
                    //stores last snake head position bc this will be the next circles position
                    lastX = recArray[i].X;
                    lastY = recArray[i].Y;

                    //places snake head at new postion
                    rect.X = x;
                    rect.Y = y;

                    recArray[i] = rect;
                }
                else
                {
                    //stores current body position
                    currentX = recArray[i].X;
                    currentY = recArray[i].Y;

                    //makes body position, last snake position
                    rect.X = lastX;
                    rect.Y = lastY;

                    //draws body piece
                    recArray[i] = rect;
                    graphics.FillEllipse(new SolidBrush(Color.Green), recArray[i]);

                    //moves current body position to lastpos
                    lastX = currentX;
                    lastY = currentY;

                    //if snake piece is greater than 6 (becasue if less than 6 the piece already intercects with head)
                    if (i > 6)
                    {
                        //if snake collides into iteself
                        if (collision(recArray[i].X, recArray[i].Y, 10, recArray[1].X, recArray[1].Y, 10) == true)
                        {
                            //ends game
                            GameOver();
                        }
                    }
                }
            }

            //draws head (draws head after draws body so body pieces dont cover head)
            graphics.FillEllipse(new SolidBrush(Color.DarkGreen), recArray[1]);

            DrawFood();     //draws food

            FormatRock();   //draws rocks


            //if snake eats food
            if (collision(foodX, foodY, 5, recArray[1].X, recArray[1].Y, 10) == true)
            {
                //increase snake length
                snakeLength = snakeLength + 6;
                foodEaten   = 1;

                //sets players points and displays them
                points         = points + 100;
                lblPoints.Text = "POINTS: " + points;
            }



            for (int i = 1; i <= rocksToDraw; i++)
            {
                //if snake hits rock, game over
                if (collision(rockArray[i].X, rockArray[i].Y, 25, recArray[1].X, recArray[1].Y, 10) == true)
                {
                    GameOver();
                }
            }
        }
예제 #52
0
 public void FillEllipse(Rect theRect, System.Drawing.Color fillColor)
 {
     mGraphics.FillEllipse(new System.Drawing.SolidBrush(fillColor), theRect.GetRectangle());
 }
예제 #53
0
        protected override void Render(GH_Canvas canvas, System.Drawing.Graphics graphics, GH_CanvasChannel channel)
        {
            base.Render(canvas, graphics, channel);

            if (channel == GH_CanvasChannel.Objects)
            {
                Pen spacer = new Pen(UI.Colour.SpacerColour);
                Pen pen    = new Pen(UI.Colour.GsaDarkBlue)
                {
                    Width = 0.5f
                };

                Font sml = GH_FontServer.Small;
                // adjust fontsize to high resolution displays
                sml = new Font(sml.FontFamily, sml.Size / GH_GraphicsUtil.UiScale, FontStyle.Regular);

                for (int i = 0; i < dropdownlists.Count; i++)
                {
                    //Draw divider line
                    if (spacerTxts[i] != "")
                    {
                        graphics.DrawString(spacerTxts[i], sml, UI.Colour.AnnotationTextDark, SpacerBounds[i], GH_TextRenderingConstants.CenterCenter);
                        graphics.DrawLine(spacer, SpacerBounds[i].X, SpacerBounds[i].Y + SpacerBounds[i].Height / 2, SpacerBounds[i].X + (SpacerBounds[i].Width - GH_FontServer.StringWidth(spacerTxts[i], sml)) / 2 - 4, SpacerBounds[i].Y + SpacerBounds[i].Height / 2);
                        graphics.DrawLine(spacer, SpacerBounds[i].X + (SpacerBounds[i].Width - GH_FontServer.StringWidth(spacerTxts[i], sml)) / 2 + GH_FontServer.StringWidth(spacerTxts[i], sml) + 4, SpacerBounds[i].Y + SpacerBounds[i].Height / 2, SpacerBounds[i].X + SpacerBounds[i].Width, SpacerBounds[i].Y + SpacerBounds[i].Height / 2);
                    }

                    // Draw selected item
                    // set font and colour depending on inital or selected text
                    Font font = new Font(GH_FontServer.FamilyStandard, 7);
                    // adjust fontsize to high resolution displays
                    font = new Font(font.FontFamily, font.Size / GH_GraphicsUtil.UiScale, FontStyle.Regular);
                    Brush fontColour = UI.Colour.AnnotationTextDark;
                    if (initialTxts != null)
                    {
                        if (displayTexts[i] == initialTxts[i])
                        {
                            pen        = new Pen(UI.Colour.BorderColour);
                            font       = sml;
                            fontColour = Brushes.Gray;
                        }
                    }

                    // background
                    Brush background = new SolidBrush(UI.Colour.GsaLightGrey);
                    // background
                    graphics.FillRectangle(background, BorderBound[i]);
                    // border
                    graphics.DrawRectangle(pen, BorderBound[i].X, BorderBound[i].Y, BorderBound[i].Width, BorderBound[i].Height);
                    // text
                    graphics.DrawString(displayTexts[i], font, fontColour, TextBound[i], GH_TextRenderingConstants.NearCenter);
                    // draw dropdown arrow
                    ButtonsUI.DropDownArrow.DrawDropDownButton(graphics, new PointF(ButtonBound[i].X + ButtonBound[i].Width / 2, ButtonBound[i].Y + ButtonBound[i].Height / 2), UI.Colour.GsaDarkBlue, 15);

                    // draw dropdown list
                    font = new Font(GH_FontServer.FamilyStandard, 7);
                    // adjust fontsize to high resolution displays
                    font       = new Font(font.FontFamily, font.Size / GH_GraphicsUtil.UiScale, FontStyle.Regular);
                    fontColour = UI.Colour.AnnotationTextDark;
                    if (unfolded[i])
                    {
                        Pen   penborder          = new Pen(Brushes.Gray);
                        Brush dropdownbackground = new SolidBrush(UI.Colour.GsaLightGrey);
                        penborder.Width = 0.3f;
                        for (int j = 0; j < dropdownBounds[i].Count; j++)
                        {
                            RectangleF listItem = dropdownBounds[i][j];
                            if (listItem.Y < dropdownBound[i].Y)
                            {
                                if (listItem.Y + listItem.Height < dropdownBound[i].Y)
                                {
                                    dropdownBounds[i][j] = new RectangleF();
                                    continue;
                                }
                                else
                                {
                                    listItem.Height      = listItem.Height - (dropdownBound[i].Y - listItem.Y);
                                    listItem.Y           = dropdownBound[i].Y;
                                    dropdownBounds[i][j] = listItem;
                                }
                            }
                            else if (listItem.Y + listItem.Height > dropdownBound[i].Y + dropdownBound[i].Height)
                            {
                                if (listItem.Y > dropdownBound[i].Y + dropdownBound[i].Height)
                                {
                                    dropdownBounds[i][j] = new RectangleF();
                                    continue;
                                }
                                else
                                {
                                    listItem.Height      = dropdownBound[i].Y + dropdownBound[i].Height - listItem.Y;
                                    dropdownBounds[i][j] = listItem;
                                }
                            }

                            // background
                            graphics.FillRectangle(dropdownbackground, dropdownBounds[i][j]);
                            // border
                            graphics.DrawRectangle(penborder, dropdownBounds[i][j].X, dropdownBounds[i][j].Y, dropdownBounds[i][j].Width, dropdownBounds[i][j].Height);
                            // text
                            if (dropdownBounds[i][j].Height > 2)
                            {
                                graphics.DrawString(dropdownlists[i][j], font, fontColour, dropdownBounds[i][j], GH_TextRenderingConstants.NearCenter);
                            }
                        }
                        // border
                        graphics.DrawRectangle(pen, dropdownBound[i].X, dropdownBound[i].Y, dropdownBound[i].Width, dropdownBound[i].Height);

                        // draw vertical scroll bar
                        Brush scrollbar = new SolidBrush(Color.FromArgb(dragY ? 160 : 120, Color.Black));
                        Pen   scrollPen = new Pen(scrollbar);
                        scrollPen.Width    = scrollBar.Width - 2;
                        scrollPen.StartCap = System.Drawing.Drawing2D.LineCap.Round;
                        scrollPen.EndCap   = System.Drawing.Drawing2D.LineCap.Round;
                        graphics.DrawLine(scrollPen, scrollBar.X + 4, scrollBar.Y + 4, scrollBar.X + 4, scrollBar.Y + scrollBar.Height - 4);
                    }
                }

                if (drawSlider)
                {
                    //Draw divider line
                    int i = spacerTxts.Count - 1;
                    if (spacerTxts[i] != "")
                    {
                        graphics.DrawString(spacerTxts[i], sml, UI.Colour.AnnotationTextDark, SpacerBounds[i], GH_TextRenderingConstants.CenterCenter);
                        graphics.DrawLine(spacer, SpacerBounds[i].X, SpacerBounds[i].Y + SpacerBounds[i].Height / 2, SpacerBounds[i].X + (SpacerBounds[i].Width - GH_FontServer.StringWidth(spacerTxts[i], sml)) / 2 - 4, SpacerBounds[i].Y + SpacerBounds[i].Height / 2);
                        graphics.DrawLine(spacer, SpacerBounds[i].X + (SpacerBounds[i].Width - GH_FontServer.StringWidth(spacerTxts[i], sml)) / 2 + GH_FontServer.StringWidth(spacerTxts[i], sml) + 4, SpacerBounds[i].Y + SpacerBounds[i].Height / 2, SpacerBounds[i].X + SpacerBounds[i].Width, SpacerBounds[i].Y + SpacerBounds[i].Height / 2);
                    }

                    // draw drag line and intervals
                    Pen line = new Pen(UI.Colour.GsaDarkGrey);
                    graphics.DrawLine(line, new PointF(SliderBound.X + GrabBound.Width / 2, SliderBound.Y + SliderBound.Height / 2), new PointF(SliderBound.X + SliderBound.Width - GrabBound.Width / 2, SliderBound.Y + SliderBound.Height / 2));

                    // draw grab item
                    Pen penS = new Pen(UI.Colour.GsaDarkBlue);
                    penS.Width = 2f;
                    RectangleF button = new RectangleF(GrabBound.X, GrabBound.Y, GrabBound.Width, GrabBound.Height);
                    button.Inflate(-2, -2);
                    Brush fill = new SolidBrush(UI.Colour.GsaLightGrey);
                    graphics.FillEllipse(fill, button);
                    graphics.DrawEllipse(penS, button);

                    // Draw display value text
                    Font font = new Font(GH_FontServer.FamilyStandard, 7);
                    // adjust fontsize to high resolution displays
                    font = new Font(font.FontFamily, font.Size / GH_GraphicsUtil.UiScale, FontStyle.Regular);
                    string val = string.Format(new System.Globalization.NumberFormatInfo()
                    {
                        NumberDecimalDigits = noDigits
                    }, "{0:F}", new decimal(CurrentValue));

                    graphics.DrawString(val, font, UI.Colour.AnnotationTextDark, SliderValTextBound, ((CurrentValue - MinValue) / (MaxValue - MinValue) < 0.5) ? GH_TextRenderingConstants.NearCenter : GH_TextRenderingConstants.FarCenter);
                }
            }
        }
예제 #54
0
        Bitmap GetBitmap(Viewer.MapData mapData)
        {
            int topBorderSize = 14;

            Bitmap bm = new Bitmap(Scale(mapData.w), Scale(mapData.h) + topBorderSize);

            using (System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(bm))
            {
                gr.SmoothingMode = SmoothingMode.None;
                gr.Clear(System.Drawing.Color.Black);

                // World Zones
                if (chkGrid.Checked)
                {
                    foreach (var zone in mapData.worldZones)
                    {
                        gr.DrawRectangle(Pens.Gray, Scale(zone.x1), Scale(zone.y1), Scale(zone.x2 - zone.x1), Scale(zone.y2 - zone.y1));
                    }
                }

                // POIS
                if (chkPOIs.Checked)
                {
                    foreach (var poi in mapData.poiZones)
                    {
                        // Zone
                        gr.DrawRectangle(Pens.DarkGray, Scale(poi.x1), Scale(poi.y1), Scale(poi.x2 - poi.x1), Scale(poi.y2 - poi.y1));
                    }
                }

                // Draw inactive.
                if (chkInactive.Checked)
                {
                    foreach (var zombie in mapData.inactive)
                    {
                        gr.FillEllipse(Brushes.Red, Scale(zombie.x), Scale(zombie.y), 2, 2);
                    }
                }

                // Active
                if (chkActive.Checked)
                {
                    foreach (var zombie in mapData.active)
                    {
                        gr.FillEllipse(Brushes.Blue, Scale(zombie.x), Scale(zombie.y), 2, 2);
                    }
                }

                // Visible zones.
                if (chkPlayers.Checked)
                {
                    foreach (var zone in mapData.playerZones)
                    {
                        // Zone
                        gr.DrawRectangle(Pens.Green, Scale(zone.x1), Scale(zone.y1), Scale(zone.x2 - zone.x1), Scale(zone.y2 - zone.y1));

                        // Spawn Block.
                        gr.DrawRectangle(Pens.Yellow, Scale(zone.x3), Scale(zone.y3), Scale(zone.x4 - zone.x3), Scale(zone.y4 - zone.y3));
                    }
                }

                // Stats
                {
                    gr.FillRectangle(Brushes.Black, 0, 0, mapData.mapW, 20);

                    float x = 4.0f;

                    gr.DrawString(string.Format("Speed: {0}x", mapData.timescale), SystemFonts.DefaultFont, Brushes.Green, x, 4.0f);
                    x += 70.0f;

                    gr.DrawString(string.Format("Map: {0}x{1}", mapData.mapW, mapData.mapH), SystemFonts.DefaultFont, Brushes.Green, x, 4.0f);
                    x += 100.0f;

                    gr.DrawString(string.Format("Density: {0}/km²", mapData.density), SystemFonts.DefaultFont, Brushes.Green, x, 4.0f);
                    x += 100.0f;

                    gr.DrawString(string.Format("Inactive: {0}", mapData.inactive.Count), SystemFonts.DefaultFont, Brushes.Green, x, 4.0f);
                    x += 100.0f;

                    gr.DrawString(string.Format("Active: {0}", mapData.active.Count), SystemFonts.DefaultFont, Brushes.Green, x, 4.0f);
                    x += 70.0f;

                    gr.DrawString(string.Format("Zombie Speed: {0}", mapData.zombieSpeed), SystemFonts.DefaultFont, Brushes.Green, x, 4.0f);
                    x += 100.0f;
                }
            }
            return(bm);
        }
예제 #55
0
파일: Form1.cs 프로젝트: sciss0r/gk6
 private void drawPoint(int x, int y)
 {
     g.DrawEllipse(pen_red, x - 1 + pictureBox1.Width / 2, -y - 1 + pictureBox1.Height / 2, 3, 3);
     g.FillEllipse(brush1, x - 1 + pictureBox1.Width / 2, -y - 1 + pictureBox1.Height / 2, 3, 3);
 }
예제 #56
0
        Bitmap GetBitmap(State state)
        {
            int topBorderSize = 14;

            var worldInfo   = state.worldInfo;
            var worldZones  = state.worldZones;
            var poiZones    = state.poiZones;
            var playerZones = state.playerZones;
            var active      = state.active;
            var inactive    = state.inactive;

            if (worldInfo.w == 0 || worldInfo.h == 0)
            {
                return(null);
            }

            Bitmap bm = new Bitmap(ScaleCoord(worldInfo.w), ScaleCoord(worldInfo.h) + topBorderSize);

            using (System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(bm))
            {
                gr.SmoothingMode = SmoothingMode.None;
                gr.Clear(System.Drawing.Color.Black);

                // World Zones
                if (chkGrid.Checked && worldZones.zones != null)
                {
                    foreach (var zone in worldZones.zones)
                    {
                        gr.DrawRectangle(Pens.Gray, ScaleCoord(zone.x1), ScaleCoord(zone.y1), ScaleCoord(zone.x2 - zone.x1), ScaleCoord(zone.y2 - zone.y1));
                    }
                }

                // POIS
                if (chkPOIs.Checked && poiZones.zones != null)
                {
                    foreach (var poi in poiZones.zones)
                    {
                        // Zone
                        gr.DrawRectangle(Pens.DarkGray, ScaleCoord(poi.x1), ScaleCoord(poi.y1), ScaleCoord(poi.x2 - poi.x1), ScaleCoord(poi.y2 - poi.y1));
                    }
                }

                // Draw inactive.
                if (chkInactive.Checked && inactive.list != null)
                {
                    foreach (var zombie in inactive.list)
                    {
                        gr.FillEllipse(Brushes.Red, ScaleCoord(zombie.x), ScaleCoord(zombie.y), 2, 2);
                    }
                }

                // Active
                if (chkActive.Checked && active.list != null)
                {
                    foreach (var zombie in active.list)
                    {
                        gr.FillEllipse(Brushes.Blue, ScaleCoord(zombie.x), ScaleCoord(zombie.y), 2, 2);
                    }
                }

                // Visible zones.
                if (chkPlayers.Checked && playerZones.zones != null)
                {
                    foreach (var zone in playerZones.zones)
                    {
                        // Zone
                        gr.DrawRectangle(Pens.Green, ScaleCoord(zone.x1), ScaleCoord(zone.y1), ScaleCoord(zone.x2 - zone.x1), ScaleCoord(zone.y2 - zone.y1));

                        // Spawn Block.
                        gr.DrawRectangle(Pens.Yellow, ScaleCoord(zone.x3), ScaleCoord(zone.y3), ScaleCoord(zone.x4 - zone.x3), ScaleCoord(zone.y4 - zone.y3));
                    }
                }

                // Sounds
                {
                    var sounds = state.sounds;
                    if (sounds != null)
                    {
                        foreach (var snd in sounds)
                        {
                            var elapsed = snd.watch.ElapsedMilliseconds;
                            var alpha   = (elapsed / 1000.0f);
                            int dim     = (int)(alpha * snd.radius) * 2;
                            int x       = snd.x - (dim / 2);
                            int y       = snd.y - (dim / 2);

                            gr.DrawEllipse(Pens.Green, ScaleCoord(x), ScaleCoord(y), ScaleCoord(dim), ScaleCoord(dim));
                        }
                    }
                }

                // Stats
                {
                    gr.FillRectangle(Brushes.Black, 0, 0, worldInfo.mapW, 20);

                    float x = 4.0f;

                    gr.DrawString(string.Format("Speed: {0}x", worldInfo.timescale), SystemFonts.DefaultFont, Brushes.Green, x, 4.0f);
                    x += 70.0f;

                    gr.DrawString(string.Format("Map: {0}x{1}", worldInfo.mapW, worldInfo.mapH), SystemFonts.DefaultFont, Brushes.Green, x, 4.0f);
                    x += 100.0f;

                    gr.DrawString(string.Format("Density: {0}/km²", worldInfo.density), SystemFonts.DefaultFont, Brushes.Green, x, 4.0f);
                    x += 100.0f;

                    gr.DrawString(string.Format("Inactive: {0}", inactive.list == null ? 0 : inactive.list.Count), SystemFonts.DefaultFont, Brushes.Green, x, 4.0f);
                    x += 100.0f;

                    gr.DrawString(string.Format("Active: {0}", active.list == null ? 0 : active.list.Count), SystemFonts.DefaultFont, Brushes.Green, x, 4.0f);
                    x += 70.0f;

                    gr.DrawString(string.Format("Zombie Speed: {0}", worldInfo.zombieSpeed), SystemFonts.DefaultFont, Brushes.Green, x, 4.0f);
                    x += 100.0f;
                }
            }
            return(bm);
        }
예제 #57
0
 private void DrawNewPoint()
 {
     pointerToGraphicSurface.FillEllipse(Brushes.Red, (float)(x), (float)(y), 2, 2);
 }
예제 #58
0
            public override void Draw(System.Drawing.Graphics gr)
            {
                Brush brush = new SolidBrush(Color.Yellow);

                gr.FillEllipse(brush, -radius, -radius, 2 * radius, 2 * radius);
            }
예제 #59
0
        private void DrawAccelerationCurve(System.Drawing.Graphics g, MotorCar car, Acceleration.Entry entry, bool selected)
        {
            // curve
            Point[] points = new Point[car.Acceleration.ImageWidth];

            for (int x = 0; x < car.Acceleration.ImageWidth; x++)
            {
                double velocity = car.Acceleration.XtoVelocity(x);
                double acceleration;

                if (car.Acceleration.Resistance)
                {
                    acceleration = Math.Max(car.Acceleration.GetAcceleration(entry, velocity) - GetDeceleration(car, velocity), 0.0);
                }
                else
                {
                    acceleration = car.Acceleration.GetAcceleration(entry, velocity);
                }

                int y = (int)Math.Round(car.Acceleration.AccelerationToY(acceleration));

                points[x] = new Point(x, y);
            }

            double hue;

            if (car.Acceleration.Entries.Count <= 1)
            {
                hue = 1.0;
            }
            else
            {
                hue = 0.5 * car.Acceleration.Entries.IndexOf(entry) / (car.Acceleration.Entries.Count - 1);
            }

            Color color = Utilities.GetColor(hue, selected);

            g.DrawLines(new Pen(color), points);

            // points
            {
                double v1 = entry.V1;
                double a1 = entry.A1;

                if (car.Acceleration.Resistance)
                {
                    a1 -= GetDeceleration(car, v1);
                }

                int x1 = (int)Math.Round(car.Acceleration.VelocityToX(v1));
                int y1 = (int)Math.Round(car.Acceleration.AccelerationToY(a1));

                g.FillEllipse(new SolidBrush(color), new Rectangle(x1 - 2, y1 - 2, 5, 5));

                double v2 = entry.V2;
                double a2 = car.Acceleration.GetAcceleration(entry, v2);

                if (car.Acceleration.Resistance)
                {
                    a2 -= GetDeceleration(car, v2);
                }

                int x2 = (int)Math.Round(car.Acceleration.VelocityToX(v2));
                int y2 = (int)Math.Round(car.Acceleration.AccelerationToY(a2));

                g.FillEllipse(new SolidBrush(color), new Rectangle(x2 - 2, y2 - 2, 5, 5));
            }
        }
예제 #60
0
        public void paint(ref System.Drawing.Graphics canvas, ref ViewPort vp, bool polygonOutline = false)
        {
            int   point_r  = 5; // Point radius
            Point p        = new Point();
            int   n_points = 0;

            float line_width_k = (100 / (canvas.DpiX / 25.4f)) * vp.projection_scale; // Line width coefficient. (S52 docs says :"The coordinates are within the range of 0 to 32767 units. Each unit represents 0.01 mm")

            foreach (var geom in geometry)
            {
                int transparency = (4 - geom.transparency) * 64;
                transparency = Math.Min(transparency, 255);
                transparency = Math.Max(0, transparency);

                var color = Color.FromArgb(transparency, Style.S52colors[geom.color]);
                Pen pen   = new Pen(color, geom.penWidth * line_width_k);



                switch (geom.type)
                {
                case GeometryType.LINE:
                    if (geom.points.Count() < 2)
                    {
                        continue;
                    }

                    n_points = geom.points.Count();

                    var projPnts = new Point[n_points];

                    for (int i = 0; i < n_points; i++)
                    {
                        projPnts[i] = vp.project(geom.points[i]);
                    }


                    canvas.DrawLines(pen, projPnts);


                    break;

                case GeometryType.CIRCLE:
                    var circle = geom as HCircle;
                    p = vp.project(circle.points[0]);
                    var radius = circle.radius * vp.projection_scale;
                    if (circle.filled)
                    {
                        canvas.FillEllipse(new SolidBrush(color), p.X - radius, p.Y - radius, radius * 2, radius * 2);
                    }
                    else
                    {
                        canvas.DrawEllipse(pen, p.X - radius, p.Y - radius, radius * 2, radius * 2);
                    }

                    break;

                case GeometryType.POINT:

                    p = vp.project(geom.points[0]);
                    int size = (int)(geom.penWidth * line_width_k);
                    canvas.FillRectangle(new SolidBrush(color), p.X - size / 2, p.Y - size / 2, size, size);

                    break;

                case GeometryType.POLYGON:

                    if (geom.points.Count() < 2)
                    {
                        continue;
                    }

                    n_points = geom.points.Count();
                    projPnts = new Point[n_points];

                    for (int i = 0; i < n_points; i++)
                    {
                        projPnts[i] = vp.project(geom.points[i]);
                    }

                    canvas.FillPolygon(new SolidBrush(color), projPnts);
                    if (polygonOutline)
                    {
                        canvas.DrawPolygon(pen, projPnts);
                    }

                    break;
                }
            }

            foreach (var geom in geometry)
            {
                if (!geom.selected)
                {
                    continue;
                }

                switch (geom.type)
                {
                case GeometryType.LINE:

                    n_points = geom.points.Count();

                    var projPnts = new Point[n_points];

                    for (int i = 0; i < n_points; i++)
                    {
                        projPnts[i] = vp.project(geom.points[i]);
                    }

                    if (n_points > 1)
                    {
                        canvas.DrawLines(new Pen(Color.Red), projPnts);
                    }


                    for (int i = 0; i < n_points; i++)
                    {
                        canvas.DrawEllipse(new Pen(Color.Red), projPnts[i].X - point_r, projPnts[i].Y - point_r, point_r * 2, point_r * 2);
                    }

                    break;

                case GeometryType.CIRCLE:
                    var circle = geom as HCircle;
                    p = vp.project(circle.points[0]);
                    var radius = circle.radius * vp.projection_scale;

                    canvas.DrawEllipse(new Pen(Color.Red), p.X - radius, p.Y - radius, radius * 2, radius * 2);
                    canvas.DrawEllipse(new Pen(Color.Red), p.X - point_r, p.Y - point_r, point_r * 2, point_r * 2);

                    break;

                case GeometryType.POINT:

                    p = vp.project(geom.points[0]);
                    canvas.DrawEllipse(new Pen(Color.Red), p.X - point_r, p.Y - point_r, point_r * 2, point_r * 2);

                    break;

                case GeometryType.POLYGON:
                    n_points = geom.points.Count();

                    projPnts = new Point[n_points];

                    for (int i = 0; i < n_points; i++)
                    {
                        projPnts[i] = vp.project(geom.points[i]);
                    }

                    if (n_points > 1)
                    {
                        canvas.DrawLines(new Pen(Color.Red), projPnts);
                    }


                    for (int i = 0; i < n_points; i++)
                    {
                        canvas.DrawEllipse(new Pen(Color.Red), projPnts[i].X - point_r, projPnts[i].Y - point_r, point_r * 2, point_r * 2);
                    }

                    break;
                }
            }
        }