LVGL:渐变方案

仿照qt的QGradient::Preset渐变类型写的,因为lvgl只支持水平/垂直渐变,且只支持两种颜色的渐变,所以有些类型的渐变未能实现,有些则缺少中间颜色。

代码:

namespace Gradient
{
enum Preset
{
    WarmFlame = 1,
    NightFade = 2,
    SpringWarmth = 3,
    JuicyPeach = 4,
    YoungPassion = 5,
    LadyLips = 6,
    SunnyMorning = 7,
    RainyAshville = 8,
    FrozenDreams = 9,
    WinterNeva = 10,
    DustyGrass = 11,
    TemptingAzure = 12,
    HeavyRain = 13,
    AmyCrisp = 14,
    MeanFruit = 15,
    DeepBlue = 16,
    RipeMalinka = 17,
    CloudyKnoxville = 18,
    MalibuBeach = 19,
    NewLife = 20,
    TrueSunset = 21,
    MorpheusDen = 22,
    RareWind = 23,
    NearMoon = 24,
    WildApple = 25,
    SaintPetersburg = 26,
    PlumPlate = 28,
    EverlastingSky = 29,
    HappyFisher = 30,
    Blessing = 31,
    SharpeyeEagle = 32,
    LadogaBottom = 33,
    LemonGate = 34,
    ItmeoBranding = 35,
    ZeusMiracle = 36,
    OldHat = 37,
    StarWine = 38,
    HappyAcid = 41,
    AwesomePine = 42,
    NewYork = 43,
    ShyRainbow = 44,
    MixedHopes = 46,
    FlyHigh = 47,
    StrongBliss = 48,
    FreshMilk = 49,
    SnowAgain = 50,
    FebruaryInk = 51,
    KindSteel = 52,
    SoftGrass = 53,
    GrownEarly = 54,
    SharpBlues = 55,
    ShadyWater = 56,
    DirtyBeauty = 57,
    GreatWhale = 58,
    TeenNotebook = 59,
    PoliteRumors = 60,
    SweetPeriod = 61,
    WideMatrix = 62,
    SoftCherish = 63,
    RedSalvation = 64,
    BurningSpring = 65,
    NightParty = 66,
    SkyGlider = 67,
    HeavenPeach = 68,
    PurpleDivision = 69,
    AquaSplash = 70,
    SpikyNaga = 72,
    LoveKiss = 73,
    CleanMirror = 75,
    PremiumDark = 76,
    ColdEvening = 77,
    CochitiLake = 78,
    SummerGames = 79,
    PassionateBed = 80,
    MountainRock = 81,
    DesertHump = 82,
    JungleDay = 83,
    PhoenixStart = 84,
    OctoberSilence = 85,
    FarawayRiver = 86,
    AlchemistLab = 87,
    OverSun = 88,
    PremiumWhite = 89,
    MarsParty = 90,
    EternalConstance = 91,
    JapanBlush = 92,
    SmilingRain = 93,
    CloudyApple = 94,
    BigMango = 95,
    HealthyWater = 96,
    AmourAmour = 97,
    RiskyConcrete = 98,
    StrongStick = 99,
    ViciousStance = 100,
    PaloAlto = 101,
    HappyMemories = 102,
    MidnightBloom = 103,
    Crystalline = 104,
    PartyBliss = 106,
    ConfidentCloud = 107,
    LeCocktail = 108,
    RiverCity = 109,
    FrozenBerry = 110,
    ChildCare = 112,
    FlyingLemon = 113,
    NewRetrowave = 114,
    HiddenJaguar = 115,
    AboveTheSky = 116,
    Nega = 117,
    DenseWater = 118,
    Seashore = 120,
    MarbleWall = 121,
    CheerfulCaramel = 122,
    NightSky = 123,
    MagicLake = 124,
    YoungGrass = 125,
    ColorfulPeach = 126,
    GentleCare = 127,
    PlumBath = 128,
    HappyUnicorn = 129,
    AfricanField = 131,
    SolidStone = 132,
    OrangeJuice = 133,
    GlassWater = 134,
    NorthMiracle = 136,
    FruitBlend = 137,
    MillenniumPine = 138,
    HighFlight = 139,
    MoleHall = 140,
    SpaceShift = 142,
    ForestInei = 143,
    RoyalGarden = 144,
    RichMetal = 145,
    JuicyCake = 146,
    SmartIndigo = 147,
    SandStrike = 148,
    NorseBeauty = 149,
    AquaGuidance = 150,
    SunVeggie = 151,
    SeaLord = 152,
    BlackSea = 153,
    GrassShampoo = 154,
    LandingAircraft = 155,
    WitchDance = 156,
    SleeplessNight = 157,
    AngelCare = 158,
    CrystalRiver = 159,
    SoftLipstick = 160,
    SaltMountain = 161,
    PerfectWhite = 162,
    FreshOasis = 163,
    StrictNovember = 164,
    MorningSalad = 165,
    DeepRelief = 166,
    SeaStrike = 167,
    NightCall = 168,
    SupremeSky = 169,
    LightBlue = 170,
    MindCrawl = 171,
    LilyMeadow = 172,
    SugarLollipop = 173,
    SweetDessert = 174,
    MagicRay = 175,
    TeenParty = 176,
    FrozenHeat = 177,
    GagarinView = 178,
    FabledSunset = 179,
    PerfectBlue = 180,

