/**
* 色情報を表す。
* 基本的な色は"red"や"black"などで指定可能。
*
* https://www.w3.org/TR/SVG11/types.html#ColorKeywords
*
* または"#FF0000"のような16進数表記も可能。console.logで表示するときはこちらになる。
* Live.rgb(1,1,1)のような関数を使って指定することも可能
*
* @example
* function start() {
* model.multiplyColor = "red"
* console.log(model.multiplyColor) // #FF0000
*
* model.multiplyColor = "#FFFFFF"
* model.screenColor = Live.rgb(0, 0, 1)
* }
*/
class Color {
/**
* 有効かどうか
* @type {boolean}
*/
valid = 0
/**
* 赤成分
* @type {number}
*/
r = 0
/**
* 緑成分
* @type {number}
*/
g = 0
/**
* 青成分
* @type {number}
*/
b = 0
}
/**
* paint関数で引数として渡ってくる、描画のためのオブジェクト
* @example
* function paint(painter) {
* painter.clear()
* painter.pen = "black"
* painter.drawRect(0, 0, 100, 100)
* painter.pen = "green"
* painter.drawEllipse(0, 0, 100, 100)
* painter.pen = "blue"
* painter.drawLine(0, 0, 100, 100)
* painter.pen = "red"
* painter.drawText(20, 20, "Hello, World!")
* }
*/
class Painter {
/**
* 画面の横幅
* @type {number}
*/
width = 0
/**
* 画面の高さ
* @type {number}
*/
height = 0
/**
* 描画時の色
* @type {Color}
*/
pen = "red"
/**
* 文字のサイズ
* @type {number}
*/
pixelSize = 1
/**
* 文字のサイズ
* @type {number}
*/
pointSize = 1
/**
* 線の太さ
* @type {number}
*/
penWidth = 1
/**
* フォントの指定
* @type {string}
*/
font = ""
/**
* 有効なフォントの一覧
* @type {string[]}
*/
fontList = [""]
/**
* 塗りつぶしの色
* @type {Color}
*/
brush = "black"
/**
* 描画したものを初期化する
*/
clear() { }
/**
* 文字を描画する
* @param x {number}
* @param y {number} 文字の左上を基準とする( API 1.0.0(nL1.8.0)から )
* @param text {string}
*/
drawText(x, y, text) { }
/**
* 線を描画する
* @param x1 {number}
* @param y1 {number}
* @param x2 {number}
* @param y2 {number}
*/
drawLine(x1, y1, x2, y2) { }
/**
* 点を描画する
* @param x {number}
* @param y {number}
*/
drawPoint(x, y) { }
/**
* 楕円を描画する
* @param centerX {number}
* @param centerY {number}
* @param rx {number}
* @param ry {number}
*/
drawEllipse(centerX, centerY, rx, ry) { }
/**
* 四角形を描画する
* @param x {number}
* @param y {number}
* @param width {number}
* @param height {number}
*/
drawRect(x, y, width, height) { }
/**
* 円を描画する
* @param x {number}
* @param y {number}
* @param radius {number}
*/
drawCircle(x, y, radius) { }
/**
* 画像を描画する
* @param x {number}
* @param y {number}
* @param image {string} scriptsフォルダにある画像ファイル名
*/
drawImage(x, y, image) { }
}
/**
* Cubismのパラメータを表すオブジェクト
* @example
* function start(){
* for(let param of model.parameters){
* console.log("ID:",param.id)
* console.log(" Name:",param.name)
* console.log(" Default Value:",param.defaultValue)
* console.log(" Max:",param.max)
* console.log(" Min:",param.min)
* console.log(" Value:",param.value)
* }
* }
*/
class Parameter {
/**
* パラメータのID
* @type {string}
*/
id = ""
/**
* パラメータの値
* @type {number}
*/
value = 0
/**
* パラメータの名前。cdi.jsonに記載が無い場合は空文字列
* @type {string}
*/
name = ""
/**
* パラメータの最小値
* @type {number}
*/
min = 0
/**
* パラメータの最大値
* @type {number}
*/
max = 1
/**
* パラメータの初期値
* @type {number}
*/
defaultValue = 0
}
/**
* Cubismのパーツを表すオブジェクト
* @example
* function start(){
* for(let part of model.parts){
* console.log("ID:",part.id)
* console.log(" Name:",part.name)
* console.log(" Opacity:",part.opacity)
* console.log(" Parent Part:",part.parentPart?.id)
* console.log(" MultiplyColor:",part.multiplyColor)
* console.log(" ScreenColor:",part.screenColor)
* console.log(" Drawable Children Count:",part.drawables.length)
* console.log(" Part Children Count:",part.parts.length)
* }
* }
*/
class Part {
/**
* パーツID
* Cubism Editorで設定したもの
* @type {string}
*/
id = ""
/**
* パーツ名。cdi.jsonに記載が無い場合は空文字列
* @type {string}
*/
name = ""
/**
* 親パーツ
* @type {Part}
*/
parentPart = {}
/**
* パーツの不透明度
* @type {number}
*/
opacity = 1
/**
* 子パーツ
* @type {Part[]}
*/
parts = []
/**
* 子描画オブジェクト
* @type {Drawable[]}
*/
drawables = []
/**
* パーツの乗算色
* @type {Color}
*/
multiplyColor = {}
/**
* パーツのスクリーン色
* @type {Color}
*/
screenColor = {}
}
/**
* Cubismの描画オブジェクトを表すオブジェクト
* @example
* function start(){
* for(let drawable of model.drawables){
* console.log("ID",drawable.id)
* console.log(" Opacity",drawable.opacity)
* console.log(" DrawOrder",drawable.drawOrder)
* console.log(" Parent Part:",drawable.parentPart?.id)
* console.log(" MultiplyColor:",drawable.multiplyColor)
* console.log(" ScreenColor:",drawable.screenColor)
* }
* }
*/
class Drawable {
/**
* 描画オブジェクトID
* Cubism Editorで設定したもの
* @type {string}
* @readonly
*/
id = ""
/**
* 親パーツ
* @type {{}}
* @readonly
*/
parentPart = {}
/**
* 不透明度
* @type {number}
* @readonly
*/
opacity = 1
/**
* 描画順
* @type {number}
* @readonly
*/
drawOrder = 1
/**
* 乗算色
* @type {Color}
*/
multiplyColor = {}
/**
* スクリーン色
* @type {Color}
*/
screenColor = {}
}
/**
* Cubismのモーションを表すオブジェクト
* @example
* function start(){
* for(let motion of model.motions){
* console.log("Name",motion.name)
* }
*
* if(model.motions.length>0){
* let motion=model.motions[Math.floor(Math.random() * model.motions.length)];
* motion.start()
* }
* }
*/
class Motion {
/**
* モーション名
* @type {string}
*/
name = ""
/**
* モーションを開始する
*/
start() {
}
/**
* 停止する
*/
stop() {
}
}
/**
* Cubismの表情を表すオブジェクト
* @example
* function start(){
* for(let expression of model.expressions){
* console.log("Name",expression.name)
* }
*
* if(model.expressions.length>0){
* let expression=model.expressions[Math.floor(Math.random() * model.expressions.length)];
* expression.start()
* console.log("Start Expression",expression.name)
* }
* }
*/
class Expression {
/**
* 表情名
* @type {string}
*/
name = ""
/**
* 表情を再生する
*/
start() {
}
/**
* 表情を停止する
*/
stop() {
}
}
/**
* Live2Dモデルを操作するオブジェクト
* @example
* function start(){
* console.log("parameters",model.parameters.length)
* console.log("parts",model.parts.length)
* console.log("drawables",model.drawables.length)
* console.log("motions",model.motions.length)
* console.log("expressions",model.expressions.length)
* }
*/
class Model {
/**
* パラメータの一覧
* @type {Parameter[]}
*/
parameters = []
/**
* パラメータを取得する。
* @param id {string} IDが無い場合は名前で検索する
* @returns {Parameter}
*/
parameter(id) {
return new Parameter()
}
/**
* パーツの一覧
* @type {Part[]}
*/
parts = []
/**
* パーツを取得する。
* @param id {string} IDが無い場合は名前で検索する
* @returns {Part}
*/
part(id) {
return new Part()
}
/**
* 描画オブジェクトの一覧
* @type {Drawable[]}
*/
drawables = []
/**
* 描画オブジェクトを取得する。
* @param id {string} IDが無い場合は名前で検索する
* @returns {Drawable}
*/
drawable(id) {
return new Drawable()
}
/**
* モーション(motion3.json)の一覧
* @type {Motion[]}
*/
motions = []
/**
* モーションを取得する。
* @param name {string}
* @returns {Motion}
*/
motion(name) {
return new Motion()
}
/**
* 表情(exp3.json)の一覧
* @type {Expression[]}
*/
expressions = []
/**
* 表情を取得する。
* @param name {string} ファイル名またはmodel3.jsonに記載の名前
* @returns {Expression}
*/
expression(name) {
return new Expression()
}
/**
* 乗算色
* @type {Color}
* @example
* function start(){
* model.multiplyColor="#00ff00"
* console.log(model.multiplyColor)
* }
*/
multiplyColor = {}
/**
* スクリーン色
* @type {Color}
* @example
* function start(){
* model.screenColor="#ff0000"
* console.log(model.screenColor)
* }
*/
screenColor = {}
/**
* 再生中のモーションを終了する関数
*/
stopMotion() {
}
/**
* モデルを移動する
* @param {Object} param - 設定オブジェクト。
* @param {number} [param.PositionX] - X座標
* @param {number} [param.PositionX] - Y座標
* @param {number} [param.Scale] - 大きさ
* @param {number} [param.Rotation] - 回転
* @param {number} [param.Delay=1] - 完了までの秒数
* @param {boolean} [param.Absolute=false] - 絶対座標で移動するかどうか
* @param {string} [param.InterpolationType="Linear"] - 補間方法
* @example
model.move({
Rotation: 90,
Delay: 3
})
*/
move(param) {
}
}
/**
* アイテム
*/
class Item{
/**
* ID
* @type {string}
*/
id = ""
}
/**
* 画像
*/
class Image{
/**
* ID
* @type {string}
*/
id = ""
width = 0
height = 0
}
/**
* シーン
* @example
* function start() {
* console.log("ID:",scene.id)
* console.log(" Model:",scene.models.length)
* console.log(" Item:",scene.items.length)
* }
*/
class Scene {
/**
* ID
* @type {string}
*/
id = ""
/**
* モデル一覧(Live2Dアイテムを除く)
* @type {Model[]}
*/
models = []
/**
* アイテム一覧
* @type {Item[]}
*/
items = []
}
/**
* グローバルにアクセスできるオブジェクト
*/
class Live {
/**
* スクリプトのバージョン
* @type {string}
*/
version = "2.0.0"
/**
* すべてのシーンのモデルの一覧
* @type {Model[]}
*/
models = []
/**
* すべてのシーンのアイテムの一覧
* @type {Item[]}
*/
items = []
/**
* 右上にメッセージを表示する
* @param message {string}
*/
showMessage(message) {
}
/**
* シーンの一覧
* @type {Scene[]}
*/
scenes = []
/**
* LIVEパラメータの一覧
* @type {Array<{id: string, createdBy: string, group: string, base: number, min: number, max: number, repeat: boolean}>}
* @property {string} id パラメータのID。{@link LiveParameters}を参照
* @property {string} createdBy パラメータの作成者
* @property {string} group パラメータのグループ名
* @property {number} base パラメータの基準値
* @property {number} min パラメータの最小値
* @property {number} max パラメータの最大値
* @property {boolean} repeat 最大値と最小値がつながる場合にtrue
*/
parameters = []
/**
* LIVEパラメータを追加する
* @param {Object} param - パラメータ設定オブジェクト。
* @param {string} param.Id - パラメータのID。
* @param {string} param.Group - パラメータが属するグループ。
* @param {number} param.Base - パラメータの基本値。
* @param {number} param.Max - パラメータの最大値。
* @param {number} param.Min - パラメータの最小値。
* @param {boolean} param.Repeat - パラメータが繰り返し可能かどうか。
*/
insertParameter(param) {
}
/**
* 色の数値から#FFFFFFの形式に変更
* @param red {number} 0~1
* @param green {number} 0~1
* @param blue {number} 0~1
* @returns {Color}
*/
rgb(red, green, blue) {
}
/**
* コンボボックスでの選択ダイアログを開く
* ※ モーダルダイアログで開きます
* @param title {string} ウィンドウタイトル
* @param text {string} 本文
* @param list {string[]} 選択肢の一覧
* @param selectedCallback {Function} 選択したときに呼ばれる関数
* @param canceledCallback {Function} キャンセルしたときに呼ばれる関数
* @param changedCallback {Function} 変更があったときに呼ばれる関数
*/
openListDialog(title, text, list,
selectedCallback, canceledCallback = {}, changedCallback = {}) {
}
/**
* カラーダイアログを開く
*/
openColorDialog(selectedCallback, canceledCallback = {}, changedCallback = {}) { }
/**
* テキスト入力ダイアログを開く
*/
openTextDialog(title, text, selectedCallback, canceledCallback = {}, changedCallback = {}) { }
/**
* 複数行のテキスト入力ダイアログを開く
*/
openMultiTextDialog(title, text, selectedCallback, canceledCallback = {}, changedCallback = {}) { }
/**
* 整数入力ダイアログを開く
*/
openIntDialog(title, text, min = 0, value = 0, max = 100, selectedCallback = {}, canceledCallback = {}, changedCallback = {}) { }
/**
* 小数入力ダイアログを開く
*/
openFloatDialog(title, text, min = 0, value = 0, max = 100, selectedCallback = {}, canceledCallback = {}, changedCallback = {}) { }
/**
* エラーダイアログを開く
*/
openErrorDialog(title, text, acceptedCallback = {}) { }
/**
* メッセージダイアログを開く
*/
openMessageDialog(title, text, acceptedCallback = {}, canceledCallback = {}, detail = {}) { }
}