Burning Image 0.3 released

New version of Grails plugin for image manipulation released. Current version allows to:

  • scale image with approximate width and height
  • scale image with accurate width and height
  • add image watermark
  • crop image
  • write text on image
  • mark domain class as image container by using @FileImageContainer annotation
  • save image binded to domain class by using ImageUpladService
  • validate uploaded image

To read more go to project home page.

Groovy exercises – text wrapping

This is my groovy solution for simple text wrapping problem:

 
def input = "The quick brown fox jumps over the lazy dog. "
 
String.metaClass.wrap = {token, length ->
    def line = token
    def elements = delegate.tokenize().reverse()
 
    while(elements.size()){
        if ((line + elements.last()).size() < length){
            line += ' ' + elements.pop()
        }
        else {
            println line
            line = token
        }
    }
 
    if (line != token){
        println line
    }
}
 
(input * 10).wrap('>', 72)
 

Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds. Valid XHTML and CSS.