    NumPresets
};

void setGradient(Gradient::Preset gradient,lv_draw_rect_dsc_t * rect_dsc);
}

void Gradient::setGradient(Preset gradient, lv_draw_rect_dsc_t *rect_dsc)
{
    std::map<Preset,std::tuple<lv_color_t,lv_color_t,lv_grad_dir_t>> map;
    map[WarmFlame] = std::make_tuple(lv_color_make(0xff,0x9a,0x9e),lv_color_make(0xfa,0xd0,0xc4),LV_GRAD_DIR_HOR);
    map[NightFade] = std::make_tuple(lv_color_make(0xfb,0xc2,0xeb),lv_color_make(0xa1,0x8c,0xd1),LV_GRAD_DIR_VER);
    map[SpringWarmth] = std::make_tuple(lv_color_make(0xff,0xd1,0xff),lv_color_make(0xfa,0xd0,0xc4),LV_GRAD_DIR_VER);
    map[JuicyPeach] = std::make_tuple(lv_color_make(0xff,0xec,0xd2),lv_color_make(0xfc,0xb6,0x9f),LV_GRAD_DIR_HOR);
    map[YoungPassion] = std::make_tuple(lv_color_make(0xff,0x81,0x77),lv_color_make(0xb1,0x2a,0x5b),LV_GRAD_DIR_HOR);
    map[LadyLips] = std::make_tuple(lv_color_make(0xfe,0xcf,0xef),lv_color_make(0xff,0x9a,0x9e),LV_GRAD_DIR_VER);
    map[SunnyMorning] = std::make_tuple(lv_color_make(0xf6,0xd3,0x65),lv_color_make(0xfd,0xa0,0x85),LV_GRAD_DIR_HOR);
    map[RainyAshville] = std::make_tuple(lv_color_make(0xa6,0xc1,0xee),lv_color_make(0xfb,0xc2,0xeb),LV_GRAD_DIR_VER);
    map[FrozenDreams] = std::make_tuple(lv_color_hex(0xe6dee9),lv_color_hex(0xfdcbf1),LV_GRAD_DIR_VER);
    map[WinterNeva] = std::make_tuple(lv_color_hex(0xa1c4fd),lv_color_hex(0xc2e9fb),LV_GRAD_DIR_HOR);
    map[DustyGrass] = std::make_tuple(lv_color_hex(0xd4fc79),lv_color_hex(0x96e6a1),LV_GRAD_DIR_HOR);
    map[TemptingAzure] = std::make_tuple(lv_color_hex(0x84fab0),lv_color_hex(0x8fd3f4),LV_GRAD_DIR_HOR);
    map[HeavyRain] = std::make_tuple(lv_color_hex(0xe2ebf0),lv_color_hex(0xcfd9df),LV_GRAD_DIR_VER);
    map[AmyCrisp] = std::make_tuple(lv_color_hex(0xa6c0fe),lv_color_hex(0xf68084),LV_GRAD_DIR_HOR);
    map[MeanFruit] = std::make_tuple(lv_color_hex(0xfccb90),lv_color_hex(0xd57eeb),LV_GRAD_DIR_HOR);
    map[DeepBlue] = std::make_tuple(lv_color_hex(0xe0c3fc),lv_color_hex(0x8ec5fc),LV_GRAD_DIR_HOR);
    map[RipeMalinka] = std::make_tuple(lv_color_hex(0xf093fb),lv_color_hex(0xf5576c),LV_GRAD_DIR_HOR);
    map[CloudyKnoxville] = std::make_tuple(lv_color_hex(0xfdfbfb),lv_color_hex(0xebedee),LV_GRAD_DIR_HOR);
    map[MalibuBeach] = std::make_tuple(lv_color_hex(0x4facfe),lv_color_hex(0x00f2fe),LV_GRAD_DIR_HOR);
    map[NewLife] = std::make_tuple(lv_color_hex(0x38f9d7),lv_color_hex(0x43e97b),LV_GRAD_DIR_HOR);//20
    map[TrueSunset] = std::make_tuple(lv_color_hex(0xfee140),lv_color_hex(0xfa709a),LV_GRAD_DIR_HOR);
    map[MorpheusDen] = std::make_tuple(lv_color_hex(0x330867),lv_color_hex(0x30cfd0),LV_GRAD_DIR_VER);
    map[RareWind] = std::make_tuple(lv_color_hex(0xfed6e3),lv_color_hex(0xa8edea),LV_GRAD_DIR_VER);
    map[NearMoon] = std::make_tuple(lv_color_hex(0xb490ca),lv_color_hex(0x5ee7df),LV_GRAD_DIR_VER);
    map[WildApple] = std::make_tuple(lv_color_hex(0xfef9d7),lv_color_hex(0xd299c2),LV_GRAD_DIR_VER);
    map[SaintPetersburg] = std::make_tuple(lv_color_hex(0xf5f7fa),lv_color_hex(0xc3cfe2),LV_GRAD_DIR_HOR);
    map[PlumPlate] = std::make_tuple(lv_color_hex(0x667eea),lv_color_hex(0x764ba2),LV_GRAD_DIR_HOR);
    map[EverlastingSky] = std::make_tuple(lv_color_hex(0xfdfcfb),lv_color_hex(0xe2d1c3),LV_GRAD_DIR_HOR);
    map[HappyFisher] = std::make_tuple(lv_color_hex(0x89f7fe),lv_color_hex(0x66a6ff),LV_GRAD_DIR_HOR);
    map[Blessing] = std::make_tuple(lv_color_hex(0xd1fdff),lv_color_hex(0xfddb92),LV_GRAD_DIR_VER);
    map[SharpeyeEagle] = std::make_tuple(lv_color_hex(0xb1f4cf),lv_color_hex(0x9890e3),LV_GRAD_DIR_VER);
    map[LadogaBottom] = std::make_tuple(lv_color_hex(0xd9ded8),lv_color_hex(0xebc0fd),LV_GRAD_DIR_VER);
    map[LemonGate] = std::make_tuple(lv_color_hex(0xf9f586),lv_color_hex(0x96fbc4),LV_GRAD_DIR_VER);
    map[ItmeoBranding] = std::make_tuple(lv_color_hex(0x2af598),lv_color_hex(0x009efd),LV_GRAD_DIR_VER);
    map[ZeusMiracle] = std::make_tuple(lv_color_hex(0xf6f3ff),lv_color_hex(0xcd9cf2),LV_GRAD_DIR_VER);//35

    // map[OldHat] =
    // map[StarWine] =

    map[HappyAcid] = std::make_tuple(lv_color_hex(0x72afd3),lv_color_hex(0x37ecba),LV_GRAD_DIR_VER);
    map[AwesomePine] = std::make_tuple(lv_color_hex(0xcfc7f8),lv_color_hex(0xebbba7),LV_GRAD_DIR_VER);
    map[NewYork] = std::make_tuple(lv_color_hex(0xace0f9),lv_color_hex(0xfff1eb),LV_GRAD_DIR_VER);

    // map[ShyRainbow] =
    map[MixedHopes] = std::make_tuple(lv_color_hex(0xfa71cd),lv_color_hex(0xc471f5),LV_GRAD_DIR_VER);
    map[FlyHigh] = std::make_tuple(lv_color_hex(0x6f86d6),lv_color_hex(0x48c6ef),LV_GRAD_DIR_VER);

    // map[StrongBliss] =
    map[FreshMilk] = std::make_tuple(lv_color_hex(0xf5efef),lv_color_hex(0xfeada6),LV_GRAD_DIR_VER);
    map[SnowAgain] = std::make_tuple(lv_color_hex(0xeef1f5),lv_color_hex(0xe6e9f0),LV_GRAD_DIR_VER);
    map[FebruaryInk] = std::make_tuple(lv_color_hex(0xe7f0fd),lv_color_hex(0xaccbee),LV_GRAD_DIR_VER);
    map[KindSteel] = std::make_tuple(lv_color_hex(0xe9defa),lv_color_hex(0xfbfcdb),LV_GRAD_DIR_HOR);
    map[SoftGrass] = std::make_tuple(lv_color_hex(0xdeecdd),lv_color_hex(0xc1dfc4),LV_GRAD_DIR_VER);
    map[GrownEarly] = std::make_tuple(lv_color_hex(0x3cba92),lv_color_hex(0x0ba360),LV_GRAD_DIR_VER);
    map[SharpBlues] = std::make_tuple(lv_color_hex(0x005bea),lv_color_hex(0x00c6fb),LV_GRAD_DIR_VER);
    map[ShadyWater] = std::make_tuple(lv_color_hex(0x74ebd5),lv_color_hex(0x9face6),LV_GRAD_DIR_HOR);
    map[DirtyBeauty] = std::make_tuple(lv_color_hex(0xbac8e0),lv_color_hex(0x6a85b6),LV_GRAD_DIR_VER);
    map[GreatWhale] = std::make_tuple(lv_color_hex(0x6991c7),lv_color_hex(0xa3bded),LV_GRAD_DIR_VER);
    map[TeenNotebook] = std::make_tuple(lv_color_hex(0xfbc8d4),lv_color_hex(0x9795f0),LV_GRAD_DIR_VER);
    map[PoliteRumors] = std::make_tuple(lv_color_hex(0x8989ba),lv_color_hex(0xa7a6cb),LV_GRAD_DIR_VER);

    // map[SweetPeriod] =
    // map[WideMatrix] =
    // map[SoftCherish] =

    map[RedSalvation] = std::make_tuple(lv_color_hex(0x453a94),lv_color_hex(0xf43b47),LV_GRAD_DIR_VER);

    // map[BurningSpring] =

    map[NightParty] = std::make_tuple(lv_color_hex(0xd43f8d),lv_color_hex(0x0250c5),LV_GRAD_DIR_VER);
    map[SkyGlider] = std::make_tuple(lv_color_hex(0x6e45e2),lv_color_hex(0x88d3ce),LV_GRAD_DIR_VER);
    map[HeavenPeach] = std::make_tuple(lv_color_hex(0x97d9e1),lv_color_hex(0xd9afd9),LV_GRAD_DIR_VER);
    map[PurpleDivision] = std::make_tuple(lv_color_hex(0xe5b2ca),lv_color_hex(0x7028e4),LV_GRAD_DIR_VER);
    map[AquaSplash] = std::make_tuple(lv_color_hex(0x13547a),lv_color_hex(0x80d0c7),LV_GRAD_DIR_HOR);

    // map[SpikyNaga] =

    map[LoveKiss] = std::make_tuple(lv_color_hex(0xffb199),lv_color_hex(0xff0844),LV_GRAD_DIR_VER);
    map[CleanMirror] = std::make_tuple(lv_color_hex(0x93a5cf),lv_color_hex(0xe4efe9),LV_GRAD_DIR_HOR);
    map[PremiumDark] = std::make_tuple(lv_color_hex(0x434343),lv_color_hex(0x000000),LV_GRAD_DIR_HOR);
    map[ColdEvening] = std::make_tuple(lv_color_hex(0xa2b6df),lv_color_hex(0x0c3483),LV_GRAD_DIR_VER);
    map[CochitiLake] = std::make_tuple(lv_color_hex(0x93a5cf),lv_color_hex(0xe4efe9),LV_GRAD_DIR_HOR);
    map[SummerGames] = std::make_tuple(lv_color_hex(0x92fe9d),lv_color_hex(0x00c9ff),LV_GRAD_DIR_HOR);
    map[PassionateBed] = std::make_tuple(lv_color_hex(0xff758c),lv_color_hex(0xff7eb3),LV_GRAD_DIR_HOR);
    map[MountainRock] = std::make_tuple(lv_color_hex(0x868f96),lv_color_hex(0x596164),LV_GRAD_DIR_HOR);
    map[DesertHump] = std::make_tuple(lv_color_hex(0xdfa579),lv_color_hex(0xc79081),LV_GRAD_DIR_VER);
    map[JungleDay] = std::make_tuple(lv_color_hex(0x8baaaa),lv_color_hex(0xae8b9c),LV_GRAD_DIR_HOR);
    map[PhoenixStart] = std::make_tuple(lv_color_hex(0xf83600),lv_color_hex(0xf9d423),LV_GRAD_DIR_HOR);
    map[OctoberSilence] = std::make_tuple(lv_color_hex(0xb721ff),lv_color_hex(0x21d4fd),LV_GRAD_DIR_HOR);
    map[FarawayRiver] = std::make_tuple(lv_color_hex(0x6e45e2),lv_color_hex(0x88d3ce),LV_GRAD_DIR_HOR);
    map[AlchemistLab] = std::make_tuple(lv_color_hex(0xd558c8),lv_color_hex(0x24d292),LV_GRAD_DIR_HOR);
    map[OverSun] = std::make_tuple(lv_color_hex(0xabecd6),lv_color_hex(0xfbed96),LV_GRAD_DIR_HOR);

    // map[PremiumWhite] =

    map[MarsParty] = std::make_tuple(lv_color_hex(0x9b23ea),lv_color_hex(0x5f72bd),LV_GRAD_DIR_VER);
    map[EternalConstance] = std::make_tuple(lv_color_hex(0x537895),lv_color_hex(0x09203f),LV_GRAD_DIR_VER);
    map[JapanBlush] = std::make_tuple(lv_color_hex(0xddd6f3),lv_color_hex(0xfaaca8),LV_GRAD_DIR_HOR);
    map[SmilingRain] = std::make_tuple(lv_color_hex(0xdcb0ed),lv_color_hex(0x99c99c),LV_GRAD_DIR_HOR);
    map[CloudyApple] = std::make_tuple(lv_color_hex(0xe3eeff),lv_color_hex(0xf3e7e9),LV_GRAD_DIR_VER);
    map[BigMango] = std::make_tuple(lv_color_hex(0xd09693),lv_color_hex(0xc71d6f),LV_GRAD_DIR_VER);
    map[HealthyWater] = std::make_tuple(lv_color_hex(0x96deda),lv_color_hex(0x50c9c3),LV_GRAD_DIR_HOR);
    map[AmourAmour] = std::make_tuple(lv_color_hex(0xfe5196),lv_color_hex(0xf77062),LV_GRAD_DIR_VER);
    map[RiskyConcrete] = std::make_tuple(lv_color_hex(0xebebeb),lv_color_hex(0xc4c5c7),LV_GRAD_DIR_VER);
    map[StrongStick] = std::make_tuple(lv_color_hex(0xa8caba),lv_color_hex(0x5d4157),LV_GRAD_DIR_HOR);
    map[ViciousStance] = std::make_tuple(lv_color_hex(0x29323c),lv_color_hex(0x485563),LV_GRAD_DIR_HOR);
    map[PaloAlto] = std::make_tuple(lv_color_hex(0xf4d03f),lv_color_hex(0x16a085),LV_GRAD_DIR_HOR);
    map[HappyMemories] = std::make_tuple(lv_color_hex(0xf09819),lv_color_hex(0xff5858),LV_GRAD_DIR_HOR);
    map[MidnightBloom] = std::make_tuple(lv_color_hex(0x4e4376),lv_color_hex(0x2b5876),LV_GRAD_DIR_HOR);
    map[Crystalline] = std::make_tuple(lv_color_hex(0x8ddad5),lv_color_hex(0x00cdac),LV_GRAD_DIR_HOR);

    map[PartyBliss] = std::make_tuple(lv_color_hex(0x04befe),lv_color_hex(0x4481eb),LV_GRAD_DIR_VER);
    map[ConfidentCloud] = std::make_tuple(lv_color_hex(0xf3e7e9),lv_color_hex(0xdad4ec),LV_GRAD_DIR_VER);
    map[LeCocktail] = std::make_tuple(lv_color_hex(0x874da2),lv_color_hex(0xc43a30),LV_GRAD_DIR_HOR);
    map[RiverCity] = std::make_tuple(lv_color_hex(0x04befe),lv_color_hex(0x4481eb),LV_GRAD_DIR_VER);
    map[FrozenBerry] = std::make_tuple(lv_color_hex(0xc7eafd),lv_color_hex(0xe8198b),LV_GRAD_DIR_VER);
    map[ChildCare] = std::make_tuple(lv_color_hex(0xfdd6bd),lv_color_hex(0xf794a4),LV_GRAD_DIR_HOR);
    map[FlyingLemon] = std::make_tuple(lv_color_hex(0x64b3f4),lv_color_hex(0xc2e59c),LV_GRAD_DIR_HOR);
    map[NewRetrowave] = std::make_tuple(lv_color_hex(0xa981bb),lv_color_hex(0x3b41c5),LV_GRAD_DIR_VER);
    map[HiddenJaguar] = std::make_tuple(lv_color_hex(0xf9f047),lv_color_hex(0x0fd850),LV_GRAD_DIR_VER);

    // map[AboveTheSky] =

    map[Nega] = std::make_tuple(lv_color_hex(0xee9ca7),lv_color_hex(0xffdde1),LV_GRAD_DIR_HOR);
    map[DenseWater] = std::make_tuple(lv_color_hex(0x3ab5b0),lv_color_hex(0x56317a),LV_GRAD_DIR_HOR);
    map[Seashore] = std::make_tuple(lv_color_hex(0x68e0cf),lv_color_hex(0x209cff),LV_GRAD_DIR_VER);
    map[MarbleWall] = std::make_tuple(lv_color_hex(0xe6dee9),lv_color_hex(0xbdc2e8),LV_GRAD_DIR_VER);
    map[CheerfulCaramel] = std::make_tuple(lv_color_hex(0xeacda3),lv_color_hex(0xe6b980),LV_GRAD_DIR_VER);
    map[NightSky] = std::make_tuple(lv_color_hex(0x2a5298),lv_color_hex(0x1e3c72),LV_GRAD_DIR_VER);
    map[MagicLake] = std::make_tuple(lv_color_hex(0xc9ffbf),lv_color_hex(0xffafbd),LV_GRAD_DIR_VER);
    map[YoungGrass] = std::make_tuple(lv_color_hex(0x00e3ae),lv_color_hex(0x9be15d),LV_GRAD_DIR_VER);
    map[ColorfulPeach] = std::make_tuple(lv_color_hex(0xed6ea0),lv_color_hex(0xec8c69),LV_GRAD_DIR_HOR);
    map[GentleCare] = std::make_tuple(lv_color_hex(0xffc3a0),lv_color_hex(0xffafbd),LV_GRAD_DIR_HOR);
    map[PlumBath] = std::make_tuple(lv_color_hex(0x6713d2),lv_color_hex(0xcc208e),LV_GRAD_DIR_VER);
    map[HappyUnicorn] = std::make_tuple(lv_color_hex(0x12fff7),lv_color_hex(0xb3ffab),LV_GRAD_DIR_VER);
    map[AfricanField] = std::make_tuple(lv_color_hex(0xFF6B95),lv_color_hex(0xFFC796),LV_GRAD_DIR_HOR);
    map[SolidStone] = std::make_tuple(lv_color_hex(0x243949),lv_color_hex(0x517fa4),LV_GRAD_DIR_HOR);
    map[OrangeJuice] = std::make_tuple(lv_color_hex(0xff9a44),lv_color_hex(0xfc6076),LV_GRAD_DIR_VER);
    map[GlassWater] = std::make_tuple(lv_color_hex(0xffffff),lv_color_hex(0xdfe9f3),LV_GRAD_DIR_VER);
    map[NorthMiracle] = std::make_tuple(lv_color_hex(0x00dbde),lv_color_hex(0xfc00ff),LV_GRAD_DIR_HOR);
    map[FruitBlend] = std::make_tuple(lv_color_hex(0xf9d423),lv_color_hex(0xff4e50),LV_GRAD_DIR_HOR);
    map[MillenniumPine] = std::make_tuple(lv_color_hex(0xf5d100),lv_color_hex(0x50cc7f),LV_GRAD_DIR_VER);
    map[HighFlight] = std::make_tuple(lv_color_hex(0x0acffe),lv_color_hex(0x495aff),LV_GRAD_DIR_HOR);
    map[MoleHall] = std::make_tuple(lv_color_hex(0x9bc5c3),lv_color_hex(0x616161),LV_GRAD_DIR_HOR);

    // map[SpaceShift] =

    map[ForestInei] = std::make_tuple(lv_color_hex(0xbfd9fe),lv_color_hex(0xdf89b5),LV_GRAD_DIR_VER);
    map[RoyalGarden] = std::make_tuple(lv_color_hex(0xed6ea0),lv_color_hex(0xec8c69),LV_GRAD_DIR_HOR);
    map[RichMetal] = std::make_tuple(lv_color_hex(0xd7d2cc),lv_color_hex(0x304352),LV_GRAD_DIR_HOR);
    map[JuicyCake] = std::make_tuple(lv_color_hex(0xf9d423),lv_color_hex(0xe14fad),LV_GRAD_DIR_VER);
    map[SmartIndigo] = std::make_tuple(lv_color_hex(0x7579ff),lv_color_hex(0xb224ef),LV_GRAD_DIR_VER);
    map[SandStrike] = std::make_tuple(lv_color_hex(0xc1c161),lv_color_hex(0xd4d4b1),LV_GRAD_DIR_HOR);
    map[NorseBeauty] = std::make_tuple(lv_color_hex(0xec77ab),lv_color_hex(0x7873f5),LV_GRAD_DIR_HOR);
    map[AquaGuidance] = std::make_tuple(lv_color_hex(0x00ecbc),lv_color_hex(0x007adf),LV_GRAD_DIR_VER);
    map[SunVeggie] = std::make_tuple(lv_color_hex(0x20E2D7),lv_color_hex(0xF9FEA5),LV_GRAD_DIR_HOR);

    // map[SeaLord] =
    // map[BlackSea] =

    map[GrassShampoo] = std::make_tuple(lv_color_hex(0xDFFFCD),lv_color_hex(0x39F3BB),LV_GRAD_DIR_HOR);

    // map[LandingAircraft] =

    map[WitchDance] = std::make_tuple(lv_color_hex(0xA8BFFF),lv_color_hex(0x884D80),LV_GRAD_DIR_HOR);
    map[SleeplessNight] = std::make_tuple(lv_color_hex(0x5271C4),lv_color_hex(0xECA1FE),LV_GRAD_DIR_HOR);
    map[AngelCare] = std::make_tuple(lv_color_hex(0xFFE29F),lv_color_hex(0xFF719A),LV_GRAD_DIR_HOR);
    map[CrystalRiver] = std::make_tuple(lv_color_hex(0x22E1FF),lv_color_hex(0x625EB1),LV_GRAD_DIR_HOR);
    map[SoftLipstick] = std::make_tuple(lv_color_hex(0xB6CEE8),lv_color_hex(0xF578DC),LV_GRAD_DIR_HOR);
    map[SaltMountain] = std::make_tuple(lv_color_hex(0xFFFEFF),lv_color_hex(0xD7FFFE),LV_GRAD_DIR_HOR);
    map[PerfectWhite] = std::make_tuple(lv_color_hex(0xE3FDF5),lv_color_hex(0xFFE6FA),LV_GRAD_DIR_HOR);
    map[FreshOasis] = std::make_tuple(lv_color_hex(0x7DE2FC),lv_color_hex(0xB9B6E5),LV_GRAD_DIR_HOR);
    map[StrictNovember] = std::make_tuple(lv_color_hex(0xCBBACC),lv_color_hex(0x2580B3),LV_GRAD_DIR_HOR);
    map[MorningSalad] = std::make_tuple(lv_color_hex(0xB7F8DB),lv_color_hex(0x50A7C2),LV_GRAD_DIR_HOR);
    map[DeepRelief] = std::make_tuple(lv_color_hex(0x7085B6),lv_color_hex(0xDEF3F8),LV_GRAD_DIR_HOR);

    // map[SeaStrike] =

    map[NightCall] = std::make_tuple(lv_color_hex(0xAC32E4),lv_color_hex(0x4801FF),LV_GRAD_DIR_HOR);
    map[SupremeSky] = std::make_tuple(lv_color_hex(0xD4FFEC),lv_color_hex(0x4596FB),LV_GRAD_DIR_HOR);
    map[LightBlue] = std::make_tuple(lv_color_hex(0x9EFBD3),lv_color_hex(0x45D4FB),LV_GRAD_DIR_HOR);
    map[MindCrawl] = std::make_tuple(lv_color_hex(0x473B7B),lv_color_hex(0x30D2BE),LV_GRAD_DIR_HOR);
    map[LilyMeadow] = std::make_tuple(lv_color_hex(0x65379B),lv_color_hex(0x6457C6),LV_GRAD_DIR_HOR);
    map[SugarLollipop] = std::make_tuple(lv_color_hex(0xA445B2),lv_color_hex(0xFF0066),LV_GRAD_DIR_HOR);
    map[SweetDessert] = std::make_tuple(lv_color_hex(0x7742B2),lv_color_hex(0xFD8BD9),LV_GRAD_DIR_HOR);
    map[MagicRay] = std::make_tuple(lv_color_hex(0xFF3CAC),lv_color_hex(0x2B86C5),LV_GRAD_DIR_HOR);
    map[TeenParty] = std::make_tuple(lv_color_hex(0xFF057C),lv_color_hex(0x321575),LV_GRAD_DIR_HOR);
    map[FrozenHeat] = std::make_tuple(lv_color_hex(0xFF057C),lv_color_hex(0x4CC3FF),LV_GRAD_DIR_HOR);

    // map[GagarinView] =
    // map[FabledSunset] =

    map[PerfectBlue] = std::make_tuple(lv_color_hex(0x3D4E81),lv_color_hex(0x6E7FF3),LV_GRAD_DIR_HOR);

    auto it = map.find(gradient);
    if (it == map.end())
    {
        rect_dsc->bg_color = lv_color_hex(0xFFFFFF);
        rect_dsc->bg_grad_color = lv_color_hex(0xFFFFFF);
        rect_dsc->bg_grad_dir = LV_GRAD_DIR_HOR;
    }
    else
    {
        auto tuple = map[gradient];
        rect_dsc->bg_color = std::get<0>(tuple);
        rect_dsc->bg_grad_color = std::get<1>(tuple);
        rect_dsc->bg_grad_dir = std::get<2>(tuple);
    }
}

