Groovy web console

subscribe to the feed Subscribe
to this
site
Leinwand (via #groovywebconsole)
tweet this snippet Tweet
this
script

Leinwand

Published 3 months ago by Anonymous
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
class Rounding {    
    public BigDecimal round(int n) {         
        return setScale(n, BigDecimal.ROUND_HALF_UP);     
    } 
}
BigDecimal.mixin Rounding

def f1 = 1920/800
def f2 = 1920/1080

def b1 = 4.0
def h = b1/f1
def b2 = h * f2

def bg = b1 + b1 - b2

println 'Bildbreite 1920/800 : ' + b1.round(2) + 'm'
println 'Bildbreite 1920/1080: ' + b2.round(2) + 'm'
println 'Bildh?e            : ' + h.round(2) + 'm'
println 'Maskierungsbretter  : ' + ((b1-b2)/2).round(2) + 'm'
println 'min Raumbreite      : ' + bg.round(2) + 'm'