This file contains 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
print(string.sub("123456789", 1)) --should print original string | |
print(string.sub("123456789", 1, -1)) --should print original string | |
print(string.sub("123456789", 4, 7)) --should print 4567 | |
print(string.sub("123456789", 1, 4)) --should print the 1st 4 chars | |
print(string.sub("123456789", -4, -1)) --should print the last 4 chars | |
print(string.sub("123456789", 2, -2)) --should remove the first and last char | |
print(string.sub("123456789", 2)) --should remove the first char | |
print(string.sub("123456789", 1, -2)) --should remove the last char | |
print(string.sub("123456789", -2)) --should print only the last 2 chars | |
print(string.sub("123456789", 1, 2)) --should print only the first 2 chars |
This file contains 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
local sequenceData = { | |
{ | |
name = "normalRun", --name of animation sequence | |
start = 1, --starting frame index | |
count = 8, --total number of frames to animate consecutively before stopping or looping | |
time = 800, --optional, in milliseconds; if not supplied, the sprite is frame-based | |
loopCount = 0, --optional. 0 (default) repeats forever; a positive integer specifies the number of loops | |
loopDirection = "forward" --optional, either "forward" (default) or "bounce" which will play forward then backwards through the sequence of frames | |
} --if defining more sequences, place a comma here and proceed to the next sequence sub-table | |
} |
This file contains 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
local sequenceData = { | |
{ | |
name = "fastRun", | |
frames = { 1,2,4,5,6,7 }, --specific order of frame indexes from the image sheet | |
time = 250, | |
loopCount = 0 | |
} --if defining more sequences, place a comma here and proceed to the next sequence sub-table | |
} |
This file contains 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
local sequenceData = { | |
{ name="normalRun", start=1, count=8, time=800 }, | |
{ name="fastRun", frames={ 1,2,4,5,6,7 }, time=250, loopCount=0 } | |
} |
This file contains 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
local function mySpriteListener( event ) | |
if ( event.phase == "ended" ) then | |
local thisSprite = event.target --"event.target" references the sprite | |
thisSprite:setSequence( "fastRun" ) --switch to "fastRun" sequence | |
thisSprite:play() --play the new sequence; it won't play automatically! | |
end | |
end | |
animation:addEventListener( "sprite", mySpriteListener ) --add a sprite listener to your sprite |
This file contains 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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Leaflet Zoomify Demo</title> | |
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.css" /> | |
<!--[if lte IE 8]> | |
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.ie.css" /> | |
<![endif]--> | |
<style type="text/css"> |
This file contains 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
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', 'send-ajax-data.php'); | |
xhr.send(null); | |
xhr.onreadystatechange = function () { | |
var DONE = 4; // readyState 4 means the request is done. | |
var OK = 200; // status 200 is a successful return. | |
if (xhr.readyState === DONE) { | |
if (xhr.status === OK) | |
console.log(xhr.responseText); // 'This is the returned text.' |
This file contains 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
function toPixels(pNum) { | |
'use strict'; | |
return pNum + 'px'; | |
} |
This file contains 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
// Animated GIF | |
convert -delay 120 -loop 0 *.png animated.gif | |
// Get duration for animated gif frames | |
identify -format "Frame %s: %Tcs\n" animated.gif |
This file contains 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
// Change canvas size (resize canvas to 48x48 pixels) | |
convert input.png -gravity center -background transparent -extent 48x48 output.png | |
// Resize | |
convert img1.png -resize 400x300 img2.png | |
// Resize by height only: | |
convert img1.png -resize x300 img2.png | |
// width_x_height_+_leftoffset_+_topoffset_ |
OlderNewer