mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 18:44:05 +09:00
weather to not use expensive math; colormap now also holds cvec
This commit is contained in:
@@ -3,6 +3,7 @@ package net.torvald.terrarum
|
|||||||
import com.badlogic.gdx.files.FileHandle
|
import com.badlogic.gdx.files.FileHandle
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.Pixmap
|
import com.badlogic.gdx.graphics.Pixmap
|
||||||
|
import net.torvald.gdx.graphics.Cvec
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2017-06-17.
|
* Created by minjaesong on 2017-06-17.
|
||||||
@@ -22,6 +23,7 @@ class GdxColorMap {
|
|||||||
pixmap.getPixel(it % pixmap.width, it / pixmap.width)
|
pixmap.getPixel(it % pixmap.width, it / pixmap.width)
|
||||||
}
|
}
|
||||||
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
||||||
|
dataCvec = dataRaw.map { Cvec(it) }.toTypedArray()
|
||||||
|
|
||||||
pixmap.dispose()
|
pixmap.dispose()
|
||||||
}
|
}
|
||||||
@@ -35,6 +37,7 @@ class GdxColorMap {
|
|||||||
pixmap.getPixel(it % pixmap.width, it / pixmap.width)
|
pixmap.getPixel(it % pixmap.width, it / pixmap.width)
|
||||||
}
|
}
|
||||||
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
||||||
|
dataCvec = dataRaw.map { Cvec(it) }.toTypedArray()
|
||||||
|
|
||||||
if (disposePixmap) pixmap.dispose()
|
if (disposePixmap) pixmap.dispose()
|
||||||
}
|
}
|
||||||
@@ -42,6 +45,7 @@ class GdxColorMap {
|
|||||||
constructor(color: Color) {
|
constructor(color: Color) {
|
||||||
dataRaw = intArrayOf(color.toIntBits())
|
dataRaw = intArrayOf(color.toIntBits())
|
||||||
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
||||||
|
dataCvec = dataRaw.map { Cvec(it) }.toTypedArray()
|
||||||
width = 1
|
width = 1
|
||||||
height = 1
|
height = 1
|
||||||
is2D = false
|
is2D = false
|
||||||
@@ -50,6 +54,7 @@ class GdxColorMap {
|
|||||||
constructor(gradStart: Color, gradEnd: Color) {
|
constructor(gradStart: Color, gradEnd: Color) {
|
||||||
dataRaw = intArrayOf(gradStart.toIntBits(), gradEnd.toIntBits())
|
dataRaw = intArrayOf(gradStart.toIntBits(), gradEnd.toIntBits())
|
||||||
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
||||||
|
dataCvec = dataRaw.map { Cvec(it) }.toTypedArray()
|
||||||
width = 1
|
width = 1
|
||||||
height = 2
|
height = 2
|
||||||
is2D = true
|
is2D = true
|
||||||
@@ -57,7 +62,7 @@ class GdxColorMap {
|
|||||||
|
|
||||||
private val dataRaw: IntArray
|
private val dataRaw: IntArray
|
||||||
private val dataGdxColor: Array<Color>
|
private val dataGdxColor: Array<Color>
|
||||||
//private val dataCvec: Array<Cvec>
|
private val dataCvec: Array<Cvec>
|
||||||
val width: Int
|
val width: Int
|
||||||
val height: Int
|
val height: Int
|
||||||
val is2D: Boolean
|
val is2D: Boolean
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
// interpolate R, G, B and A
|
// interpolate R, G, B and A
|
||||||
val scale = (timeInSec % dataPointDistance).toFloat() / dataPointDistance // [0.0, 1.0]
|
val scale = (timeInSec % dataPointDistance).toFloat() / dataPointDistance // [0.0, 1.0]
|
||||||
|
|
||||||
val newCol = CIELuvUtil.getGradient(scale, colourThis, colourNext)
|
val newCol = colourThis.cpy().lerp(colourNext, scale)//CIELuvUtil.getGradient(scale, colourThis, colourNext)
|
||||||
|
|
||||||
/* // very nice monitor code
|
/* // very nice monitor code
|
||||||
// 65 -> 66 | 300 | 19623 | RGB8(255, 0, 255) -[41%]-> RGB8(193, 97, 23) | * `230`40`160`
|
// 65 -> 66 | 300 | 19623 | RGB8(255, 0, 255) -[41%]-> RGB8(193, 97, 23) | * `230`40`160`
|
||||||
|
|||||||
Reference in New Issue
Block a user