APG Raster Graphics - Line

24
APG Raster Graphics - Line JIŘÍ ŽÁRA

Transcript of APG Raster Graphics - Line

Prezentace aplikace PowerPointAPG – Line Drawing
APG – Line Drawing
element)
Slope defines a driving/major axis for sampling
(by 1 pixel step)
Bresenham algorithm [int]
APG – Line Drawing
DDA (int x1, int y1, int x2, int y2) {
double k, Y;
setPixel (x1, y1);
Y += k;
d1 = yreal – yi
k = Δy
xi+1 = xi + 1
yi+1 = yi
pi+1 = pi + 2Δy – 2Δx (yi+1 – yi)
Bresenham (int x1, int y1, int x2, int y2) {
int c0, c1, p;
init (c0, c1, p);
if (p < 0) {
c0 = 2 (y2 – y1);
p = c0 – (x2 – x1);
APG – Line Drawing
Odd segment drawn, even skipped
APG – Line Drawing
APG – Line Drawing
length>0 END
length -= lengths[segm]
[xp, yp] = [xk, yk]
a) int segm; int segmLength;
b) segm mod 2 enable/disable setPixel()
c) decrement segmLength, when 0 prepare for next segment
APG – Line Drawing
APG – Line Drawing
Oblique lines appear thinner
Modified Bresenham = bad approach
By segments = good technique
setPixel T × setPixel (in a proper direction)
b) Angular correction
APG – Line Drawing
outline
Antialiasing = smoothing (via pixel intensities)
APG – Line Drawing
Global (Full screen) antialiasing
– image processing technique (filtering)
intensities
-1
0
1
´ , = , + , +
Filter function H (kernel)
Jií ára, 23.09.2020