Add Random push/pop + palette colors add via hex strings (#179)

This commit is contained in:
Ricardo Matias
2021-03-11 16:20:49 +01:00
committed by GitHub
parent c43e6c633e
commit a9a12811c4
2 changed files with 40 additions and 12 deletions

View File

@@ -102,7 +102,7 @@ class PaletteStudio(
private var onChangeListener = {}
private fun loadCollection(newCollection: Collections) {
fun loadCollection(newCollection: Collections) {
val collectionPath: URL = collectionsResource.getValue(newCollection)
palettes = mutableListOf()
@@ -177,6 +177,7 @@ class PaletteStudio(
onChangeListener = fn
}
@JvmName("addColorRGBaList")
fun add(newPalette: List<ColorRGBa>) {
palette = createPalette(newPalette)
@@ -184,6 +185,15 @@ class PaletteStudio(
paletteIndex = palettes.lastIndex
}
@JvmName("addHexList")
fun add(hexColors: List<String>) {
val newPalette = hexColors.map { ColorRGBa.fromHex(it) }
palette = createPalette(newPalette)
palettes.add(newPalette)
paletteIndex = palettes.lastIndex
}
fun loadExternal(filePath: String) {
palettes = mutableListOf()
@@ -222,8 +232,8 @@ class PaletteStudio(
palette = createPalette(colors)
}
fun changeCollection(newCollection: Collections) {
loadCollection(newCollection)
fun newCollection() {
palettes.clear()
}
private fun registerKeybindings(keyboard: Keyboard) {
@@ -249,4 +259,4 @@ class PaletteStudio(
override fun setup(program: Program) {
registerKeybindings(program.keyboard)
}
}
}