Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey Codeproject,

I've already figured out that there's 86400 seconds in a day, and I'd like to make a color more black towards the 86400 mark.

So, I started by doing the following:

C#
// pseudo code
// Color * 0f = Completely Transparent
// BackgroundColor = Color
Color.Black * (1f / 86400f * DateTime.TotalSeconds)


The problem is though, the moment it hits midnight, the total seconds will be reset to 0, since a new day started. It's still night thought at that point.

Does anyone have an idea on how to fix this?

Best Regards,
- 11841791

What I have tried:

C#
// pseudo code
// Color * 0f = Completely Transparent
// BackgroundColor = Color
Color.Black * (1f / 86400f * DateTime.TotalSeconds)
Posted
Updated 13-Jul-16 7:02am
v4

1 solution

Rather than using the number of seconds since midnight.
Use the number of seconds around (before or after) 12 o clock.
abs((86400/2)-DateTime.TotalSeconds)

[Update]
Pay attention to the fact that the maximum result of my formula is 43200.
 
Share this answer
 
v2
Comments
Member 11841791 13-Jul-16 13:45pm    
Color.Black * ((1f / 86400f) * (float)Math.Abs((86400f / 2f) - World.DateTime.Second))

Is the working fully version! Thanks a lot!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900