aardio 文档

aardio 范例: 动画天气卡片

import win.ui;
/*DSG{{*/
var winform = win.form(text="动画天气卡片";right=360;bottom=535;max=false;min=false)
winform.add(
btnRain={cls="plus";text="雨";left=121;top=485;right=166;bottom=525;bgcolor=0xD9904A;border={radius=8};color=0xFFFFFF;font=LOGFONT(h=-14;weight=600);notify=1;z=3};
btnSnow={cls="plus";text="雪";left=171;top=485;right=216;bottom=525;bgcolor=0xC37C8E;border={radius=8};color=0xFFFFFF;font=LOGFONT(h=-14;weight=600);z=4};
btnSunny={cls="plus";text="晴";left=74;top=485;right=119;bottom=525;bgcolor=0x0095FF;border={radius=8};color=0xFFFFFF;font=LOGFONT(h=-14;weight=600);z=2};
btnWind={cls="plus";text="风";left=221;top=485;right=266;bottom=525;bgcolor=0x9AA626;border={radius=8};color=0xFFFFFF;font=LOGFONT(h=-14;weight=600);notify=1;z=5};
plus={cls="plus";left=18;top=20;right=338;bottom=470;border={color=0xFFD0D0D0;radius=20;width=2};notify=1;z=1}
)
/*}}*/

// 天气状态
var weatherState = "sunny";

// 粒子数据
var rainDrops = {};
var snowFlakes = {};
var clouds = {};
var sunRays = {};
var windLines = {};
var trees = {};
var leaves = {};

// 闪电数据
var lightning = {
    active = false;
    flashOpacity = 0;
    bolts = {};
    nextFlash = 0;
    thunderDelay = 0;
};

// 动画时间戳
var animTime = 0;

// 初始化雨滴
var initRain = function() {
    rainDrops = {};
    for(i=1; 120) {
        table.push(rainDrops, {
            x = math.random(0, 610);
            y = math.random(-200, 450);
            speed = math.random(12, 20);
            length = math.random(15, 30);
            opacity = math.random(100, 200);
            width = math.random(1, 2);
        });
    }
}

// 初始化雪花
var initSnow = function() {
    snowFlakes = {};
    for(i=1; 100) {
        table.push(snowFlakes, {
            x = math.random(0, 610);
            y = math.random(-100, 450);
            speed = math.random(10, 25) / 10;
            size = math.random(4, 12);
            swing = math.random(0, 628) / 100;
            swingSpeed = math.random(2, 6) / 100;
            opacity = math.random(180, 255);
            rotation = math.random(0, 360);
            rotSpeed = math.random(-3, 3);
        });
    }
}

// 初始化云朵
var initClouds = function(count, dark) {
    clouds = {};
    for(i=1; count) {
        table.push(clouds, {
            x = math.random(-150, 610);
            y = math.random(40, 180);
            width = math.random(100, 180);
            height = math.random(50, 80);
            speed = math.random(3, 12) / 10;
            opacity = dark ? math.random(200, 240) : math.random(180, 230);
            dark = dark;
        });
    }
}

// 初始化太阳光线
var initSunRays = function() {
    sunRays = {};
    for(i=1; 16) {
        table.push(sunRays, {
            angle = (i-1) * 22.5;
            length = math.random(70, 120);
            baseOpacity = math.random(60, 120);
            phase = math.random(0, 628) / 100;
        });
    }
}

// 初始化风线
var initWindLines = function() {
    windLines = {};
    for(i=1; 20) {
        table.push(windLines, {
            x = math.random(-250, 610);
            y = math.random(80, 380);
            length = math.random(60, 150);
            speed = math.random(15, 30);
            opacity = math.random(80, 160);
            curve = math.random(3, 8);
        });
    }
}

