Interpolation source code
A comment on my last post requested the source code. I've made it available as a google hosted project.
A comment on my last post requested the source code. I've made it available as a google hosted project.
Posted by Richard at 4:19 pm 1 comments
Labels: game programming, programming, pyglet, python
The most active MUD-related forum is currently MUDBytes. One of the good things is that the team there maintain their own forum software, and as the idea or need arises, it gets extended to support new features. However this is both good and bad, as the amount of feature "cruft" that decorates each displayed post increases.
Finding the "cruft" distracting, I decided to write a greasemonkey script to remove as much as possible. Here's the result:
And the greasemonkey script:
// ==UserScript==
// @name MUDBytes Page Cleaner
// @namespace http://disinterest.org
// @description Makes the pages less cluttered.
// @include http://www.mudbytes.net/topic-*
// @include http://www.mudbytes.net/index.php*
// ==/UserScript==
var tds = document.getElementsByTagName("td");
var posterInfoTD = null;
var classNames = "";
for(var i = 0; i < tds.length; i++){
classNames = tds[i].className;
if (classNames == "posterinfo") {
posterInfoTD = tds[i];
} else if (classNames == "posttop") {
for (var j = 0; j < tds[i].childNodes.length; j++) {
var topElement = tds[i].childNodes[j];
if (topElement.className == "button butright") {
topElement.className = "butright";
topElement.innerHTML = " ["+ topElement.innerHTML +"]";
}
}
// Remove the arrows.
var divs = tds[i].getElementsByTagName("div");
divs[0].innerHTML = "";
// Inject the poster name.
var posterText = document.createTextNode(" -- ");
var posterNameB = document.createElement("b");
var as = posterInfoTD.getElementsByTagName("a");
if (as.length > 0) {
posterNameB.appendChild(as[0].cloneNode(true));
} else {
var posterNameText = document.createTextNode("Guest");
posterNameB.appendChild(posterNameText);
}
divs[divs.length-1].appendChild(posterText);
divs[divs.length-1].appendChild(posterNameB);
// Remove the LHS poster info area.
posterInfoTD.parentNode.removeChild(posterInfoTD);
} else if (classNames == "postbottom") {
tds[i].innerHTML = "";
}
}
// Reduce the reading area width to make it more readable.
var tableElements = document.getElementsByTagName("table");
for (var i = 0; i < tableElements.length; i++) {
if (tableElements[i].className == "stand")
tableElements[i].style.width = '700px';
}
Posted by Richard at 12:05 pm 0 comments
Labels: greasemonkey, html, javascript, mud, programming, web programming
A link about interpolation tricks was recently posted to reddit. I found myself using Pyglet to write a simple user interface to play with the different algorithms, screenshots of which are shown below.
Linear:
Smooth step:
Hermite:
I should really use the Tk bindings that come with Python to do something like this, or better yet do it as a web page.
Posted by Richard at 2:15 pm 2 comments
Labels: game programming, programming, python, reddit
Reading reddit is becoming too costly in terms of time spent and value gained. Most of the comments littering each link only serve to drown out those that add the detail that would comprise value. A long time ago, someone used to summarise posts to the Linux Kernel mailing list as Kernel Traffic. More often than not when reading reddit, I wish someone was doing a "Reddit Traffic" and just close the tab for the given submitted link giving up on it.
Posted by Richard at 5:40 pm 0 comments
Labels: reddit