使用示例:

int main(int argc, char **argv)
{
    lv_init();
    hal_init();

    lv_log_register_print_cb(esp32_log_cb);

    lv_obj_t * page = lv_canvas_create(lv_scr_act());
    lv_obj_set_size(page, LV_HOR_RES, LV_VER_RES);       //设置为屏幕大小

    lv_coord_t canvas_width = LV_HOR_RES;
    lv_coord_t canvas_height = LV_VER_RES;
    lv_img_cf_t color_format = LV_IMG_CF_TRUE_COLOR ; // ARGB8888格式

    size_t buffer_size = lv_img_cf_get_px_size(color_format) * canvas_width / 8 * canvas_height;

    std::unique_ptr<unsigned char[]> buffer = std::make_unique<unsigned char[]>(buffer_size);
    lv_canvas_set_buffer(page, buffer.get(), canvas_width, canvas_height, color_format);

    lv_draw_rect_dsc_t rect_dsc;
    lv_draw_rect_dsc_init(&rect_dsc);// 初始化矩形样式描述符

    Gradient::Preset set = Gradient::SoftLipstick;
    Gradient::setGradient(set,&rect_dsc);
    lv_canvas_draw_rect(page, 0, 0, LV_HOR_RES, LV_VER_RES, &rect_dsc);// 在Canvas上绘制一个矩形

    while (1)
    {
        lv_timer_handler();
        usleep(5 * 1000);
    }

    return 0;
}

