This repository was archived by the owner on Jan 4, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 120
api total colors
Jesse Freeman edited this page Nov 11, 2021
·
1 revision
The TotalColors() API returns the total number of colors in the ColorChip. By default, it returns all of the available colors from the ColorChip. By supplying true for the ignoreEmpty argument, it returns only colors that are not transparent (#FF00FF).
TotalColors ( ignoreEmpty )| Name | Value | Description |
|---|---|---|
| ignoreEmpty | bool | This is an optional parameter that defaults to false to get all available colors from the ColorChip or supply true for all non-transparent (#FF00FF) colors. |
| Value | Description |
|---|---|
| int | This method returns the total number of colors in the color chip based on the ignoreEmpty argument's value. |
In this example, we are going to display the total color values. Running this code will output the following:
![]()
function Init()
-- Example Title
DrawText("TotalColors()", 8, 8, DrawMode.TilemapCache, "large", 15)
DrawText("Lua Example", 8, 16, DrawMode.TilemapCache, "medium", 15, -4)
-- Get total colors values
local totalColors = TotalColors()
local usedColors = TotalColors(true)
-- Display the used vs total colors on the screen
DrawText("Total Colors " .. usedColors .. "/" .. totalColors, 1, 4, DrawMode.Tile, "large", 15)
end
function Draw()
-- Redraw the display
RedrawDisplay()
endnamespace PixelVision8.Player
{
class TotalColorsExample : GameChip
{
public override void Init()
{
// Example Title
DrawText("TotalColors()", 8, 8, DrawMode.TilemapCache, "large", 15);
DrawText("C Sharp Example", 8, 16, DrawMode.TilemapCache, "medium", 15, -4);
// Get total colors values
var totalColors = TotalColors();
var usedColors = TotalColors(true);
// Display the used vs total colors on the screen
DrawText("Total Colors " + usedColors + "/" + totalColors, 1, 4, DrawMode.Tile, "large", 15);
}
public override void Draw()
{
// Redraw the display
RedrawDisplay();
}
}
}- Game Project
- Lua Games (coming soon)
- C# Sharp Games
- C# Sharp Vs Lua
- API Cheat Sheet
- Enums
- Visual Studio Code
- Atom
- Tiled (Coming Soon)
- Aseprite (Coming Soon)
- AddScript
- BackgroundColor
- Button
- CalculateDistance
- CalculateIndex
- CalculatePosition
- CharacterToPixelData
- Clamp
- Clear
- Color
- ColorsPerSprite
- Display
- DrawMetaSprite
- DrawPixels
- DrawRect
- DrawSprite
- DrawText
- DrawTilemap
- Flag
- InputString
- IsChannelPlaying
- Key
- LoadTilemap
- MaxSpriteCount
- MouseButton
- MousePosition
- NewCanvas
- NewPoint
- NewRect
- PaletteOffset
- PauseSong
- PlaySong
- PlaySound
- ReadAllMetadata
- ReadMetadata
- ReadSaveData
- RedrawDisplay
- Repeat
- ReplaceColor
- RewindSong
- ScrollPosition
- SongData
- Sound
- SplitLines
- SpriteSize
- Sprite
- StopSong
- StopSound
- Tile
- TilemapSize
- TotalColors
- TotalSprites
- UpdateTiles
- WordWrap
- WriteSaveData