Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Funny face

dave1707dave1707 Mod
in General Posts: 5,987

Not much going on, so here's something for the kids. Use in portrait mode with the camera at the top. Aim the camera at your face and then tile the iPad side to side or turn your head side to side. Hold the iPad closer or farther away from you for different effects. This takes whatever is on the left half of the screen and copies it reversed onto the right half of the screen.

displayMode(FULLSCREEN)
supportedOrientations(PORTRAIT_ANY)

function setup()
    spriteMode(CORNER)
    cameraSource(CAMERA_FRONT)
end

function draw()
    background(0)
    collectgarbage()
    img=image(CAMERA) 
    if img~=nil then
        sprite(img,0,0)
        img1=img:copy(0,0,WIDTH//2,HEIGHT//1)
        sprite(img1,2*WIDTH//2,0,-WIDTH//2,HEIGHT)
    end
end

Comments

  • edited April 7 Posts: 28

    @dave1707 Thanks, I just wasted 20 minutes playing with this thing, and I don't have any kids. So cool all the things that can be done with just a few lines of code in Codea. With a few more splits it would almost create a kaleidoscope affect.

    Just wondering... What's up with all the WIDTH//2 stuff? I tried removing some of the / to see, but it didn't seem to change anything as far as I could tell. Though, I'm guessing you had a good reason for using two slashes instead of just one.

  • dave1707dave1707 Mod
    Posts: 5,987

    @Circuit The // is an integer divide to insure that the division doesn't result in a fractional number. When I was writing this, I was getting an error message for the img:copy, "number has no integer representation" . So anytime I get that message I always do the integer divide. If you comment the displayMode(FULLSCREEN) and change the // to /, you'll probably get the error message.

  • dave1707dave1707 Mod
    Posts: 5,987

    @Circuit That's the whole purpose of some of the useless code I post. Just to waste time (mine), show that some things don't take a lot of code, and maybe give someone an idea for something else. In your case, a kaleidoscope. Maybe someone will take this and write one.

  • Posts: 28

    @dave1707 Actually, this post ended up helping me with one of my random projects where I was getting said "number has no integer representation" error. I got it working before using math.floor, but just tried using the // instead. Saved me a few unnecessary calculations and everything works now without the error. So, not such a waste of time now I suppose.

Sign In or Register to comment.