相关内容:

Qt绘图:渐变_qt画圆环并填充颜色-CSDN博客

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/447659.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

allegro PCB设计心得笔记(二) -- ERROR(SPMHUT-144): Illegal arc specification

使用Allegro PCB Editor设计PCB&#xff0c;其中使用了中文丝印&#xff0c;设计完成后&#xff0c;进行Tools -> Database Check&#xff0c;提示如下错误&#xff1a; 对PCB文件进行反复检查&#xff0c;也没有找到具体问题&#xff0c;但是删除中文丝印封装后&#xff0c…

安卓玩机工具推荐----MTK芯片读写分区 备份分区 恢复分区 制作线刷包 工具操作解析

安卓玩机工具推荐----高通芯片9008端口读写分区 备份分区 恢复分区 制作线刷包 工具操作解析 安卓玩机工具推荐----ADB状态读写分区 备份分区 恢复分区 查看分区号 工具操作解析 前面做了两期教程。分别解析了下ADB端口与高通9008端口备份分区一些基础的常识&#xff0c;那么…

【Oracle之DataGuard的初步学习】

** 以下所有均是基于11G版本的 ** 一、DataGuard的部署方式 DG的部署最常用的方式就是直接在备库端部署一个空库然后再设置参数&#xff0c;但是这样做在初始同步时如果数据量过大会耗费较长的时间&#xff1b;相对来说这中方式比较简单不易出错。 还有一种方式就是通过rman的备…

