me

Archive for the ‘Labs’ Category

Star Wars Crawl

Saturday, June 18th, 2011

So CSS 3D transforms are cool! I just stumbled upon them recently and came to know that they’ve been there for almost an year now. Few browsers support the 3D transforms, Chrome does it and that makes me happy :). So I started playing with it and made a ’star wars opening crawl’. Check it out…I’m looking forward to dive deeper into it and hopefully will come up with something good. Here is the ‘Star Wars Crawl

Logo Turtle Interpreter

Friday, March 18th, 2011

For the past couple of days I’ve been trying to finish what I had started off a while back but had abandoned midway - a logo turtle interpreter.
For those who dont know what logo turtle is:

Turtle graphics is a term in computer graphics for a method of programming vector graphics using a relative cursor (the “turtle”) upon a Cartesian plane

It was basically used in schools to familiarize 7-8 year old kids to computers. And I was always interested in making one because it was small little logo turtle that introduced me to the world of computers. Yeah we had logo turtle in first grade(good ol’ days ;). So this is kinda my tribute to the wonderful language.

I’ve been playing with javascript lately so I thought I’d try it out. Basically its a lot of javascript code that basically moves the triangle(which is a svg polygon). The js changes the position attributes of the triangle according to the command. And also a path(svg line) is created accordingly. A lil knowledge of coordinate geometry also helped.

Here is a documented code for the ‘fd’ command.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
if(cmd == "fd")
{
 
//Create the path
//x1 and y1 are set to the current position of the turtle
path.setAttribute("x1", currx);
path.setAttribute("y1", curry);
 
//x2 and y2 are calculated x = mov*sin(angle) where angle is chaged on each lt/rt command
path.setAttribute("x2", currx + (move*sin1));
path.setAttribute("y2", curry - (move*cos1));
path.setAttribute("class", 'line1');
 
//Generates a new path 
document.getElementById("svg_main").appendChild(path);
TransX = TransX + (move*sin1);
TransY = TransY + (-1*(move*cos1));
currx = TransX;
curry = TransY;
 
//Calculate the change in position
ptx = ptx + (move*sin1);
pty = pty + (-1*(move*cos1));
//Moves the turtle
document.getElementById("triangle").setAttribute("transform", 'rotate(' + myangle + ',' + (210+ptx) + ',' + (196+pty) + ') translate('+ ptx + ',' + pty + ')'); 
 
}

Check out the whole code on the live page.

I have to continue playing with javascript and svg…its pretty fun. And yea hopefully next time I’d try out jquery and the canvas element…they seem interesting.

Check it out in action here
PS: And ping me if you find any bug and its open source so feel free to play with the code.
PPS: Yea I know there is a severe lack in the functionality but I guess additional commands can be added easily later…am just too lazy to add them right now
And yea Chrome only!

GCMS(my blogging system) alpha is here

Tuesday, January 5th, 2010

Well so after almost a fortnight of writing and rewriting code…i present the alpha of GCMS - The blogging system that lets you write(only!). Its still under development…so don’t expect anything fancy because this the first working version, is just skeletal and there are no additional features. There has been hardly any testing and the code is premature.

BTW, the name, GCMS, is just a code name during the alpha version…actually i couldnt come up with any clever name, hence code name : GCMS :P, which stands for Ganesh’s Content Management System. I shall come up with a better name…hopefully soon!

It is something I did for fun and for learning more about PHP. I plan to update it daily(i mean weekly :P) the code is free for use under the GNU GPL. I hope you build upon it, test it and share your insights with me and others :)

Download Source Code of GCMS 0.1 Jan05/2010

Resumed building a CMS/Blogging System

Sunday, December 27th, 2009

Over the past few days(almost a week) I resumed working on a content management system that I had abandoned a few months ago. It is coming up quite all right, and has some primitive functionality. I don’t see it replacing wordpress for my site but it may come handy for smaller sites. Anyways, the main challenge I faced while resuming was the lack of documentation/commenting(duh! the books never lied about comments). I have made it a point to comment on whatever new code I write. And also, kudos to the online tutorials which have made life easier. Pagination is easy with the help of online tuts.

For those who are not following…things’ll get clear as soon as the alpha version comes out…dont expect anything spectacular. It’ll contain some basic(basic is an understatement…downright skeletal would be appropriate) features. Its not intended for commercial purposes, its just something I am doing to try out my PHP skills. BTW did I mention it runs on PHP and uses MySQL database.

Stay tuned for more updates…and expect better posts in the recent future ;)