#include <stdio.h>
#include <math.h>

On Sun, May 15, 2022, 11:10 AM Undiscussed Horrific Abuse, One Victim of Many <gmkarl@gmail.com> wrote:
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

int grid[5*5] = 0;

struct pt {
  int x;
  int y;
};

void plot(pt p)
{
  grid[p.x+p.y*5] = 1;
}


pt1 = 2,1
pt2 = 4,3
pt3 = 0,3

p pt1 = {2,1};
p pt2 = {4,3};
p pt3 = {0,3};


line(a,b):
void line(pt a, pt b)
{
  change = b/a
  pt change;
  change.x = b.x - a.x;
  change.y = b.y - a.y;
  ct = max(abs(change))
  int ctx = abs(change.x)
  int cty = abs(change.y)
  int ct = ctx > cty ? ctx : cty;
  for t = 0..ct inclusive:
  for (double t = 0; t <= ct; ++ t) {
    plot(a + change * t / ct)
    plot(a.x + change.x * t / ct, a.y + change.y * t / ct);
  }

line(pt1,pt2)
line(pt2,pt3)
line(pt3,pt1)
int main()
{
  line(pt1, pt2);
  line(pt2, pt3);
  line(pt3, pt1);

  for (int x = 0; x < 5; x ++) {
    for (int y = 0; y < 5; y ++)
      printf("%d", grid[x + y * 5]);
    printf("\n");
  }
}