4

I was doing some research the other day and discovered that I can make desktop PHP applications using PHP GTK and then it hit me:

Is it possible to draw animations using PHP?

Is even 3D possible? I'm not asking if it is a good idea or anything, there are tons of scripting languages for that and I'm aware of that! I just want to know if it is possible! Does anyone know?

Loupax
  • 4,728
  • 6
  • 41
  • 68
  • Just FYI, that project was last updated 2 years ago (ironically, it stated that development was still going) – Madara's Ghost Aug 20 '12 at 21:12
  • PHP can include or source scripts. Have you tried including any scripts for animations and running them from a PHP page? I believe they should work. – Shabab Aug 20 '12 at 21:12
  • Yes, but remember that PHP is a *server side* technology, and that animations are best rendered *client side*. In other words: generate and send animation frames from the server: BAD. Generate an "animation" and send all at once, or in relatively large chunks (a Flash file, an HTML5 animation - whatever): BETTER. – paulsm4 Aug 20 '12 at 21:15
  • @paulsm4 I'm perfectly aware of that :) What I'm curious about is whether I can make a desktop 3D application using php. And yes, I know this comment is an oxymoron :P – Loupax Aug 20 '12 at 21:17
  • 1
    @Loupax: Theoretically? Sure - PHP can work with images, and if you can make one image, you can make multiple, and if you can make an image, you can render a 3D environment - plus, you *can* do non-web-based scripting with PHP. In practice? It is an absolutely terrible and pointless idea. Use a language and toolset that's actually suited for the job, instead of driving a nail through a wall with a saw. – Michael Madsen Aug 20 '12 at 21:25

2 Answers2

2

Animation ? Not directly possible with GD, need additional libraries from what I know. 3D drawing ? Yes, it's possible.

Check out these resources:

Draw a cube with php

create simple animated gif

create animated gif with php

Community
  • 1
  • 1
Cosmin Atanasiu
  • 2,532
  • 3
  • 21
  • 26
1

I have not experimented with it at all, but there is an OpenGL extension on github https://github.com/yoya/phpopengl. It appears to be a fork of a sourceforge project which has ceased development.

To my knowledge, this would be the only way to create true 3D graphics or animations using PHP.

JamesArmes
  • 1,315
  • 4
  • 18
  • 23
  • If you think of it, since PHP can run extensions written in C, it doesn't sound SO crazy! But I can still say that "there is an OpenGL extension on PHP" and nobody will believe me :P – Loupax Aug 20 '12 at 21:33