Skip to content
Permalink
Browse files

Initial commit of the scrambleserver!

  • Loading branch information...
jfly committed May 15, 2010
1 parent 50a7d87 commit ccdada3b9e29b545a6c2274c2890fc229723fda8
Showing with 4,262 additions and 0 deletions.
  1. +9 −0 servers/scrambleserver/.classpath
  2. +17 −0 servers/scrambleserver/.project
  3. +353 −0 servers/scrambleserver/com/eekboom/utils/Strings.java
  4. +357 −0 servers/scrambleserver/jstest/Archive/mootools-1.2.4-core-yc.js
  5. +62 −0 servers/scrambleserver/jstest/Archive/snippets.js
  6. +229 −0 servers/scrambleserver/jstest/Color.js/Color.js
  7. +155 −0 servers/scrambleserver/jstest/Color.js/index.htm
  8. +168 −0 servers/scrambleserver/jstest/Source/Assets/ColorRoller.css
  9. BIN servers/scrambleserver/jstest/Source/Assets/Sources/ColorPicker.pdn
  10. BIN servers/scrambleserver/jstest/Source/Assets/Sources/ColorPickerLarge.pdn
  11. BIN servers/scrambleserver/jstest/Source/Assets/Sources/adobe.pdn
  12. BIN servers/scrambleserver/jstest/Source/Assets/Sources/rainbow2.pdn
  13. BIN servers/scrambleserver/jstest/Source/Assets/adobehsB.png
  14. BIN servers/scrambleserver/jstest/Source/Assets/adobehsG.png
  15. BIN servers/scrambleserver/jstest/Source/Assets/adobehsL.png
  16. BIN servers/scrambleserver/jstest/Source/Assets/border.png
  17. BIN servers/scrambleserver/jstest/Source/Assets/clear.gif
  18. BIN servers/scrambleserver/jstest/Source/Assets/clear.png
  19. BIN servers/scrambleserver/jstest/Source/Assets/crShow.png
  20. BIN servers/scrambleserver/jstest/Source/Assets/crop.gif
  21. BIN servers/scrambleserver/jstest/Source/Assets/gimp.png
  22. BIN servers/scrambleserver/jstest/Source/Assets/greyscale.png
  23. BIN servers/scrambleserver/jstest/Source/Assets/isoceles.gif
  24. BIN servers/scrambleserver/jstest/Source/Assets/paint.png
  25. BIN servers/scrambleserver/jstest/Source/Assets/rainbow.png
  26. BIN servers/scrambleserver/jstest/Source/Assets/wheel.png
  27. +321 −0 servers/scrambleserver/jstest/Source/ColorRoller.js
  28. +357 −0 servers/scrambleserver/jstest/mootools-1.2.4-core-yc.js
  29. +232 −0 servers/scrambleserver/jstest/mootools-1.2.4.4-more.js
  30. +218 −0 servers/scrambleserver/jstest/scrambler.html
  31. BIN servers/scrambleserver/lib/gson-1.4.jar
  32. BIN servers/scrambleserver/lib/jopt-simple-3.2.jar
  33. +4 −0 servers/scrambleserver/libraries
  34. BIN servers/scrambleserver/media/miniCurr.gif
  35. BIN servers/scrambleserver/media/op_8x8.gif
  36. BIN servers/scrambleserver/media/win_LB.png
  37. BIN servers/scrambleserver/media/win_LM.png
  38. BIN servers/scrambleserver/media/win_LT.png
  39. BIN servers/scrambleserver/media/win_MB.png
  40. BIN servers/scrambleserver/media/win_MM.png
  41. BIN servers/scrambleserver/media/win_MT.png
  42. BIN servers/scrambleserver/media/win_RB.png
  43. BIN servers/scrambleserver/media/win_RM.png
  44. BIN servers/scrambleserver/media/win_RT.png
  45. BIN servers/scrambleserver/media/win_close.png
  46. +8 −0 servers/scrambleserver/net/gnehzr/cct/scrambles/InvalidScrambleException.java
  47. +26 −0 servers/scrambleserver/net/gnehzr/cct/scrambles/PuzzleFace.java
  48. +129 −0 servers/scrambleserver/net/gnehzr/cct/scrambles/ScrambleGenerator.java
  49. +119 −0 servers/scrambleserver/net/gnehzr/cct/scrambles/ScrambleImageGenerator.java
  50. +209 −0 servers/scrambleserver/net/gnehzr/cct/scrambles/ScrambleServer.java
  51. +118 −0 servers/scrambleserver/net/gnehzr/cct/scrambles/ScrambleUtils.java
  52. +50 −0 servers/scrambleserver/scramblers/ClockScrambler.java
  53. +668 −0 servers/scrambleserver/scramblers/CubeScrambler.java
  54. +453 −0 servers/scrambleserver/scramblers/MegaminxScrambler.java
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="lib/|images/|media/|Source/|Archive/" kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="lib/jopt-simple-3.2.jar"/>
<classpathentry kind="lib" path="lib/gson-1.4.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/JCubeExplorer"/>
<classpathentry kind="output" path=""/>
</classpath>
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ScrambleServer</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -0,0 +1,62 @@
setBG1:function(val){
var v = Math.round(val * 2.55), grey = v+','+v+','+v, shape = 'radial';

if (Browser.Engine.gecko && window.hasOwnProperty("onhashchange"))
this.e.crShade.setStyle('background-image','-moz-'+shape+'-gradient(center center, circle closest-side, rgb('+grey+') '+(100-(this.val||1))+'%, rgba('+grey+',0)100%)');//rgb('+grey+'),
else if (Browser.Engine.trident && shape == 'linear')
this.e.crShade.setStyle(
Browser.Engine.version < 4 ? 'filter':'-ms-filter',
'progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr="#FF'+000000+'", EndColorStr="#00'+000000+'")'
);
else if (Browser.Engine.webkit)
this.e.crShade.setStyle('background','-webkit-gradient('+shape+', center center, 0, center center, '+70.5+', from(rgb('+grey+')), to(rgba('+grey+',0))');
else this.e.crBox.setStyle('background-color', 'rgb('+grey+')');
},

