A recent design I had to build required that each list item in a menu (WordPress) be a different colour. After some head scratching I came up with a method using jQuery.

We start off be making sure our counter is 0. Then loop through each list item. We can get the current item number from jQuery and which element we are currently acting on. Setting the colour variable to be 1 + i means we count from 1 up to the total number of list items. I’m using modulo operator to loop the numbers after 8. Using jQuery we can then add class to the current element. The class could contain any CSS operation. I used this for a spectrum of colours.

    colour=0;
	
	$('.nav ul li').each( function(i, elem) 
	{
	
		colour=1+(i%8);
	
		$(elem).addClass('listitem'+colour);
			
	});
Filed under: Programming — Tags: , , , — admin @ 8:29 pm

Using jQuery and CSS we can change the colour of alternate rows in a table. The code below will lock on to each table row and change the background colour on alternate rows. I’m making the change with CSS but you could always add a CSS class instead.

    jQuery('table tr').each(function(i, domEle)
	{
	
         /* skip the first row (probably your headings) */
	  if ( i!=0 )
	  {
	  
                /* if i / 2 has no remainer set the background to this */ 
		if ( i%2==0 )
		{
	  
	      jQuery( domEle ).css('background-color','#dcddde');
		
		}
		else  /* if i / 2 does have a remainder change the colour to this */
		{
		
		  jQuery( domEle ).css('background-color','#f3f3f4');
		
		}
	  
	  }
	
	});

If you want add a class instead replace


jQuery( domEle ).css('background-color','#f3f3f4');

/* with */

jQuery( domEle ).addClass('odd');
Filed under: Programming — Tags: , , , , , , — admin @ 8:19 pm

Lazy Sunday

June 12, 2011

Today has been kind of a lazy day so I’ve got a couple of things out the way.

First off you’ve probably noticed the re-styling of the site. Feel free to let me know what you think.

Secondly; I’ve added 4 more Warhammer Quest card makers, Magic Cards, Monster Events Cards, Unexpected Event Cards and Treasure Cards. Again let me know what you think.

Filed under: Warhammer Quest — Tags: , , , , — admin @ 4:36 pm

G Max download

April 24, 2011

If you’ve been trying to download the version of G Max 1.2 hosted by Turbosquid you’ll have been frustrated by a bad link. After a bit of playing around, this is link you need to download G Max.

G Max is a cut down version of Discreets 3d Studio max. G Max is designed to allow developers to build 3d models for use in video games. You can download tutorials and help guides at Turbosquids G Max page

Filed under: Uncategorized — admin @ 11:11 am

If you’re like me and have designers handing you wonderful looking designs to build, then you’ve probably encountered the situation where they’ve used an Apple font with no true type font available. I’ve scoured the internet looking for useful tools and methods to convert from one to the other. I’ve compiled the ones I use below.

You’ll need a linux box for most of these although you could try cygwin.

Convert Postscript Type 1 font to TTF

This is the first part of a two step procedure. T1unmac can convert postscript type 1 fonts to pfb files. If you’re scratching you’re head the PS1 fonts are usually name “._FontName” (they’re probably hidden so you’ll need to “show hidden files”). The command words like this

t1unmac --appledouble ._FontName > FontName.pfb

This will return a .pfb file that you can use in the next step.

The next step is to use FontForge to convert to .pfb file into a True Type Font. Save the code before as convert.pe I can’t take credit for the script I found it on the FontForge website.

#!/usr/local/bin/fontforge
i=1
format=".ttf"
while ( i<$argc )
  if ( $argv[i]=="-format" || $argv[i]=="--format" )
    i=i+1
    if ( i<$argc )
      format = $argv[i]
      if ( format!=".ttf" && format!=".otf" && \
	  format!=".pfb" && format!=".svg" )
	Error( "Expected one of '.ttf', '.otf', '.pfb' or '.svg' for format" )
      endif
    endif
  else
    Open($argv[i])
    if ( $order==2 && (format==".otf" || format==".pfb" ))
      SetFontOrder(3)
      SelectAll()
      Simplify(128+32+8,1.5)
      ScaleToEm(1000)
    elseif ( $order==3 && format==".ttf" )
      ScaleToEm(2048)
      RoundToInt()
    endif
    Generate($argv[i]:r + format)
  endif
  i = i+1
endloop

You use the script like this

convert.pe --format ".ttf" *.pfb

This will find all files that end .pfb and convert them to .ttf files. The script can also output .svg and .otf.

Split a .dfont file

Another type of Apple font archive you could've encountered is a dfont file. These files can be split into their components (usually .ttf files) using the command fondu. The command you use for this is.

fondu FontName.dfont

This will output the content into the current folder.

Filed under: Programming — Tags: , , , , , , , — admin @ 8:23 pm

If you’re trying to include YouTube videos or Google maps, in fact anything that uses an IFRAME in your WordPress you’ve probably run into problems. The visual view in WordPress removes the IFRAME code. Well I have a solution for you, use javascript to insert the code. Below is the code I’m using. All you would need to do is change the address in the URI variable and alter the width and height attributes.


Here is the video.

Filed under: Programming — Tags: , , , — admin @ 7:51 pm

Questions

February 15, 2011

If I’ve learned anything from life it’s that though many questions should never be answered, many more should never be asked.

Filed under: Thoughts for the day — admin @ 10:45 pm

Anger

January 6, 2011

I know the anger that dwells in a mans heart for I see it in myself.
During times of great frustration it threatens to overwelm us.
Do we keep it in check knowing the regret we will feel should we rage against the world.
For all that civilised men do to quell these feelings, it lurks, waiting to be called.
It is an anger that can only be soothed by the flames or war.

Filed under: Thoughts for the day — admin @ 7:17 pm

Revenge is a fire that offers no warmth, it can only ever burn you.

Filed under: Thoughts for the day — admin @ 7:16 pm

New Warhammer Quest Tool

December 16, 2010

I don’t know if there is much demand for customised Warhamer Quest dungeon cards, but I’ve created an online tool that allows you to create new dungeon cards. Just find the file you want to appear on the card, fill in the title, room description, any special information and room type and click upload.

Create your own dungeon card

If you find the tool useful let me know and I’ll look at making a tool for creating magic and event cards too.

Filed under: Warhammer Quest — Tags: , , , — admin @ 9:09 pm

About me

Jonathan Spicer

My CV

My curriculum vitae and a wealth of other facts about me.

Warhammer Quest tools

Flickering flame effect Flickering flame effect Flickering flame effect

Powered by WordPress