// 初始化树木
var initTrees = function() {
    trees = {};
    var treePositions = {100, 250, 420, 550};
    for(i=1; #treePositions) {
        table.push(trees, {
            x = treePositions[i];
            y = 400;
            height = math.random(60, 90);
            swing = math.random(0, 314) / 100;
            swingSpeed = math.random(8, 15) / 100;
        });
    }
}

// 初始化飘落的树叶
var initLeaves = function() {
    leaves = {};
    for(i=1; 15) {
        table.push(leaves, {
            x = math.random(0, 610);
            y = math.random(100, 380);
            speedX = math.random(8, 18);
            speedY = math.random(-2, 3);
            rotation = math.random(0, 360);
            rotSpeed = math.random(5, 15);
            size = math.random(8, 15);
            color = math.random(1, 3);
        });
    }
}

// 生成闪电形状
var generateLightningBolt = function(startX, startY, endY, width) {
    var bolt = {};
    var x = startX;
    var y = startY;
    var segments = math.random(8, 15);
    var segmentHeight = (endY - startY) / segments;

    table.push(bolt, {x = x, y = y});

    for(i=1; segments) {
        y = y + segmentHeight;
        x = x + math.random(-30, 30);
        table.push(bolt, {x = x, y = y});

        // 随机添加分支
        if(math.random(1, 100) > 70 && i > 2 && i < segments - 2) {
            var branch = {};
            var bx, by = x, y;
            var branchLen = math.random(3, 6);
            var branchDir = math.random(1, 2) == 1 ? -1 : 1;

            for(j=1; branchLen) {
                bx = bx + math.random(10, 25) * branchDir;
                by = by + math.random(15, 30);
                table.push(branch, {x = bx, y = by});
            }
            bolt.branch = branch;
            bolt.branchStart = i;
        }
    }

    return bolt;
}

// 初始化闪电
var initLightning = function() {
    lightning = {
        active = false;
        flashOpacity = 0;
        bolts = {};
        nextFlash = 10;
        thunderDelay = 0;
        playThunder = false;
    };
}

// 触发闪电
var triggerLightning = function(width) {
    lightning.active = true;
    lightning.flashOpacity = 200;
    lightning.bolts = {};

    // 生成1-2条主闪电
    var boltCount = math.random(1, 2);
    for(i=1; boltCount) {
        var startX = math.random(50, width - 50);
        table.push(lightning.bolts, generateLightningBolt(startX, 0, math.random(280, 380), 3));
    }

    // 设置雷声延迟
    lightning.thunderDelay = math.random(8, 25);
    lightning.playThunder = true;
}

import sys.midiOut;
var midiOut = sys.midiOut();

// 播放雷声
var playThunder = function() {
    if(midiOut) {

        //多线程并发播放雷声
        midiOut.playAsync("changeInstrument(127), 1____, 低沉雷声","C2", 400);
    }
}

// 切换天气
var switchWeather = function(weather) {
    for(hwnd,ctrl in winform.eachControlEx("plus") ){
        ctrl.disabled = false;
    }

    weatherState = weather;

    if(midiOut) midiOut.reset();//关闭所有正在播放的音效

    if(weather == "sunny") {
        initClouds(4, false);
        initSunRays();
    }
    elseif(weather == "rain") {
        initClouds(6, true);
        initRain();
        initLightning();
    }
    elseif(weather == "snow") {
        initClouds(5, false);
        initSnow();    
    }
    elseif(weather == "wind") {
        initClouds(5, false);
        initWindLines();
        initTrees();
        initLeaves(); 
    }
}

// 初始化默认天气
switchWeather("rain");
winform.btnRain.disabled = true;

