private void DrawLineH(RPen rpen, int y1, int x1, int x2) { if (x1 > x2) { int t = x1; x1 = x2; x2 = t; } PenAdapter pen = rpen.ToPenA(); pen.color.SetToSDLRenderer(); int width = (int)pen.width; int w0, w1; w0 = w1 = width / 2; //w1 -= (width != 1 && width % 2 == 1) ? 1 : 0; List <SDL.SDL_Rect> rects = new List <SDL.SDL_Rect>(); int length = (int)(x2 - x1) + 1; switch (pen.dashStyle) { case RDashStyle.Solid: rects.Add(new SDL.SDL_Rect { x = x1, y = y1 - w0, w = length, h = width }); break; case RDashStyle.Dot: for (int x = (int)x1; x <= x2 - width + 1; x += width * 2) { rects.Add(new SDL.SDL_Rect { x = x, y = y1 - w0, w = width, h = width }); } if (length % (width * 2) < width) { rects.Add(new SDL.SDL_Rect { x = x2 - length % (width * 2) + 1, y = y1 - w0, w = length % width, h = width }); } break; case RDashStyle.Dash: for (int x = (int)x1; x <= x2 - width * 2 + 1; x += width * 3) { rects.Add(new SDL.SDL_Rect { x = x, y = y1 - w0, w = width * 2, h = width }); } if (length % (width * 3) < width * 2) { rects.Add(new SDL.SDL_Rect { x = x2 - length % (width * 3) + 1, y = y1 - w0, w = length % (width * 3) + 1, h = width }); } break; } SDL.SDL_RenderFillRects(_renderer, rects.ToArray(), rects.Count); }
internal List <SDL.SDL_Point> GetArcSDLPoints(PenAdapter pen, PathItem corner) { List <SDL.SDL_Point> points = new List <SDL.SDL_Point>(); Double step = 90f / ((double)corner.arc_r * Math.PI / 2f); //points.Add(new SDL.SDL_Point { x = corner.arc_cx, y = corner.arc_cy }); for (double angle = 0; angle <= 90; angle += step) { points.Add(GetArcSDLPointAtAngle(corner, angle)); switch (pen.dashStyle) { case RDashStyle.Solid: break; case RDashStyle.Dot: angle += step * 1.5f; break; case RDashStyle.Dash: angle += step; points.Add(GetArcSDLPointAtAngle(corner, angle)); angle += step * 2f; break; } } return(points); }
private void DrawLineV(RPen rpen, int x1, int y1, int y2) { if (y1 > y2) { int t = y1; y1 = y2; y2 = t; } PenAdapter pen = rpen.ToPenA(); pen.color.SetToSDLRenderer(); int width = (int)pen.width; int w0, w1; w0 = w1 = width / 2; //w1 -= (width != 1 && width % 2 == 1) ? 1 : 0; List <SDL.SDL_Rect> rects = new List <SDL.SDL_Rect>(); int length = (int)(y2 - y1); switch (pen.dashStyle) { case RDashStyle.Solid: rects.Add(new SDL.SDL_Rect { x = x1 - w0, y = y1, w = width, h = length }); break; case RDashStyle.Dot: for (int y = y1; y <= y2 - width + 1; y += width * 2) { rects.Add(new SDL.SDL_Rect { x = x1 - w0, y = y, w = width, h = width }); } if (length % (width * 2) < width) { rects.Add(new SDL.SDL_Rect { x = x1 - w0, y = y2 - length % (width * 2) + 1, w = width, h = length % width }); } break; case RDashStyle.Dash: for (int y = y1; y <= y2 - width * 2 + 1; y += width * 3) { rects.Add(new SDL.SDL_Rect { x = x1 - w0, y = y, w = width, h = width * 2 }); } if (length % (width * 3) < width * 2) { rects.Add(new SDL.SDL_Rect { x = x1 - w0, y = y2 - length % (width * 3) + 1, w = width, h = length % (width * 3) }); } break; } SDL.SDL_RenderFillRects(_renderer, rects.ToArray(), rects.Count); }