function Firefox36(){
var FF36;
// Any of the below will return true if browser is 3.6, false for 3.5
FF36 = !!new Element('div').setStyle('background','-moz-linear-gradient(red, blue)').getStyle('background');

FF36 = window.hasOwnProperty('onhashchange');
FF36 = Hash.has(window, 'onhashchange');
}

/*
Notes:
#1:
Zero degrees on the sphere is assumed to be at the the 12:00 position.
This differs from classic trig, which assumes zero to be at 3:00.
To switch to classic, make the following changes:
In updateBox:
h = Math.atan2(y,x) * 180 / Math.PI,
In setBox:
left :this.radius + radius * Math.cos(angle) ,
top :this.radius + radius * Math.sin(angle)
#2:
Full support in Firefox 3.6, and webkit.
Support for linear in trident.
Fallback hsg support for Opera, Trident/radial, FF 3.5, other browsers.
Regarding IE support:
a. Overview of filters:
http://msdn.microsoft.com/en-us/library/ms532853%28VS.85%29.aspx
http://www.ssi-developer.net/css/visual-filters.shtml
b. The gradient filter does not support a start [or end] point, and cannot do radial.
http://msdn.microsoft.com/en-us/library/ms532997%28VS.85%29.aspx
c. The light filter may well be able to do a controlled radial gradient, though I failed to create one.
It allows for any numbers of points, cones or ambiences.
http://msdn.microsoft.com/en-us/library/ms533011%28VS.85%29.aspx
http://www.javascriptkit.com/filters/light.shtml
d. The alpha linear filter supports start [and end] points.
[It also allows for angle gradients. The gradient is applied to the whole element, not just the background.]
The radial filter does not support start points [though it does support endpoints]
http://msdn.microsoft.com/en-us/library/ms532967%28VS.85%29.aspx
http://www.javascriptkit.com/filters/alpha.shtml
e. [Other useful filters are Composite, which allows for elements to be combined. and BasicImage: Rotation, opacity, greyscale, mirror, xray, etc.
*/

shading: function(){
var bgs = "background-image: -moz-radial-gradient(rgba(255,255,255,1), rgba(255,255,255,0)),\
-webkit-gradient(radial, center center, 0, center center, 70.5, from(green), to(yellow))";
},
@@ -0,0 +1,229 @@
/*
---
script: Color.js
description: Class for creating and manipulating colors in JavaScript. Supports HSB -> RGB Conversions and vice versa.
license: MIT-style license
authors:
- Sam Goody
- Valerio Proietti
requires:
- core:1.2.4/Array
- core:1.2.4/String
- core:1.2.4/Number
- core:1.2.4/Hash
- core:1.2.4/Function
- core:1.2.4/$util
provides: [Color]
...
*/

var Color = new Native({

initialize: function(color, type){
if (arguments.length >= 3){
type = 'rgb'; color = Array.slice(arguments, 0, 3);
} else if (typeof color == 'string'){
if (color.match(/rgb/)) color = color.rgbToHex().hexToRgb(true);
else if (color.match(/hsb/)) color = color.hsbToRgb();
else color = color.hexToRgb(true);
}
type = type || 'rgb';
switch (type){
case 'hsb':
var old = color;
color = color.hsbToRgb();
color.hsb = old;
break;
case 'hex': color = color.hexToRgb(true); break;
}
color.rgb = color.slice(0, 3);
color.hsb = color.hsb || color.rgbToHsb();
color.hex = color.rgbToHex();
return $extend(color, this);
}

});

