local pd <const> = playdate
local gfx <const> = pd.graphics

local icons = playdate.graphics.imagetable.new('images/memory')

class('Icon').extends(gfx.sprite)

function Icon:init(x, y, iconIndex)
    Icon.super.init(self)
    self:moveTo(x, y)
    self:setIcon(iconIndex)
end

function Icon:setIcon(iconIndex)
    local cache = gfx.image.new(22, 22)
    gfx.pushContext(cache)
        local icon = icons:getImage(iconIndex)
        icon:draw(0, 0)
    gfx.popContext()
    self:setImage(cache)
end

IconAccountBox = 1
IconAccount = 2
IconAlertBoxFill = 3
IconAlertBox = 4
IconAlertCircleFill = 5
IconAlertCircle = 6
IconAlertHexagonFill = 7
IconAlertHexagon = 8
IconAlertOctagon = 9
IconAlertRhombusFill = 10
IconAlertRhombus = 11
IconAlert = 12
IconAlignHorizontalCenter = 13
IconAlignHorizontalDistribute = 14
IconAlignHorizontalLeft = 15
IconAlignHorizontalRight = 16
IconAlignVerticalBottom = 17
IconAlignVerticalCenter = 18
IconAlignVerticalDistribute = 19
IconAlignVerticalTop = 20
IconAlphaAFill = 21
IconAlphaA = 22
IconAlphaBFill = 23
IconAlphaB = 24
IconAlphaCFill = 25
IconAlphaC = 26
IconAlphaDFill = 27
IconAlphaD = 28
IconAlphaEFill = 29
IconAlphaE = 30
IconAlphaFFill = 31
IconAlphaF = 32
IconAlphaGFill = 33
IconAlphaG = 34
IconAlphaHFill = 35
IconAlphaH = 36
IconAlphaIFill = 37
IconAlphaI = 38
IconAlphaJFill = 39
IconAlphaJ = 40
IconAlphaKFill = 41
IconAlphaK = 42
IconAlphaLFill = 43
IconAlphaL = 44
IconAlphaMFill = 45
IconAlphaM = 46
IconAlphaNFill = 47
IconAlphaN = 48
IconAlphaOFill = 49
IconAlphaO = 50
IconAlphaPFill = 51
IconAlphaP = 52
IconAlphaQFill = 53
IconAlphaQ = 54
IconAlphaRFill = 55
IconAlphaR = 56
IconAlphaSFill = 57
IconAlphaS = 58
IconAlphaTFill = 59
IconAlphaT = 60
IconAlphaUFill = 61
IconAlphaU = 62
IconAlphaVFill = 63
IconAlphaV = 64
IconAlphaWFill = 65
IconAlphaW = 66
IconAlphaXFill = 67
IconAlphaX = 68
IconAlphaYFill = 69
IconAlphaY = 70
IconAlphaZFill = 71
IconAlphaZ = 72
IconAnvil = 73
IconApplicationCode = 74
IconApplication = 75
IconAppsBoxFill = 76
IconAppsBox = 77
IconApps = 78
IconArchive = 79
IconArrowBottomLeftCircle = 80
IconArrowBottomLeft = 81
IconArrowBottomRightCircle = 82
IconArrowBottomRight = 83
IconArrowDownBold = 84
IconArrowDownBox = 85
IconArrowDownCircle = 86
IconArrowDownLeftBox = 87
IconArrowDownLeft = 88
IconArrowDownRightBox = 89
IconArrowDownRight = 90
IconArrowDown = 91
IconArrowLeftBold = 92
IconArrowLeftBox = 93
IconArrowLeftCircle = 94
IconArrowLeftDown = 95
IconArrowLeftRight = 96
IconArrowLeftUp = 97
IconArrowLeft = 98
IconArrowRightBold = 99
IconArrowRightBox = 100
IconArrowRightCircle = 101
IconArrowRightDown = 102
IconArrowRightUp = 103
IconArrowRight = 104
IconArrowTopLeftCircle = 105
IconArrowTopLeft = 106
IconArrowTopRightCircle = 107
IconArrowTopRight = 108
IconArrowUpBold = 109
IconArrowUpBox = 110
IconArrowUpCircle = 111
IconArrowUpDown = 112
IconArrowUpLeftBox = 113
IconArrowUpLeft = 114
IconArrowUpRightBox = 115
IconArrowUpRight = 116
IconArrowUp = 117
IconArrow = 118
IconAspectRatio = 119
IconAxe = 120
IconBagPersonalFill = 121
IconBagPersonal = 122
IconBank = 123
IconBarcode = 124
IconBattery0 = 125
IconBattery100 = 126
IconBattery25 = 127
IconBattery50 = 128
IconBattery75 = 129
IconBattleAxe = 130
IconBeer = 131
IconBell = 132
IconBlood = 133
IconBook = 134
IconBookmark = 135
IconBorderBottomLeftRight = 136
IconBorderBottomLeft = 137
IconBorderBottomRight = 138
IconBorderBottom = 139
IconBorderInside = 140
IconBorderLeftRight = 141
IconBorderLeft = 142
IconBorderNone = 143
IconBorderOutside = 144
IconBorderRight = 145
IconBorderTopBottom = 146
IconBorderTopLeftBottom = 147
IconBorderTopLeftRight = 148
IconBorderTopLeft = 149
IconBorderTopRightBottom = 150
IconBorderTopRight = 151
IconBorderTop = 152
IconBowArrow = 153
IconBow = 154
IconBoxLightDashedDownLeft = 155
IconBoxLightDashedDownRight = 156
IconBoxLightDashedHorizontal = 157
IconBoxLightDashedUpLeft = 158
IconBoxLightDashedUpRight = 159
IconBoxLightDashedVerticalHorizontal = 160
IconBoxLightDashedVertical = 161
IconBoxLightDoubleDownLeft = 162
IconBoxLightDoubleDownRight = 163
IconBoxLightDoubleHorizontalDown = 164
IconBoxLightDoubleHorizontalLightDown = 165
IconBoxLightDoubleHorizontalLightUp = 166
IconBoxLightDoubleHorizontalUp = 167
IconBoxLightDoubleHorizontal = 168
IconBoxLightDoubleRoundDownLeft = 169
IconBoxLightDoubleRoundDownRight = 170
IconBoxLightDoubleRoundUpLeft = 171
IconBoxLightDoubleRoundUpRight = 172
IconBoxLightDoubleUpLeft = 173
IconBoxLightDoubleUpRight = 174
IconBoxLightDoubleVerticalHorizontal = 175
IconBoxLightDoubleVerticalLeft = 176
IconBoxLightDoubleVerticalLightLeft = 177
IconBoxLightDoubleVerticalLightRight = 178
IconBoxLightDoubleVerticalRight = 179
IconBoxLightDoubleVertical = 180
IconBoxLightDownLeftCircle = 181
IconBoxLightDownLeftStippleInner = 182
IconBoxLightDownLeftStippleOuter = 183
IconBoxLightDownLeftStipple = 184
IconBoxLightDownLeft = 185
IconBoxLightDownRightCircle = 186
IconBoxLightDownRightStippleInner = 187
IconBoxLightDownRightStippleOuter = 188
IconBoxLightDownRightStipple = 189
IconBoxLightDownRight = 190
IconBoxLightFoldDownLeft = 191
IconBoxLightFoldDownRight = 192
IconBoxLightFoldUpLeft = 193
IconBoxLightFoldUpRight = 194
IconBoxLightHorizontalCircle = 195
IconBoxLightHorizontalDownStippleDownLeft = 196
IconBoxLightHorizontalDownStippleDownRight = 197
IconBoxLightHorizontalDownStippleDown = 198
IconBoxLightHorizontalDownStipple = 199
IconBoxLightHorizontalDown = 200
IconBoxLightHorizontalMenuDown = 201
IconBoxLightHorizontalMenuLeft = 202
IconBoxLightHorizontalMenuRight = 203
IconBoxLightHorizontalMenuUp = 204
IconBoxLightHorizontalStippleDown = 205
IconBoxLightHorizontalStippleUp = 206
IconBoxLightHorizontalStipple = 207
IconBoxLightHorizontalUpStippleDown = 208
IconBoxLightHorizontalUpStippleUpLeft = 209
IconBoxLightHorizontalUpStippleUpRight = 210
IconBoxLightHorizontalUpStippleUp = 211
IconBoxLightHorizontalUpStipple = 212
IconBoxLightHorizontalUp = 213
IconBoxLightHorizontal = 214
IconBoxLightRoundDownLeftStippleInner = 215
IconBoxLightRoundDownLeftStippleOuter = 216
IconBoxLightRoundDownLeftStipple = 217
IconBoxLightRoundDownLeft = 218
IconBoxLightRoundDownRightStippleInner = 219
IconBoxLightRoundDownRightStippleOuter = 220
IconBoxLightRoundDownRightStipple = 221
IconBoxLightRoundDownRight = 222
IconBoxLightRoundUpLeftStippleInner = 223
IconBoxLightRoundUpLeftStippleOuter = 224
IconBoxLightRoundUpLeftStipple = 225
IconBoxLightRoundUpLeft = 226
IconBoxLightRoundUpRightStippleInner = 227
IconBoxLightRoundUpRightStippleOuter = 228
IconBoxLightRoundUpRightStipple = 229
IconBoxLightRoundUpRight = 230
IconBoxLightUpLeftCircle = 231
IconBoxLightUpLeftStippleInner = 232
IconBoxLightUpLeftStippleOuter = 233
IconBoxLightUpLeftStipple = 234
IconBoxLightUpLeft = 235
IconBoxLightUpRightCircle = 236
IconBoxLightUpRightStippleInner = 237
IconBoxLightUpRightStippleOuter = 238
IconBoxLightUpRightStipple = 239
IconBoxLightUpRight = 240
IconBoxLightVerticalCircle = 241
IconBoxLightVerticalHorizontalStippleDownLeft = 242
IconBoxLightVerticalHorizontalStippleDownRight = 243
IconBoxLightVerticalHorizontalStippleDown = 244
IconBoxLightVerticalHorizontalStippleLeftDownRight = 245
IconBoxLightVerticalHorizontalStippleLeftUpRight = 246
IconBoxLightVerticalHorizontalStippleLeft = 247
IconBoxLightVerticalHorizontalStippleRightDownLeft = 248
IconBoxLightVerticalHorizontalStippleRightUpLeft = 249
IconBoxLightVerticalHorizontalStippleRight = 250
IconBoxLightVerticalHorizontalStippleUpLeft = 251
IconBoxLightVerticalHorizontalStippleUpRight = 252
IconBoxLightVerticalHorizontalStippleUp = 253
IconBoxLightVerticalHorizontalStipple = 254
IconBoxLightVerticalHorizontal = 255
IconBoxLightVerticalLeftStippleDownLeft = 256
IconBoxLightVerticalLeftStippleLeft = 257
IconBoxLightVerticalLeftStippleUpLeft = 258
IconBoxLightVerticalLeftStipple = 259
IconBoxLightVerticalLeft = 260
IconBoxLightVerticalMenuDown = 261
IconBoxLightVerticalMenuLeft = 262
IconBoxLightVerticalMenuRight = 263
IconBoxLightVerticalMenuUp = 264
IconBoxLightVerticalRightStippleDownRight = 265
IconBoxLightVerticalRightStippleLeft = 266
IconBoxLightVerticalRightStippleRight = 267
IconBoxLightVerticalRightStippleUpRight = 268
IconBoxLightVerticalRightStipple = 269
IconBoxLightVerticalRight = 270
IconBoxLightVerticalStippleLeft = 271
IconBoxLightVerticalStippleRight = 272
IconBoxLightVerticalStipple = 273
IconBoxLightVertical = 274
IconBoxOuterLightAll = 275
IconBoxOuterLightDashedAll = 276
IconBoxOuterLightDashedDownLeftRight = 277
IconBoxOuterLightDashedDownLeft = 278
IconBoxOuterLightDashedDownRight = 279
IconBoxOuterLightDashedDown = 280
IconBoxOuterLightDashedFoldDownLeft = 281
IconBoxOuterLightDashedFoldDownRight = 282
IconBoxOuterLightDashedFoldUpLeft = 283
IconBoxOuterLightDashedFoldUpRight = 284
IconBoxOuterLightDashedLeftRight = 285
IconBoxOuterLightDashedLeft = 286
IconBoxOuterLightDashedRight = 287
IconBoxOuterLightDashedUpDownLeft = 288
IconBoxOuterLightDashedUpDownRight = 289
IconBoxOuterLightDashedUpDown = 290
IconBoxOuterLightDashedUpLeftRight = 291
IconBoxOuterLightDashedUpLeft = 292
IconBoxOuterLightDashedUpRight = 293
IconBoxOuterLightDashedUp = 294
IconBoxOuterLightDownLeftRight = 295
IconBoxOuterLightDownLeftStipple = 296
IconBoxOuterLightDownLeft = 297
IconBoxOuterLightDownRightStipple = 298
IconBoxOuterLightDownRight = 299
IconBoxOuterLightDownStipple = 300
IconBoxOuterLightDownVerticalStippleLeft = 301
IconBoxOuterLightDownVerticalStippleRight = 302
IconBoxOuterLightDownVerticalStipple = 303
IconBoxOuterLightDown = 304
IconBoxOuterLightLeftHorizontalStippleDown = 305
IconBoxOuterLightLeftHorizontalStippleUp = 306
IconBoxOuterLightLeftHorizontalStipple = 307
IconBoxOuterLightLeftRightStipple = 308
IconBoxOuterLightLeftRight = 309
IconBoxOuterLightLeftStipple = 310
IconBoxOuterLightLeft = 311
IconBoxOuterLightRightHorizontalStippleDown = 312
IconBoxOuterLightRightHorizontalStippleUp = 313
IconBoxOuterLightRightHorizontalStipple = 314
IconBoxOuterLightRightStipple = 315
IconBoxOuterLightRight = 316
IconBoxOuterLightRoundDownLeft = 317
IconBoxOuterLightRoundDownRight = 318
IconBoxOuterLightRoundUpLeft = 319
IconBoxOuterLightRoundUpRight = 320
IconBoxOuterLightUpDownLeft = 321
IconBoxOuterLightUpDownRight = 322
IconBoxOuterLightUpDownStipple = 323
IconBoxOuterLightUpDown = 324
IconBoxOuterLightUpLeftRight = 325
IconBoxOuterLightUpLeftStipple = 326
IconBoxOuterLightUpLeft = 327
IconBoxOuterLightUpRightStipple = 328
IconBoxOuterLightUpRight = 329
IconBoxOuterLightUpStipple = 330
IconBoxOuterLightUpVerticalStippleLeft = 331
IconBoxOuterLightUpVerticalStippleRight = 332
IconBoxOuterLightUpVerticalStipple = 333
IconBoxOuterLightUp = 334
IconBox = 335
IconBriefcase = 336
IconBroadcast = 337
IconBugFill = 338
IconBug = 339
IconCalculator = 340
IconCalendarImport = 341
IconCalendarMonth = 342
IconCalendar = 343
IconCancel = 344
IconCardText = 345
IconCard = 346
IconCart = 347
IconCash = 348
IconCast = 349
IconCastle = 350
IconChartBar = 351
IconChatProcessing = 352
IconChat = 353
IconCheck = 354
IconCheckboxBlank = 355
IconCheckboxCross = 356
IconCheckboxIntermediateVariant = 357
IconCheckboxIntermediate = 358
IconCheckboxMarked = 359
IconCheckerLarge = 360
IconCheckerMedium = 361
IconCheckerSmall = 362
IconCheckerboard = 363
IconChestFill = 364
IconChest = 365
IconChevronDownCircle = 366
IconChevronDown = 367
IconChevronLeftCircle = 368
IconChevronLeft = 369
IconChevronRightCircle = 370
IconChevronRight = 371
IconChevronUpCircle = 372
IconChevronUp = 373
IconCircle = 374
IconClipboard = 375
IconClockFill = 376
IconClock = 377
IconCloseOutline = 378
IconClose = 379
IconCloudDown = 380
IconCloudUp = 381
IconCloud = 382
IconCoffee = 383
IconCoinCopper = 384
IconCoinElectrum = 385
IconCoinGold = 386
IconCoinPlatinum = 387
IconCoinSilver = 388
IconCommentText = 389
IconCommentUser = 390
IconComment = 391
IconCompassEastArrow = 392
IconCompassNorthArrow = 393
IconCompassNorthEast = 394
IconCompassNorthWest = 395
IconCompassSouthArrow = 396
IconCompassSouthEast = 397
IconCompassSouthWest = 398
IconCompassWestArrow = 399
IconCompass = 400
IconCreditCard = 401
IconCrossbow = 402
IconCrown = 403
IconCubeUnfolded = 404
IconCube = 405
IconDagger = 406
IconDatabase = 407
IconDevice = 408
IconDiamond = 409
IconDivision = 410
IconDoorBox = 411
IconDoorOpen = 412
IconDoor = 413
IconDotHexagonFill = 414
IconDotHexagon = 415
IconDotOctagonFill = 416
IconDotOctagon = 417
IconDownload = 418
IconEmail = 419
IconEyeFill = 420
IconEye = 421
IconFile = 422
IconFill = 423
IconFilter = 424
IconFire = 425
IconFlaskEmpty = 426
IconFlaskRoundBottomEmpty = 427
IconFlaskRoundBottom = 428
IconFlask = 429
IconFloppyDisk = 430
IconFolderOpen = 431
IconFolder = 432
IconFormatAlignBottom = 433
IconFormatAlignCenter = 434
IconFormatAlignJustify = 435
IconFormatAlignLeft = 436
IconFormatAlignRight = 437
IconFormatAlignTop = 438
IconFormatBold = 439
IconFormatFloatLeft = 440
IconFormatFloatRight = 441
IconFormatHorizontalAlignCenter = 442
IconFormatItalic = 443
IconFormatLineSpacing = 444
IconFormatTextMultiline = 445
IconFormatTextSingleLine = 446
IconFormatText = 447
IconFormatVerticalAlignCenter = 448
IconGamepadCenterFill = 449
IconGamepadCenter = 450
IconGamepadDownFill = 451
IconGamepadDownLeftFill = 452
IconGamepadDownLeft = 453
IconGamepadDownRightFill = 454
IconGamepadDownRight = 455
IconGamepadDown = 456
IconGamepadFill = 457
IconGamepadLeftFill = 458
IconGamepadLeft = 459
IconGamepadRightFill = 460
IconGamepadRight = 461
IconGamepadUpFill = 462
IconGamepadUpLeftFill = 463
IconGamepadUpLeft = 464
IconGamepadUpRightFill = 465
IconGamepadUpRight = 466
IconGamepadUp = 467
IconGamepad = 468
IconGlaive = 469
IconGlasses = 470
IconHalberd = 471
IconHeartBroken = 472
IconHeart = 473
IconHelpBoxFill = 474
IconHelpBox = 475
IconHelp = 476
IconHexagon = 477
IconHomeThatched = 478
IconImage = 479
IconJavalin = 480
IconJournal = 481
IconKey = 482
IconLabelVariant = 483
IconLabel = 484
IconLance = 485
IconLed = 486
IconLightbulb = 487
IconLinen = 488
IconLockOpen = 489
IconLock = 490
IconLogin = 491
IconLogout = 492
IconMagnifyMinus = 493
IconMagnifyPlus = 494
IconMap = 495
IconMenuBottomLeft = 496
IconMenuBottomRight = 497
IconMenuDownFill = 498
IconMenuDown = 499
IconMenuLeftFill = 500
IconMenuLeftRight = 501
IconMenuLeft = 502
IconMenuRightFill = 503
IconMenuRight = 504
IconMenuTopLeft = 505
IconMenuTopRight = 506
IconMenuUpDown = 507
IconMenuUpFill = 508
IconMenuUp = 509
IconMessageProcessing = 510
IconMessageText = 511
IconMessageUser = 512
IconMessage = 513
IconMicrophone = 514
IconMinusBoxFill = 515
IconMinusBox = 516
IconMinusCircleFill = 517
IconMinusCircle = 518
IconMinus = 519
IconMonitorImage = 520
IconMonitor = 521
IconMultiply = 522
IconMusicNote = 523
IconNecklace = 524
IconNoteNailed = 525
IconNote = 526
IconNotebook = 527
IconNotification = 528
IconNumber = 529
IconOctagon = 530
IconPaperclip = 531
IconPause = 532
IconPeace = 533
IconPencil = 534
IconPickaxe = 535
IconPictogrammers = 536
IconPike = 537
IconPlay = 538
IconPlusBoxFill = 539
IconPlusBox = 540
IconPlusCircleFill = 541
IconPlusCircle = 542
IconPlus = 543
IconPoll = 544
IconPound = 545
IconQuarterstaff = 546
IconRadioboxMarked = 547
IconRadiobox = 548
IconRange = 549
IconRelativeScale = 550
IconRemoveCircle = 551
IconRing = 552
IconRotateClockwise = 553
IconRotateCounterclockwise = 554
IconScimitar = 555
IconScript = 556
IconSearch = 557
IconShield = 558
IconShovel = 559
IconSkull = 560
IconSliderEnd = 561
IconSliderRight = 562
IconSpeaker = 563
IconSpear = 564
IconStool = 565
IconStop = 566
IconSword = 567
IconTableTopDoorHorizontal = 568
IconTableTopDoorOneWayDown = 569
IconTableTopDoorOneWayLeft = 570
IconTableTopDoorOneWayRight = 571
IconTableTopDoorOneWayUp = 572
IconTableTopDoorSecretHorizontal = 573
IconTableTopDoorSecretVertical = 574
IconTableTopDoorVertical = 575
IconTableTopHorizontalRotateClockwise = 576
IconTableTopHorizontalRotateCounterclockwise = 577
IconTableTopHorizontalStairsAscendLeft = 578
IconTableTopHorizontalStairsAscendRight = 579
IconTableTopHorizontalStairsDescendDown = 580
IconTableTopHorizontalStairsDescendLeft = 581
IconTableTopHorizontalStairsDescendRight = 582
IconTableTopHorizontalStairsDescendUp = 583
IconTableTopSpiralStairsDown = 584
IconTableTopSpiralStairsLeft = 585
IconTableTopSpiralStairsRight = 586
IconTableTopSpiralStairsRoundDown = 587
IconTableTopSpiralStairsRoundLeft = 588
IconTableTopSpiralStairsRoundRight = 589
IconTableTopSpiralStairsRoundUp = 590
IconTableTopSpiralStairsUp = 591
IconTableTopStairsDown = 592
IconTableTopStairsLeft = 593
IconTableTopStairsRight = 594
IconTableTopStairsUp = 595
IconTableTopVerticalRotateClockwise = 596
IconTableTopVerticalRotateCounterclockwise = 597
IconTableTopVerticalStairsAscendDown = 598
IconTableTopVerticalStairsAscendUp = 599
IconTagText = 600
IconTag = 601
IconTarget = 602
IconTent = 603
IconTerminal = 604
IconTextBox = 605
IconTextImage = 606
IconTileCautionHeavy = 607
IconTileCautionThin = 608
IconTileDiamondHex = 609
IconTimeSand = 610
IconToggleSwitchOff = 611
IconToggleSwitchOn = 612
IconToolbox = 613
IconTooltipAboveAlert = 614
IconTooltipAboveHelp = 615
IconTooltipAboveText = 616
IconTooltipAbove = 617
IconTooltipBelowAlert = 618
IconTooltipBelowHelp = 619
IconTooltipBelowText = 620
IconTooltipBelow = 621
IconTooltipEndAlert = 622
IconTooltipEndHelp = 623
IconTooltipEndText = 624
IconTooltipEnd = 625
IconTooltipStartAlert = 626
IconTooltipStartHelp = 627
IconTooltipStartText = 628
IconTooltipStart = 629
IconTorch = 630
IconToyBrick = 631
IconTrash = 632
IconTrident = 633
IconUmbrella = 634
IconUpload = 635
IconVolumeHigh = 636
IconVolumeLow = 637
IconVolumeMedium = 638
IconVolumeMute = 639
IconWallFill = 640
IconWallFrontDamaged = 641
IconWallFrontGate = 642
IconWallFront = 643
IconWall = 644
IconWaterFill = 645
IconWater = 646
IconWeightFill = 647
IconWeight = 648
IconWell = 649
IconWhip = 650
IconWind = 651