.
[ Voor 99% gewijzigd door Engineer op 13-10-2018 11:08 ]
[ Voor 99% gewijzigd door Engineer op 13-10-2018 11:08 ]
Ken Thompson's famous line from V6 UNIX is equaly applicable to this post:
'You are not expected to understand this'
[ Voor 10% gewijzigd door rollebol op 22-09-2003 17:02 ]
[ Voor 28% gewijzigd door .oisyn op 22-09-2003 17:03 ]
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
[ Voor 98% gewijzigd door Engineer op 13-10-2018 11:08 ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
| <? function drawline($img, $x1, $y1, $x2, $y2, $color) { /* Als een lijn van rechts naar links wordt gevraagd, zet dit dan om zodat deze van links naar rechts wordt getekend. */ if ($x2 < $x1) { $x = $x1; $x1 = $x2; $x2 = $x; $y = $y1; $y1 = $y2; $y2 = $y; } /* Bepaal de richtingsco-efficient */ $m = ((($x2 - $x1) == 0) ? 0 : (($y2 - $y1) / ($x2 - $x1))); /* Als de Y verplaatsing bij X niet minder is dan -1 en niet meer dan 1, is deze manier van tekenen goed */ if (($m >= -1) && ($m <= 1)) { $x = $x1; $y = $y1; while ($x <= $x2) { imagesetpixel($img, $x++, $y, $color); $y += $m; } } /* Anders moeten we op deze manier tekenen */ else { $n = ((($y2 - $y1) == 0) ? 0 : (($x2 - $x1) / ($y2 - $y1))); $x = $x1; $y = $y1; if ($m > 0) { while ($y <= $y2) { imagesetpixel($img, $x, $y++, $color); $x += $n; } } else { while ($y >= $y2) { imagesetpixel($img, $x, $y--, $color); $x -= $n; } } } } /* Plaatje en kleuren defineren */ $img = imagecreate(500,500); $white = imagecolorallocate($img, 255, 255, 255); $black = imagecolorallocate($img, 0, 0, 0); /* 360 lijnen in een cirkel tekenen */ for ($i = 0; $i <= 360; $i++) { drawline($img, 250, 250, (sin(deg2rad($i)) * 200) + 250, (cos(deg2rad($i)) * 200) + 250, $black); } /* Plaatje weergeven */ header("Content-type: image/png"); imagepng($img); ?> |
[ Voor 3% gewijzigd door GeniusDex op 23-09-2003 16:20 ]
Please guys, I'm trying to troll here.
If I failed to offend you in this post, please leave a message. I will address you in next post.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| // drawLine tekent een line van (x1,y1) tot (x2,y2) // let op: x1 < x2, y1 < y2 en deltax > deltay void drawLine (int x1, int y1, int x2, int y2) { int dx = x2 - x1; int dy = y2 - y1; int yp = 0; while (x1 < x2) { plotPixel (x1, y1); x1++; yp += dy; if (yp >= dx) { y1++; yp -= dx; } } } |
[ Voor 77% gewijzigd door .oisyn op 23-09-2003 17:22 ]
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
Ik ben van het principe uitgegaan dat y 4.5 - 4.499999..... op y=4 uitkomen, 5.5 - 5.4999999.... op y=5, etc. en heb daar zelf op voortbedacht en kwam met dit..oisyn schreef op 23 September 2003 @ 16:29:
Die deling is trouwens niet eens nodig, als je het slim aanpakt (nogmaals: bresenham)
Please guys, I'm trying to troll here.
If I failed to offend you in this post, please leave a message. I will address you in next post.
De reden om geen deling te doen is omdat een deling erg traag is. Door ipv te delen door (bv) dy alle andere reverenties met dy te vermenigvuldigen heb je hetzelfde effect zonder deling.GeniusDex schreef op 23 September 2003 @ 16:34:
[...]
Ik ben van het principe uitgegaan dat y 4.5 - 4.499999..... op y=4 uitkomen, 5.5 - 5.4999999.... op y=5, etc. en heb daar zelf op voortbedacht en kwam met dit.
Ken Thompson's famous line from V6 UNIX is equaly applicable to this post:
'You are not expected to understand this'