| 3289 |
this.ruleImage = this.getImageData(sprite.image); |
this.ruleImage = this.getImageData(sprite.image); |
| 3290 |
} |
} |
| 3291 |
}; |
}; |
| 3292 |
|
UniversalTransitionFilter.prototype.createMask = function () { |
| 3293 |
|
var mask; |
| 3294 |
|
var a = (this.getImageData(this.opt.mask1)).data; |
| 3295 |
|
var b = (this.getImageData(this.opt.mask2)).data; |
| 3296 |
|
var d = this.ruleImage.data; |
| 3297 |
|
mask = { |
| 3298 |
|
}; |
| 3299 |
|
var enableCount = 0; |
| 3300 |
|
for(var i = 0, len = a.length; i < len; i += 4) { |
| 3301 |
|
if(a[i] == b[i] && a[i + 1] == b[i + 1] && a[i + 2] == b[i + 2] && a[i + 3] == b[i + 3]) { |
| 3302 |
|
mask[i] = 1; |
| 3303 |
|
} else { |
| 3304 |
|
mask[i] = 0; |
| 3305 |
|
} |
| 3306 |
|
} |
| 3307 |
|
this.mask = mask; |
| 3308 |
|
return mask; |
| 3309 |
|
}; |
| 3310 |
UniversalTransitionFilter.prototype.filter = function (pixels) { |
UniversalTransitionFilter.prototype.filter = function (pixels) { |
| 3311 |
if(!this.ruleImage) { |
if(!this.ruleImage) { |
| 3312 |
this.createRuleImage(); |
this.createRuleImage(); |
| 3319 |
var h2 = this.ruleImage.height; |
var h2 = this.ruleImage.height; |
| 3320 |
var data = pixels.data; |
var data = pixels.data; |
| 3321 |
var data2 = this.ruleImage.data; |
var data2 = this.ruleImage.data; |
| 3322 |
|
var mask; |
| 3323 |
|
if(this.opt.mask1 && this.opt.mask2) { |
| 3324 |
|
mask = (this.mask) ? this.mask : this.createMask(); |
| 3325 |
|
} |
| 3326 |
if(w == w2 && h == h2) { |
if(w == w2 && h == h2) { |
| 3327 |
for(var i = 0, length = data.length; i < length >> 2; i++) { |
for(var i = 0, length = data.length; i < length >> 2; i++) { |
| 3328 |
var index = i << 2; |
var index = i << 2; |
| 3329 |
|
if(mask && mask[index]) { |
| 3330 |
|
if(this.opt.maskDraw) { |
| 3331 |
|
continue; |
| 3332 |
|
} else { |
| 3333 |
|
data[index + 3] = 0; |
| 3334 |
|
continue; |
| 3335 |
|
} |
| 3336 |
|
} |
| 3337 |
data[index + 3] = Math.round(data[index + 3] / 255 * Math.max(0, data2[index] - amount)); |
data[index + 3] = Math.round(data[index + 3] / 255 * Math.max(0, data2[index] - amount)); |
| 3338 |
} |
} |
| 3339 |
} else if(repeat) { |
} else if(repeat) { |
| 3340 |
for(var x = 0; x < w; x++) { |
for(var x = 0; x < w; x++) { |
| 3341 |
for(var y = 0; y < h; y++) { |
for(var y = 0; y < h; y++) { |
| 3342 |
|
var index = (x + y * w) * 4; |
| 3343 |
|
if(mask && mask[index]) { |
| 3344 |
|
if(this.opt.maskDraw) { |
| 3345 |
|
continue; |
| 3346 |
|
} else { |
| 3347 |
|
data[index + 3] = 0; |
| 3348 |
|
continue; |
| 3349 |
|
} |
| 3350 |
|
} |
| 3351 |
var x2 = x % w2; |
var x2 = x % w2; |
| 3352 |
var y2 = y % h2; |
var y2 = y % h2; |
|
var index = (x + y * w) * 4; |
|
| 3353 |
var index2 = (x2 + y2 * w2) * 4; |
var index2 = (x2 + y2 * w2) * 4; |
| 3354 |
data[index + 3] = Math.round(data[index + 3] / 255 * Math.max(0, data2[index2] - amount)); |
data[index + 3] = Math.round(data[index + 3] / 255 * Math.max(0, data2[index2] - amount)); |
| 3355 |
} |
} |
| 3359 |
var yPer = Math.round(h2 / h * 100) / 100; |
var yPer = Math.round(h2 / h * 100) / 100; |
| 3360 |
for(var x = 0; x < w; x++) { |
for(var x = 0; x < w; x++) { |
| 3361 |
for(var y = 0; y < h; y++) { |
for(var y = 0; y < h; y++) { |
| 3362 |
|
var index = (x + y * w) * 4; |
| 3363 |
|
if(mask && mask[index]) { |
| 3364 |
|
if(this.opt.maskDraw) { |
| 3365 |
|
continue; |
| 3366 |
|
} else { |
| 3367 |
|
data[index + 3] = 0; |
| 3368 |
|
continue; |
| 3369 |
|
} |
| 3370 |
|
} |
| 3371 |
var x2 = Math.round(xPer * x); |
var x2 = Math.round(xPer * x); |
| 3372 |
var y2 = Math.round(yPer * y); |
var y2 = Math.round(yPer * y); |
|
var index = (x + y * w) * 4; |
|
| 3373 |
var index2 = (x2 + y2 * w2) * 4; |
var index2 = (x2 + y2 * w2) * 4; |
| 3374 |
data[index + 3] = Math.round(data[index + 3] / 255 * Math.max(0, data2[index2] - amount)); |
data[index + 3] = Math.round(data[index + 3] / 255 * Math.max(0, data2[index2] - amount)); |
| 3375 |
} |
} |
| 3379 |
return UniversalTransitionFilter; |
return UniversalTransitionFilter; |
| 3380 |
})(Filter); |
})(Filter); |
| 3381 |
ImageFilter.UniversalTransitionFilter = UniversalTransitionFilter; |
ImageFilter.UniversalTransitionFilter = UniversalTransitionFilter; |
| 3382 |
|
var ReverseUniversalTransitionFilter = (function (_super) { |
| 3383 |
|
__extends(ReverseUniversalTransitionFilter, _super); |
| 3384 |
|
function ReverseUniversalTransitionFilter() { |
| 3385 |
|
_super.apply(this, arguments); |
| 3386 |
|
|
| 3387 |
|
} |
| 3388 |
|
ReverseUniversalTransitionFilter.prototype.createImageData = function (width, height) { |
| 3389 |
|
var canvas = window.createCanvas(width, height); |
| 3390 |
|
var context = canvas.getContext("2d"); |
| 3391 |
|
return context.createImageData(width, height); |
| 3392 |
|
}; |
| 3393 |
|
ReverseUniversalTransitionFilter.prototype.createRuleImage = function () { |
| 3394 |
|
_super.prototype.createRuleImage.call(this); |
| 3395 |
|
var d = this.ruleImage.data; |
| 3396 |
|
for(var i = 0, length = d.length; i < length >> 2; i++) { |
| 3397 |
|
var index = i << 2; |
| 3398 |
|
d[index] = 255 - d[index]; |
| 3399 |
|
d[index + 1] = 255 - d[index + 1]; |
| 3400 |
|
d[index + 2] = 255 - d[index + 2]; |
| 3401 |
|
} |
| 3402 |
|
}; |
| 3403 |
|
return ReverseUniversalTransitionFilter; |
| 3404 |
|
})(UniversalTransitionFilter); |
| 3405 |
|
ImageFilter.ReverseUniversalTransitionFilter = ReverseUniversalTransitionFilter; |
| 3406 |
var GreyscaleFilter = (function (_super) { |
var GreyscaleFilter = (function (_super) { |
| 3407 |
__extends(GreyscaleFilter, _super); |
__extends(GreyscaleFilter, _super); |
| 3408 |
function GreyscaleFilter(opacity) { |
function GreyscaleFilter(opacity) { |
| 3938 |
if(this.props[prop].autoDelete) { |
if(this.props[prop].autoDelete) { |
| 3939 |
this.removed_from_timeline.handleInsert(0, this, function () { |
this.removed_from_timeline.handleInsert(0, this, function () { |
| 3940 |
this.entity.filter.remove(filter); |
this.entity.filter.remove(filter); |
| 3941 |
if(this.entity.filter.length == 0) { |
if(this.entity.filter.count() == 0) { |
| 3942 |
delete this.entity.filter; |
delete this.entity.filter; |
| 3943 |
} |
} |
| 3944 |
this.entity.updated(); |
this.entity.updated(); |
| 5450 |
end: 255 |
end: 255 |
| 5451 |
} |
} |
| 5452 |
}, t).removeFromScene(); |
}, t).removeFromScene(); |
| 5453 |
this.sp2.tl().show().filter(ImageFilter.UniversalTransitionFilter, { |
this.sp2.tl().show().filter(ImageFilter.ReverseUniversalTransitionFilter, { |
| 5454 |
image: image, |
image: image, |
| 5455 |
repeat: repeat, |
repeat: repeat, |
| 5456 |
amount: { |
amount: { |