diff options
| author | Akshay Nair <phenax5@gmail.com> | 2026-10-24 20:15:58 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2026-10-24 20:15:58 +0530 |
| commit | 5e51938952b5275debce06e5cee4a5f71eacaeb1 (patch) | |
| tree | 97a56033a6049f89f62754bbd37c6767d3c932e4 /src/main | |
| parent | e251d719710a951954e2dd9f93544afc601a6600 (diff) | |
| download | art-playground-openrndr-5e51938952b5275debce06e5cee4a5f71eacaeb1.tar.gz art-playground-openrndr-5e51938952b5275debce06e5cee4a5f71eacaeb1.zip | |
Use different coloring for blood
Diffstat (limited to '')
| -rw-r--r-- | src/main/kotlin/blood/BloodProgram.kt | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/src/main/kotlin/blood/BloodProgram.kt b/src/main/kotlin/blood/BloodProgram.kt index ed70213..25d0060 100644 --- a/src/main/kotlin/blood/BloodProgram.kt +++ b/src/main/kotlin/blood/BloodProgram.kt @@ -7,7 +7,6 @@ import org.openrndr.WindowMultisample import org.openrndr.application import org.openrndr.color.* import org.openrndr.draw.* -import org.openrndr.extra.noise.perlinLinear import org.openrndr.extra.shadestyles.fills.gradients.gradient import org.openrndr.math.IntVector2 import org.openrndr.math.Vector2 @@ -63,32 +62,50 @@ fun main() = application { fun nextState(dt: Double): Cells { return Array(cell_count.y) { row -> + var f = feedRate + var k = killRate Array(cell_count.x) { col -> val d = cells[row][col] val lapl = laplaceThyNeighbour(row, col) - val u = -d.x * d.y * d.y + feedRate * (1 - d.x) - val v = d.x * d.y * d.y - (feedRate + killRate) * d.y + val u = -d.x * d.y * d.y + f * (1 - d.x) + val v = d.x * d.y * d.y - (f + k) * d.y var change = lapl * diffusion + Vector2(u, v) coerceIn(d + change * dt, 0.0, 1.0) } } } - val col_flesh = ColorRGBa(0.53, 0.20, 0.20) - val col_blood = ColorRGBa(0.34, 0.00, 0.00) + fun srgb(r: Double, g: Double, b: Double): ColorRGBa { + return ColorRGBa(Math.pow(r, 2.2), Math.pow(g, 2.2), Math.pow(b, 2.2)) + } + + val col_flesh = srgb(0.53, 0.20, 0.20) + val col_blood = srgb(0.34, 0.00, 0.00) + + val col_s1 = srgb(0.06, 0.28, 0.8) + val col_s2 = srgb(0.90, 0.71, 0.13) + val col_s3 = srgb(0.04, 0.38, 0.34) + val col_s4 = srgb(0.07, 0.1, 0.88) + val col_bg = col_s1.shade(0.1) fun drawCell(pos: Vector2, amounts: Vector2) { - var color = col_flesh.opacify(0.0) + var color = col_bg.opacify(0.0) - run { - val noiseScale = 0.99 - val noise = perlinLinear(100, pos.x * noiseScale, pos.y * noiseScale) - color = mix(color, col_flesh.shade(1.1).opacify(0.14), noise) - } + // run { + // val noiseScale = 0.99 + // val noise = perlinLinear(100, pos.x * noiseScale, pos.y * noiseScale) + // color = mix(color, col_bg.shade(1.1).opacify(0.14), noise) + // } - color = mix(color, col_blood, (amounts.y * 3).coerceIn(0.0, 1.0)) - if (amounts.y > 0.38) color = mix(color, ColorRGBa.BLACK, amounts.y * 0.08) - if (amounts.y > 0.40) color = mix(color, ColorRGBa.WHITE, amounts.y * 0.28) + // color = mix(color, col_blood, (amounts.y * 3).coerceIn(0.0, 1.0)) + // if (amounts.y > 0.38) color = mix(color, ColorRGBa.BLACK, amounts.y * 0.08) + // if (amounts.y > 0.40) color = mix(color, ColorRGBa.WHITE, amounts.y * 0.28) + val v = (amounts.y * 3).coerceIn(0.0, 1.0) + color = mix(color, col_s1, v) + if (amounts.y > 0.20) color = mix(color, col_s1, v) + if (amounts.y > 0.26) color = mix(color, col_s2, v) + if (amounts.y > 0.30) color = mix(color, col_s1, v) + if (amounts.y > 0.34) color = mix(color, col_s1.shade(0.4), v) drawer.fill = color drawer.stroke = drawer.fill @@ -98,11 +115,11 @@ fun main() = application { extend { repeat(config.iterationsPerFrame) { cells = nextState(0.8) } } extend { - drawer.clear(col_flesh) + drawer.clear(col_bg) drawer.shadeStyle = gradient<ColorRGBa> { - stops[0.4] = col_flesh - stops[0.9] = col_flesh.shade(0.65) + stops[0.4] = col_bg + stops[0.9] = col_bg.shade(0.65) radial {} } drawer.rectangle( |
