NoBS Code
NoBS Code
  • 7
  • 89 831
Xiaolin Wu's Line Algorithm - Rasterizing Lines with Anti-Aliasing
In this video we'll take a look at Xiaolin Wu's line algorithm. It can draw anti-aliased lines at sub-pixel positions, which results in lines that look and move smoother than those drawn using e.g. Bresenham's algorithm.
- Chapters -
0:00 - Introduction
0:40 - Notes and Recap
1:22 - Deconstructing Wu's Line
3:25 - Plotting Points
5:22 - Distances & Opacities
6:35 - Fixing the Function
7:58 - Handling the Endpoints
10:17 - Conclusion
- Music Credits -
Music by Tokyo Walker Music, released under the CC BY-NC-SA 3.0 license.
Songs:
Closing Time - www.soundcloud.com/user-356546060/closing-time
Lamp - soundcloud.com/user-356546060/lamp
Artist Media & Socials:
Spotify: open.spotify.com/artist/7cktl8j9CsS2TwsgzakhsD
Apple Music: music.apple.com/us/artist/tokyo-m…walker/1503480346
UA-cam: ua-cam.com/channels/3lLfvhpPGtwd5qD25cMDcA.html
Instagram: tokyo_music_walker
Twitter: TMW99407138
Переглядів: 6 101

Відео

The Midpoint Circle Algorithm Explained Step by Step
Переглядів 43 тис.День тому
In this video we'll take a look at how the midpoint circle algorithm works. We go through all steps required to implement the algorithm. - Chapters - 0:00 - Introduction 1:07 - First Implementation 4:05 - Testing the Midpoint 5:40 - Initial Decision Parameter 8:10 - Approximation 9:52 - Incrementing Decision Parameter 13:03 - Conclusion - Music Credits - Music by Tokyo Walker Music, released un...
Bresenham's Line Algorithm - Demystified Step by Step
Переглядів 48 тис.2 місяці тому
Bresenham's Line Algorithm is simple, but how exactly does it work? In this video we go through the steps necessary to draw a line inside a grid of pixels using only integers. To do this, we're going to write the algorithm from scratch and derive the decision parameter used in Bresenham's algorithm. - Chapters - 0:00 - Intro 2:00 - Draw Lines using Floats 3:32 - Supporting all Octants (Floats) ...
How Computers Store Text - ASCII, Unicode, UTF-8, UTF-16, and UTF-32
Переглядів 1 тис.3 місяці тому
How do computers store text? In this video you will learn how we encode text into numbers, and decode those back into text. We'll talk about the ASCII and Unicode standards, as well as the UTF-8, UTF-16, and UTF-32 text encodings. The former standards represent characters and codepoints respectively to store text in binary. The UTF-8, UTF-16, and UTF-32 encodings are used to actually represent ...
How Computers Store Binary Data - RAM, ROM, Flash, Magnetic, and Optical
Переглядів 4853 місяці тому
This video explains how computers are able to store data using physical devices, such as Hard Disk Drives, Solid State Drives, Memory, and more. We go over volatile storage devices like dynamic random access memory, to non-volatile devices such as ROM, Flash Memory, and so on. Chapters 0:00 - Intro 0:18 - Switches & Transistors 1:42 - Semiconductor 3:13 - Building a Diode 4:37 - Building a Tran...
How does Hexadecimal work? And why do we use it?
Переглядів 2503 місяці тому
This video explains how hexadecimal works in simple terms. It covers the basics and how to convert hexadecimal to decimal, convert decimal to hexadecimal, convert hexadecimal to binary, convert binary to hexadecimal, and explains why we would use hexadecimal in the first place. - Chapters - 0:00 - Hexadecimal Number System 1:09 - Hexadecimal to Decimal 1:33 - Decimal to Hexadecimal 2:41 - Hexad...
How does Binary work? From the Basics to Floating Point
Переглядів 5443 місяці тому
This video explains how binary works in simple terms. No prior knowledge required. It covers everything from basic conversions to binary arithmetic, sign bits, ones complement, twos complement, biases, fixed point, floating point numbers, and more. - Chapters - 0:00 Intro 0:11 Binary Numeral System 1:00 Binary to Decimal 1:15 Decimal to Binary 2:01 Conversion by Halving 2:30 Conversion by Doubl...