okcc呼叫中心的客服代表应该具备哪些条件?

对每个企业管理者来说&#xff0c;选择最高效和最理想的呼叫中心提供商来简化他们的客户服务操作是一项关键工作内容。除了要确保提供商拥有处理这一重要任务所需的技术和资源之外&#xff0c;确定他们是否具备最高质量的合适人员来执行这项任务同样很重要。 客户服务代表是每…

多核多cluster多系统之间缓存一致性概述

目录 1.思考和质疑2.怎样去维护多核多系统缓存的一致性2.1多核缓存一致性2.2多Master之间的缓存一致性2.3dynamIQ架构同一个core中的L1和L2 cache 3.MESI协议的介绍4.ACE维护的缓存一致性5.软件定义的缓存和替换策略6.动图示例 本文转自 周贺贺&#xff0c;baron&#xff0c;代…

jvm八股

文章目录 运行时数据区域Java堆对象创建对象的内存布局对象的访问定位句柄直接指针 GC判断对象是否已死引用计数算法可达性分析算法 引用的类别垃圾收集算法分代收集理论标记清除算法标记复制算法标记整理算法 实现细节并发的可达性分析 垃圾收集器serial收集器ParNew收集器Par…

虾皮Shopee商品详情数据采集,item_get-根据ID取商品详情