// 绘制云朵
var drawCloud = function(graphics, x, y, w, h, opacity, dark) {
    var baseColor = dark ? 0x6E7B8B : 0xFFFFFF;
    var r = (baseColor >> 16) & 0xFF;
    var g = (baseColor >> 8) & 0xFF;
    var b = baseColor & 0xFF;
    var color = (opacity << 24) | (r << 16) | (g << 8) | b;

    var brush = gdip.solidBrush(color);
    graphics.fillEllipse(brush, x, y + h * 0.2, w * 0.4, h * 0.8);
    graphics.fillEllipse(brush, x + w * 0.2, y - h * 0.1, w * 0.45, h);
    graphics.fillEllipse(brush, x + w * 0.45, y + h * 0.1, w * 0.4, h * 0.85);
    graphics.fillEllipse(brush, x + w * 0.15, y + h * 0.3, w * 0.55, h * 0.6);
    brush.delete();
}

// 绘制树木
var drawTree = function(graphics, x, y, height, swing) {
    var swingOffset = math.sin(swing) * 15;

    var trunkPts = {
        ::POINTF(x - 10, y);
        ::POINTF(x + 10, y);
        ::POINTF(x + 6 + swingOffset * 0.3, y - height * 0.5);
        ::POINTF(x - 6 + swingOffset * 0.3, y - height * 0.5);
    };
    var trunkBrush = gdip.solidBrush(0xFF5D4037);
    graphics.fillPolygon(trunkBrush, trunkPts);
    trunkBrush.delete();

    var layers = {
        {offset = 0, size = 1.0, color = 0xFF2E7D32};
        {offset = -0.25, size = 0.8, color = 0xFF388E3C};
        {offset = -0.45, size = 0.6, color = 0xFF43A047};
    };

    for(i, layer in layers) {
        var layerY = y - height * 0.4 + layer.offset * height;
        var layerW = 70 * layer.size;
        var layerH = 55 * layer.size;
        var offsetX = swingOffset * (0.5 + i * 0.2);

        var leafBrush = gdip.solidBrush(layer.color);
        graphics.fillEllipse(leafBrush, x - layerW/2 + offsetX, layerY - layerH/2, layerW, layerH);
        leafBrush.delete();
    }
}

// 绘制雪花形状
var drawSnowflake = function(graphics, x, y, size, rotation, opacity) {
    var brush = gdip.solidBrush((opacity << 24) | 0xFFFFFF);
    graphics.fillEllipse(brush, x - size/2, y - size/2, size, size);
    brush.delete();

    if(size > 6) {
        var pen = gdip.pen((math.floor(opacity * 0.6) << 24) | 0xFFFFFF, 1);
        for(i=0; 2) {
            var angle = math.rad(rotation + i * 60);
            var dx = math.cos(angle) * size * 0.4;
            var dy = math.sin(angle) * size * 0.4;
            graphics.drawLine(pen, x - dx, y - dy, x + dx, y + dy);
        }
        pen.delete();
    }
}