Color.implement({

mix: function(){
var colors = Array.slice(arguments);
var alpha = ($type(colors.getLast()) == 'number') ? colors.pop() : 50;
var rgb = this.slice();
colors.each(function(color){
color = new Color(color);
for (var i = 0; i < 3; i++) rgb[i] = Math.round((rgb[i] / 100 * (100 - alpha)) + (color[i] / 100 * alpha));
});
return new Color(rgb, 'rgb');
},

invert: function(){
return new Color(this.map(function(value){
return 255 - value;
}));
},

setHue: function(value){
return new Color([value, this.hsb[1], this.hsb[2]], 'hsb');
},

setSaturation: function(percent){
return new Color([this.hsb[0], percent, this.hsb[2]], 'hsb');
},

setBrightness: function(percent){
return new Color([this.hsb[0], this.hsb[1], percent], 'hsb');
}

});

var $RGB = function(r, g, b){
return new Color([r, g, b], 'rgb');
};

var $HSB = function(h, s, b){
return new Color([h, s, b], 'hsb');
};

var $HEX = function(hex){
return new Color(hex, 'hex');
};

Array.implement({

rgbToHsb: function(){
var red = this[0],
green = this[1],
blue = this[2],
hue = 0;
var max = Math.max(red, green, blue),
min = Math.min(red, green, blue);
var delta = max - min;
var brightness = max / 255,
saturation = (max != 0) ? delta / max : 0;
if(saturation != 0) {
var rr = (max - red) / delta;
var gr = (max - green) / delta;
var br = (max - blue) / delta;
if (red == max) hue = br - gr;
else if (green == max) hue = 2 + rr - br;
else hue = 4 + gr - rr;
hue /= 6;
if (hue < 0) hue++;
}
return [Math.round(hue * 360), Math.round(saturation * 100), Math.round(brightness * 100)];
},

hsbToRgb: function(){
var br = Math.round(this[2] / 100 * 255);
if (this[1] == 0){
return [br, br, br];
} else {
var hue = this[0] % 360;
var f = hue % 60;
var p = Math.round((this[2] * (100 - this[1])) / 10000 * 255);
var q = Math.round((this[2] * (6000 - this[1] * f)) / 600000 * 255);
var t = Math.round((this[2] * (6000 - this[1] * (60 - f))) / 600000 * 255);
switch (Math.floor(hue / 60)){
case 0: return [br, t, p];
case 1: return [q, br, p];
case 2: return [p, br, t];
case 3: return [p, q, br];
case 4: return [t, p, br];
case 5: return [br, p, q];
}
}
return false;
},

fromRgb: function(space,decimal){
var v,
hsl = 0,
rgb = $A(this).sort(function(a,b){
return res = a - b
}),
min = rgb[0],
max = rgb[2];

switch((space||'').toLowerCase().slice(-1)){
default :
v = max / 2.55;
span = v; break;
case 'g':
v = min / (min - max + 255) * 100;
span = 100; break;
case 'l':
v = (+max + +min) / 5.1;
span = v * 2;
if (v > 50){
span = 200 - span;
hsl = 100 - span;
}
}

var s = 100 * (min / 2.55 - v) / (hsl - v);
var d = (100 * (rgb[1] / 2.55 - v) / s + v - hsl) / span;
for(var ind = '', i = 0; i < 3; i++) ind += rgb.indexOf(this[i]);
var h = '210,120,021,012,102,201,110,020,011,002,101,000'.indexOf(ind)/4%6;
h += h%2 ? 1-d : d;
return [h*60,s,v].map(function(i){ return decimal ? i||0 : Math.round(i||0) });
},

toRgb: function(space,decimal){
var val = this[2] * 1, hsl = 0;
switch((space||'v').slice(-1).toLowerCase()){
default : span = val; break;
case 'g': span = 100; break;
case 'l': span = val * 2;
if (val > 50){
span = 200 - span;
hsl = 100 - span;
}
}
var hue = this[0]%360/60, rad = Math.floor(hue), odd = rad%2;
var rgb = [], map = [0, (odd ? 1+rad-hue : hue-rad), 1];
map.each(function(density,i){
var index = Math.floor(hue / 2 + 5 + i * (odd||-1))%3;
var color = this[1] / 100 * (density * span - val + hsl) + val;
rgb[index] = decimal ? color * 2.55 : Math.round(color * 2.55);
//rgb[index] = Math.round(color * 2.55);
}, this);
return rgb;
}
});

String.implement({

rgbToHsb: function(){
var rgb = this.match(/\d{1,3}/g);
return (rgb) ? rgb.rgbToHsb() : null;
},

hsbToRgb: function(){
var hsb = this.match(/\d{1,3}/g);
return (hsb) ? hsb.hsbToRgb() : null;
},

fromRgb: function(space){
var rgb = this.match(/\d{1,3}/g);
return (rgb) ? rgb.fromRgb(space) : null;
},

toRgb: function(space){
var hsb = this.match(/\d{1,3}/g);
return (hsb) ? hsb.toRgb(space) : null;
}

});
/*
ToDo:
6,163,0 - infinity
168,4,4 - 360 / 0
*/

0 comments on commit ccdada3

Please sign in to comment.
You can’t perform that action at this time.