Shopee&#xff08;虾皮&#xff09;是一个流行的东南亚电商平台&#xff0c;许多商家和开发者都对其商品详情数据感兴趣。为了采集Shopee上的商品详情数据&#xff0c;特别是根据商品ID获取商品详情&#xff0c;通常需要使用Shopee提供的API接口或者通过爬虫技术。然而&#x…

【Docker安装教程】Docker安装Redis详解

安装Redis前我们必须要保证Docker运行OK&#xff0c;如何安装Docker参考《CentOS 7 上的 Docker 安装与配置》 步骤 1: 拉取 Redis 镜像 首先&#xff0c;确保你已经安装了 Docker。然后&#xff0c;使用以下命令拉取最新的 Redis 镜像&#xff1a; docker pull redis](http…

强烈安利!FastReport 商业图形库,炫酷可视化报告开发首选~

FastReport Business Graphics .NET&#xff0c;是一款基于fastreport报表开发控件的商业图形库&#xff0c;借助 FastReport 商业图形库&#xff0c;您可以可视化不同的分层数据&#xff0c;构建业务图表以进行进一步分析和决策。利用数据呈现领域专家针对 .NET 7、.NET Core、…

微信小程序-分包

分包 1.什么是分包 分包指的是把一个完整的小程序项目&#xff0c;按照需求划分为不同的子包&#xff0c;在构建时打包成不同的分包&#xff0c;用户在使用时按需进行加载。 2.分包的好处 对小程序进行分包的好处主要有以下两点&#xff1a; 可以优化小程序首次启动的下载时间…

