| 360 |
delete this.pointCapture; |
delete this.pointCapture; |
| 361 |
}; |
}; |
| 362 |
E.prototype.removeDrawOption = function (name) { |
E.prototype.removeDrawOption = function (name) { |
| 363 |
|
if(!this.options) { |
| 364 |
|
return; |
| 365 |
|
} |
| 366 |
if(this.options[name]) { |
if(this.options[name]) { |
| 367 |
delete this.options[name]; |
delete this.options[name]; |
| 368 |
} |
} |
| 428 |
throw "Can not remove layer. (use scene.deleteLayer)"; |
throw "Can not remove layer. (use scene.deleteLayer)"; |
| 429 |
} |
} |
| 430 |
}; |
}; |
| 431 |
|
E.prototype.insert = function (entity, index) { |
| 432 |
|
if(!this.entities) { |
| 433 |
|
throw "Can not call append of non-container entity"; |
| 434 |
|
} |
| 435 |
|
entity.scene = this.scene; |
| 436 |
|
entity.parent = this; |
| 437 |
|
this.entities.splice(index, 0, entity); |
| 438 |
|
entity.activate(); |
| 439 |
|
}; |
| 440 |
E.prototype.append = function (entity) { |
E.prototype.append = function (entity) { |
| 441 |
if(!this.entities) { |
if(!this.entities) { |
| 442 |
throw "Can not call append of non-container entity"; |
throw "Can not call append of non-container entity"; |
| 605 |
} |
} |
| 606 |
return null; |
return null; |
| 607 |
}; |
}; |
| 608 |
|
E.prototype.createSprite = function () { |
| 609 |
|
var buffer = new BufferedRenderer({ |
| 610 |
|
width: this.width, |
| 611 |
|
height: this.height |
| 612 |
|
}); |
| 613 |
|
var x = this.x; |
| 614 |
|
var y = this.y; |
| 615 |
|
this.x = 0; |
| 616 |
|
this.y = 0; |
| 617 |
|
buffer.renderUnit(this); |
| 618 |
|
this.x = x; |
| 619 |
|
this.y = y; |
| 620 |
|
return buffer.createSprite(); |
| 621 |
|
}; |
| 622 |
E.prototype.update = function (t) { |
E.prototype.update = function (t) { |
| 623 |
}; |
}; |
| 624 |
E.prototype.interval = function () { |
E.prototype.interval = function () { |
| 662 |
} |
} |
| 663 |
this.type = type ? type : ShapeType.rect; |
this.type = type ? type : ShapeType.rect; |
| 664 |
} |
} |
| 665 |
|
Shape.PI_200_PER = Math.PI * 2; |
| 666 |
Shape.prototype.setStyle = function (style) { |
Shape.prototype.setStyle = function (style) { |
| 667 |
this.style = style; |
this.style = style; |
| 668 |
this.setColor(this.getColor()); |
this.setColor(this.getColor()); |
| 687 |
return this.getDrawOption("filltyle"); |
return this.getDrawOption("filltyle"); |
| 688 |
} |
} |
| 689 |
}; |
}; |
| 690 |
|
Shape.prototype.synchronize = function (syncObj, syncFunc) { |
| 691 |
|
this.syncObj = syncObj; |
| 692 |
|
this.syncFunc = syncFunc; |
| 693 |
|
}; |
| 694 |
Shape.prototype.draw = function (area, context) { |
Shape.prototype.draw = function (area, context) { |
| 695 |
|
if(this.syncObj) { |
| 696 |
|
this.syncFunc.call(this.syncObj, this); |
| 697 |
|
} |
| 698 |
context.beginPath(); |
context.beginPath(); |
| 699 |
switch(this.type) { |
switch(this.type) { |
| 700 |
case ShapeType.rect: { |
case ShapeType.rect: { |
| 704 |
} |
} |
| 705 |
case ShapeType.arc: { |
case ShapeType.arc: { |
| 706 |
var w2 = this.width / 2; |
var w2 = this.width / 2; |
| 707 |
context.arc(w2, w2, w2, 0, Math.PI * 2, false); |
context.arc(w2, w2, w2, 0, Shape.PI_200_PER, false); |
| 708 |
break; |
break; |
| 709 |
|
|
| 710 |
} |
} |
| 1305 |
Label.prototype.getColor = function () { |
Label.prototype.getColor = function () { |
| 1306 |
return this.getDrawOption("fillStyle"); |
return this.getDrawOption("fillStyle"); |
| 1307 |
}; |
}; |
| 1308 |
|
Label.prototype.synchronize = function (obj, prop, round) { |
| 1309 |
|
this.syncObj = obj; |
| 1310 |
|
this.syncProp = prop; |
| 1311 |
|
this.syncRound = round; |
| 1312 |
|
}; |
| 1313 |
Label.prototype.draw = function (area, context) { |
Label.prototype.draw = function (area, context) { |
| 1314 |
|
if(this.syncObj) { |
| 1315 |
|
var val; |
| 1316 |
|
if(typeof this.syncObj[this.syncProp] == "function") { |
| 1317 |
|
val = this.syncObj[this.syncProp](this); |
| 1318 |
|
} else { |
| 1319 |
|
val = this.syncObj[this.syncProp]; |
| 1320 |
|
} |
| 1321 |
|
this.text = this.syncRound ? Math.round(val) : val; |
| 1322 |
|
} |
| 1323 |
if(this.maxWidth) { |
if(this.maxWidth) { |
| 1324 |
context.fillText(this.text, 0, 0, this.maxWidth); |
context.fillText(this.text, 0, 0, this.maxWidth); |
| 1325 |
} else { |
} else { |
| 2097 |
var param = { |
var param = { |
| 2098 |
}; |
}; |
| 2099 |
for(var i = 0; i < ary.length; i++) { |
for(var i = 0; i < ary.length; i++) { |
| 2100 |
param[i] = ary[i]; |
param[ary[i]] = ary[i]; |
| 2101 |
} |
} |
| 2102 |
this.preload(param); |
this.preload(param); |
| 2103 |
}; |
}; |
| 3089 |
} |
} |
| 3090 |
} |
} |
| 3091 |
} |
} |
| 3092 |
|
JGUtil.createLinearGradient = function createLinearGradient(rect, colors, offsets) { |
| 3093 |
|
var canvas = window.createCanvas(1, 1); |
| 3094 |
|
var context = canvas.getContext("2d"); |
| 3095 |
|
if(typeof rect == "number") { |
| 3096 |
|
rect = new Rectangle(arguments[0], arguments[1], arguments[2], arguments[3]); |
| 3097 |
|
colors = arguments[4]; |
| 3098 |
|
offsets = arguments[5]; |
| 3099 |
|
} |
| 3100 |
|
if(offsets == undefined) { |
| 3101 |
|
offsets = []; |
| 3102 |
|
var p = 1 / (colors.length - 1); |
| 3103 |
|
for(var i = 0; i < colors.length; i++) { |
| 3104 |
|
offsets.push(i * p); |
| 3105 |
|
} |
| 3106 |
|
} |
| 3107 |
|
var gradient = context.createLinearGradient(rect.left, rect.top, rect.right, rect.bottom); |
| 3108 |
|
for(var i = 0; i < colors.length; i++) { |
| 3109 |
|
gradient.addColorStop(offsets[i], colors[i]); |
| 3110 |
|
} |
| 3111 |
|
return gradient; |
| 3112 |
|
} |
| 3113 |
|
JGUtil.createRadialGradient = function createRadialGradient(rect, radius1, radius2, colors, offsets) { |
| 3114 |
|
var canvas = window.createCanvas(1, 1); |
| 3115 |
|
var context = canvas.getContext("2d"); |
| 3116 |
|
if(typeof rect == "number") { |
| 3117 |
|
rect = new Rectangle(arguments[0], arguments[1], arguments[2], arguments[3]); |
| 3118 |
|
radius1 = arguments[4]; |
| 3119 |
|
radius2 = arguments[5]; |
| 3120 |
|
colors = arguments[6]; |
| 3121 |
|
offsets = arguments[7]; |
| 3122 |
|
} |
| 3123 |
|
if(offsets == undefined) { |
| 3124 |
|
offsets = []; |
| 3125 |
|
var p = 1 / (colors.length - 1); |
| 3126 |
|
for(var i = 0; i < colors.length; i++) { |
| 3127 |
|
offsets.push(i * p); |
| 3128 |
|
} |
| 3129 |
|
} |
| 3130 |
|
var gradient = context.createRadialGradient(rect.left, rect.top, radius1, rect.right, rect.bottom, radius2); |
| 3131 |
|
for(var i = 0; i < colors.length; i++) { |
| 3132 |
|
gradient.addColorStop(offsets[i], colors[i]); |
| 3133 |
|
} |
| 3134 |
|
return gradient; |
| 3135 |
|
} |
| 3136 |
|
JGUtil.createPattern = function createPattern(image, repeat) { |
| 3137 |
|
var canvas = window.createCanvas(1, 1); |
| 3138 |
|
var context = canvas.getContext("2d"); |
| 3139 |
|
return context.createPattern(image, repeat == undefined ? "repeat" : repeat); |
| 3140 |
|
} |
| 3141 |
return JGUtil; |
return JGUtil; |
| 3142 |
})(); |
})(); |
| 3143 |
var Line = (function (_super) { |
var Line = (function (_super) { |