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
  • No one is chatting at the moment.
  • SylverReZ @ SylverReZ:
    Hope they made lots of spaget
  • K3N1 @ K3N1:
    Chill dog
  • SylverReZ @ SylverReZ:
    Chilli dog
  • Skelletonike @ Skelletonike:
    Damn, I'm loving the new zelda.
  • xtremegamer @ xtremegamer:
    loving the new zelda, i started a game, it was so fucking good, so i
    am waiting on my friend to get home so we can start a new one together
  • Skelletonike @ Skelletonike:
    I just dislike that they don't let me choose the voices before the game starts. Happened with botw as well, had to change to japanese and restart.
  • K3N1 @ K3N1:
    But the important question is can you choose gender
  • Skelletonike @ Skelletonike:
    Same way you can choose Gerald's gender.
  • Skelletonike @ Skelletonike:
    *Geralt, damn autocorrect.
  • Psionic Roshambo @ Psionic Roshambo:
    But can he be trans? Lol
  • K3N1 @ K3N1:
    Zelda transforms into link
  • Psionic Roshambo @ Psionic Roshambo:
    Link I'm not the princess your looking for.... *Pulls a crying game*
  • K3N1 @ K3N1:
    *skirt up* it's exactly what I always wanted
  • Skelletonike @ Skelletonike:
    Just scanned all my zelda amiibos, took a while but didn't get anything that cool, did get the lon lon ranch hylian fabrics though.
  • Skelletonike @ Skelletonike:
    It was pretty funny when I scanned wolf link and got a shit load of meat.
  • K3N1 @ K3N1:
    @Skelletonike, btw I ran that custom for mgs4 on the deck I'm amazed it got that far in game
  • K3N1 @ K3N1:
    Plug in*
  • K3N1 @ K3N1:
    Your favorite activity
  • BentlyMods @ BentlyMods:
    My fav actvity is:

    mario-dancing.gif
  • Psionic Roshambo @ Psionic Roshambo:
    Do the Mario lol
  • K3N1 @ K3N1:
    🍑
  • K3N1 @ K3N1:
    Whoever developed Bramble was smoking that good shit fucking gnomes
    K3N1 @ K3N1: Whoever developed Bramble was smoking that good shit fucking gnomes