From f4217d5057b311bf14b219dba2f3cfc3edfcbdd8 Mon Sep 17 00:00:00 2001 From: Matt Mascarenhas Date: Sat, 18 Mar 2017 02:04:13 +0000 Subject: [PATCH] hmml_to_html.c: Coloured authors [#3] --- hmml_to_html/hmml_to_html.c | 54 +++++++++++++++++++++++++++++++++---- hmml_to_html/style.css | 20 +++++++++++--- 2 files changed, 65 insertions(+), 9 deletions(-) diff --git a/hmml_to_html/hmml_to_html.c b/hmml_to_html/hmml_to_html.c index 0acf16c..4f2f180 100644 --- a/hmml_to_html/hmml_to_html.c +++ b/hmml_to_html/hmml_to_html.c @@ -97,6 +97,41 @@ StringsDiffer(char *A, char *B) return *A - *B; } +int +CharToColour(char Char) +{ + if(Char >= 'a' && Char <= 'z') + { + return (((float)Char - 'a') / ('z' - 'a') * 0xFFFFFF); + } + else if(Char >= 'A' && Char <= 'Z') + { + return (((float)Char - 'A') / ('Z' - 'A') * 0xFFFFFF); + } + else if(Char >= '0' && Char <= '9') + { + return (((float)Char - '0') / ('9' - '0') * 0xFFFFFF); + } + else + { + return 0x777777; + } +} + +int +StringToColourHash(char *String) +{ + int Result = 0; + + int i; + for(i = 0; String[i]; ++i) + { + Result += CharToColour(String[i]); + } + + return Result / i; +} + int main(int ArgC, char **Args) { @@ -139,7 +174,7 @@ main(int ArgC, char **Args) if(HMML.well_formed) { - ClaimBuffer(MemoryArena, &ClaimedMemory, &Working, 1024); + ClaimBuffer(MemoryArena, &ClaimedMemory, &Working, 1024 * 4); sprintf(Working.Location, "\n" @@ -223,6 +258,19 @@ HMML.annotations[AnnotationIndex].time); "
%s ", + StringToColourHash(HMML.annotations[AnnotationIndex].author), HMML.annotations[AnnotationIndex].author); + Text.Ptr += Inc; + } + if(HMML.annotations[AnnotationIndex].marker_count) { for(int MarkerIndex = 0; MarkerIndex < HMML.annotations[AnnotationIndex].marker_count; ++MarkerIndex) @@ -241,8 +289,6 @@ HMML.annotations[AnnotationIndex].time); InPtr = HMML.annotations[AnnotationIndex].text; - ClaimBuffer(MemoryArena, &ClaimedMemory, &Text, 256); - if(HMML.annotations[AnnotationIndex].reference_count) // || HMML.annotations[AnnotationIndex].is_quote) { sprintf(Working.Location, " data-ref=\"%d\"", AnnotationIndex); @@ -255,7 +301,6 @@ HMML.annotations[AnnotationIndex].time); *Text.Ptr++ = *InPtr++; } - int Inc = 0; if(HMML.annotations[AnnotationIndex].references[RefLocalIndex].offset <= 2) { if(HMML.annotations[AnnotationIndex].references[RefLocalIndex].page) @@ -291,7 +336,6 @@ HMML.annotations[AnnotationIndex].time); Text.Ptr += Inc; ++DataRef; } - CopyStringToBuffer(InPtr, &Text); } *Out.Ptr++ = '>'; diff --git a/hmml_to_html/style.css b/hmml_to_html/style.css index 53a896b..c44de88 100644 --- a/hmml_to_html/style.css +++ b/hmml_to_html/style.css @@ -44,20 +44,23 @@ .marker:hover.blackboard > .content { background-color: #FFF8E7; background-size: 12px 12px; - background-image: linear-gradient(to right, rgba(51, 153, 255, .16) 1px, transparent 1px), linear-gradient(to bottom, rgba(51, 153, 255, .16) 1px, transparent 1px); + background-image: linear-gradient(to right , rgba(51, 153, 255, .16) 1px, transparent 1px), + linear-gradient(to bottom, rgba(51, 153, 255, .16) 1px, transparent 1px); } .marker:hover.blackboard .faded .content { background-color: rgba(42, 49, 114, 0.7); background-size: 12px 12px; - background-image: linear-gradient(to right, rgba(0, 0, 0, .16) 1px, transparent 1px), linear-gradient(to bottom, rgba(0, 0, 0, .16) 1px, transparent 1px); + background-image: linear-gradient(to right , rgba(0, 0, 0, .16) 1px, transparent 1px), + linear-gradient(to bottom, rgba(0, 0, 0, .16) 1px, transparent 1px) color: #FFFFFF; } .marker.blackboard > .content { background-color: #FFFFFF; background-size: 12px 12px; - background-image: linear-gradient(to right, rgba(51, 153, 255, .16) 1px, transparent 1px), linear-gradient(to bottom, rgba(51, 153, 255, .16) 1px, transparent 1px); + background-image: linear-gradient(to right , rgba(51, 153, 255, .16) 1px, transparent 1px), + linear-gradient(to bottom, rgba(51, 153, 255, .16) 1px, transparent 1px); color: black; } @@ -68,10 +71,19 @@ .marker.blackboard .progress .content { background-color: #2A3172; background-size: 12px 12px; - background-image: linear-gradient(to right, rgba(255, 255, 255, .16) 1px, transparent 1px), linear-gradient(to bottom, rgba(255, 255, 255, .16) 1px, transparent 1px); + background-image: linear-gradient(to right , rgba(255, 255, 255, .16) 1px, transparent 1px), + linear-gradient(to bottom, rgba(255, 255, 255, .16) 1px, transparent 1px); color: #FFFFFF; } +.marker.authored .content .author { + font-style: normal; +} + +.marker.authored { + font-style: oblique; +} + /* MANDATORY */ .player_container {