diff options
author | San Jacobs | 2023-07-20 22:48:01 +0200 |
---|---|---|
committer | San Jacobs | 2023-07-20 22:48:01 +0200 |
commit | 80362dbf454bb4bc5b19deb438b7c485240ef367 (patch) | |
tree | d2f49177855d72e2a4c66a944643d0ca6a9d503a | |
parent | 50ff7b2e4fb5902f87b80e95f40f76ab45bc6a70 (diff) | |
download | satscalc-80362dbf454bb4bc5b19deb438b7c485240ef367.tar.gz satscalc-80362dbf454bb4bc5b19deb438b7c485240ef367.tar.bz2 satscalc-80362dbf454bb4bc5b19deb438b7c485240ef367.zip |
Fractions come in pairs now
-rw-r--r-- | src/main.odin | 12 | ||||
-rw-r--r-- | src/time.odin | 24 |
2 files changed, 19 insertions, 17 deletions
diff --git a/src/main.odin b/src/main.odin index b6af03d..bcbaeec 100644 --- a/src/main.odin +++ b/src/main.odin @@ -86,13 +86,11 @@ main :: proc() { fmt.println("\nNew day!") - day.fractions[0] = daycount(diff(beginning, day.call)) - fmt.println(day.fractions[0]) - for each_block, i in day.blocks { if i == day.total_timeblocks do break - day.fractions[i+1] = daycount(diff(beginning, each_block.end)) - fmt.println(day.fractions[i+1]) + day.fractions[i].start = daycount(diff(beginning, each_block.start)) + day.fractions[i].end = daycount(diff(beginning, each_block.end)) + fmt.println(day.fractions[i]) } } @@ -153,9 +151,9 @@ main :: proc() { block_color = ORANGE } - DrawRectangle(TIMELINE_START+i32(math.round(day.fractions[j]*f32(width+TIMELINE_END-TIMELINE_START))), + DrawRectangle(TIMELINE_START+i32(math.round(day.fractions[j].start*f32(width+TIMELINE_END-TIMELINE_START))), DAY_HEIGHT*i32(i+1)-4, - i32(math.round(f32(width+TIMELINE_END-TIMELINE_START)*(day.fractions[j+1]-day.fractions[j])+0.5)), + i32(math.round(f32(width+TIMELINE_END-TIMELINE_START)*(day.fractions[j].end-day.fractions[j].start)+0.5)), DAY_HEIGHT-1, block_color) } diff --git a/src/time.odin b/src/time.odin index 080096b..44c810a 100644 --- a/src/time.odin +++ b/src/time.odin @@ -42,6 +42,12 @@ Timeblock :: struct { reason : string, } +Fractionpair :: struct { + start : f32, + end : f32, +} + + Workday :: struct { call : Moment, wrap : Moment, @@ -52,16 +58,14 @@ Workday :: struct { // cause more blocks blocks : [16]Timeblock, - // Fractions store how far - // through the day each - // timesplit occurs. - // They should probably be - // changed to come in pairs, - // as moments do in timeblocks, - // because then we can store - // both the start and end - // of timeblocks in fractions - fractions : [16]f32, + // Fractions store how long + // since the workday's + // preceding midnight + // a timesplit occurs. + // They're pairs so they + // can exactly map to each + // timeblock's start and end + fractions : [16]Fractionpair, total_timeblocks : int, } |