45 lines
1.5 KiB
JavaScript
45 lines
1.5 KiB
JavaScript
/*:
|
|
* @plugindesc グラデーション背景描画プラグイン
|
|
* @target MZ
|
|
* @help
|
|
* このプラグインは紫から桃色のグラデーション背景を描画します。
|
|
*
|
|
* イベントの「スクリプト」コマンドで以下を使用してください。
|
|
* グラデーションを表示: GradientOverlay.show();
|
|
* グラデーションを削除: GradientOverlay.hide();
|
|
*/
|
|
|
|
(() => {
|
|
const GradientOverlay = {};
|
|
|
|
GradientOverlay.show = function() {
|
|
if (SceneManager._gradientSprite) return;
|
|
|
|
const gradientSprite = new Sprite();
|
|
const width = Graphics.width;
|
|
const height = Graphics.height;
|
|
|
|
const bitmap = new Bitmap(width, height);
|
|
const context = bitmap._context;
|
|
const gradient = context.createLinearGradient(0, 0, 0, height);
|
|
gradient.addColorStop(0, 'purple');
|
|
gradient.addColorStop(1, 'pink');
|
|
|
|
context.fillStyle = gradient;
|
|
context.fillRect(0, 0, width, height);
|
|
bitmap._setDirty();
|
|
|
|
gradientSprite.bitmap = bitmap;
|
|
SceneManager._scene.addChild(gradientSprite);
|
|
SceneManager._gradientSprite = gradientSprite;
|
|
};
|
|
|
|
GradientOverlay.hide = function() {
|
|
if (SceneManager._gradientSprite) {
|
|
SceneManager._scene.removeChild(SceneManager._gradientSprite);
|
|
SceneManager._gradientSprite = null;
|
|
}
|
|
};
|
|
|
|
window.GradientOverlay = GradientOverlay;
|
|
})();
|