How are capital gains tax calculated

So I know that long term capital gains are taxed after 40k annual income, however how much of the sell off is taxed?

For example let’s say I’ve put 100k in my retirement account and over the years it has grown to 200k. I reach retirement and sell off 60k to live off for a year. Would ALL of that 60k be considered capital gains? Even though only technically half was gains and the other half was my initial investment which shouldn’t be taxed?