Skip to content

Instantly share code, notes, and snippets.

@chinghanho
Last active July 29, 2016 11:10
Show Gist options
  • Save chinghanho/32737f14ae0ac985db44fa8ac4711a6b to your computer and use it in GitHub Desktop.
Save chinghanho/32737f14ae0ac985db44fa8ac4711a6b to your computer and use it in GitHub Desktop.
模糊圈越大景深越深
var cocs = [0.014, 0.019, 0.029]
var dofs = []
var distance = 1000
var focal = 50
var f_number = 2.8
for (let i = 0; i <= cocs.length - 1; i++) {
let coc = cocs[i]
let farPoint = (distance * Math.pow(focal, 2)) / (Math.pow(focal, 2) - (f_number * coc * distance))
let nearPoint = (distance * Math.pow(focal, 2)) / (Math.pow(focal, 2) + (f_number * coc * distance))
let dof = farPoint - nearPoint
dofs.push({ coc: coc, dof: dof })
}
// [
// {
// "coc": 0.014,
// "dof": 31.367712140989397
// },
// {
// "coc": 0.019,
// "dof": 42.57928153372279
// },
// {
// "coc": 0.029,
// "dof": 65.02860194963807
// }
// ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment