mirror of
https://github.com/bspeice/speice.io
synced 2024-12-22 08:38:09 -05:00
Add solo transforms
This commit is contained in:
parent
f3c463360e
commit
ce4fdd154a
@ -41,7 +41,7 @@ export function randomInteger(min: number, max: number) {
|
||||
return Math.floor(Math.random() * (max - min)) + min;
|
||||
}
|
||||
|
||||
export function weightedChoice<T>(choices: [number, T][]) {
|
||||
export function weightedChoice<T>(choices: [number, T][]): [number, T] {
|
||||
const weightSum = choices.reduce(
|
||||
(current, [weight, _t]) => current + weight,
|
||||
0
|
||||
@ -51,7 +51,7 @@ export function weightedChoice<T>(choices: [number, T][]) {
|
||||
for (var i = 0; i < choices.length; i++) {
|
||||
const [weight, t] = choices[i];
|
||||
if (choice < weight) {
|
||||
return t;
|
||||
return [i, t];
|
||||
}
|
||||
|
||||
choice -= weight;
|
||||
|
@ -80,12 +80,12 @@ export class Flame {
|
||||
|
||||
constructor(public readonly transforms: [number, Transform][]) {}
|
||||
|
||||
step() {
|
||||
const transform = weightedChoice(this.transforms);
|
||||
step(): void {
|
||||
const [_index, transform] = weightedChoice(this.transforms);
|
||||
[this.x, this.y] = transform.apply(this.x, this.y);
|
||||
}
|
||||
|
||||
current() {
|
||||
current(): [number, number] {
|
||||
return [this.x, this.y];
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ export class FlameFinal extends Flame {
|
||||
[this.x, this.y] = this.final.apply(this.x, this.y);
|
||||
}
|
||||
|
||||
override current() {
|
||||
override current(): [number, number] {
|
||||
if (!this.didLog) {
|
||||
this.didLog = true;
|
||||
console.trace(`Getting final xform to plot`);
|
||||
|
86
posts/2023/06/flam3/4a-solo.ts
Normal file
86
posts/2023/06/flam3/4a-solo.ts
Normal file
@ -0,0 +1,86 @@
|
||||
import { weightedChoice } from "./0-utility";
|
||||
import {
|
||||
transform1,
|
||||
transform1Weight,
|
||||
transform2Weight,
|
||||
transform3,
|
||||
transform3Weight,
|
||||
} from "./2a-variations";
|
||||
import { transform2Post } from "./2b-post";
|
||||
import { FlameFinal, transformFinal } from "./2c-final";
|
||||
import { AccumulateLogarithmic } from "./3c-logarithmic";
|
||||
|
||||
export class AccumulateSolo extends AccumulateLogarithmic {
|
||||
constructor(
|
||||
width: number,
|
||||
height: number,
|
||||
public readonly soloTransform: number
|
||||
) {
|
||||
super(width, height);
|
||||
}
|
||||
|
||||
accumulateWithIndex(x: number, y: number, index: number) {
|
||||
if (index === this.soloTransform) {
|
||||
super.accumulate(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class FlameIndex extends FlameFinal {
|
||||
protected index: number = -1;
|
||||
|
||||
step() {
|
||||
const [index, transform] = weightedChoice(this.transforms);
|
||||
this.index = index;
|
||||
[this.x, this.y] = transform.apply(this.x, this.y);
|
||||
}
|
||||
|
||||
currentWithIndex(): [number, number, number] {
|
||||
const [finalX, finalY] = this.final.apply(this.x, this.y);
|
||||
return [finalX, finalY, this.index];
|
||||
}
|
||||
}
|
||||
|
||||
export function render(
|
||||
flame: FlameIndex,
|
||||
quality: number,
|
||||
accumulator: AccumulateSolo,
|
||||
image: ImageData
|
||||
) {
|
||||
const iterations = quality * image.width * image.height;
|
||||
|
||||
for (var i = 0; i < iterations; i++) {
|
||||
flame.step();
|
||||
|
||||
if (i > 20) {
|
||||
const [flameX, flameY, index] = flame.currentWithIndex();
|
||||
accumulator.accumulateWithIndex(flameX, flameY, index);
|
||||
}
|
||||
}
|
||||
|
||||
accumulator.render(image);
|
||||
}
|
||||
|
||||
export const flameIndex = new FlameIndex(
|
||||
[
|
||||
[transform1Weight, transform1],
|
||||
[transform2Weight, transform2Post],
|
||||
[transform3Weight, transform3],
|
||||
],
|
||||
transformFinal
|
||||
);
|
||||
|
||||
export function renderTransform1(image: ImageData) {
|
||||
const accumulateTransform1 = new AccumulateSolo(image.width, image.height, 0);
|
||||
render(flameIndex, 10, accumulateTransform1, image);
|
||||
}
|
||||
|
||||
export function renderTransform2(image: ImageData) {
|
||||
const accumulateTransform2 = new AccumulateSolo(image.width, image.height, 1);
|
||||
render(flameIndex, 10, accumulateTransform2, image);
|
||||
}
|
||||
|
||||
export function renderTransform3(image: ImageData) {
|
||||
const accumulateTransform3 = new AccumulateSolo(image.width, image.height, 2);
|
||||
render(flameIndex, 10, accumulateTransform3, image);
|
||||
}
|
@ -8,6 +8,11 @@ import { renderFinal } from "./2c-final";
|
||||
import { renderBinary } from "./3a-binary";
|
||||
import { renderLinear } from "./3b-linear";
|
||||
import { renderLogarithmic } from "./3c-logarithmic";
|
||||
import {
|
||||
renderTransform1,
|
||||
renderTransform2,
|
||||
renderTransform3,
|
||||
} from "./4a-solo";
|
||||
|
||||
export default function () {
|
||||
const Layout = Blog({
|
||||
@ -17,7 +22,7 @@ export default function () {
|
||||
});
|
||||
return (
|
||||
<Layout>
|
||||
<div>
|
||||
{/* <div>
|
||||
<Canvas f={gasket} />
|
||||
<Canvas f={renderBaseline} />
|
||||
</div>
|
||||
@ -28,7 +33,10 @@ export default function () {
|
||||
<div>
|
||||
<Canvas f={renderLinear} />
|
||||
<Canvas f={renderLogarithmic} />
|
||||
</div>
|
||||
</div> */}
|
||||
<Canvas f={renderTransform1} />
|
||||
<Canvas f={renderTransform2} />
|
||||
<Canvas f={renderTransform3} />
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
@ -1,43 +1,4 @@
|
||||
<Flames name="variations">
|
||||
<flame name="baseline" version="Apophysis 2.08 beta" size="600 600" center="0 0" scale="150" oversample="1" filter="0.2" quality="1" background="0 0 0" brightness="4" gamma="4" >
|
||||
<xform weight="0.422330042096567" color="0" pdj="1" coefs="1.51523 0.740356 -3.048677 -1.455964 0.724135 -0.362059" pdj_a="1.09358" pdj_b="2.13048" pdj_c="2.54127" pdj_d="2.37267" />
|
||||
<xform weight="0.564534951145298" color="0" julia="1" coefs="-1.381068 1.381068 -1.381068 -1.381068 0 0" />
|
||||
<xform weight="0.0131350067581356" color="0" linear="1" popcorn="1" coefs="0.031393 -0.031367 0.031367 0.031393 0 0" />
|
||||
<palette count="256" format="RGB">
|
||||
3A78875998AA5E9DAC78B1C2599BAB36798A2252601B3438
|
||||
1823270D1215080705010101000000000002080A090A0809
|
||||
0C070D0B090A030406010101000000000000000000000000
|
||||
0A00000B0A080E1213101B1F21202830243A6737357A3C31
|
||||
864424643A22452F1838251427190E1C12080E0F110E1213
|
||||
1014152110183720105D320FA0531F9144180409080A1312
|
||||
0C13140E13160E15160E17160F16171015180B161C0A1225
|
||||
0A0F2F101E37172E40294C5A3B6B7549798758879975A9BE
|
||||
79A7BF7EA6C0949FA2AA9985B7A27BC4AB72AC965A867654
|
||||
61574E4C4D48374343474141573F3F7C5C36B0914EC1DFF9
|
||||
C4E4FAC8E9FCBEE1F4B5DAEDB2D8EDB0D6ED5398A7386D78
|
||||
1D424A1B3B4219343B1B383E1D3C411D3B462155623D7C8B
|
||||
46747F4F6C74636454785C3584663E917047BEA467CEA86A
|
||||
DEAC6DC5975EAC834F916E41765A335F3D21431F21241625
|
||||
1F202B1A2B321A2D321B30331B323A1628360E1D220E1D21
|
||||
0F1D20101C1F111C1E111D1E121E1E2B21153B2B1B725432
|
||||
85542C9854279B63369F7346AD7C3AB2763AB18F4FB39453
|
||||
B69957B99B56BC9E56C19651CB9346AB6A2A9851254E341D
|
||||
2F261B10181A0E15160C12120D11120A10100D0D0D0C0E0E
|
||||
0B0F100B10120C11140F191A101F221829331A373B1E3D52
|
||||
1A40551744591D556420424C1E3B431D3C41112C33102328
|
||||
101B1D10191E111820101D2311242A1B33371B3A3F276476
|
||||
3E637D556284545F7D7759355C41261B30290E16180B0F0F
|
||||
0908060405030002010A0E0F12171A1C1B2B17343C3C7481
|
||||
467F8F508A9E528FA23E81923769722E69772248512B545E
|
||||
35616C688589807F85939FB5ABD6E6B3D6EA89B7CE5891A4
|
||||
467E92356C81194A6B1A373F132C310E1C1F050409020205
|
||||
0000020000000101010800000B0000170A000D0D0D0D1110
|
||||
0F0E14100F141F11082619082F1904210F05111717101919
|
||||
0F1B1B101F22182C2B252E2B282D311B2E321A2E2F162E30
|
||||
1325270E191B0F1314190D0F2E1211461A27552227612723
|
||||
6C303A56213D3033381C343619343B15383E193A431A4E5C
|
||||
</palette>
|
||||
</flame>
|
||||
<flame name="post xform" version="Apophysis 2.08 beta" size="600 600" center="0 0" scale="150" oversample="1" filter="0.2" quality="1" background="0 0 0" brightness="4" gamma="4" >
|
||||
<xform weight="0.422330042096567" color="0" pdj="1" coefs="1.51523 0.740356 -3.048677 -1.455964 0.724135 -0.362059" pdj_a="1.09358" pdj_b="2.13048" pdj_c="2.54127" pdj_d="2.37267" />
|
||||
<xform weight="0.564534951145298" color="0" julia="1" coefs="-1.381068 1.381068 -1.381068 -1.381068 0 0" />
|
||||
@ -117,4 +78,43 @@
|
||||
6C303A56213D3033381C343619343B15383E193A431A4E5C
|
||||
</palette>
|
||||
</flame>
|
||||
<flame name="baseline" version="Apophysis 2.08 beta" size="600 600" center="0 0" scale="150" oversample="1" filter="0.2" quality="1" background="0 0 0" brightness="4" gamma="4" >
|
||||
<xform weight="0.422330042096567" color="0" pdj="1" coefs="1.51523 0.740356 -3.048677 -1.455964 0.724135 -0.362059" pdj_a="1.09358" pdj_b="2.13048" pdj_c="2.54127" pdj_d="2.37267" />
|
||||
<xform weight="0.564534951145298" color="0.13" julia="1" coefs="-1.381068 1.381068 -1.381068 -1.381068 0 0" />
|
||||
<xform weight="0.0131350067581356" color="0.844" linear="1" popcorn="1" coefs="0.031393 -0.031367 0.031367 0.031393 0 0" />
|
||||
<palette count="256" format="RGB">
|
||||
FF0000D31616BD2121A72C2C9137377C4242714747664D4D
|
||||
3A63631D7171008080008B8B00969600A1A100ACAC00B1B1
|
||||
00B7B700CCCC00D7D700E2E200EDED00F8F800FBFB00FFFF
|
||||
2CF0FF42E8FF58E0FF6DD8FF83D1FF8ECDFF99C9FFAFC2FF
|
||||
C5BAFFFFA6FFE9A2FFD39FFFBD9CFFA799FF9C97FF9196FF
|
||||
668FFF508CFF3A89FF2485FF0E82FF0781FF0080FF0B80FF
|
||||
1680FF2C80FF3780FF4280FF4D80FF5880FF5D80FF6380FF
|
||||
7980FF7785F4758BE96A96D35FA1BD59A6B254ACA749B791
|
||||
3EC17C28D7501DE23A12ED2409F61200FF0016E9002CD300
|
||||
58A7006D9100837C00996600AF5000BA4500C53A00DB2400
|
||||
F10E00E90B00D31600BD2100B22600A72C009137007C4200
|
||||
5058003A6300246E001973000E79000080000A7500146A00
|
||||
1E5F003249003C3E004633004B2D005028005A1D00651200
|
||||
8100008C00009800009E0000A40000AF0000BB0000C70000
|
||||
D20000EA0000F00000F60000FD0000F2160BE82C16DD4221
|
||||
C76E37BC8342B2994DACA452A7AF589CC56392DB6E87F179
|
||||
80FF8080E99680E39B80DEA180D3AC80C8B780BEC180B3CC
|
||||
809DE2808EF08080FF7A80F47580E96A80D35F80BD5480A7
|
||||
4980913380662D805B2880501D803A12802407800E008000
|
||||
2C841A3784204285265887336E8940838B4D998D5AAF8E66
|
||||
C59073FF9595FF9393FF9292FF9090FF8D8DFF8B8BFF8888
|
||||
FF8383FF8181FF8080FF7E7EFF7B7BFF7979FF7777FF7783
|
||||
FF768EFF769AFF75A6FF75B1FF74BDFF74C9FF73D4FF73E0
|
||||
FF72F8FF71FBFF71FFFF6BEDFF65DBFF5FC9FF5AB7FF54A5
|
||||
FF4E93FF4881FF426FFF3C5DFF374BFF2D2DFA293AF62548
|
||||
F12155ED1E63E81A70E4167EDF128BDB0E99D60AA6D106B4
|
||||
CD02C1CA00CACC00B9CE00A7CF0096D10085D30073D50062
|
||||
D70050D8003FDA002EDC001CDE000BDF0000D90C06D4180C
|
||||
CE2413C82F19C33B1FBD4725B7532BB25F32AC6B38A6773E
|
||||
9D8A489D7E429E723C9E66359F5B2FA04F29A04323A1371D
|
||||
A12B16A21F10A3130AA30804A40000A000009C0000980000
|
||||
9400009000008C00008800008400008000007C0000750000
|
||||
</palette>
|
||||
</flame>
|
||||
</Flames>
|
||||
|
@ -38,46 +38,6 @@
|
||||
6C303A56213D3033381C343619343B15383E193A431A4E5C
|
||||
</palette>
|
||||
</flame>
|
||||
<flame name="final xform" version="Apophysis 2.08 beta" size="600 600" center="0 0" scale="150" oversample="1" filter="0.2" quality="1" background="0 0 0" brightness="4" gamma="4" >
|
||||
<xform weight="0.422330042096567" color="0" pdj="1" coefs="1.51523 0.740356 -3.048677 -1.455964 0.724135 -0.362059" pdj_a="1.09358" pdj_b="2.13048" pdj_c="2.54127" pdj_d="2.37267" />
|
||||
<xform weight="0.564534951145298" color="0" julia="1" coefs="-1.381068 1.381068 -1.381068 -1.381068 0 0" />
|
||||
<xform weight="0.0131350067581356" color="0" linear="1" popcorn="1" coefs="0.031393 -0.031367 0.031367 0.031393 0 0" post="1 0 0 1 0.241352 0.271521" />
|
||||
<finalxform color="0" symmetry="1" julia="1" coefs="2 0 0 2 0 0" />
|
||||
<palette count="256" format="RGB">
|
||||
3A78875998AA5E9DAC78B1C2599BAB36798A2252601B3438
|
||||
1823270D1215080705010101000000000002080A090A0809
|
||||
0C070D0B090A030406010101000000000000000000000000
|
||||
0A00000B0A080E1213101B1F21202830243A6737357A3C31
|
||||
864424643A22452F1838251427190E1C12080E0F110E1213
|
||||
1014152110183720105D320FA0531F9144180409080A1312
|
||||
0C13140E13160E15160E17160F16171015180B161C0A1225
|
||||
0A0F2F101E37172E40294C5A3B6B7549798758879975A9BE
|
||||
79A7BF7EA6C0949FA2AA9985B7A27BC4AB72AC965A867654
|
||||
61574E4C4D48374343474141573F3F7C5C36B0914EC1DFF9
|
||||
C4E4FAC8E9FCBEE1F4B5DAEDB2D8EDB0D6ED5398A7386D78
|
||||
1D424A1B3B4219343B1B383E1D3C411D3B462155623D7C8B
|
||||
46747F4F6C74636454785C3584663E917047BEA467CEA86A
|
||||
DEAC6DC5975EAC834F916E41765A335F3D21431F21241625
|
||||
1F202B1A2B321A2D321B30331B323A1628360E1D220E1D21
|
||||
0F1D20101C1F111C1E111D1E121E1E2B21153B2B1B725432
|
||||
85542C9854279B63369F7346AD7C3AB2763AB18F4FB39453
|
||||
B69957B99B56BC9E56C19651CB9346AB6A2A9851254E341D
|
||||
2F261B10181A0E15160C12120D11120A10100D0D0D0C0E0E
|
||||
0B0F100B10120C11140F191A101F221829331A373B1E3D52
|
||||
1A40551744591D556420424C1E3B431D3C41112C33102328
|
||||
101B1D10191E111820101D2311242A1B33371B3A3F276476
|
||||
3E637D556284545F7D7759355C41261B30290E16180B0F0F
|
||||
0908060405030002010A0E0F12171A1C1B2B17343C3C7481
|
||||
467F8F508A9E528FA23E81923769722E69772248512B545E
|
||||
35616C688589807F85939FB5ABD6E6B3D6EA89B7CE5891A4
|
||||
467E92356C81194A6B1A373F132C310E1C1F050409020205
|
||||
0000020000000101010800000B0000170A000D0D0D0D1110
|
||||
0F0E14100F141F11082619082F1904210F05111717101919
|
||||
0F1B1B101F22182C2B252E2B282D311B2E321A2E2F162E30
|
||||
1325270E191B0F1314190D0F2E1211461A27552227612723
|
||||
6C303A56213D3033381C343619343B15383E193A431A4E5C
|
||||
</palette>
|
||||
</flame>
|
||||
<flame name="baseline" version="Apophysis 2.08 beta" size="600 600" center="0 0" scale="150" oversample="1" filter="0.2" quality="1" background="0 0 0" brightness="4" gamma="4" >
|
||||
<xform weight="0.422330042096567" color="0" pdj="1" coefs="1.51523 0.740356 -3.048677 -1.455964 0.724135 -0.362059" pdj_a="1.09358" pdj_b="2.13048" pdj_c="2.54127" pdj_d="2.37267" />
|
||||
<xform weight="0.564534951145298" color="0.13" julia="1" coefs="-1.381068 1.381068 -1.381068 -1.381068 0 0" />
|
||||
@ -117,4 +77,44 @@
|
||||
9400009000008C00008800008400008000007C0000750000
|
||||
</palette>
|
||||
</flame>
|
||||
<flame name="final xform" version="Apophysis 2.08 beta" size="600 600" center="0 0" scale="150" oversample="1" filter="0.2" quality="1" background="1 1 1" brightness="4" gamma="4" >
|
||||
<xform weight="0.422330042096567" color="0.349" pdj="1" coefs="1.51523 0.740356 -3.048677 -1.455964 0.724135 -0.362059" pdj_a="1.09358" pdj_b="2.13048" pdj_c="2.54127" pdj_d="2.37267" />
|
||||
<xform weight="0.564534951145298" color="0" julia="1" coefs="-1.381068 1.381068 -1.381068 -1.381068 0 0" />
|
||||
<xform weight="0.0131350067581356" color="0.844" linear="1" popcorn="1" coefs="0.031393 -0.031367 0.031367 0.031393 0 0" post="1 0 0 1 0.241352 0.271521" />
|
||||
<finalxform color="0" symmetry="1" julia="1" coefs="2 0 0 2 0 0" />
|
||||
<palette count="256" format="RGB">
|
||||
7E3037762C45722B496E2A4E6A2950672853652754632656
|
||||
5C265C5724595322574D2155482153462050451F4E441E4D
|
||||
431E4C3F1E473F1E453F1E433F1E3F3F1E3B3E1E393E1E37
|
||||
421D36431C38451C3A471B3B491B3C4A1A3C4B1A3D4D1A3E
|
||||
4F19405318435517445817465A16475D15495E154960154A
|
||||
65134E6812506B12526E1153711055720F55740F55770E57
|
||||
7A0E59810C58840B58880A588B09588F0858910756930755
|
||||
9A05539D0451A1034FA5024BA90147AA0046AC0045B00242
|
||||
B4043DBB0634BE082EC20A29C30B27C50C26C90F1DCC1116
|
||||
D32110D6280EDA300CDC380ADF4109E04508E24A08E45106
|
||||
E75704EA6402EC6B01EE7300EE7600EF7A00F07E00F18300
|
||||
F29000F29300F39600F39900F39C00F3A000F3A100F3A201
|
||||
F2A502F1A805F0A906EFAA08EEA909EEA80AEDA60CEBA50F
|
||||
E5A313E1A113DD9F13DB9E13D99D14D49C15D09815CC9518
|
||||
C79318BE8B1ABB891BB9871DB4811FB07D1FAB7621A67123
|
||||
9C6227975C289256299053298E502A89482C853F2D803A2E
|
||||
7E3037762C45742B47722B496E2A4E6A2951672853632656
|
||||
5C265C5724595322575022564E2255482153452050451F4E
|
||||
431E4C3F1E473E1D463D1D453F1E43411E413F1E3B3E1E37
|
||||
421D36421D38431D3B451C3A471B3A491B3C4B1A3D4D1A3E
|
||||
4F19405318435418445518455817465A16475D154960154A
|
||||
65134E66124F6812506B12526E1153711055740F55770E57
|
||||
7A0E597E0D57810C58840B58880A588B09588F0858930755
|
||||
9A05539C04529E0452A1034FA5024BA90147AC0045B00242
|
||||
B4043DB7053ABB0634BE0831C20A29C50C26C90F1DCC1116
|
||||
D01711D32110D72A0EDA300CDD390ADF4109E24A08E45106
|
||||
E75704E95F03EA6402EC6C01EE7300EF7A00F07E00F18300
|
||||
F28900F29000F39300F39600F39C00F3A000F3A100F3A201
|
||||
F2A502F2A503F1A805F0A807EFAA08EEA80AEDA60CEBA50F
|
||||
E9A411E5A313E1A113DD9F13D99D14D49C15D09815CC9518
|
||||
C79318C38F1ABE8B1AB9871DB4811FB07D1FAB7621A67123
|
||||
A16A249C6227975E289256298E502A89482C853F2D803A2E
|
||||
</palette>
|
||||
</flame>
|
||||
</Flames>
|
||||
|
Loading…
Reference in New Issue
Block a user