Better timing and text and layout

This commit is contained in:
Ruben van de Ven 2024-06-22 16:03:32 +02:00
parent 1590fa5615
commit 7e0f414c66
4 changed files with 55 additions and 9 deletions

View file

@ -39,10 +39,14 @@ def filter_date(date: str):
return date return date
def clean_title(title: str) -> str:
return title.removesuffix('/').strip()
with open("data/batch2/Rapport_transit_1.csv", encoding='utf-8-sig') as fp: with open("data/batch2/Rapport_transit_1.csv", encoding='utf-8-sig') as fp:
# items # items
reader = csv.DictReader(fp, delimiter=",") reader = csv.DictReader(fp, delimiter=",")
for item in reader: for item in reader:
item['Title'] = clean_title(item['Title'])
item['Publication Date'] = filter_date(item['Publication Date']) item['Publication Date'] = filter_date(item['Publication Date'])
item['Sort Date'] = item['Publication Date'][-4:] # some dates are ranges, only sort by last year item['Sort Date'] = item['Publication Date'][-4:] # some dates are ranges, only sort by last year
items.append(item) items.append(item)

View file

@ -160,6 +160,7 @@
occurences: occurences, occurences: occurences,
}; };
let tease_title = writable(true); //.filter((m, i) => i < 100);
let drawn_motions = writable(<Motion[]>[]); //.filter((m, i) => i < 100); let drawn_motions = writable(<Motion[]>[]); //.filter((m, i) => i < 100);
$: opacity = Math.max(0.055, Math.min(0.3, 70 / $drawn_motions.length)); $: opacity = Math.max(0.055, Math.min(0.3, 70 / $drawn_motions.length));
let overlay_motions = writable(<Motion[]>[]); //.filter((m, i) => i < 100); let overlay_motions = writable(<Motion[]>[]); //.filter((m, i) => i < 100);
@ -167,6 +168,7 @@
let current_item = writable(<Item | null>null); //.filter((m, i) => i < 100); let current_item = writable(<Item | null>null); //.filter((m, i) => i < 100);
const viz_data: VizData = { const viz_data: VizData = {
tease_title: tease_title,
drawn_motions: drawn_motions, drawn_motions: drawn_motions,
overlay_motions: overlay_motions, overlay_motions: overlay_motions,
events: events, events: events,
@ -219,7 +221,9 @@
}); });
</script> </script>
<h1>library of <span id="motiontitle">motions</span></h1> {#if $tease_title}
<h1 in:fade={{duration: 3000}}>library of <span id="motiontitle">motions</span></h1>
{/if}
<div id="about"> <div id="about">
<span <span
>Work by <em>Ruben van de Ven</em> for the >Work by <em>Ruben van de Ven</em> for the
@ -303,6 +307,7 @@
</div> </div>
{#if $current_item} {#if $current_item}
<div id="current"> <div id="current">
<h3>Logbook of</h3>
<h2>{$current_item.title}</h2> <h2>{$current_item.title}</h2>
<p>{[$current_item.Date, $current_item.Publisher, $current_item.Place].filter((e) => e).join(', ')}</p> <p>{[$current_item.Date, $current_item.Publisher, $current_item.Place].filter((e) => e).join(', ')}</p>
</div> </div>
@ -334,6 +339,13 @@
.entry { .entry {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
h3{
margin-bottom: 10px;;
}
p{
margin:0;
}
.date { .date {
width: 180px; width: 180px;
} }
@ -350,6 +362,7 @@
height: var(--divider-width); height: var(--divider-width);
width: var(--divider-width); width: var(--divider-width);
background-color: rgb(79 70 229); background-color: rgb(79 70 229);
// background-color: rgba(70, 229, 112, 1);;
border-radius: calc(var(--divider-width) / 2); border-radius: calc(var(--divider-width) / 2);
// border: solid 5px black; // border: solid 5px black;
flex-grow: 0; flex-grow: 0;
@ -375,9 +388,22 @@
} }
p { p {
} }
padding-bottom: 30px;;
} }
} }
} }
h1{
animation: fadeout;
animation-duration: 3s;
animation-delay: 10s;
animation-timing-function: ease-in;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
@keyframes fadeout{
0%{opacity: 1;}
100%{opacity: 0;}
}
#fps { #fps {
position: absolute; position: absolute;
top: 10px; top: 10px;
@ -420,8 +446,9 @@
} }
} }
#overlay_motions path { #overlay_motions path {
stroke: rgba(255, 255, 0, 0.641); // strokrgba(70, 229, 120, 0.641)41);
stroke-width: 5; stroke: rgba(70, 229, 112, 0.5);
stroke-width: 4;
opacity: 1; opacity: 1;
} }

