| 1720 |
this.buffer[this.flipNo ? 0 : 1].style.zIndex = "0"; |
this.buffer[this.flipNo ? 0 : 1].style.zIndex = "0"; |
| 1721 |
}; |
}; |
| 1722 |
GameRenderer.prototype.render = function () { |
GameRenderer.prototype.render = function () { |
| 1723 |
|
var hasUpdate = false; |
| 1724 |
if(this.scene.layerCount == 1) { |
if(this.scene.layerCount == 1) { |
| 1725 |
var layer = this.scene.root; |
var layer = this.scene.root; |
| 1726 |
if(!layer.isUpdate()) { |
if(!layer.isUpdate()) { |
| 1727 |
} else { |
} else { |
| 1728 |
|
hasUpdate = true; |
| 1729 |
if(!this.disableClear) { |
if(!this.disableClear) { |
| 1730 |
this.bc.putImageData(this.bg, 0, 0); |
this.bc.putImageData(this.bg, 0, 0); |
| 1731 |
} |
} |
| 1732 |
this.renderParent(layer, this.bc); |
this.renderParent(layer, this.bc); |
| 1733 |
layer.reflected(); |
layer.reflected(); |
|
if(this.transferMode == RenderTransferMode.Flip) { |
|
|
this.flip(); |
|
|
} else if(this.bc != this.fc) { |
|
|
this.fc.drawImage(this.buffer[1], 0, 0); |
|
|
} |
|
| 1734 |
} |
} |
| 1735 |
} else { |
} else { |
|
var hasUpdate = false; |
|
| 1736 |
for(var i in this.scene.layers) { |
for(var i in this.scene.layers) { |
| 1737 |
if(this.scene.layers[i].isUpdate()) { |
if(this.scene.layers[i].isUpdate()) { |
| 1738 |
hasUpdate = true; |
hasUpdate = true; |
| 1752 |
this.bc.drawImage(layer.canvas, 0, 0); |
this.bc.drawImage(layer.canvas, 0, 0); |
| 1753 |
layer.reflected(); |
layer.reflected(); |
| 1754 |
} |
} |
| 1755 |
|
} |
| 1756 |
|
} |
| 1757 |
|
if(hasUpdate) { |
| 1758 |
|
if(this.filter && this.filter.has()) { |
| 1759 |
|
var imageData = this.bc.getImageData(0, 0, this.game.width, this.game.height); |
| 1760 |
|
this.filter.filter(imageData); |
| 1761 |
|
this.fc.putImageData(imageData, 0, 0); |
| 1762 |
|
} else { |
| 1763 |
if(this.bc != this.fc) { |
if(this.bc != this.fc) { |
| 1764 |
this.fc.drawImage(this.buffer[1], 0, 0); |
this.fc.drawImage(this.buffer[1], 0, 0); |
| 1765 |
} else if(this.transferMode == RenderTransferMode.Flip) { |
} else if(this.transferMode == RenderTransferMode.Flip) { |
| 2294 |
}; |
}; |
| 2295 |
return FrameGame; |
return FrameGame; |
| 2296 |
})(Game); |
})(Game); |
| 2297 |
|
var ImageFilter; |
| 2298 |
|
(function (ImageFilter) { |
| 2299 |
|
var FilterChain = (function () { |
| 2300 |
|
function FilterChain() { |
| 2301 |
|
this.filters = new Array(); |
| 2302 |
|
} |
| 2303 |
|
FilterChain.prototype.get = function (index) { |
| 2304 |
|
return this.filters[index]; |
| 2305 |
|
}; |
| 2306 |
|
FilterChain.prototype.add = function (filter) { |
| 2307 |
|
this.filters.push(filter); |
| 2308 |
|
return this; |
| 2309 |
|
}; |
| 2310 |
|
FilterChain.prototype.insert = function (index, filter) { |
| 2311 |
|
for(var i = 1; i < arguments.length; i++) { |
| 2312 |
|
this.filters.splice(index, 0, arguments[i]); |
| 2313 |
|
} |
| 2314 |
|
return this; |
| 2315 |
|
}; |
| 2316 |
|
FilterChain.prototype.clear = function () { |
| 2317 |
|
this.filters = []; |
| 2318 |
|
return this; |
| 2319 |
|
}; |
| 2320 |
|
FilterChain.prototype.count = function () { |
| 2321 |
|
return this.filters.length; |
| 2322 |
|
}; |
| 2323 |
|
FilterChain.prototype.has = function () { |
| 2324 |
|
return this.filters.length > 0; |
| 2325 |
|
}; |
| 2326 |
|
FilterChain.prototype.createSprite = function (entity) { |
| 2327 |
|
return null; |
| 2328 |
|
}; |
| 2329 |
|
FilterChain.prototype.filter = function (pixels) { |
| 2330 |
|
var length = this.filters.length; |
| 2331 |
|
for(var i = 0; i < length; i++) { |
| 2332 |
|
this.filters[i].filter(pixels); |
| 2333 |
|
} |
| 2334 |
|
}; |
| 2335 |
|
return FilterChain; |
| 2336 |
|
})(); |
| 2337 |
|
ImageFilter.FilterChain = FilterChain; |
| 2338 |
|
var Filter = (function () { |
| 2339 |
|
function Filter() { |
| 2340 |
|
this.opt = { |
| 2341 |
|
}; |
| 2342 |
|
} |
| 2343 |
|
Filter.prototype.filter = function (pixels) { |
| 2344 |
|
}; |
| 2345 |
|
Filter.prototype.getOption = function (name, defaultValue) { |
| 2346 |
|
if(this.opt[name] === undefined) { |
| 2347 |
|
return defaultValue; |
| 2348 |
|
} |
| 2349 |
|
return this.opt[name]; |
| 2350 |
|
}; |
| 2351 |
|
Filter.prototype.findColorDifference = function (dif, dest, src) { |
| 2352 |
|
return (dif * dest + (1 - dif) * src); |
| 2353 |
|
}; |
| 2354 |
|
Filter.prototype.createColor = function (src) { |
| 2355 |
|
src = src.replace(/^#/, ''); |
| 2356 |
|
if(src.length == 3) { |
| 2357 |
|
src = src.replace(/(.)/g, '$1$1'); |
| 2358 |
|
} |
| 2359 |
|
return src; |
| 2360 |
|
}; |
| 2361 |
|
return Filter; |
| 2362 |
|
})(); |
| 2363 |
|
ImageFilter.Filter = Filter; |
| 2364 |
|
var GreyscaleFilter = (function (_super) { |
| 2365 |
|
__extends(GreyscaleFilter, _super); |
| 2366 |
|
function GreyscaleFilter(opacity) { |
| 2367 |
|
_super.call(this); |
| 2368 |
|
this.opt.opacity = opacity; |
| 2369 |
|
} |
| 2370 |
|
GreyscaleFilter.prototype.filter = function (pixels) { |
| 2371 |
|
var opacity = this.getOption("opacity", 1); |
| 2372 |
|
var data = data = pixels.data; |
| 2373 |
|
for(var i = 0, length = data.length; i < length >> 2; i++) { |
| 2374 |
|
var index = i << 2; |
| 2375 |
|
var r = data[index], g = data[index + 1], b = data[index + 2]; |
| 2376 |
|
var val = r * 0.21 + g * 0.71 + b * 0.07; |
| 2377 |
|
data[index] = this.findColorDifference(opacity, val, r); |
| 2378 |
|
data[index + 1] = this.findColorDifference(opacity, val, g); |
| 2379 |
|
data[index + 2] = this.findColorDifference(opacity, val, b); |
| 2380 |
|
} |
| 2381 |
|
}; |
| 2382 |
|
return GreyscaleFilter; |
| 2383 |
|
})(Filter); |
| 2384 |
|
ImageFilter.GreyscaleFilter = GreyscaleFilter; |
| 2385 |
|
var SepiaFilter = (function (_super) { |
| 2386 |
|
__extends(SepiaFilter, _super); |
| 2387 |
|
function SepiaFilter(opacity) { |
| 2388 |
|
_super.call(this); |
| 2389 |
|
this.opt.opacity = opacity; |
| 2390 |
|
} |
| 2391 |
|
SepiaFilter.prototype.filter = function (pixels) { |
| 2392 |
|
var opacity = this.getOption("opacity", 1); |
| 2393 |
|
var data = data = pixels.data; |
| 2394 |
|
for(var i = 0, length = data.length; i < length >> 2; i++) { |
| 2395 |
|
var index = i << 2; |
| 2396 |
|
var r = data[index], g = data[index + 1], b = data[index + 2]; |
| 2397 |
|
data[index] = this.findColorDifference(opacity, r * 0.393 + g * 0.769 + b * 0.189, r); |
| 2398 |
|
data[index + 1] = this.findColorDifference(opacity, r * 0.349 + g * 0.686 + b * 0.168, g); |
| 2399 |
|
data[index + 2] = this.findColorDifference(opacity, r * 0.272 + g * 0.534 + b * 0.131, b); |
| 2400 |
|
} |
| 2401 |
|
}; |
| 2402 |
|
return SepiaFilter; |
| 2403 |
|
})(Filter); |
| 2404 |
|
ImageFilter.SepiaFilter = SepiaFilter; |
| 2405 |
|
var TintFilter = (function (_super) { |
| 2406 |
|
__extends(TintFilter, _super); |
| 2407 |
|
function TintFilter(color, opacity) { |
| 2408 |
|
_super.call(this); |
| 2409 |
|
this.opt.color = color; |
| 2410 |
|
this.opt.opacity = opacity; |
| 2411 |
|
} |
| 2412 |
|
TintFilter.prototype.filter = function (pixels) { |
| 2413 |
|
var opacity = this.getOption("opacity", 1); |
| 2414 |
|
var color = this.getOption("color", "#f00"); |
| 2415 |
|
var data = data = pixels.data; |
| 2416 |
|
var src = parseInt(this.createColor(color), 16); |
| 2417 |
|
var r2 = (src & 16711680) >> 16, g2 = (src & 65280) >> 8, b2 = (src & 255); |
| 2418 |
|
for(var i = 0, length = data.length; i < length >> 2; i++) { |
| 2419 |
|
var index = i << 2; |
| 2420 |
|
var r = data[index], g = data[index + 1], b = data[index + 2]; |
| 2421 |
|
data[index] = this.findColorDifference(opacity, r2, r); |
| 2422 |
|
data[index + 1] = this.findColorDifference(opacity, g2, g); |
| 2423 |
|
data[index + 2] = this.findColorDifference(opacity, b2, b); |
| 2424 |
|
} |
| 2425 |
|
}; |
| 2426 |
|
return TintFilter; |
| 2427 |
|
})(Filter); |
| 2428 |
|
ImageFilter.TintFilter = TintFilter; |
| 2429 |
|
})(ImageFilter || (ImageFilter = {})); |
| 2430 |
var Action = (function () { |
var Action = (function () { |
| 2431 |
function Action(param) { |
function Action(param) { |
| 2432 |
this.added_to_timeline = new Trigger(); |
this.added_to_timeline = new Trigger(); |