cgfs:draw_lines
差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
| cgfs:draw_lines [2024/07/12 03:19] – freemikan | cgfs:draw_lines [2025/11/19 15:11] (現在) – using std::swap; freemikan | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| + | ====== DrawPixelだけで三角形を描く (1) 線を描く ====== | ||
| + | |||
| {{: | {{: | ||
| + | |||
| + | [[https:// | ||
| <file cpp> | <file cpp> | ||
| 行 37: | 行 41: | ||
| void DrawLine(vec2 const &p0, vec2 const &p1, Color const &color) { | void DrawLine(vec2 const &p0, vec2 const &p1, Color const &color) { | ||
| + | using std::swap; | ||
| + | |||
| auto x0 = p0.x; | auto x0 = p0.x; | ||
| auto y0 = p0.y; | auto y0 = p0.y; | ||
| 行 44: | 行 50: | ||
| if (std:: | if (std:: | ||
| if (x0 > x1) { | if (x0 > x1) { | ||
| - | | + | swap(x0, x1); |
| - | | + | swap(y0, y1); |
| } | } | ||
| auto i0 = static_cast< | auto i0 = static_cast< | ||
| 行 58: | 行 64: | ||
| } else { | } else { | ||
| if (y0 > y1) { | if (y0 > y1) { | ||
| - | | + | swap(y0, y1); |
| - | | + | swap(x0, x1); |
| } | } | ||
cgfs/draw_lines.1720721970.txt.gz · 最終更新: by freemikan
