From db3674b188d1c7fb7d07f235c6f8ce770d260b30 Mon Sep 17 00:00:00 2001 From: Jim Date: Wed, 26 Mar 2014 09:40:33 -0700 Subject: [PATCH] initial check-in --- README.md | 7 ++ source/DigiClockSS.cpp | 158 ++++++++++++++++++++++++++++++++++++++++ source/DigiClockSS.h | 23 ++++++ source/DigiClockSS.rsrc | Bin 0 -> 3457 bytes source/fatelk | Bin 0 -> 699 bytes source/makefile | 114 +++++++++++++++++++++++++++++ 6 files changed, 302 insertions(+) create mode 100644 source/DigiClockSS.cpp create mode 100644 source/DigiClockSS.h create mode 100644 source/DigiClockSS.rsrc create mode 100644 source/fatelk create mode 100644 source/makefile diff --git a/README.md b/README.md index 6b32932..16b264c 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,10 @@ DigiClock ========= DigiClock Screensaver Based on BinaryClock by David Enderson Uses filled rectangles and random colors. + +to build: + +cd source + +make + diff --git a/source/DigiClockSS.cpp b/source/DigiClockSS.cpp new file mode 100644 index 0000000..e907291 --- /dev/null +++ b/source/DigiClockSS.cpp @@ -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 +#include + + 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(); + } + + +} diff --git a/source/DigiClockSS.h b/source/DigiClockSS.h new file mode 100644 index 0000000..f8293eb --- /dev/null +++ b/source/DigiClockSS.h @@ -0,0 +1,23 @@ +/**************************************************************** +* DigiClockSS.h * +* * +* Version: 0.1 * +* Author: Jim Saxton * +* this source code is released under the GPL * +*---------------------------------------------------------------* +****************************************************************/ +#include +#include +#include + +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 + +}; diff --git a/source/DigiClockSS.rsrc b/source/DigiClockSS.rsrc new file mode 100644 index 0000000000000000000000000000000000000000..410584282be901498a006d4bf8f1d34024f14f62 GIT binary patch literal 3457 zcmeHKPiPZa82?@}lP0hKQnWTImTBA~TCF;Qm^hs_X_Dy-=`?9-)zYn-CQ*m#G`1yF zNI_8cBCEaVVHcqn7m>w_%3`g%QueTjcv;xP9#;|c;8i@u_sxs#E(oIFEf3zz_viQh zzK_Q@@4Xq$0DyleCbCxyr-wbhU|=k;*jH}Oahh-$%@sD#{x#&s4FHcAG4lUX2hh&b zz!N45Rrwi{Z@IWqqO8oSTxPLO-BsMztP@kz`1wND)}gizwH~PTK&=NpzX!6#;u$NK zowKIxz4LoYcD_4m+1Z)%{b#0gQ=E=H+2Q-Y5wlKNIYdaaxtT)2mS(f1!VDDI!3ax> zO@S4!x43_~j4=UxJZ1V156ZCks|j;HZ_%*MN}25Z+_Wu4v$KV~G;LFfCzhPd(&Tw5 zmMvL%DQ@QrGqcPO?XnY(hwZU?Z_&Sv>sZ@v#u;go9d6`T*bFi~U;4(eE&9d4-<#I; z73SaAyWR02AL>4)BQM4;vA3aacj8h0gUycHeSk8*czBCfZuPOqPY=XDWt^RiZ{Ist z0J%OLRYQF43fMX8WRnOk*yIY|xP5Q(?ZFq{_H-+7JQu>L`ha_)J!VSc&wg|g70i%0bM zQMgkni+?$}w*4IH6&~JSQKssQ*9QlDEl{rfE2doRTBy*MheJD7vh6+YO0sj(*m4~- zO{?5oS`sxeh=@n}Wwqt_?;St=wy-z3^{R1T!v};w=KRzvPaK-)8#O0JCcaA@OR8z= z>E7L~s&PXxc7;2sz%^AyNtL-xmARj~4@H$hB}P5LXmCUxSJP@=cbE!XlXaA2o!exc z`>98bsw3w3SZb`-2vK1*xav3cvEE^Y3ThO!VTIYnNc!>RKQEf&roP&>x{-<)g_cO# z(FIfI94)kweV-JFC(v3UZI?iBWN0OA-!qwzI-p+S16of+N$Q{?@gkb~Io3rQfl|^0 z)aMeKfqF-30i19cZ zAsQdbgd?fciHxqT!4s)e1l_oKG_OMv$%vL&1C3TexC6ATgGS@S8GXoHgPHyMXn{fS l_kwbm-v1xJre&ORuv|a)C-h|e#K`efd_CD+>w(4q@E+xTDarr< literal 0 HcmV?d00001 diff --git a/source/fatelk b/source/fatelk new file mode 100644 index 0000000000000000000000000000000000000000..729b1b78419958e09c22eb04a71dbfb0e349b199 GIT binary patch literal 699 zcmWIWW@h1H00B>4e`_!UO0YAiF}gX1D7gA~hlX%6FlRov=2gUG92{D~0#@Oa%FFnh z5y<3VxWQX+qI80{|6v1xmSzWzBc04K4<6V%G*YP~o!jmBPWo$-8{W}%E!WnzdCF$?<-;jQvQ{!j`W1E*?iFntGC@%fZ%^D&HI?a#X z+~a;;Uc+6&N||+6w~>gwt&-04WvsrxSaetIU)gL^zj)4i-9V3Z4r|&EeEg;tp<}Z0 zwPK}-_eGUj$H%7w@4NK|ms(7H&zrht{R&=*^l5iX^5*idYWwx??AMBtuf~bWJ!M(n z=M|=$4VoHcG1dB7#((2!7jgqR*-y3oiafVq#h*C_kL%~ZF8kX0V|MjTm&LOGwwSoJ zI$qeecK@B6ldIxOmZmPg<8RLx01wLN#eOJ3$-yv}!7Z^w!8Ipa0UVZ!&gfy;!mt<= zsvHb&Q?|4g7k%a5#?{GFkow{47v8i6hMh;6n&zB&a%9q(KQ@24?rz#6V!J%#?vg)$ z-rPB|D2FZnx`6xYON(UKobT9GP@wPR`yZe_}c|O*%7aPKZcr zUZ*P8I?J0}2Y+U&KJ9c}$tBQwbLG^hCtg`}FZ{&A5a7+oBrbp}J&1wh9Yic?1d;I6 z!3s$op%n}aPN}R69H3NzY!qgAARFZkRE`K8pjn{MftghgvM9itl?_BQ0pWBY&Bp}d F0RX5c?O*@^ literal 0 HcmV?d00001 diff --git a/source/makefile b/source/makefile new file mode 100644 index 0000000..3e935b5 --- /dev/null +++ b/source/makefile @@ -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
+# 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 $@