View file

@ -92,7 +92,7 @@ export function importMovement(idx, orig: Object, locations: Map<string, Locatio
target: target, target: target,
item: item, item: item,
start_date: new Date(orig["Event Start Date and Time"]), // TODO: validate unfortunate M/D/Y format start_date: new Date(orig["Event Start Date and Time"]), // TODO: validate unfortunate M/D/Y format
end_date: new Date(orig["Event Start Date and Time"]), // TODO: validate unfortunate M/D/Y format end_date: new Date(orig["Event End Date and Time"]), // TODO: validate unfortunate M/D/Y format
_original: orig, _original: orig,
d: "", // bit of a hacky workaround, refactor in object d: "", // bit of a hacky workaround, refactor in object
}; };
@ -125,6 +125,7 @@ export type Log = {
// Type used by the scenes with all reactive Writables for drawable objects // Type used by the scenes with all reactive Writables for drawable objects
export type VizData = { export type VizData = {
tease_title: Writable<Boolean>,
drawn_motions: Writable<Motion[]>, drawn_motions: Writable<Motion[]>,
overlay_motions: Writable<Motion[]>, overlay_motions: Writable<Motion[]>,
events: Writable<Log[]>, events: Writable<Log[]>,

View file

@ -61,6 +61,8 @@ export class All extends Scene {
constructor(data: Data, viz_data: VizData, nextScene: CallableFunction) { constructor(data: Data, viz_data: VizData, nextScene: CallableFunction) {
super(data, viz_data, nextScene); super(data, viz_data, nextScene);
viz_data.tease_title.set(true)
// start setInterval to trigger additions per 100 or so to drawn_movements (rendered on map) // start setInterval to trigger additions per 100 or so to drawn_movements (rendered on map)
// when done, trigger parent.done() // when done, trigger parent.done()
// this.allMovements = data.movements; // this.allMovements = data.movements;
@ -130,6 +132,8 @@ export class Timeline extends Scene {
constructor(data: Data, viz_data: VizData, nextScene: CallableFunction) { constructor(data: Data, viz_data: VizData, nextScene: CallableFunction) {
super(data, viz_data, nextScene); super(data, viz_data, nextScene);
viz_data.tease_title.set(false)
// clear canvas // clear canvas
// this.viz_data.drawn_motions.update(items => []) // this.viz_data.drawn_motions.update(items => [])
@ -150,7 +154,7 @@ export class Timeline extends Scene {
console.log('start timeline', item, movements) console.log('start timeline', item, movements)
this.interval = setInterval(this.tick.bind(this), 3000); this.interval = setInterval(this.tick.bind(this), 5000);
} }
@ -171,15 +175,16 @@ export class Timeline extends Scene {
} }
const pick = item_movements[Math.floor(Math.random() * item_movements.length)] const pick = item_movements[Math.floor(Math.random() * item_movements.length)]
pick[1].sort((a: Movement, b: Movement) => (a.end_date - b.end_date)) pick[1].sort((a: Movement, b: Movement) => (b.end_date - a.end_date)) // reverse order
return pick; return pick;
} }
tick() { tick() {
if (this.step >= this.movements.length) { if (this.step >= this.movements.length) {
console.log('this', 'done') clearInterval(this.interval)
setTimeout(this.nextScene.bind(this), 5000)
// todo: ease out all entries // todo: ease out all entries
this.nextScene() // this.nextScene()
return; return;
} }
@ -188,7 +193,16 @@ export class Timeline extends Scene {
this.drawMovements([mov], 2000, true) this.drawMovements([mov], 2000, true)
// const motion: Motion = { duration: 2000, movement: mov }; // const motion: Motion = { duration: 2000, movement: mov };
// TODO: also consider end date // TODO: also consider end date
const log: Log = { date: mov.start_date, title: `Transfer to ${mov.target.name}`, description: "" };
let title = this.step === 0 ?
`'${mov.item.title}' arrived at ${mov.target.name}`:
`Item arrived at ${mov.target.name}`;
let description = `Travelling from ${mov.source.name}`;
const log: Log = { date: mov.end_date, title: title, description: description };
// const log2: Log = { date: mov.start_date, title: title_send, description: "" };
// console.log(motion, motion.movement.source, motion.movement.target) // console.log(motion, motion.movement.source, motion.movement.target)
// this.viz_data.overlay_motions.update(items => ([...items, motion])) // this.viz_data.overlay_motions.update(items => ([...items, motion]))
this.viz_data.events.update(items => ([...items, log])) this.viz_data.events.update(items => ([...items, log]))