КОМЕНТАРІ

  • @pebbleschan6085
    @pebbleschan6085 2 години тому

    What a load of BS! 🎉

  • @zhabiboss
    @zhabiboss 7 годин тому

    I like the video but it’s kinda strange when you choose to through all those steps with showing the binomials and taking 10 seconds just to get from 2x + 1 + y + y to 2(x + y) + 1 and then not explain the filling of the circle to the audience.

  • @DaKeypunchAr
    @DaKeypunchAr 8 годин тому

    i got to know about the trailing one thing and the infinity and nan thing only. well i had studied this topic before. and yes this is a good guide.

  • @Odod4000
    @Odod4000 10 годин тому

    im making a graphics library rn your videos really help

  • @kestergreen3844
    @kestergreen3844 11 годин тому

    Amazing video. One tip though when explaining math... use allot of pauses to allow the words to transform from noise to comprehension in our minds. For example at this point: ua-cam.com/video/f3Rs20k-hcI/v-deo.html when you say "the change in y" add a pause and then continue to say "for one step in x". These two pieces of information are seperate and have different meaning. Allow your listeners and viewers a chance to recognise the distinct meaning of each piece of information your conveying.

  • @Z3rgatul
    @Z3rgatul 14 годин тому

    0:15 is this really "perfectly anti-aliased" line? It seems like a good approximation. Perfectly anti-aliased should calculate orthogonal distance to the line, and not just delta X or Y. This requires more compute power

  • @sukursukur3617
    @sukursukur3617 14 годин тому

    Why did you build that circle?

  • @tHEuKER
    @tHEuKER 19 годин тому

    Why not multiply every term by 4 to get p = 1 - 4r? Multiplication by 4 is quite cheap.

  • @0memega
    @0memega 21 годину тому

    Still waiting for the Digital Differential Analyzer, or DDA, it could also be used with floats. It's most popular application would be in psuedo 3D, raycasting, present in Wolfenstein 3D and other games when they weren't powerful enough to render true 3D

  • @typicwhisper6569
    @typicwhisper6569 23 години тому

    I think there is something wrong with the opacity and blending, causing dark spots on the line. the alpha should be A^(1/2.2) (or 1-(1-A)^2.2 idk), where A is the original alpha from 0 to 1.

  • @FadkinsDiet
    @FadkinsDiet День тому

    this method uses approximate distances from the lune to rhe center of the pixel. There's going to be less distortion for a line that is nearly zero slipe compared to a line that is nearly diagonal. I wonder how better it would look to do a proper perpendicular distance from the line to the center point of the cell.

  • @ai_outline
    @ai_outline День тому

    This channel has so much potential!! Amazing ❤️

  • @wWvwvV
    @wWvwvV День тому

    There is also the probably more efficient DDA algorithm. It also uses floating point arithmetic. DDA stands for "digital differencial analyzer". The derivatives are predetermined. Add the correct slope/derivative to get to the next integer pixel. The difference to Xiaolin Wu is, only the pixels the line goes through are considered/affected.

  • @Flourish38
    @Flourish38 День тому

    I think the reason this line looks pretty mediocre is that you are assigning color values in the sRGB colorspace, which is *not linear*. If you redid the code using a linear color space (linear RGB would probably be fine here), I think it would look much better. Wikipedia has very good pages talking about this, you can also search for "converting to and from linear RGB".

  • @aidennwitz
    @aidennwitz День тому

    fantastic series <3

  • @Lespati-wy9dy
    @Lespati-wy9dy День тому

    Love it!

  • @CartoType
    @CartoType День тому

    There are two debatable assumptions here: first, that Bresenham looks worse than Xiaolin Wu (in my opinion Bresenham looks better); and more importantly, that it is worthwhile to draw single-pixel-wide lines. With modern displays having three or four hundred dots per inch, you can’t see a line one pixel wide. A better approach is to draw lines that have a zero-width centre line and a non-zero width, by stroking a path using a circular or sometimes non-circular pen. Graphics systems compute the envelope of the line, which is the Minkowski sum of the pen and the zero-width line, and then fill it using a suitable anti-aliasing system.

    • @tbird81
      @tbird81 День тому

      With modern displays you'd use a GPU. But it's useful to know vaguely how this algorithm works.

    • @HoSza1
      @HoSza1 День тому

      And how do you think gpus draw antialiased lines?

    • @tbird81
      @tbird81 День тому

      @@HoSza1 In the fragment shader, usually using a distance function, and fract for the opacity. They don't use bresenham! A loop is exactly what you'd avoid!

    • @HoSza1
      @HoSza1 18 годин тому

      @@tbird81 The essence of this algorithm is not a loop, but to determine the proportion of the areas created by the line segment in the two pixels. You can do that in paralel without ever using a loop.

  • @blackwatch4471
    @blackwatch4471 День тому

    Are you using something/some program to represent those pixels or are they just edited in?

  • @roboltamy
    @roboltamy День тому

    I'd really appreciate a video on AA lines with thickness

  • @Wololo123abc
    @Wololo123abc День тому

    Hello!

  • @gulyasgyorgy
    @gulyasgyorgy День тому

    amazing, hidden gem

  • @tenburger
    @tenburger День тому

    olm kanalını daha bugün gördüm ne kadar az video var diye üzüldüm ya allahu teala sesimi duymuş demek ki

  • @roboltamy
    @roboltamy День тому

    Ok now this is some timing. I was watching your video on Bresenham per a friend's recommendation and now that I'm trying to understand Xaiolin Wu you post a video on it.

    • @Sloimay
      @Sloimay День тому

      Funnily enough I was checking out the HLP discord yesterday on a whim and saw your status. I immediately looked it up and now the goat makes a video on it XD

  • @noamrtd-g4f
    @noamrtd-g4f День тому

    5:03 I implemented the 2 last algorithms in assembly (TASM 8086x) for fun (the version that was used for doom), I was so happy when I realized you have created another video, but man there is not chance I'm doing this under the conditions of ASSEMBLY. on another note... I absolutely LOVE your videos, keep them up! I've not seen a better explanation of those algorithms anywhere, and your videos made my day!

  • @Wolf-if1bt
    @Wolf-if1bt День тому

    Can we improve this algorithm to work only with integers?

    • @ivankramarenko
      @ivankramarenko День тому

      i think yes, if alpha in range 0..255 then we can multiplie all distances by 255. ex. x = 255 as 1, 512 as 2, 1024 as 4... and fast calc this use rightshift x = 512 >> 8

    • @Wololo123abc
      @Wololo123abc День тому

      ​@@ivankramarenkoFixed point instead of Floating point

  • @joeeeee8738
    @joeeeee8738 День тому

    Can't wait for the next videos of this series!

  • @hyunwhanjoe3477
    @hyunwhanjoe3477 День тому

    I had no idea how UTF-8 worked for years and in one minute I got a sense of how it worked. Great job with the video

  • @grayfoxa
    @grayfoxa День тому

    i think you explain that "Bresenham's line algorithm"

  • @GCKteamKrispy
    @GCKteamKrispy 2 дні тому

    Whoever made this algorithm is a genius for me

  • @jursamaj
    @jursamaj 2 дні тому

    16:09 dx needs to be positive for the range(dx+1) to work, but y, and thus m, being negative doesn't hurt the algorithm. Because the signs are inter-related, there are only 4 combinations, not 8. dx being negative is solved by simply swapping the points. With that simple change, you've already covered the left and right quadrants. 8:15 Had you simplified at 7:49 *before* substituting the definition of py, the doubling would ha been much simpler to handle. 10:26 pInitial, being an initial value, should have been set *before* the for loop, not in it. 12:12 When simplifying, you missed (i+1-i) becoming just 1. Likewise, I would have made (yNext-y) into (y+yP-y) [where yP is 0 or 1, indicating the increment in y], which simplifies to just yP. 14:10 Now here it's true that the algorithm assumes positive m. I suspect you were anticipating this when you claimed the floating point version couldn't handle negative m.

  • @jozsiolah1435
    @jozsiolah1435 3 дні тому

    Optical instructions exist for monitors and tv. For example, Sonic Master System gameplay last level instructs the computer to speed up the fan, to prevent overheating. Just by watching the video, the level turns on the S5 power mode, when watching videos, the phone will be cold, and was hot before.

  • @moggucci
    @moggucci 3 дні тому

    Could you please explain the algorithm for constructing a line with antialiasing?

  • @nvs-different-ideas
    @nvs-different-ideas 3 дні тому

    I dont see where is use p to draw

  • @semyonarteev3100
    @semyonarteev3100 3 дні тому

    -> Lowercase char |= 32

  • @onkelhoy1
    @onkelhoy1 4 дні тому

    Why not just put drawline(y0, x0, y1, x1) instead of copy the entire function and swap x and y?

  • @gsestream
    @gsestream 4 дні тому

    linear interpolation

  • @SlothHuntOnYou
    @SlothHuntOnYou 4 дні тому

    how add "stroke" to that?=)

  • @SimplexonYt
    @SimplexonYt 5 днів тому

    this is something intuitive that i was able to implement it in desmos in about two minutes

  • @czajla
    @czajla 5 днів тому

    years ago I have implemented this algorithm on ZX Spectrum in Z80 assembly, using only integers and with no multiplications. Boy, that was fast

  • @FooneTuring
    @FooneTuring 5 днів тому

    I interviewed at IMVU back in... God, 2010? And the tech part of the interview was just "derive this algorithm". It was a lot of fun, but this video really would have helped!

  • @amalkurvat
    @amalkurvat 5 днів тому

    Since python has many version. It's a WARNING/ CRITICAL to do graphical computer science or low programming in python.

  • @art-creator
    @art-creator 6 днів тому

    It can easily be generalized to line for zero-level set coverage finding

  • @OeHomestead
    @OeHomestead 7 днів тому

    I wrote an assembly version of the algo for some Amiga demos back in the days. Used it to draw vector graphics.

  • @reyariass
    @reyariass 7 днів тому

    At first I didn’t like you showing the steps to shorten the equation… but, I then realized it actually answered my usual question when viewing these equations which is “why are there hardcoded numbers?!”, this is great! Thank you!

  • @Yueyelongbob
    @Yueyelongbob 7 днів тому

    u can just solve y++, not x++, it is just 3 step.

  • @mathmachine4266
    @mathmachine4266 7 днів тому

    8:25 or you could change the > into >=, removing that slight difference. This is what I thought you were gonna do all along. Since yMid is always a half integer, and x is always an integer, the sum of their squares is always 1/4 greater than an integer. So if k+1/4>r², and both k and r² are integers, that's the same as saying k>=r².

  • @jimwinchester339
    @jimwinchester339 7 днів тому

    With a few modifications, you can also draw ellipses using the same general approach. It's important to mention, because in many cases the aspect ratio of the pixels is not 1:1, so your "circle" is actually drawn as an ellipse anyway.

  • @torrentails
    @torrentails 7 днів тому

    Cringing hard at the camelCase in Python code 😖😛 Awesome vid though, always love seeing more CS content!

  • @aidennwitz
    @aidennwitz 8 днів тому

    this is great, thank you! a thick line modification of this or line algorithm would be great too

    • @AdamDavisEE
      @AdamDavisEE 5 днів тому

      The simple thick line algorithm would take two of these as the outer and inner edges, and then fill between on each row. I'm sure there are optimizations, but that will get you to a quick solution you can use now. So if you wanted a circle with radius 100 and a line thickness of 9, then you'd have two circles with radius 104 and 96. Fill the center just like you'd fill the center of a single circle, just make the beginning point the inside circle (or midline if the inside circle's minimum y value is greater than then y value of the starting point).

  • @Yashss4617
    @Yashss4617 8 днів тому

    Can you please continue this with the ellipse drawing algorithm