Hacking My function to draw a line (not just horiz or vert) that works In libwiiu

brienj

Trying to avoid getting cancer
OP
Member
Joined
Jan 3, 2016
Messages
1,232
Trophies
0
Website
twitter.com
XP
2,007
Country
United States
The function drawLine in libwiiu only draws a horizontal or vertical line. So what if you want to draw a 30, 45, or 60 degree angle? I was doing some testing, and found the DDA Algorithm, modified to work with libwiiu, to be the best. So here is the code for the DDA Algorithm I modified. You can replace the normal drawLine function with it if you want, it works just as well.

Code:
void draw2DLine(int x1, int y1, int x2, int y2, char r, char g, char b)
{
	int s, dx, dy, m;
	float xi, yi, x, y;
	dx = x2 - x1;
	dy = y2 - y1;
	if (abs(dx) > abs(dy)) {
		s = dx;
	}
	else {
		s = dy;
	}
	xi = dx / (float) s;
	yi = dy / (float) s;
	x = x1;
	y = y1;

	drawPixel(x1, y1, r, g, b);
	if (s > m) {
		m = 0;
		for (m; m < s; m++) {
			x += xi;
			y += yi;
			drawPixel(x, y, r, g, b);
		}
	}
	else {
		m = 0;
		for (m; m > s; m--) {
			x -= xi;
			y -= yi;
			drawPixel(x, y, r, g, b);
		}
	}
}
 
D

Deleted User

Guest
Awesome! Why don't you create a merge pull request in the libwiiu repo on github? ^_^

...unless you already have done?
 
  • Like
Reactions: brienj
General chit-chat
Help Users
  • coolax @ coolax:
    hey guys anyone can help me for LOZ : TOTK ? im trying to install theses 60fps file but I don't understand where i'm suppose to paste them. ? anyone kno ?
  • K3N1 @ K3N1:
    Your mom's spaghetti
  • Psionic Roshambo @ Psionic Roshambo:
    Her armpits sweaty already
  • K3N1 @ K3N1:
    On the surface
  • Psionic Roshambo @ Psionic Roshambo:
    Flies crawling and pizza stained already
  • K3N1 @ K3N1:
    My noodle has vomit on it already
  • Psionic Roshambo @ Psionic Roshambo:
    Monica's dress stained already
  • SylverReZ @ SylverReZ:
    @Psionic Roshambo, Bill Clinton no!
    +1
  • SylverReZ @ SylverReZ:
    Lmao
    +1
  • Sonic Angel Knight @ Sonic Angel Knight:
    Mama Mia spaghetti :P
    +1
  • DJPlace @ DJPlace:
    don't forget the meatballs
    +1
  • Sonic Angel Knight @ Sonic Angel Knight:
    Mama mia wouldn't forget meatballs in her spaghetti. :P
  • Sonic Angel Knight @ Sonic Angel Knight:
    Speaking of meatballs, what's the deal with meatball sandwich? How can people eat those? It's ROUND. Trying to bite those in a sandwich is a challenge. It's easier to eat a burger stacked with toppings. :ninja:
  • idcwhat3v3r @ idcwhat3v3r:
    here's my cup of care
  • idcwhat3v3r @ idcwhat3v3r:
    oh look, IT'S FUCKING EMPTY.
  • K3N1 @ K3N1:
    Seems familiar
  • Psionic Roshambo @ Psionic Roshambo:
    Spaghetti noodles are straight until you get them hot and wet too lol
  • Sonic Angel Knight @ Sonic Angel Knight:
    Which one are best? The flat noodle, or the not flat ones? :ninja:
  • K3N1 @ K3N1:
    Fat noodles are best
  • idcwhat3v3r @ idcwhat3v3r:
    ofc more hoes come to explode this place
  • idcwhat3v3r @ idcwhat3v3r:
    i dont give a fat SHIT about spagetti
    idcwhat3v3r @ idcwhat3v3r: i dont give a fat SHIT about spagetti