【Python】进阶学习:基于Matplotlib--使用plt.savefig()实现图形文件的保存

【Python】进阶学习&#xff1a;基于Matplotlib–使用plt.savefig()实现图形文件的保存 &#x1f308; 个人主页&#xff1a;高斯小哥 &#x1f525; 高质量专栏&#xff1a;Matplotlib之旅&#xff1a;零基础精通数据可视化、Python基础【高质量合集】、PyTorch零基础入门教程…

jvisualvm 工具的使用

文章目录 Visual GC 插件下载代码示例说明spaces 区域PermHeap Graphs 区域Compile Time&#xff08;编译时间&#xff09;Class Loader Time&#xff08;类加载时间&#xff09;GC TimeEden Space&#xff08;Eden 区&#xff09;Survivor 0 / Survivor 1&#xff08;S0 和 S1…

python 导入excel空间三维坐标 生成三维曲面地形图 5-4、线条平滑曲面且可通过面观察柱体变化(四)

环境 python:python-3.12.0-amd64 包: matplotlib 3.8.2 pandas 2.1.4 openpyxl 3.1.2 scipy 1.12.0 import pandas as pd import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from scipy.interpolate import griddata from matplotlib.c…

MySQL数据库在Windows和Linux中由于大小写默认规则不同,出现大小写问题如何解决?

