Rotating images

edited April 2017 in Python Mode

Hi, it's me with a displaying question again...

I tried using rotate(-angle) and then drawing an image, but it won't display the image. (I also put resetMatrix() behind)

I guess displaying an image rotated is one of those things that's impossible to do as well? (I was only trying to rotate the image multiples of PI/2)

Kind regards, OrOrg

Answers

  • No example code? Hard to tell what your problem is. Maybe you rotated the image around the top left corner, so it's not drawn on the screen at all?

    Try throwing a translate(width/2,height/2); in at the start of draw. Do you see your image at all now?

  • edited April 2017
    ###
     # Mirror Positioning Calc (v1.2)
     # by GoToLoop (2014/Mar)
     #
     # forum.Processing.org/two/discussion/21857/rotating-images#Item_2
     # loading-image-from-url-lags-in-js
     #
     # forum.Processing.org/two/discussion/3439/
     # how-to-do-flip-canvas-horizontal-to-an-image-and-save#Item_21
     #
     # OpenProcessing.org/sketch/139280
    ###
    
    URL = 'http:/' + '/upload.Wikimedia.org' +\
          '/wikipedia/commons/thumb/5/59/' + 'Processing_Logo_Clipped.svg/'
    
    NAME = '256px-Processing_Logo_Clipped.svg.png'
    
    SIGS = (-1, -1), (1, -1), (1, 1), (-1, 1)
    
    X, Y, FPS = 150, 50, .25
    
    PI_16, NUM = QUARTER_PI*.25, len(SIGS)
    
    def setup():
        size(600, 400)
        smooth(3), frameRate(FPS)
        imageMode(CORNER), blendMode(REPLACE)
        background(0200)
    
        global img
        img = loadImage(URL + NAME)
    
    
    def draw():
        sigX, sigY = SIGS[frameCount % NUM]
        info = "sigX = %i  |  sigY = %i" % (sigX, sigY)
        frame.setTitle(info)
    
        x = X*sigX + img.width*(sigX>>1)
        y = Y*sigY + img.height*(sigY>>1)
    
        rotate(PI_16), scale(sigX, sigY)
        image(img, x, y)
    
  • Answer ✓

    I am, once again, a moron. Indeed, the canvas still has to move. Welp, I can only say I can learn from mistakes. Thanks for the lots of information, the only thing I had to do was put a translate() in, however. The reason I did not put my code in here is becaus it is 951 lines long now, so... it's not very useful to put it here, and it was not necessary, after all. I'll try to now display the images in a non-resource-extensive way, but that might be tricky, it already had a hard time to keep up last time (up to 100 images to display per 1/30 second now...)

    Thanks again!

Sign In or Register to comment.