コード例 #1
0
ファイル: Whiteboard.cs プロジェクト: patmosxx-v2/d2dlib
        private void drawPen(Point currentPoint)
        {
            var diff = new Point(currentPoint.X - this.lastPoint.X, currentPoint.Y - this.lastPoint.Y);

            memg.BeginRender();
            D2DEllipse ellipse = new D2DEllipse(D2DPoint.Zero, this.penSize);
            D2DRect    rect    = new D2DRect(0, 0, this.penSize.Width * 2, this.penSize.Height * 2);

            float len = (float)Math.Sqrt(diff.X * diff.X + diff.Y * diff.Y);
            float seg = 1.0f / len;

            // draw a continuous line
            for (float t = 0; t < 1; t += seg)
            {
                float x = this.lastPoint.X + diff.X * t, y = this.lastPoint.Y + diff.Y * t;

                if (this.penColor == D2DColor.White)
                {
                    rect.X = x - this.penSize.Width;
                    rect.Y = y - this.penSize.Height;
                    memg.FillRectangle(rect, this.penColor);
                }
                else
                {
                    ellipse.origin = new D2DPoint(x, y);
                    memg.FillEllipse(ellipse, this.penColor);
                }
            }

            memg.EndRender();

            this.lastPoint = currentPoint;
        }
コード例 #2
0
ファイル: StarSpace.cs プロジェクト: patmosxx-v2/d2dlib
        protected override void OnRender(unvell.D2DLib.D2DGraphics g)
        {
            D2DEllipse ellipse = new D2DEllipse();

            for (int i = 0; i < stars.Length; i++)
            {
                var s = stars[i];

                if (s.x != 0 && s.y != 0)
                {
                    ellipse.X       = s.x;
                    ellipse.Y       = s.y;
                    ellipse.radiusX = ellipse.radiusY = s.size;
                    brush.Color     = s.color;

                    g.FillEllipse(ellipse, brush);
                }
            }
        }