Windows和Linux差异&#xff1a;在Windows上&#xff0c;lower_case_table_names默认为1&#xff0c;而在Linux上&#xff0c;默认值通常为0。因此&#xff0c;在Linux上更改这个设置更常见&#xff0c;以确保与Windows环境的兼容性或实现特定的大小写敏感性需求。 操作系统的大…

【活动】探索人工智能的“迷惑瞬间”:真实体验与技术挑战

&#x1f308;个人主页: 鑫宝Code &#x1f525;热门专栏: 闲话杂谈&#xff5c; 炫酷HTML | JavaScript基础 ​&#x1f4ab;个人格言: "如无必要&#xff0c;勿增实体" 文章目录 标题&#xff1a;探索人工智能的“迷惑瞬间”&#xff1a;真实体验与技术挑战引言…

深入理解React中的useReducer:管理复杂状态逻辑的利器

&#x1f90d; 前端开发工程师、技术日更博主、已过CET6 &#x1f368; 阿珊和她的猫_CSDN博客专家、23年度博客之星前端领域TOP1 &#x1f560; 牛客高级专题作者、打造专栏《前端面试必备》 、《2024面试高频手撕题》 &#x1f35a; 蓝桥云课签约作者、上架课程《Vue.js 和 E…

基于springboot实现摄影网站系统项目【项目源码】

基于springboot实现摄影网站系统演示 摘要 随着时代的进步&#xff0c;社会生产力高速发展&#xff0c;新技术层出不穷信息量急剧膨胀&#xff0c;整个社会已成为信息化的社会人们对信息和数据的利用和处理已经进入自动化、网络化和社会化的阶段。如在查找情报资料、处理银行账…

酒店客房管理系统|基于Springboot的酒店客房管理系统设计与实现(源码+数据库+文档)

酒店客房管理系统目录 目录 基于Springboot的酒店客房管理系统设计与实现 一、前言 二、系统功能设计 三、系统实现 1、 用户信息管理 2、会员信息管理 3、 客房信息管理 4、收藏客房管理 四、数据库设计 1、实体ER图 五、核心代码 六、论文参考 七、最新计算机…

【Web】浅聊Java反序列化之Rome——EqualsBeanObjectBean

目录 简介 原理分析 ToStringBean EqualsBean ObjectBean EXP ①EqualsBean直球纯享版 ②EqualsBean配合ObjectBean优化版 ③纯ObjectBean实现版 关于《浅聊Java反序列化》系列&#xff0c;纯是记录自己的学习历程&#xff0c;宥于本人水平有限&#xff0c;内容很水&a…

WiFi贴码推广能赚钱吗?掌握WiFi贴码推广技巧

“WiFi贴码推广能赚钱吗”是当前很多创业者关注的一个话题&#xff0c;WiFi贴码推广这一新兴的商业模式&#xff0c;是指商家在其门店或者特定场所提供免费WiFi&#xff0c;不需要输入密码wifi二维码即可连接&#xff0c;连接后合作商就会获得一定的收益。这种模式既方便了用户…