Created
          April 10, 2021 12:18 
        
      - 
      
 - 
        
Save triacontane/a3446789181cff50033776b2c34e570b to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or 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
    
  
  
    
  | //https://note.affi-sapo-sv.com//js-canvas-how-use.php | |
| /*:ja | |
| * @plugindesc 円グラフまたは折れ線グラフ | |
| * @author | |
| * | |
| * @help | |
| * 【プラグインコマンド】 | |
| * PIE_GRAPH [グラフ番号] [中心座標X] [中心座標Y] [グラフ幅] [グラフ高さ] [グラフデータ変数] [ラベルデータ変数] [色データ変数] | |
| * 円グラフ [グラフ番号] [中心座標X] [中心座標Y] [グラフ幅] [グラフ高さ] [グラフデータ変数] [ラベルデータ変数] [色データ変数] | |
| * | |
| * 例: PIE_GRAPH 1 300 300 200 200 10 11 12 | |
| * | |
| * グラフ番号 1 | |
| * 中心座標X 300 | |
| * 中心座標Y 300 | |
| * グラフ幅 200 | |
| * グラフ高さ 200 | |
| * 変数10 [10,50,20,30] //グラフデータ | |
| * 変数11 ["体力","魔力","気力","努力"] //ラベルデータ | |
| * 変数12 ["Red", "Green", "Blue", "Green"] //色 | |
| * | |
| * | |
| * LINE_GRAPH [グラフ番号] [中心座標X] [中心座標Y] [グラフ幅] [グラフ高さ] [グラフデータ変数] [ラベルデータ変数] [色] | |
| * 折れ線グラフ [グラフ番号] [中心座標X] [中心座標Y] [グラフ幅] [グラフ高さ] [グラフデータ変数] [ラベルデータ変数] [色] | |
| * | |
| * 例: LINE_GRAPH 1 300 300 200 200 10 11 "Black" | |
| * | |
| * グラフ番号 1 | |
| * 中心座標X 300 | |
| * 中心座標Y 300 | |
| * グラフ幅 200 | |
| * グラフ高さ 200 | |
| * 変数10 [10,50,20,30] //グラフデータ | |
| * 変数11 [10,50,20,30] //ラベルデータ | |
| * 色 "Black" //色 | |
| * | |
| *GRAPH_REMOVE [グラフ番号] | |
| *グラフ削除 [グラフ番号] | |
| * | |
| * 利用規約 : MITライセンス | |
| */ | |
| //Graphics.boxWidth 実際の幅 | |
| (function() { | |
| 'use strict'; | |
| const PLUGIN_NAME = "" | |
| //============================================================================= | |
| // Game_Interpreter | |
| // プラグインコマンドを定義します。 | |
| //============================================================================= | |
| var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand; | |
| Game_Interpreter.prototype.pluginCommand = function(command, args) { | |
| _Game_Interpreter_pluginCommand.call(this, command, args); | |
| this.pluginCommandMakeGraph(command, args); | |
| }; | |
| Game_Interpreter.prototype.pluginCommandMakeGraph = function(command, args) { | |
| var myData, myLabel, myColor; | |
| var GraphNum = 0; | |
| var graphInfo = {}; | |
| switch (command.toUpperCase()) { | |
| case 'PIE_GRAPH' : | |
| case '円グラフ': | |
| GraphNum = parseInt(args[0]) || 0; | |
| ;//数字に変換 | |
| graphInfo.x = parseInt(args[1]) || 0; | |
| ;//数字に変換 中心座標X | |
| graphInfo.y = parseInt(args[2]) || 0; | |
| ;//数字に変換 中心座標Y | |
| graphInfo.width = parseInt(args[3]) || 0; | |
| ;//数字に変換 グラフ幅 | |
| graphInfo.height = parseInt(args[4]) || 0; | |
| ;//数字に変換 グラフ高さ | |
| myData = $gameVariables.value(parseInt(args[5])) || 0; | |
| ;//数字に変換して配列 グラフデータ変数 | |
| myLabel = $gameVariables.value(parseInt(args[6])) || 0; | |
| ;//数字に変換して配列 ラベルデータ変数 | |
| myColor = $gameVariables.value(parseInt(args[7])) || 0; | |
| ;//数字に変換して配列 色データ変数 | |
| $gameMap.setDrawPieGraph(GraphNum, graphInfo, myData, myLabel, myColor); | |
| break; | |
| case 'LINE_GRAPH' : | |
| case '折れ線グラフ': | |
| CenterX = parseInt(args[0]);//数字に変換 中心座標X | |
| CenterY = parseInt(args[1]);//数字に変換 中心座標Y | |
| GraphW = parseInt(args[2]);//数字に変換 グラフ幅 | |
| GraphH = parseInt(args[3]);//数字に変換 グラフ高さ | |
| myData = $gameVariables.value(parseInt(args[4]));//数字に変換して配列 グラフデータ変数 | |
| myLabel = $gameVariables.value(parseInt(args[5]));//数字に変換して配列 ラベルデータ変数 | |
| myColor = $gameVariables.value(parseInt(args[6]));//数字に変換して配列 色データ変数 | |
| break; | |
| case 'GRAPH_REMOVE' : | |
| case 'グラフ削除': | |
| var number = parseInt(args[0]); | |
| $gameMap.setEraseGraph(number); | |
| break; | |
| } | |
| }; | |
| // ---------- プロパティ定義 ---------- | |
| //Game_Screen | |
| // | |
| //参考:トリアコンタン様のDWindow.js | |
| // ----------------------------------------- | |
| var _Game_Map_setup = Game_Map.prototype.setup; | |
| Game_Map.prototype.setup = function(mapId) { | |
| _Game_Map_setup.apply(this, arguments); | |
| if (!this.GraphInfos) this.GraphInfos = []; | |
| if (!this.myDatas) this.myDatas = []; | |
| if (!this.myLabels) this.myLabels = []; | |
| if (!this.myColors) this.myColors = []; | |
| }; | |
| Game_Map.prototype.setDrawPieGraph = function(GraphNum, graphInfo, myData, myLabel, myColor) { | |
| this.GraphInfos[GraphNum] = graphInfo; | |
| this.myDatas[GraphNum] = myData; | |
| this.myLabels[GraphNum] = myLabel; | |
| this.myColors[GraphNum] = myColor; | |
| }; | |
| Game_Map.prototype.setDrawGraph = function(GraphNum, graphInfo, myData, myLabel, myColor) { | |
| this.GraphInfos[GraphNum] = graphInfo; | |
| this.myDatas[GraphNum] = myData; | |
| this.myLabels[GraphNum] = myLabel; | |
| this.myColors[GraphNum] = myColor; | |
| }; | |
| Game_Map.prototype.setEraseGraph = function(GraphNum) { | |
| this.GraphInfos[GraphNum] = null; | |
| }; | |
| Game_Map.prototype.findGraph = function(GraphNum) { | |
| if (!this.GraphInfos) this.GraphInfos = []; | |
| return this.GraphInfos[GraphNum]; | |
| }; | |
| var _Game_Map_update = Game_Map.prototype.update; | |
| Game_Map.prototype.update = function(sceneActive) { | |
| _Game_Map_update.apply(this, arguments); | |
| this.updateMyGraph(); | |
| }; | |
| //↓必要かどうかは検討↓ | |
| Game_Map.prototype.updateMyGraph = function() { | |
| if (!this.GraphInfos) { | |
| return; | |
| } | |
| }; | |
| // | |
| //============================================================================= | |
| // Spriteset | |
| //============================================================================= | |
| var _Spriteset_Base_createUpperLayer = Spriteset_Base.prototype.createUpperLayer; | |
| Spriteset_Base.prototype.createUpperLayer = function() { | |
| _Spriteset_Base_createUpperLayer.apply(this, arguments); | |
| this.createMyGraph(); | |
| }; | |
| Spriteset_Base.prototype.createMyGraph = function() { | |
| this._myGraphs = []; | |
| for (var i = 0; i < 10; i++) { | |
| this._myGraphs[i] = new myGraph(i); | |
| this.addChild(this._myGraphs[i]); | |
| } | |
| } | |
| //============================================================================= | |
| // myGraph | |
| //============================================================================= | |
| function myGraph() { | |
| this.initialize.apply(this, arguments); | |
| } | |
| myGraph.prototype = Object.create(Window_Base.prototype); | |
| myGraph.prototype.constructor = myGraph; | |
| myGraph.prototype.initialize = function(number) { | |
| this._GraphNum = number; | |
| Window_Base.prototype.initialize.call(this, 0, 0, 1, 1); | |
| this.update(); | |
| }; | |
| myGraph.prototype.graphInfo = function() { | |
| return $gameMap.findGraph(this._GraphNum); | |
| }; | |
| myGraph.prototype.update = function() { | |
| Window_Base.prototype.update.call(this); | |
| var info = this.graphInfo(); | |
| if (info) { | |
| if (info.x !== this.x || info.y !== this.y || info.width !== this.width || info.height !== this.height) { | |
| this.move(info.x, info.y, info.width, info.height); | |
| } | |
| this.show(); | |
| } else { | |
| this.hide(); | |
| } | |
| }; | |
| })(); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
その他、GameScreenとGameMapに定義が混在していた実行できない状態だったので、GameMapに統一しました。