how to code a gif making a picture transform from small to large and rotate
-
how to code a gif making a picture transform from small to large and rotate?
-
hope this example is clear enough!
# path to an image path = 'https://github.com/typemytype/drawbot/raw/master/docs/content/assets/drawBot.jpg' # get the width and height of the image canvasWidth, canvasHeight = imageSize(path) # amount of frames frameCount = 24 # start the loop for frame in range(frameCount): # calculate a factor, number between 0 - 1 # going from 0 - 1 - 0 frameFactor = frame / (frameCount) * 2 if frameFactor > 1: frameFactor = 2 - frameFactor # create a new page, based on the image size newPage(canvasWidth, canvasHeight) # set frame duration in second only when the full image is shown if frameFactor == 1: frameDuration(1) else: frameDuration(.05) # easin frameFactor = frameFactor * frameFactor # translate to the middle translate(canvasWidth/2, canvasHeight/2) # scale from the middle scale(frameFactor) # rotate from the middle rotate(360 * frameFactor * 10) # translate back away from the middle translate(-canvasWidth/2, -canvasHeight/2) # draw the image image(path, (0, 0)) # save as gif saveImage("testImage.gif")
-
@frederik it works!thanks!!!