speice.io/blog/2024-11-15-playing-with-fire/3-log-density/index.mdx

55 lines
1.7 KiB
Plaintext
Raw Normal View History

2024-12-01 15:16:30 -05:00
---
slug: 2024/11/playing-with-fire-log-density
2024-12-02 22:36:25 -05:00
title: "Playing with fire: Log-density and color"
2024-12-01 15:16:30 -05:00
date: 2024-11-15 14:00:00
authors: [bspeice]
tags: []
---
So far, our `plot()` function has been fairly simple; map an input coordinate
to a specific pixel, and color in that pixel.
This works well for simple function systems (like Sierpinski's Gasket),
but more complex systems (like our reference parameters) produce grainy images.
Every time we "turn on" pixels that have already been enabled, we're wasting work.
Can we do something more intelligent with that information?
<!-- truncate -->
## Image histograms
To start with, it's worth demonstrating how much work is actually "wasted."
2024-12-01 21:57:10 -05:00
We'll render the reference image again, but this time, set each pixel's transparency
based on how many times we encounter it in the chaos game:
2024-12-01 15:16:30 -05:00
import CodeBlock from "@theme/CodeBlock";
2024-12-01 21:57:10 -05:00
import paintLinearSource from "!!raw-loader!./paintLinear"
<CodeBlock language="typescript">{paintLinearSource}</CodeBlock>
import Canvas from "../src/Canvas";
import FlameHistogram from "./FlameHistogram";
2024-12-01 21:57:10 -05:00
import {paintLinear} from "./paintLinear";
2024-12-08 16:17:21 -05:00
<Canvas><FlameHistogram quality={5} paint={paintLinear}/></Canvas>
2024-12-01 21:57:10 -05:00
## Log display
import paintLogarithmicSource from "!!raw-loader!./paintLogarithmic"
<CodeBlock language="typescript">{paintLogarithmicSource}</CodeBlock>
2024-12-01 21:57:10 -05:00
import {paintLogarithmic} from './paintLogarithmic'
2024-12-08 16:17:21 -05:00
<Canvas><FlameHistogram quality={5} paint={paintLogarithmic}/></Canvas>
2024-12-02 22:36:25 -05:00
## Color
import paintColorSource from "!!raw-loader!./paintColor"
<CodeBlock language="typescript">{paintColorSource}</CodeBlock>
2024-12-02 22:36:25 -05:00
import FlameColor from "./FlameColor";
<Canvas><FlameColor quality={15}/></Canvas>