Wow - this is a very old sketch from circa 2014 and was created with Processing 2 and webpages still allowed Applets.
First thing to say is that the code is created in Java Mode so uses the Java language therefore will not run in a webpage. If you want something for the Internet it would need converting to Javascript or find a Javascript page turner library on line. At the time I remember some JS page-turners of varying complexity and not all were free.
I did do a much more complex version that allowed for animation even on the page being turned. Unfortunately I can’t find the code for either but I have downloaded the example from OpenProcessing and if you are interested in a Java version then I will try and convert the code for Processing 3.
@quark – I just took a look at this to see if I could quickly convert it to PGraphics and P3 – but I wasn’t sure about the use of the .g2 references. Were those built-in in Processing 2? I mainly skipped from P1 to P3.
The sketch is very old and uses P2 when P2D and P3D were software emulations and did not use OpenGL. At that time all sketches were displayed using a JFrame and had a java.awt.Graphics2D (g2) drawing context. In P3 P2D and P3D use OpenGL windows so we cannot use the PGraphics class to reference the book image buffer, rather we need to use PGraphicsJava2D.
Anyway back in August I had a go converting the sketch to P3 myself and go it working except for one bug. The back (non moving) pages should appear behind the turning page, I was going to try and fix it but got side tracked and forgot about it. Anyway you can download this P3 sketch here and it you find the problem please let me know.
Okay, after digging in it looks like we will need to look at a newer approach.
@quark I really appreciate the time you put into resurrecting that sketch. However, it needs to be modernized a bit so lets see what we can do.
First, I need to think of how to organize this. It seems like we need to apply a texture (our image of some text) to a mesh so we can manipulate it easily.
Then once we do that it’s all about the math used to turn over the page right?
Okay, so I dug into the libraries looking for some examples and it seems like the ToxicLibs library is the best but it’s also pretty deprecated. last blog post was in 2011. Yikes!
Still haven’t found any examples in there about how to apply a texture to a rectangular mesh but I will keep looking.
Although the Toxiclibs library was created a decade ago it has been updated for Processing 3 so is good to use. I think it was Schiffman that updated it
The sketch I created uses 2D and clipping zones to produce the page turn affect, you could use a mesh but the mathematics is likely to be more challenging.
Anyway I used what I learnt on this sketch to create a more sophisticated example using the Dart IDE, JavaScript and Processing core. You can see it here