Created
April 5, 2014 21:22
-
-
Save esetomo/9998258 to your computer and use it in GitHub Desktop.
LSLによるカラーピッカー(そうじゃない)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string html = " | |
<!doctype html> | |
<script src='http://code.jquery.com/jquery-2.1.0.min.js'></script> | |
<script src='http://cdn.jsdelivr.net/jquery.minicolors/2.1.2/jquery.minicolors.js'></script> | |
<link rel='stylesheet' href='http://cdn.jsdelivr.net/jquery.minicolors/2.1.2/jquery.minicolors.css'/> | |
<style> | |
input{border: black solid 1px;} | |
</style> | |
<input id='color' type='text' value='#000000'> | |
<script> | |
jQuery('#color').minicolors({ | |
hide: function(hex, opacity){ | |
$.ajax({type:'POST',data:this.value}) | |
} | |
}); | |
</script> | |
"; | |
vector parseColor(string text) | |
{ | |
integer rgb = (integer)("0x" + llGetSubString(text, 1, -1)); | |
float r = ((rgb >> 16) & 0xff) / 255.0; | |
float g = ((rgb >> 8) & 0xff) / 255.0; | |
float b = (rgb & 0xff) / 255.0; | |
return <r,g,b>; | |
} | |
default | |
{ | |
state_entry() | |
{ | |
llRequestURL(); | |
} | |
http_request(key id, string method, string body) | |
{ | |
if(method == URL_REQUEST_GRANTED) | |
{ | |
llSetPrimMediaParams(0, [PRIM_MEDIA_HOME_URL, body, | |
PRIM_MEDIA_CURRENT_URL, body, | |
PRIM_MEDIA_AUTO_PLAY, TRUE, | |
PRIM_MEDIA_FIRST_CLICK_INTERACT, TRUE, | |
PRIM_MEDIA_AUTO_SCALE, TRUE, | |
PRIM_MEDIA_WIDTH_PIXELS, 256, | |
PRIM_MEDIA_HEIGHT_PIXELS, 256, | |
PRIM_MEDIA_PERMS_INTERACT, PRIM_MEDIA_PERM_ANYONE, | |
PRIM_MEDIA_PERMS_CONTROL, PRIM_MEDIA_PERM_NONE]); | |
}else if(method == "GET"){ | |
llSetContentType(id, CONTENT_TYPE_HTML); | |
llHTTPResponse(id, 200, html); | |
}else if(method == "POST"){ | |
llHTTPResponse(id, 200, ""); | |
llSetColor(parseColor(body), 1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment