Question: Can anybody suggest how to make the swapped boxes change background color on click when using the below plugin?

<http://www.vertstudios.com/blog/swap-jquery-plugin/> (see demo)

I'm not sure how to link to plugins in JSFiddle so can't demonstrate unfortunately.

The methods animate the position of all boxes affecting only those where the position has changed. I'm trying to add a method that animates the background color similarly but without success.

I don't think this is possible without customising the plugin but I could be wrong.

---

Update:

Thanks Johan. I should have said that I actually need the background color to animate back to default after the swap. I tried your solution already with the below amendment. As you can see, it behaves inconsistently. I think the way to do this properly is to customise the fakeFloat method.

```
$("#swapTrigger").click(function()
{
var index1 = $('input:radio[name=index1]:checked').val();
var index2 = $('input:radio[name=index2]:checked').val();
boxes = $(boxes).swap(index1,index2);

var $box1 = $('.box').eq(index1);
var $box2 = $('.box').eq(index2);

var randomHex = '#fc0';

$box1.animate({ backgroundColor: "#fc0" }, 300);
$box2.animate({ backgroundColor: "#fc0" }, 300);

$(boxes).fakeFloat({margin: 10, offset: 20, speed: 300}).each(function()

{
    $box1.animate({ backgroundColor: "#fff" }, 300);
    $box2.animate({ backgroundColor: "#fff" }, 300);
    $(this).html($(this).getIndexOf(boxes));
});

```

Answer: 
> 
> They want something as compact as the JS stated above
> 
> 
> 

Who's "they"? Do "they" have any understanding that Objective-C is a compiled language and the "compactness" of the source code is largely irrelevant?

Anyway, rant over. You can make a C array of CGPoints like this:

```
CGPoint myArray[] = {{0.0, 14.0}, {10.0, 32.0}, {24.0, 16.0}}; 

```

This is a standard C array initialiser. You get the number of elements like this:

```
int nElements = sizeof myArray / sizeof(CGPoint);

```
If you need to manage variable-length arrays of vertices, C++ provides `std::vector<CGPoint>`.