-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
302 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
/**************************************************************** | ||
* DigiClockSS.cpp * | ||
* * | ||
* Version: 0.1 * | ||
* Author: Jim Saxton * | ||
* this source code is released under the GPL * | ||
*---------------------------------------------------------------* | ||
* Based on BinaryCockSS by David Enderson * | ||
****************************************************************/ | ||
#include "DigiClockSS.h" | ||
#include <StringView.h> | ||
#include <stdlib.h> | ||
|
||
int red = 0; | ||
int blue = 18; | ||
int green = 0; | ||
int change = 0; | ||
|
||
|
||
extern "C" _EXPORT BScreenSaver *instantiate_screen_saver(BMessage *message, image_id image) | ||
{ | ||
return new DigiClock(message, image); | ||
} | ||
|
||
DigiClock::DigiClock(BMessage *message, image_id image) | ||
: BScreenSaver(message, image) | ||
{ | ||
} | ||
|
||
void DigiClock::StartConfig(BView *view) | ||
{ | ||
// I'll do this better later | ||
view->AddChild(new BStringView(BRect(10, 10, 200, 35), NULL, "DigiClock, by Jim Saxton")); | ||
view->AddChild(new BStringView(BRect(10, 40, 200, 50), NULL, "Based On:")); | ||
view->AddChild(new BStringView(BRect(10, 55, 300, 85), NULL, "BinaryClock by David Enderson")); | ||
|
||
} | ||
status_t DigiClock::StartSaver(BView *view, bool preview) | ||
{ | ||
rgb_color offcolor = {93, 0, 93, 0}; // temporary color for this function | ||
srand(time(NULL) %37); | ||
int thewidth=(view->Bounds()).IntegerWidth()/8; | ||
int theheight=(view->Bounds()).IntegerHeight()/5; | ||
|
||
SetTickSize(5500); | ||
|
||
for (int a=0; a<24; a++) { | ||
// this line is copied from the original program incase I need to refer back to my awful formulas | ||
// dot[a]= new BView(BRect((a/4)*14+2+(a/8*7), ((3-(a%4))*14)+2, (a/4)*14+12+2+(a/8*7), ((3-(a%4))*14)+12+2), "thedots", B_FOLLOW_NONE, B_WILL_DRAW); | ||
// sorry the formulas are so hideous. I'll try to make them better when I have time. | ||
dot[a]= new BView(BRect((a/4)*thewidth+2+(a/8*(thewidth/2))+thewidth/2, ((3-(a%4))*theheight)+2+theheight/2, (a/4)*thewidth-thewidth/20+2+(a/8*(thewidth/2))+thewidth+thewidth/2, ((3-(a%4))*theheight)-theheight/20+2+theheight+theheight/2), "thedots", B_FOLLOW_NONE, B_WILL_DRAW); | ||
dot[a]->SetViewColor(offcolor); | ||
view->AddChild(dot[a]); | ||
} | ||
|
||
return B_OK; | ||
} | ||
|
||
void DigiClock::Draw(BView *view, int32 frame) | ||
{ | ||
int lb=0; | ||
int lg=0; | ||
int lr=0; | ||
if (change == 0) { | ||
|
||
red = rand() % 255; | ||
blue = rand() % 255; | ||
green = rand () % 255; | ||
change=rand() % 5000; | ||
if (red+blue+green< 125) { | ||
red = red + 20; | ||
blue = blue + 20; | ||
green = green + 20; | ||
|
||
} | ||
} | ||
change = change+1; // change the color? | ||
if (change > 5000){ | ||
change=0; | ||
} | ||
lb=blue-90; | ||
lg=green-90; | ||
lr=red-90; | ||
|
||
if (lr+lb+lg>125) { | ||
lr=lr-20; | ||
lb=lb-20; | ||
lg=lg-20; | ||
} | ||
if (lr+lb+lg<70){ | ||
lr=lr+20; | ||
lb=lb+20; | ||
lg=lg+20; | ||
} | ||
if (lb<0) lb=20; | ||
if (lr<0) lr=20; | ||
if (lb<0) lb=20; | ||
|
||
rgb_color oncolor = {red,green, blue, 0}; // color when clock part is on | ||
rgb_color offcolor = {lr, lg,lb, 0}; // color when clock part is off | ||
|
||
if (frame==0) { | ||
rgb_color backcolor = {0, 0, 0, 0}; // temporary color for this function | ||
/* Fill the screen with black on the first frame: */ | ||
//view->SetLowColor( 0, 0, 0 ); | ||
//view->FillRect( view->Bounds(), B_SOLID_LOW ); | ||
view->SetViewColor(backcolor); | ||
view->Invalidate(); | ||
} | ||
|
||
time_t clock = time( (time_t*) NULL); | ||
struct tm *tmptr = localtime(&clock); | ||
|
||
for (int a=0; a<4; a++) { | ||
if (((tmptr->tm_hour)/10)&(int)pow(2,a)) | ||
dot[a]->SetViewColor(oncolor); | ||
else | ||
dot[a]->SetViewColor(offcolor); | ||
dot[a]->Invalidate(); | ||
} | ||
for (int a=4; a<8; a++) { | ||
if (((tmptr->tm_hour)%10)&(int)pow(2,(a-4))) | ||
dot[a]->SetViewColor(oncolor); | ||
else | ||
dot[a]->SetViewColor(offcolor); | ||
dot[a]->Invalidate(); | ||
} | ||
for (int a=8; a<12; a++) { | ||
if (((tmptr->tm_min)/10)&(int)pow(2,(a-8))) | ||
dot[a]->SetViewColor(oncolor); | ||
else | ||
dot[a]->SetViewColor(offcolor); | ||
dot[a]->Invalidate(); | ||
} | ||
for (int a=12; a<16; a++) { | ||
if (((tmptr->tm_min)%10)&(int)pow(2,(a-12))) | ||
dot[a]->SetViewColor(oncolor); | ||
else | ||
dot[a]->SetViewColor(offcolor); | ||
dot[a]->Invalidate(); | ||
} | ||
for (int a=16; a<20; a++) { | ||
if (((tmptr->tm_sec)/10)&(int)pow(2,(a-16))) | ||
dot[a]->SetViewColor(oncolor); | ||
else | ||
dot[a]->SetViewColor(offcolor); | ||
dot[a]->Invalidate(); | ||
} | ||
for (int a=20; a<24; a++) { | ||
if (((tmptr->tm_sec)%10)&(int)pow(2,(a-20))) | ||
dot[a]->SetViewColor(oncolor); | ||
else | ||
dot[a]->SetViewColor(offcolor); | ||
dot[a]->Invalidate(); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/**************************************************************** | ||
* DigiClockSS.h * | ||
* * | ||
* Version: 0.1 * | ||
* Author: Jim Saxton * | ||
* this source code is released under the GPL * | ||
*---------------------------------------------------------------* | ||
****************************************************************/ | ||
#include <ScreenSaver.h> | ||
#include <time.h> | ||
#include <math.h> | ||
|
||
class DigiClock : public BScreenSaver | ||
{ | ||
public: | ||
DigiClock(BMessage *message, image_id id); | ||
void StartConfig(BView *view); | ||
status_t StartSaver(BView *v, bool preview); | ||
void Draw(BView *v, int32 frame); | ||
|
||
BView *dot[24]; // the 24 dots on the clock | ||
|
||
}; |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
## BeOS Generic Makefile v2.1 ## | ||
|
||
## Fill in this file to specify the project being created, and the referenced | ||
## makefile-engine will do all of the hard work for you. This handles both | ||
## Intel and PowerPC builds of the BeOS. | ||
|
||
## Application Specific Settings --------------------------------------------- | ||
|
||
# specify the name of the binary | ||
NAME=DigiClock | ||
|
||
# specify the type of binary | ||
# APP: Application | ||
# SHARED: Shared library or add-on | ||
# STATIC: Static library archive | ||
# DRIVER: Kernel Driver | ||
TYPE= SHARED | ||
|
||
# add support for new Pe and Eddie features | ||
# to fill in generic makefile | ||
|
||
#%{ | ||
# @src->@ | ||
|
||
# specify the source files to use | ||
# full paths or paths relative to the makefile can be included | ||
# all files, regardless of directory, will have their object | ||
# files created in the common object directory. | ||
# Note that this means this makefile will not work correctly | ||
# if two source files with the same name (source.c or source.cpp) | ||
# are included from different directories. Also note that spaces | ||
# in folder names do not work well with this makefile. | ||
SRCS=DigiClockSS.cpp | ||
|
||
# specify the resource files to use | ||
# full path or a relative path to the resource file can be used. | ||
RSRCS=DigiClockSS.rsrc | ||
|
||
# @<-src@ | ||
#%} | ||
|
||
# end support for Pe and Eddie | ||
|
||
# specify additional libraries to link against | ||
# there are two acceptable forms of library specifications | ||
# - if your library follows the naming pattern of: | ||
# libXXX.so or libXXX.a you can simply specify XXX | ||
# library: libbe.so entry: be | ||
# | ||
# - if your library does not follow the standard library | ||
# naming scheme you need to specify the path to the library | ||
# and it's name | ||
# library: my_lib.a entry: my_lib.a or path/my_lib.a | ||
LIBS= be _APP_ | ||
|
||
# specify additional paths to directories following the standard | ||
# libXXX.so or libXXX.a naming scheme. You can specify full paths | ||
# or paths relative to the makefile. The paths included may not | ||
# be recursive, so include all of the paths where libraries can | ||
# be found. Directories where source files are found are | ||
# automatically included. | ||
LIBPATHS= | ||
|
||
# additional paths to look for system headers | ||
# thes use the form: #include <header> | ||
# source file directories are NOT auto-included here | ||
SYSTEM_INCLUDE_PATHS = /boot/develop/headers/be/add-ons/screen_saver/ | ||
|
||
# additional paths to look for local headers | ||
# thes use the form: #include "header" | ||
# source file directories are automatically included | ||
LOCAL_INCLUDE_PATHS = | ||
|
||
# specify the level of optimization that you desire | ||
# NONE, SOME, FULL | ||
OPTIMIZE= | ||
|
||
# specify any preprocessor symbols to be defined. The symbols will not | ||
# have their values set automatically; you must supply the value (if any) | ||
# to use. For example, setting DEFINES to "DEBUG=1" will cause the | ||
# compiler option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" | ||
# would pass "-DDEBUG" on the compiler's command line. | ||
DEFINES= | ||
|
||
# specify special warning levels | ||
# if unspecified default warnings will be used | ||
# NONE = supress all warnings | ||
# ALL = enable all warnings | ||
WARNINGS = ALL | ||
|
||
# specify whether image symbols will be created | ||
# so that stack crawls in the debugger are meaningful | ||
# if TRUE symbols will be created | ||
SYMBOLS = | ||
|
||
# specify debug settings | ||
# if TRUE will allow application to be run from | ||
# a source-level debugger | ||
DEBUGGER = | ||
|
||
# specify additional compiler flags for all files | ||
COMPILER_FLAGS = | ||
|
||
# specify additional linker flags | ||
LINKER_FLAGS = | ||
|
||
|
||
## include the makefile-engine | ||
include /boot/develop/etc/makefile-engine | ||
|
||
## Rule for creating the _APP_ symlink at need | ||
$(TARGET) : _APP_ | ||
_APP_ : | ||
ln -s /boot/beos/preferences/ScreenSaver $@ |