// 绘制闪电
var drawLightning = function(graphics, bolt, opacity) {
    if(#bolt < 2) return;

    // 绘制光晕
    var glowPen = gdip.pen((math.floor(opacity * 0.3) << 24) | 0xE1F5FE, 12);
    for(i=1; #bolt - 1) {
        graphics.drawLine(glowPen, bolt[i].x, bolt[i].y, bolt[i+1].x, bolt[i+1].y);
    }
    glowPen.delete();

    // 绘制主体
    var mainPen = gdip.pen((math.floor(opacity * 0.8) << 24) | 0xFFFFFF, 4);
    for(i=1; #bolt - 1) {
        graphics.drawLine(mainPen, bolt[i].x, bolt[i].y, bolt[i+1].x, bolt[i+1].y);
    }
    mainPen.delete();

    // 绘制核心
    var corePen = gdip.pen((opacity << 24) | 0xFFFFFF, 2);
    for(i=1; #bolt - 1) {
        graphics.drawLine(corePen, bolt[i].x, bolt[i].y, bolt[i+1].x, bolt[i+1].y);
    }
    corePen.delete();

    // 绘制分支
    if(bolt.branch && bolt.branchStart) {
        var branch = bolt.branch;
        var startPt = bolt[bolt.branchStart];

        var branchGlowPen = gdip.pen((math.floor(opacity * 0.2) << 24) | 0xE1F5FE, 6);
        graphics.drawLine(branchGlowPen, startPt.x, startPt.y, branch[1].x, branch[1].y);
        for(i=1; #branch - 1) {
            graphics.drawLine(branchGlowPen, branch[i].x, branch[i].y, branch[i+1].x, branch[i+1].y);
        }
        branchGlowPen.delete();

        var branchPen = gdip.pen((math.floor(opacity * 0.6) << 24) | 0xFFFFFF, 2);
        graphics.drawLine(branchPen, startPt.x, startPt.y, branch[1].x, branch[1].y);
        for(i=1; #branch - 1) {
            graphics.drawLine(branchPen, branch[i].x, branch[i].y, branch[i+1].x, branch[i+1].y);
        }
        branchPen.delete();
    }
}

// 绘制背景
winform.plus.onDrawBackground = function(graphics,rc,backgroundColor,foregroundColor){
    var p1 = ::POINTF(0, 0);
    var p2 = ::POINTF(0, rc.bottom);

    var topColor, bottomColor;

    if(weatherState == "sunny") {
        topColor = 0xFF4FC3F7;
        bottomColor = 0xFF81C784;
    }
    elseif(weatherState == "rain") {
        topColor = 0xFF455A64;
        bottomColor = 0xFF37474F;
    }
    elseif(weatherState == "snow") {
        topColor = 0xFF90A4AE;
        bottomColor = 0xFFE8EAF6;
    }
    elseif(weatherState == "wind") {
        topColor = 0xFF64B5F6;
        bottomColor = 0xFFA5D6A7;
    }

    var brush = gdip.lineBrush(p1, p2, topColor, bottomColor, 0);
    graphics.fillRectangle(brush, rc);
    brush.delete();

    // 闪电时的天空闪光效果
    if(weatherState == "rain" && lightning.flashOpacity > 0) {
        var flashBrush = gdip.solidBrush((math.floor(lightning.flashOpacity) << 24) | 0xFFFFFF);
        graphics.fillRectangle(flashBrush, rc);
        flashBrush.delete();
    }

    // 绘制地面
    var groundY = rc.bottom - 60;
    var groundBrush;
    if(weatherState == "snow") {
        groundBrush = gdip.solidBrush(0xFFFAFAFA);
    }
    elseif(weatherState == "rain") {
        // 闪电时地面也会变亮
        var groundColor = 0xFF455A64;
        if(lightning.flashOpacity > 50) {
            var brightFactor = lightning.flashOpacity / 255;
            var r = ((groundColor >> 16) & 0xFF) + math.floor(80 * brightFactor);
            var g = ((groundColor >> 8) & 0xFF) + math.floor(80 * brightFactor);
            var b = (groundColor & 0xFF) + math.floor(80 * brightFactor);
            r = math.min(r, 255);
            g = math.min(g, 255);
            b = math.min(b, 255);
            groundColor = 0xFF000000 | (r << 16) | (g << 8) | b;
        }
        groundBrush = gdip.solidBrush(groundColor);
    }
    else {
        groundBrush = gdip.solidBrush(0xFF66BB6A);
    }
    graphics.fillRectangle(groundBrush, 0, groundY, rc.right, 60);
    groundBrush.delete();
}

// 绘制内容
winform.plus.onDrawContent = function(graphics,rc,txtColor,rcContent,foregroundColor,font){
    graphics.smoothingMode = 4;

    var width = rc.right - rc.left;
    var height = rc.bottom - rc.top;
    var groundY = height - 60;

    // ===== 晴天效果 =====
    if(weatherState == "sunny") {
        var sunX, sunY = width * 0.78, height * 0.18;
        var sunRadius = 50;

        for(r=3; 1; -1) {
            var glowOpacity = 20 + r * 15;
            var glowSize = sunRadius + r * 25;
            var glowBrush = gdip.solidBrush((glowOpacity << 24) | 0xFFD54F);
            graphics.fillEllipse(glowBrush, sunX - glowSize, sunY - glowSize, glowSize * 2, glowSize * 2);
            glowBrush.delete();
        }

        for(i, ray in sunRays) {
            var angle = math.rad(ray.angle + animTime * 0.5);
            var pulse = math.sin(animTime * 0.05 + ray.phase);
            var currentLength = ray.length + pulse * 20;
            var opacity = ray.baseOpacity + pulse * 40;

            var x2 = sunX + math.cos(angle) * currentLength;
            var y2 = sunY + math.sin(angle) * currentLength;

            var pen = gdip.pen((math.floor(opacity) << 24) | 0xFFD54F, 4);
            graphics.drawLine(pen, sunX, sunY, x2, y2);
            pen.delete();
        }

        var sunBrush = gdip.solidBrush(0xFFFFD54F);
        graphics.fillEllipse(sunBrush, sunX - sunRadius, sunY - sunRadius, sunRadius * 2, sunRadius * 2);
        sunBrush.delete();

        var highlightBrush = gdip.solidBrush(0x80FFFFFF);
        graphics.fillEllipse(highlightBrush, sunX - sunRadius * 0.6, sunY - sunRadius * 0.6, sunRadius * 0.8, sunRadius * 0.6);
        highlightBrush.delete();
    }

    // ===== 绘制云朵 =====
    for(i, cloud in clouds) {
        var cloudOpacity = cloud.opacity;
        // 闪电时云朵变亮
        if(weatherState == "rain" && lightning.flashOpacity > 50) {
            cloudOpacity = math.min(255, cloudOpacity + lightning.flashOpacity / 3);
        }
        drawCloud(graphics, cloud.x, cloud.y, cloud.width, cloud.height, cloudOpacity, cloud.dark);
    }

    // ===== 降雨效果 =====
    if(weatherState == "rain") {
        // 绘制闪电
        if(lightning.active && lightning.flashOpacity > 30) {
            for(i, bolt in lightning.bolts) {
                drawLightning(graphics, bolt, lightning.flashOpacity);
            }
        }

        // 雨滴
        for(i, drop in rainDrops) {
            var dropOpacity = drop.opacity;
            // 闪电时雨滴更亮
            if(lightning.flashOpacity > 50) {
                dropOpacity = math.min(255, dropOpacity + lightning.flashOpacity / 2);
            }
            var pen = gdip.pen((dropOpacity << 24) | 0xB3E5FC, drop.width);
            graphics.drawLine(pen, drop.x, drop.y, drop.x - 3, drop.y + drop.length);
            pen.delete();
        }

        // 水洼
        for(i=1; 6) {
            var px = 30 + (i-1) * 100;
            var rippleOffset = math.sin(animTime * 0.1 + i) * 3;

            var puddleOpacity = 0x60;
            if(lightning.flashOpacity > 50) {
                puddleOpacity = math.min(0xA0, puddleOpacity + lightning.flashOpacity / 4);
            }

            var puddleBrush = gdip.solidBrush((puddleOpacity << 24) | 0x5C6BC0);
            graphics.fillEllipse(puddleBrush, px, groundY + 10, 70, 18);
            puddleBrush.delete();

            var ripplePen = gdip.pen(0x407986CB, 1);
            graphics.drawEllipse(ripplePen, px + 15 + rippleOffset, groundY + 12, 40 + rippleOffset * 2, 12);
            ripplePen.delete();
        }

        // 雨滴溅起效果
        for(i=1; 8) {
            var splashX = math.random(50, 550);
            var splashY = groundY + 5;
            var splashPhase = (animTime + i * 37) % 30;
            if(splashPhase < 10) {
                var splashBrush = gdip.solidBrush(((150 - splashPhase * 10) << 24) | 0xB3E5FC);
                graphics.fillEllipse(splashBrush, splashX - splashPhase, splashY - splashPhase/2, splashPhase * 2, splashPhase);
                splashBrush.delete();
            }
        }
    }

    // ===== 下雪效果 =====
    if(weatherState == "snow") {
        for(i, flake in snowFlakes) {
            drawSnowflake(graphics, flake.x, flake.y, flake.size, flake.rotation, flake.opacity);
        }

        var snowPts = {::POINTF(0, height)};
        for(x=0; width; 30) {
            var snowHeight = 25 + math.sin(x * 0.03 + animTime * 0.02) * 8;
            table.push(snowPts, ::POINTF(x, groundY - snowHeight));
        }
        table.push(snowPts, ::POINTF(width, groundY - 20));
        table.push(snowPts, ::POINTF(width, height));

        var snowGroundBrush = gdip.solidBrush(0xFFFAFAFA);
        graphics.fillPolygon(snowGroundBrush, snowPts);
        snowGroundBrush.delete();

        var highlightPen = gdip.pen(0x40FFFFFF, 2);
        for(x=20; width-20; 80) {
            var hlY = groundY - 15 + math.sin(x * 0.05) * 5;
            graphics.drawCurve(highlightPen, {x, hlY, x+30, hlY-3, x+60, hlY+2});
        }
        highlightPen.delete();
    }

    // ===== 风力效果 =====
    if(weatherState == "wind") {
        for(i, line in windLines) {
            var pts = {};
            for(j=0; 5) {
                var px = line.x + j * line.length / 5;
                var py = line.y + math.sin(j * 0.8 + animTime * 0.1) * line.curve;
                table.push(pts, px);
                table.push(pts, py);
            }

            var pen = gdip.pen((line.opacity << 24) | 0xFFFFFF, 2);
            graphics.drawCurve(pen, pts);
            pen.delete();
        }

        for(i, tree in trees) {
            drawTree(graphics, tree.x, tree.y, tree.height, tree.swing);
        }

        var leafColors = {0xFF8BC34A, 0xFFCDDC39, 0xFFFFA726};
        for(i, leaf in leaves) {
            var color = leafColors[leaf.color];
            var leafBrush = gdip.solidBrush(color);

            var pts = {
                ::POINTF(leaf.x, leaf.y - leaf.size/2);
                ::POINTF(leaf.x + leaf.size/2, leaf.y);
                ::POINTF(leaf.x, leaf.y + leaf.size/2);
                ::POINTF(leaf.x - leaf.size/3, leaf.y);
            };
            graphics.fillPolygon(leafBrush, pts);
            leafBrush.delete();
        }
    }

    // ===== 天气标签 =====
    var labelBg = gdip.solidBrush(0x60000000);
    graphics.fillRectangle(labelBg, width/2 - 80, 15, 160, 45);
    labelBg.delete();

    var labels = {
        sunny = "晴空万里";
        rain = "雷雨交加";
        snow = "雪花飘飘";
        wind = "清风徐来";
    };

    var font = gdip.font("Tahoma", 10,,3/*_UnitPoint*/);
    var format = gdip.stringformat();
    format.align = 1;
    format.lineAlign = 1;

    var textBrush = gdip.solidBrush(0xFFFFFFFF);
    graphics.drawString(labels[weatherState], font, ::RECTF(0, 15, width, 45), format, textBrush);

    textBrush.delete();
    format.delete();
    font.delete();
}

// 动画更新
winform.plus.onAnimation = function(state, beginning, change, timestamp, duration) {
    animTime = animTime + 1;

    var rc = owner.getClientRect();
    var width = rc.right - rc.left;

    // 更新云朵
    for(i, cloud in clouds) {
        cloud.x = cloud.x + cloud.speed;
        if(cloud.x > 650) cloud.x = -cloud.width - 50;
    }

    // 更新雨滴和闪电
    if(weatherState == "rain") {
        for(i, drop in rainDrops) {
            drop.y = drop.y + drop.speed;
            drop.x = drop.x - 1;
            if(drop.y > 400) {
                drop.y = math.random(-100, -20);
                drop.x = math.random(0, 650);
            }
        }

        // 更新闪电
        if(lightning.flashOpacity > 0) {
            lightning.flashOpacity = lightning.flashOpacity - 12;
            if(lightning.flashOpacity <= 0) {
                lightning.flashOpacity = 0;
                lightning.active = false;
            }
        }

        // 雷声延迟播放
        if(lightning.playThunder) {
            lightning.thunderDelay = lightning.thunderDelay - 1;
            if(lightning.thunderDelay <= 0) {
                playThunder();
                lightning.playThunder = false;
            }
        }

        // 触发下一次闪电
        lightning.nextFlash = lightning.nextFlash - 1;
        if(lightning.nextFlash <= 0) {
            triggerLightning(width);
            lightning.nextFlash = math.random(80, 200);
        }
    }

    // 更新雪花
    if(weatherState == "snow") {
        for(i, flake in snowFlakes) {
            flake.y = flake.y + flake.speed;
            flake.swing = flake.swing + flake.swingSpeed;
            flake.x = flake.x + math.sin(flake.swing) * 0.8;
            flake.rotation = flake.rotation + flake.rotSpeed;

            if(flake.y > 380) {
                flake.y = math.random(-50, -10);
                flake.x = math.random(0, 610);
            }
        }
    }

    // 更新风效果
    if(weatherState == "wind") {
        for(i, line in windLines) {
            line.x = line.x + line.speed;
            if(line.x > 700) {
                line.x = -line.length - 50;
                line.y = math.random(80, 380);
            }
        }

        for(i, tree in trees) {
            tree.swing = tree.swing + tree.swingSpeed;
        }

        for(i, leaf in leaves) {
            leaf.x = leaf.x + leaf.speedX;
            leaf.y = leaf.y + leaf.speedY + math.sin(animTime * 0.1 + i) * 0.5;
            leaf.rotation = leaf.rotation + leaf.rotSpeed;

            if(leaf.x > 650) {
                leaf.x = -20;
                leaf.y = math.random(100, 350);
            }
        }
    }

    return state + 1;
}

// 开始动画
winform.plus.startAnimation(25, 0);

// 按钮事件
winform.btnSunny.oncommand = function() {
    switchWeather("sunny");
    owner.disabled = true;
}

winform.btnRain.oncommand = function() {
    switchWeather("rain");
    owner.disabled = true;
}

winform.btnSnow.oncommand = function() {
    switchWeather("snow");
    owner.disabled = true;
}

winform.btnWind.oncommand = function() {
    switchWeather("wind");
    owner.disabled = true;

    if(midiOut) {
        //播放风声
        midiOut.playAsync("changeInstrument(122), 1____,5____,1____,5____,3____,6____,1____,5____","C3",100);
    }
}

// 按钮样式
winform.btnSunny.skin({
    background = {default=0xFFFF9500; hover=0xFFFF7F00; active=0xFFE56900; disabled=0xFFC0C0C0};
    color = {default=0xFFFFFFFF};
});

winform.btnRain.skin({
    background = {default=0xFF4A90D9; hover=0xFF3A7FC8; active=0xFF2A6EB7; disabled=0xFFC0C0C0};
    color = {default=0xFFFFFFFF};
});

winform.btnSnow.skin({
    background = {default=0xFF8E7CC3; hover=0xFF7A68AF; active=0xFF66549B; disabled=0xFFC0C0C0};
    color = {default=0xFFFFFFFF};
});

winform.btnWind.skin({
    background = {default=0xFF26A69A; hover=0xFF1E958A; active=0xFF16847A; disabled=0xFFC0C0C0};
    color = {default=0xFFFFFFFF};
});

winform.show();
win.loopMessage();
Markdown 格式