Gaussian blur moves object when applied in different places in the code?



  • Why does applying a Gaussian blur in different places in the code move the image it applies to? Example code, output, revised code putting the blur call before the 1st image, output.

    size(550, 300)
    # initiate a new image object
    im = ImageObject()
    # draw in the image
    # the 'with' statement will create a custom context
    # only drawing in the image object
    with im:
       # set a size for the image
       size(200, 200)
       # draw something
       fill(1, 0, 0)
       rect(0, 0, width(), height())
       fill(1)
       fontSize(30)
       text("Hello World", (10, 10))
    # draw in the image in the main context
    image(im, (10, 50))
    # apply some filters
    im.gaussianBlur()
    # get the offset (with a blur this will be negative)
    x, y = im.offset()
    # draw in the image in the main context
    image(im, (300+x, 50+y))
    

    yields:
    gaussian_test_01.jpg

    size(550, 300)
    # initiate a new image object
    im = ImageObject()
    # draw in the image
    # the 'with' statement will create a custom context
    # only drawing in the image object
    with im:
       # set a size for the image
       size(200, 200)
       # draw something
       fill(1, 0, 0)
       rect(0, 0, width(), height())
       fill(1)
       fontSize(30)
       text("Hello World", (10, 10))
    # apply some filters
    im.gaussianBlur()
    # draw in the image in the main context
    image(im, (10, 50))
    # get the offset (with a blur this will be negative)
    x, y = im.offset()
    # draw in the image in the main context
    image(im, (300+x, 50+y))
    

    yields:
    gaussian_test_02.jpg


  • admin

    not really a bug: when applying a blur the images gets bigger, check with im.size() before and after the blur is applied.

    im.offset() is providing you the correct x, y difference.


Log in to reply