# Roofpig - A Canvas/Javascript web cube



## Lars Petrus (Jun 30, 2014)

Back in the 90's I and others wrote Java applets to animate cubes on the web. It was cool technology at the time, but in 2014 they're almost unusable.

So I wrote a Canvas/Javascript based version for the modern web. Mostly so http://lar5.com/cube could be useful again, but also for anyone who wants animated cubes on their web site. It's called Roofpig, should be very easy to use, and lives on https://github.com/larspetrus/Roofpig.

Have fun!


----------



## Kirjava (Jun 30, 2014)

With this and alg.cubing.net I'm glad that java cubing applets are finally being eradicated from the web.

Nice work.


----------



## Dane man (Jun 30, 2014)

Niiice. It's about time that cube java applets got either an update or kicked out. 

Well done. Though, when it's turning it looks kind of... hole-y. (inb4 it's the Holy Cube) It's not a major problem, just an aesthetic thing.

Good work!


----------



## Lucas Garron (Jun 30, 2014)

Woohoo! I'm not the only one!

I was going to rewrite the core part of twisty.js soon, since it's almost 3 years old. Making it an applet replacement was soon on the roadmap.
Let's collaborate or something.


First thought: Add some easing to your moves.


----------



## Renslay (Jun 30, 2014)

Woah! Thank you! I'm really glad to hear that.

Also, that's the website where I first learned about speedcubing, and I've learned my very first speedmethod, back at 2005... Aaaw, the old memories.


----------



## qqwref (Jul 1, 2014)

Haha, good job replacing those old Java applets  Nowadays Java is just so awful to use on the web.


----------



## dbax0999 (Jul 1, 2014)

This is really cool! Excited to get it set up on my server.


----------



## Filipe Teixeira (Jul 3, 2014)

when I saw the name I remembered this:


----------



## Lars Petrus (Jul 3, 2014)

A _second_ roof pig! Most unexpected!

*Dane*: The hole-y-ness stopped bothering me. Thanks for the reminder. It's not hard to fix but it not trivial either, and you can do it in a few different ways.

*Lucas*: I never even though of "easing" before. I'll put that in. Thanks!

If anyone needs Roofpig help, I'm very happy to answer questions here, at [email protected] or maybe even at https://github.com/larspetrus/Roofpig/issues


----------



## Dane man (Jul 3, 2014)

Lars Petrus said:


> *Dane*: The hole-y-ness stopped bothering me. Thanks for the reminder. It's not hard to fix but it not trivial either, and you can do it in a few different ways.]


Well, I think the easiest way would be to make two double sided black planes appear on the inside when a turn in made. For example, if a B turn is made, then the black planes would appear between that slice and the rest of the cube before the slice starts to rotate. One plane will stay where it is, and the other plane will rotate with the side.

But if you don't have time, that's fine. It works as it is. You could even leave it for " holiness' " sake ;P


----------



## Lars Petrus (Jul 3, 2014)

OK, I fixed the Holy-ness. It's live on lar5.com, but not in the official release file on Github.

Not sure how to best handle releases, but too often seems bad.


----------



## megaminxwin (Jul 4, 2014)

Hooray! I saw this on your site before it was properly announced, and I was glad that it replaced the Java applets. Those things are horrible. It was glitching up before, but those problems seem to have been fixed now.

I also like how you've changed the "made with a mac" gif to "powered by roofpig". This isn't 1998 any more.


----------



## dbax0999 (Jul 4, 2014)

Are you planning on adding support for setup + alg instead of always ending in a solved cube? Or perhaps, setting the color scheme / pov for the beginning of the solve rather than the end? 

I ask because I think this has a lot of potential to use for reconstructing solves, which mostly have a fixed start pov rather than a fixed end pov. If you don't plan on doing this I'll fork the code and see what I can do, but my Ruby is pretty noob.


----------



## Lars Petrus (Jul 4, 2014)

> Are you planning on adding support for setup + alg instead of always ending in a solved cube?

I hope you just didn't notice the _setupmoves_ parameter? If not, what do you seek more precisely?

> Or perhaps, setting the color scheme / pov for the beginning of the solve rather than the end? 

Hm... That's actually a bug!

It didn't occur to me that perspective changing moves (M, E, S, x, y, z etc) would affect pov and colors.


----------



## dbax0999 (Jul 4, 2014)

> the setupmoves parameter?



I must have missed that, my bad. 



> Hm... That's actually a bug!



Oh, I wasn't sure what behavior you were looking for. I submitted an issue on github so you can keep track of it.


----------



## Filipe Teixeira (Jul 4, 2014)

Lars Petrus said:


> OK, I fixed the Holy-ness. It's live on lar5.com, but not in the official release file on Github.
> 
> Not sure how to best handle releases, but too often seems bad.



Looks how it appears on my PC:


----------



## Lars Petrus (Jul 4, 2014)

filipemtx said:


> Looks how it appears on my PC:



Thanks!

It looked very similar on my crappy old 2009 Netbook. I hope you also have a pretty old graphics card?

The reason is that the black "plastic" is too close to the sticker, and I guess the card doesn't have good enough resolution to fully separate them.

I made the sticker 6 times thicker, and now it looks OK (if not perfect) for me.


----------



## Filipe Teixeira (Jul 4, 2014)

Nice! Now its working.

Also I have to say its a honor to meet such a great person like you that ivententend a great method.


----------



## Lars Petrus (Jul 11, 2014)

I released version 1.1. It fixes at least some of David's concerns (let me know), and implements Lucas' animation "easing".

https://github.com/larspetrus/Roofpig


----------



## Renslay (Jul 11, 2014)

Maybe I missed that, but is it possible to play around with the cube? If I remember well, the old Java version allowed user-made movements. Not that I miss that feature, just asking.


----------



## Lars Petrus (Jul 12, 2014)

It's not part of the official features, but rotation works pretty well, use keys ASDZXC. Actual moves are on JKL, and are not good.

I'll do something useful with that stuff some day.


----------



## Lars Petrus (Jul 8, 2015)

Version 1.3 of Roofpig is out: https://github.com/larspetrus/Roofpig

What's new is a "startsolved" feature (to make pretty patterns etc) and much better error messaging. Also upgraded to the latest three.js and jQuery.

If you or a friend has a web site with old java cubes, it's easy to replace them with Roofpigs. Ping me and I'll help you get started!


----------

