diff --git a/ChangeLog b/ChangeLog index 7677e30..ca1d401 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Oct 31 11:36:50 GMT 1999 +(gilbertt) + +Added E-ScreenShoot + +------------------------------------------------------------------------------- + Mon Oct 18 16:02:50 PDT 1999 (Mandrake) diff --git a/epplets/E-ScreenShoot.ABOUT/E_ScreenShoot_buttons.png b/epplets/E-ScreenShoot.ABOUT/E_ScreenShoot_buttons.png new file mode 100644 index 0000000..714eb97 Binary files /dev/null and b/epplets/E-ScreenShoot.ABOUT/E_ScreenShoot_buttons.png differ diff --git a/epplets/E-ScreenShoot.ABOUT/E_ScreenShoot_cloak.png b/epplets/E-ScreenShoot.ABOUT/E_ScreenShoot_cloak.png new file mode 100644 index 0000000..8a4ee1e Binary files /dev/null and b/epplets/E-ScreenShoot.ABOUT/E_ScreenShoot_cloak.png differ diff --git a/epplets/E-ScreenShoot.ABOUT/MAIN b/epplets/E-ScreenShoot.ABOUT/MAIN new file mode 100644 index 0000000..c0a5e23 --- /dev/null +++ b/epplets/E-ScreenShoot.ABOUT/MAIN @@ -0,0 +1,319 @@ + + +

+E-ScreenShoot + +

+An Enlightenment Screenshot Grabber. + +

+By Tom Gilbert - 1999 +

+This epplet takes screenshots. You'll need to have ImageMagick installed for +anything to happen ;) +

+o _Control_Overview(overview)
+o _Cloaking(cloaking)
+o _What_Do_All_These_Buttons_Do???(buttons)
+o _Config_File_Options(config)
+o _Cloaking(cloaking)
+o _Misc_Info(misc)
+

+Tom Gilbert (gilbertt@tomgilbert.freeserve.co.uk) + + + +

+Control Overview + + +

+ + + + + +

+Cloaking + + +

+I couldn't just write a screenshot grabber. It had to do something.... Else. +

+Cloaking is it. Like it or loathe it, I think it rules! +

+Benefits:
+o Hides the ugly squashed-in buttons
+o Looks nice
+o Makes you screenshots prettier
+o Multiple instance identification. Set up two instances, one grabbing to +your home directory as a png, and one grabbing to a web resource, using 60% +jpg compression. Set a different cloak-animation on each, and you'll be able +to tell them apart ;-) +

+ + + + +

+What do all these buttons do? + +

+Ok, so you are confronted with quite a few buttons, and a slider. +

+The first two buttons should be obvious. You pressed one of them to get this +help ;-) +

+The slider controls the compression quality of your screenshot. +High (upwards) means high quality, high file size, low vice versa. This +option only effects jpg, png and miff output. +

+The config button in the top-right changes the cloak-mode of the epplet. +This is kind of like a 48x48 screensaver for an epplet, and covers up all +those crammed-in buttons with some eye-candy. Experiment with the various +modes to see which ones you like. +

+_There's_more,_click_here_to_continue(buttons2) + + + +

+What do all these buttons do? (2nd Row) + +

+The leftmost button on the second row toggles root/window mode. In root +mode (the default), the button is not depressed. When you take a screenshot +in this mode, the entire desktop will be captured. When in window mode +(button depressed), you will get a crosshair cursor. Either click on a +window with this cursor to capture only that window, or click and drag a +recangular area to grab that instead. +

+The middle button on the second row allows you to select the cloak timeout. +This is the delay before the epplet cloak appears. +

+The rightmost button on the second row is the screenshot delay. Use this to +configure a delay between pressing the button, and having the shot taken. A +short delay is useful for arranging some windows or refocusing. +

+_There's_more,_click_here_to_continue(buttons3) + + + + +

+What do all these buttons do? (3rd Row) + +

+The left-hand button on the bottom row is used to change the colour of the +RasterFire clock-animation (whose intensity is proprtional to screenshot +quality btw). In a future version, this popup will change the colours used +for all cloak_animations. +

+The bottom-right button is used to take the screenshot! Use it when you're +happy with all the options, and want to start shootin' +

+_Config_File_Options(config)
+ + + + +

+Configuration File Options + +

+Once the epplet has been run once, a configuration file will be created in +~/enlightenment/epplet_configs/E-ScreenShooter/E-ScreenShooter.cfg +

+You may edit this file to fine-tune your screenshooting options. +

+_Example_File(confile)
+_Interface_Options(intopt)
+_Screen-shot_Options(shotopt)
+ + + +

+Example Configuration File + +

+### Automatically generated Epplet config file for E-ScreenShoot. +
+QUALITY 75 +
+WIN_AREA 0 +
+WM_FRAME 1 +
+DO_CLOAK 1 +
+BEEP 1 +
+CLOAK_ANIM 1 +
+SHOT_DELAY 0.0 +
+CLOAK_DELAY 4.0 +
+DRAW_INTERVAL 0.1 +
+DIRECTORY ~/ +
+FILE_PREFIX shot_ +
+FILE_STAMP `date +%d-%m-%y_%H%M%S` +
+FILE_TYPE jpg +

+_Interface_Options(intopt)
+_Screen-shot_Options(shotopt)
+ + + +

+Interface Configuration File Options + +

+ +DO_CLOAK 1 +
+ +BOOLEAN 0/1: This option determines whether the applet is ever cloaked. 1 +mean yes, 0 means no. +
+ +CLOAK_ANIM 1 +
+ +NUMERIC INTEGER: This determines which cloak animation to use. Don't fiddle +with this in the config, as you can do so using the popup menu. +
+ +CLOAK_DELAY 4.0 +
+ +NUMERIC FLOAT: This determines the time interval before the epplet is cloaked. Again, this +can be changed using a popup on the epplet. +
+ +DRAW_INTERVAL 0.1 +
+ +NUMERIC FLOAT: This is the frequency of cloak-animation draws. A low value +means lots of draws, a high value means jerky, slow updates. All the +animations are tuned to work best for a value of 0.1, but you have the +option to change it if the mood takes you. +

+_Screen-shot_Options(shotopt)
+ + + + +

+Screen-Shot Configuration File Options + +

+ +BEEP 1 +
+ +BOOLEAN 0/1: This determines whether you hear a beep just before, and just +after the screen-shot is taken. If 1, you will get audio feedback, if 0, +things'll be quiet. +
+ +QUALITY 75 +
+ +NUMERIC INT 1-100: Screenshot quality, as a percentage. 100 is full quality, +large filesize. This option applies only to jpg, png and miff image files. +
+ +WIN_AREA 0 +
+ +BOOLEAN 0/1: This is configurable from a button on the epplet. If 1, a +window or rectangular area will be grabbed, if 0, the whole desktop. +
+ +WM_FRAME 1 +
+ +BOOLEAN 0/1: If you are grabbing single windows, do you also want the window +manager decorations? 1 means yes, 0 means no. Does not effect +entire-desktop shots. +

+_More_Screen-Shot_Options(shotopt2) + + + +

+Screen-Shot Configuration File Options + +

+ +SHOT_DELAY 0.0 +
+ +NUMERIC FLOAT: Delay before taking shot. Can be altered using epplet popup. +
+ +DIRECTORY ~/ +
+ +STRING: Directory in which to save images. Can include shell variable or +command substitution. You must be able to write to this directory. +
+ +FILE_PREFIX shot_ +
+ +STRING: Bit to stick on the front of the filename. +
+ +FILE_STAMP `date +%d-%m-%y_%H%M%S` +
+ +STRING: Middle bit of filename. I recommend the use of something similar to +the above. This is command substitution, and uses the date program to give +the shot a unique name. +
+ +FILE_TYPE jpg +
+ +STRING: File extension. This also determines the file type. For a list of +possible filetypes, see man convert(1). It'll do almost any filetype you can +think of. I recommend jpg, png, or html (yes html - try it and see!) +

+_Misc_Info(misc)
+ + + + +

+Miscellaneous details + +

+I like eyecandy. Not everyone does, so feel free to turn off the cloaking +stuff. +

+Before you do so however, please do not worry about cpu usage. I have tuned +my drawing code lots, and its fairly clean. To prevent my epplet hogging +cpu, I have explicitly re-prioritised it to the equivalent of a NICE value +of 10. This means cpu will only be used if there is cpu available. +

+There are lots more options in the pipeline, among them are: +
+o Auto-submission to screenshot websites. +
+o Running a script on resultant image to process screenshots further. +
+o Screenshot post-processing using convert(1) +
+o Lots more eyecandy, 'cos I love it. + +

+ +Bug reports, feature requests, and positive vibes to: +
+gilbertt@tomgilbert.freeserve.co.uk diff --git a/epplets/E-ScreenShoot.ABOUT/aircut3.ttf b/epplets/E-ScreenShoot.ABOUT/aircut3.ttf new file mode 100644 index 0000000..c244ec9 Binary files /dev/null and b/epplets/E-ScreenShoot.ABOUT/aircut3.ttf differ diff --git a/epplets/E-ScreenShoot.ABOUT/bg.png b/epplets/E-ScreenShoot.ABOUT/bg.png new file mode 100644 index 0000000..3ca990a Binary files /dev/null and b/epplets/E-ScreenShoot.ABOUT/bg.png differ diff --git a/epplets/E-ScreenShoot.c b/epplets/E-ScreenShoot.c new file mode 100644 index 0000000..847cf80 --- /dev/null +++ b/epplets/E-ScreenShoot.c @@ -0,0 +1,563 @@ +/* E-ScreenShoot.c + * + * Copyright (C) 1999 Tom Gilbert + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +#include +#include +#include + + +#include +#include "utils.h" +#include "cloak.h" +#include "E-ScreenShoot.h" + +static void +save_config (void) +{ + char buf[10]; + sprintf (buf, "%d", opt.quality); + Epplet_modify_config ("QUALITY", buf); + sprintf (buf, "%d", opt.win); + Epplet_modify_config ("WIN_AREA", buf); + sprintf (buf, "%.1f", opt.delay); + Epplet_modify_config ("SHOT_DELAY", buf); + sprintf (buf, "%.1f", opt.cloak_delay); + Epplet_modify_config ("CLOAK_DELAY", buf); + sprintf (buf, "%.1f", opt.draw_interval); + Epplet_modify_config ("DRAW_INTERVAL", buf); + sprintf (buf, "%d", opt.do_cloak); + Epplet_modify_config ("DO_CLOAK", buf); + sprintf (buf, "%d", opt.cloak_anim); + Epplet_modify_config ("CLOAK_ANIM", buf); + sprintf (buf, "%d", opt.frame); + Epplet_modify_config ("WM_FRAME", buf); + sprintf (buf, "%d", opt.beep); + Epplet_modify_config ("BEEP", buf); + sprintf (buf, "%d", opt.run_script); + Epplet_modify_config ("RUN_SCRIPT", buf); + Epplet_modify_config ("DIRECTORY", opt.dir); + Epplet_modify_config ("FILE_PREFIX", opt.file_prefix); + Epplet_modify_config ("FILE_STAMP", opt.file_stamp); + Epplet_modify_config ("FILE_TYPE", opt.file_type); + Epplet_modify_config ("SCRIPT_TO_RUN", opt.script); +} + +static void +load_config (void) +{ + opt.quality = atoi (Epplet_query_config_def ("QUALITY", "75")); + invquality = (100 - opt.quality); + opt.win = atoi (Epplet_query_config_def ("WIN_AREA", "0")); + opt.run_script = atoi (Epplet_query_config_def ("RUN_SCRIPT", "0")); + opt.frame = atoi (Epplet_query_config_def ("WM_FRAME", "1")); + opt.do_cloak = atoi (Epplet_query_config_def ("DO_CLOAK", "1")); + opt.beep = atoi (Epplet_query_config_def ("BEEP", "1")); + opt.cloak_anim = atoi (Epplet_query_config_def ("CLOAK_ANIM", "8")); + opt.delay = atof (Epplet_query_config_def ("SHOT_DELAY", "0")); + opt.cloak_delay = atof (Epplet_query_config_def ("CLOAK_DELAY", "4")); + opt.draw_interval = atof (Epplet_query_config_def ("DRAW_INTERVAL", "0.1")); + if (opt.dir) + free (opt.dir); + opt.dir = _Strdup (Epplet_query_config_def ("DIRECTORY", "~/")); + if (opt.file_prefix) + free (opt.file_prefix); + opt.file_prefix = + _Strdup (Epplet_query_config_def ("FILE_PREFIX", "shot_")); + if (opt.file_stamp) + free (opt.file_stamp); + opt.file_stamp = + _Strdup (Epplet_query_config_def + ("FILE_STAMP", "`date +%d-%m-%y_%H%M%S`")); + if (opt.file_type) + free (opt.file_type); + opt.file_type = _Strdup (Epplet_query_config_def ("FILE_TYPE", "jpg")); + if (opt.script) + free (opt.script); + opt.script = + _Strdup (Epplet_query_config_def ("SCRIPT_TO_RUN", "scrshot_script")); +} + +static void +cb_close (void *data) +{ + save_config (); + Esync (); + Epplet_unremember (); + exit (0); + data = NULL; +} + +static void +cb_help (void *data) +{ + Epplet_show_about ("E-ScreenShoot"); + return; + data = NULL; +} + +static void +cloak_draw (void *data) +{ + switch (opt.cloak_anim) + { + case 0: + { + blank_buf (); + break; + } + case 1: + { + load_val = (opt.quality / 2); + draw_flame (); + Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER"); + break; + } + case 2: + { + draw_radar (); + Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER"); + break; + } + case 3: + { + draw_aa_radar (); + Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER"); + break; + } + case 4: + { + draw_aa_triangle (); + Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER"); + break; + } + case 5: + { + draw_aa_star (); + Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER"); + break; + } + case 6: + { + draw_starfield (); + Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER"); + break; + } + case 7: + { + draw_aa_starfield (); + Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER"); + break; + } + case 8: + { + draw_rotator (); + Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER"); + break; + } + case 9: + { + draw_scanner (); + Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER"); + break; + } + case 10: + { + draw_colorwarp (); + Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER"); + break; + } + case 11: + { + draw_ball (); + Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER"); + break; + } + case 12: + { + draw_atoms (); + Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER"); + break; + } + default: + { + blank_buf (); + break; + } + } + Epplet_paste_buf (buf, win, 0, 0); + return; + data = NULL; +} + +static void +cloak_epplet (void *data) +{ + if (!cloaked) + { + Epplet_gadget_hide (btn_close); + Epplet_gadget_hide (btn_conf); + Epplet_gadget_hide (btn_help); + Epplet_gadget_hide (btn_shoot); + Epplet_gadget_hide (sldr_qual); + Epplet_gadget_hide (tog_win); + Epplet_gadget_show (da); + cloak_draw (NULL); + cloaked = 1; + } + return; + data = NULL; +} + +static void +cb_cloak_anim (void *data) +{ + cb_in (NULL, 0); + opt.do_cloak = 1; + opt.cloak_anim = *((int *) data); + Epplet_timer (cloak_epplet, NULL, opt.cloak_delay, "CLOAK_TIMER"); + return; + data = NULL; +} + +static void +cb_cloak_delay (void *data) +{ + Epplet_remove_timer ("CLOAK_TIMER"); + opt.cloak_delay = *(int *) data; + Epplet_timer (cloak_epplet, NULL, opt.cloak_delay, "CLOAK_TIMER"); + return; + data = NULL; +} + +static void +cb_shot_delay (void *data) +{ + opt.delay = *(int *) data; + return; + data = NULL; +} + +static void +cb_dont_cloak (void *data) +{ + opt.do_cloak = 0; + Epplet_remove_timer ("CLOAK_TIMER"); + return; + data = NULL; +} + +static void +cb_quality (void *data) +{ + opt.quality = (100 - invquality); + return; + data = NULL; +} + +static void +cb_in (void *data, Window w) +{ + if (cloaked) + { + Epplet_gadget_hide (da); + cloaked = 0; + Epplet_gadget_show (btn_close); + Epplet_gadget_show (btn_conf); + Epplet_gadget_show (btn_help); + Epplet_gadget_show (btn_shoot); + Epplet_gadget_show (sldr_qual); + Epplet_gadget_show (tog_win); + } + Epplet_remove_timer ("CLOAK_TIMER"); + Epplet_remove_timer ("DRAW_TIMER"); + return; + data = NULL; + w = (Window) 0; +} + +static void +cb_out (void *data, Window w) +{ + Epplet_remove_timer ("CLOAK_TIMER"); + if ((!cloaked) && (opt.do_cloak)) + Epplet_timer (cloak_epplet, NULL, opt.cloak_delay, "CLOAK_TIMER"); + return; + data = NULL; + w = (Window) 0; +} + +/* Amongst all the fluff, this is the bit that does the actual work. */ +static void +do_shot (void *data) +{ + char *sys; + char qual_buf[5]; + char *filename_buf; + char frame_buf[10]; + char beep_buf[20]; + + sprintf (qual_buf, "%d", opt.quality); + + filename_buf = + _Strjoin (NULL, opt.dir, opt.file_prefix, opt.file_stamp, ".", + opt.file_type, NULL); + + if (opt.frame) + sprintf (frame_buf, "-frame"); + else + frame_buf[0] = '\0'; + + if (opt.beep) + beep_buf[0] = '\0'; + else + sprintf (beep_buf, "-silent"); + + if (!opt.win) + { + sys = _Strjoin (" ", + "import", + beep_buf, + "-window", "root", "-quality", qual_buf, filename_buf, + "&", NULL); + } + else + { + sys = _Strjoin (" ", + "import", beep_buf, frame_buf, "-quality", qual_buf, + filename_buf, "&", NULL); + } + + system (sys); + free (sys); + free (filename_buf); + return; + data = NULL; +} + +static void +cb_shoot (void *data) +{ + Epplet_remove_timer ("SHOOT_TIMER"); + if (opt.delay < 1) + do_shot (NULL); + else + Epplet_timer (do_shot, NULL, opt.delay, "SHOOT_TIMER"); + return; + data = NULL; +} + +static void +cb_color (void *data) +{ + int *d; + + d = (int *) data; + flame_col (d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8]); + Epplet_gadget_hide (col_p); +} + +static void +create_epplet_layout (void) +{ + Epplet_gadget_show (btn_close = Epplet_create_button (NULL, NULL, + 2, 2, 0, 0, "CLOSE", + 0, NULL, cb_close, + NULL)); + Epplet_gadget_show (btn_help = + Epplet_create_button (NULL, NULL, 18, 2, 0, 0, "HELP", + 0, NULL, cb_help, NULL)); + Epplet_gadget_show (btn_shoot = + Epplet_create_button (NULL, + EROOT + "/epplet_icons/E-ScreenShoot_shoot.png", + 23, 31, 22, 13, 0, 0, NULL, + cb_shoot, NULL)); + Epplet_gadget_show (tog_win = + Epplet_create_togglebutton (NULL, + EROOT + "/epplet_icons/E-ScreenShoot_win.png", + 11, 17, 10, 13, &opt.win, + NULL, NULL)); + Epplet_gadget_show (sldr_qual = + Epplet_create_vslider (2, 17, 28, 0, 100, 1, 25, + &invquality, cb_quality, NULL)); + p = Epplet_create_popup (); + Epplet_add_popup_entry (p, "Don't Cloak", NULL, cb_dont_cloak, NULL); + Epplet_add_popup_entry (p, "Blank Epplet", NULL, cb_cloak_anim, + (void *) (&(cloak_anims[0]))); + Epplet_add_popup_entry (p, "RasterFire", NULL, cb_cloak_anim, + (void *) (&(cloak_anims[1]))); + Epplet_add_popup_entry (p, "Radar", NULL, cb_cloak_anim, + (void *) (&(cloak_anims[2]))); + Epplet_add_popup_entry (p, "AA Radar", NULL, cb_cloak_anim, + (void *) (&(cloak_anims[3]))); + Epplet_add_popup_entry (p, "AA Triangle", NULL, cb_cloak_anim, + (void *) (&(cloak_anims[4]))); + Epplet_add_popup_entry (p, "AA Star", NULL, cb_cloak_anim, + (void *) (&(cloak_anims[5]))); + Epplet_add_popup_entry (p, "Starfield", NULL, cb_cloak_anim, + (void *) (&(cloak_anims[6]))); + Epplet_add_popup_entry (p, "AA Starfield", NULL, cb_cloak_anim, + (void *) (&(cloak_anims[7]))); + Epplet_add_popup_entry (p, "Rotator", NULL, cb_cloak_anim, + (void *) (&(cloak_anims[8]))); + Epplet_add_popup_entry (p, "Scanner", NULL, cb_cloak_anim, + (void *) (&(cloak_anims[9]))); + Epplet_add_popup_entry (p, "ColorShift", NULL, cb_cloak_anim, + (void *) (&(cloak_anims[10]))); + Epplet_add_popup_entry (p, "Bouncy Ball", NULL, cb_cloak_anim, + (void *) (&(cloak_anims[11]))); + Epplet_add_popup_entry (p, "Atoms", NULL, cb_cloak_anim, + (void *) (&(cloak_anims[12]))); + + col_p = Epplet_create_popup (); + Epplet_add_popup_entry (col_p, "Flame Colors", NULL, NULL, NULL); + Epplet_add_popup_entry (col_p, "Funky", NULL, cb_color, + (void *) (&(colors[0 * 9]))); + Epplet_add_popup_entry (col_p, "Turquoise", NULL, cb_color, + (void *) (&(colors[1 * 9]))); + Epplet_add_popup_entry (col_p, "Fire", NULL, cb_color, + (void *) (&(colors[2 * 9]))); + Epplet_add_popup_entry (col_p, "Copper", NULL, cb_color, + (void *) (&(colors[3 * 9]))); + Epplet_add_popup_entry (col_p, "Violet", NULL, cb_color, + (void *) (&(colors[4 * 9]))); + Epplet_add_popup_entry (col_p, "Night", NULL, cb_color, + (void *) (&(colors[5 * 9]))); + Epplet_add_popup_entry (col_p, "Sunrise", NULL, cb_color, + (void *) (&(colors[6 * 9]))); + Epplet_add_popup_entry (col_p, "Sunset", NULL, cb_color, + (void *) (&(colors[7 * 9]))); + + ctimer_p = Epplet_create_popup (); + Epplet_add_popup_entry (ctimer_p, "Cloak Delay", NULL, NULL, NULL); + Epplet_add_popup_entry (ctimer_p, "1 Sec", NULL, cb_cloak_delay, + (void *) (&(cloak_delays[0]))); + Epplet_add_popup_entry (ctimer_p, "2 Sec", NULL, cb_cloak_delay, + (void *) (&(cloak_delays[1]))); + Epplet_add_popup_entry (ctimer_p, "3 Sec", NULL, cb_cloak_delay, + (void *) (&(cloak_delays[2]))); + Epplet_add_popup_entry (ctimer_p, "4 Sec", NULL, cb_cloak_delay, + (void *) (&(cloak_delays[3]))); + Epplet_add_popup_entry (ctimer_p, "5 Sec", NULL, cb_cloak_delay, + (void *) (&(cloak_delays[4]))); + Epplet_add_popup_entry (ctimer_p, "10 Sec", NULL, cb_cloak_delay, + (void *) (&(cloak_delays[5]))); + Epplet_add_popup_entry (ctimer_p, "15 Sec", NULL, cb_cloak_delay, + (void *) (&(cloak_delays[6]))); + Epplet_add_popup_entry (ctimer_p, "20 Sec", NULL, cb_cloak_delay, + (void *) (&(cloak_delays[7]))); + Epplet_add_popup_entry (ctimer_p, "30 Sec", NULL, cb_cloak_delay, + (void *) (&(cloak_delays[8]))); + Epplet_add_popup_entry (ctimer_p, "1 min", NULL, cb_cloak_delay, + (void *) (&(cloak_delays[9]))); + Epplet_add_popup_entry (ctimer_p, "2 mins", NULL, cb_cloak_delay, + (void *) (&(cloak_delays[10]))); + + stimer_p = Epplet_create_popup (); + Epplet_add_popup_entry (stimer_p, "Shot Delay", NULL, NULL, NULL); + Epplet_add_popup_entry (stimer_p, "No Delay", NULL, cb_shot_delay, + (void *) (&(shot_delays[0]))); + Epplet_add_popup_entry (stimer_p, "1 Sec", NULL, cb_shot_delay, + (void *) (&(shot_delays[1]))); + Epplet_add_popup_entry (stimer_p, "2 Sec", NULL, cb_shot_delay, + (void *) (&(shot_delays[2]))); + Epplet_add_popup_entry (stimer_p, "3 Sec", NULL, cb_shot_delay, + (void *) (&(shot_delays[3]))); + Epplet_add_popup_entry (stimer_p, "4 Sec", NULL, cb_shot_delay, + (void *) (&(shot_delays[4]))); + Epplet_add_popup_entry (stimer_p, "5 Sec", NULL, cb_shot_delay, + (void *) (&(shot_delays[5]))); + Epplet_add_popup_entry (stimer_p, "10 Sec", NULL, cb_shot_delay, + (void *) (&(shot_delays[6]))); + Epplet_add_popup_entry (stimer_p, "15 Sec", NULL, cb_shot_delay, + (void *) (&(shot_delays[7]))); + Epplet_add_popup_entry (stimer_p, "20 Sec", NULL, cb_shot_delay, + (void *) (&(shot_delays[8]))); + Epplet_add_popup_entry (stimer_p, "30 Sec", NULL, cb_shot_delay, + (void *) (&(shot_delays[9]))); + Epplet_add_popup_entry (stimer_p, "1 min", NULL, cb_shot_delay, + (void *) (&(shot_delays[10]))); + Epplet_add_popup_entry (stimer_p, "2 mins", NULL, cb_shot_delay, + (void *) (&(shot_delays[11]))); + + + Epplet_gadget_show (btn_conf = Epplet_create_popupbutton (NULL, NULL, + 34, 2, 12, 12, + "CONFIGURE", p)); + Epplet_gadget_show (btn_col = + Epplet_create_popupbutton (NULL, + EROOT + "/epplet_icons/E-ScreenShoot_col.png", + 11, 31, 10, 13, NULL, + col_p)); + Epplet_gadget_show (btn_ctimer = + Epplet_create_popupbutton (NULL, + EROOT + "/epplet_icons/E-ScreenShoot_minitime.png", + 23, 17, 10, 13, NULL, + ctimer_p)); + + Epplet_gadget_show (btn_stimer = + Epplet_create_popupbutton (NULL, + EROOT + "/epplet_icons/E-ScreenShoot_minitime2.png", + 35, 17, 10, 13, NULL, + stimer_p)); + + + da = Epplet_create_drawingarea (2, 2, 44, 44); + win = Epplet_get_drawingarea_window (da); + buf = Epplet_make_rgb_buf (40, 40); + + cloaked = 0; + set_flame_col (0); + if (opt.do_cloak) + Epplet_timer (cloak_epplet, NULL, opt.cloak_delay, "CLOAK_TIMER"); + + Epplet_register_mouse_enter_handler (cb_in, (void *) win); + Epplet_register_mouse_leave_handler (cb_out, NULL); +} + +int +main (int argc, char **argv) +{ + int prio; + + prio = getpriority (PRIO_PROCESS, getpid ()); + setpriority (PRIO_PROCESS, getpid (), prio + 10); + + atexit (Epplet_cleanup); + + /* Initialise random numbers */ + srand (time (0)); + + Epplet_Init ("E-ScreenShoot", "0.7", "Enlightenment Screen Shootin' Epplet", + 3, 3, argc, argv, 0); + Epplet_load_config (); + + load_config (); + create_epplet_layout (); + + Epplet_show (); + Epplet_Loop (); + + return 0; +} diff --git a/epplets/E-ScreenShoot.h b/epplets/E-ScreenShoot.h new file mode 100644 index 0000000..543ae3f --- /dev/null +++ b/epplets/E-ScreenShoot.h @@ -0,0 +1,42 @@ +Epplet_gadget btn_shoot, btn_conf, btn_close, btn_help, btn_ctimer; +Epplet_gadget tog_win, btn_col, btn_stimer; +Epplet_gadget sldr_qual; +Epplet_gadget p, col_p, ctimer_p, stimer_p; +Window win; +RGB_buf buf; +Epplet_gadget da; +int cloaked = 0; +extern int load_val; +extern int colors[]; +static void cb_in (void *data, Window w); +int invquality = 0; + +int cloak_anims[] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 +}; +int cloak_delays[] = { + 1, 2, 3, 4, 5, 10, 15, 20, 30, 60, 120 +}; +int shot_delays[] = { + 0, 1, 2, 3, 4, 5, 10, 15, 20, 30, 60, 120 +}; + +struct +{ + int quality; + int win; + int beep; + int cloak_anim; + int frame; + int do_cloak; + int run_script; + double delay; + double cloak_delay; + double draw_interval; + char *dir; + char *file_prefix; + char *file_stamp; + char *file_type; + char *script; +} +opt; diff --git a/epplets/E-ScreenShoot.icon b/epplets/E-ScreenShoot.icon new file mode 100644 index 0000000..32d98d1 Binary files /dev/null and b/epplets/E-ScreenShoot.icon differ diff --git a/epplets/E-ScreenShoot_col.png b/epplets/E-ScreenShoot_col.png new file mode 100644 index 0000000..2c86544 Binary files /dev/null and b/epplets/E-ScreenShoot_col.png differ diff --git a/epplets/E-ScreenShoot_minitime.png b/epplets/E-ScreenShoot_minitime.png new file mode 100644 index 0000000..ff2fd6e Binary files /dev/null and b/epplets/E-ScreenShoot_minitime.png differ diff --git a/epplets/E-ScreenShoot_minitime2.png b/epplets/E-ScreenShoot_minitime2.png new file mode 100644 index 0000000..65509a7 Binary files /dev/null and b/epplets/E-ScreenShoot_minitime2.png differ diff --git a/epplets/E-ScreenShoot_root.png b/epplets/E-ScreenShoot_root.png new file mode 100644 index 0000000..ac59b95 Binary files /dev/null and b/epplets/E-ScreenShoot_root.png differ diff --git a/epplets/E-ScreenShoot_shoot.png b/epplets/E-ScreenShoot_shoot.png new file mode 100644 index 0000000..b852864 Binary files /dev/null and b/epplets/E-ScreenShoot_shoot.png differ diff --git a/epplets/E-ScreenShoot_time.png b/epplets/E-ScreenShoot_time.png new file mode 100644 index 0000000..6731651 Binary files /dev/null and b/epplets/E-ScreenShoot_time.png differ diff --git a/epplets/E-ScreenShoot_win.png b/epplets/E-ScreenShoot_win.png new file mode 100644 index 0000000..c238c36 Binary files /dev/null and b/epplets/E-ScreenShoot_win.png differ diff --git a/epplets/Makefile.am b/epplets/Makefile.am index e39a667..44c32e3 100644 --- a/epplets/Makefile.am +++ b/epplets/Makefile.am @@ -5,7 +5,7 @@ bindir = $(EBIN) bin_PROGRAMS = E-Load.epplet E-Clock.epplet E-Time.epplet E-Net.epplet \ E-Cpu.epplet EppletTest.epplet E-Biff.epplet E-Power.epplet Emix.epplet \ E-MemWatch.epplet E-Disk.epplet E-Areas.epplet EppletConfigTest.epplet \ -E-NetFlame.epplet E-Sys.epplet +E-NetFlame.epplet E-Sys.epplet E-ScreenShoot.epplet E_Load_epplet_SOURCES = E-Load.c E_Load_epplet_DEPENDENCIES = $(top_srcdir)/api/libepplet.la @@ -67,6 +67,11 @@ Emix_epplet_SOURCES = Emix.c Emix_epplet_DEPENDENCIES = $(top_srcdir)/api/libepplet.la Emix_epplet_LDFLAGS = -rpath $(libdir):$(pkglibdir) +E_ScreenShoot_epplet_SOURCES = \ +E-ScreenShoot.c E-ScreenShoot.h cloak.c utils.c utils.h cloak.h +E_ScreenShoot_epplet_DEPENDENCIES = $(top_srcdir)/api/libepplet.la +E_ScreenShoot_epplet_LDFLAGS = -rpath $(libdir):$(pkglibdir) + E_Areas_epplet_SOURCES = E-Areas.c E_Areas_epplet_DEPENDENCIES = $(top_srcdir)/api/libepplet.la E_Areas_epplet_LDFLAGS = -rpath $(libdir):$(pkglibdir) @@ -79,17 +84,25 @@ E-Cpu.ABOUT/MAIN E-Cpu.ABOUT/bg.png E-Cpu.ABOUT/aircut3.ttf \ E-Clock.ABOUT/MAIN E-Clock.ABOUT/bg.png E-Clock.ABOUT/aircut3.ttf \ E-Power.ABOUT/MAIN E-Power.ABOUT/bg.png E-Power.ABOUT/aircut3.ttf \ E-NetFlame.ABOUT/MAIN E-NetFlame.ABOUT/bg.png E-NetFlame.ABOUT/aircut3.ttf \ -Emix.ABOUT/MAIN Emix.ABOUT/bg.png Emix.ABOUT/aircut3.ttf +Emix.ABOUT/MAIN Emix.ABOUT/bg.png Emix.ABOUT/aircut3.ttf \ +E-ScreenShoot.ABOUT/MAIN E-ScreenShoot.ABOUT/bg.png \ +E-ScreenShoot.ABOUT/aircut3.ttf \ +E-ScreenShoot.ABOUT/E_ScreenShoot_buttons.png \ +E-ScreenShoot.ABOUT/E_ScreenShoot_cloak.png + ICONS = \ E-Load.icon E-Clock.icon E-Net.icon E-Cpu.icon E-Power.icon E-Biff.icon \ -Emix.icon E-NetFlame.icon +Emix.icon E-NetFlame.icon E-ScreenShoot.icon IMAGES =\ E-Clock-Image.png E-Power-Bat-0.png E-Power-Bat-10.png E-Power-Bat-20.png \ E-Power-Bat-30.png E-Power-Bat-40.png E-Power-Bat-50.png E-Power-Bat-60.png \ E-Power-Bat-70.png E-Power-Bat-80.png E-Power-Bat-90.png E-Power-Bat-100.png \ -nomail.png newmail.png 7of9.png +nomail.png newmail.png 7of9.png \ +E-ScreenShoot_root.png E-ScreenShoot_col.png \ +E-ScreenShoot_shoot.png E-ScreenShoot_win.png E-ScreenShoot_time.png \ +E-ScreenShoot_minitime.png E-ScreenShoot_minitime2.png EXTRA_DIST = ${ICONS} ${ABOUT_DOCS} ${IMAGES} diff --git a/epplets/cloak.c b/epplets/cloak.c new file mode 100644 index 0000000..a3a546c --- /dev/null +++ b/epplets/cloak.c @@ -0,0 +1,1033 @@ +#include +#include "cloak.h" + +#define VARIANCE 40 +#define VARTREND 16 +#define HSPREAD 10 +#define VSPREAD 160 +#define RESIDUAL 75 +#define MAX 255 +double prev_val = 0.0; +int *flame = NULL; +int *vspread, *hspread, *residual; +unsigned char rm[255], gm[255], bm[255]; +int rr, gg, bb; +extern RGB_buf buf; +int load_val = 35; + +static void aa_line (int x1, int y1, int x2, int y2, unsigned char b, + unsigned char rr, unsigned char gg, unsigned char bb); +static void set_col_pixel (int x, int y, unsigned char c, unsigned char rrr, + unsigned char ggg, unsigned char bbb); +static void set_pixel (int x, int y, unsigned char c); +static void aa_pixel (double wx, double wy, unsigned char c, + unsigned char rrr, unsigned char ggg, + unsigned char bbb); +static void color_buf (unsigned char rr, unsigned char gg, unsigned char bb); +static void fade_buf (int percent); + +/* Raster's flame colors */ +/* Look, even US spelling ;-) */ +int colors[] = { + 120, 0, 169, + 217, 152, 249, + 255, 255, 255, + + 30, 90, 90, + 50, 255, 255, + 255, 255, 255, + + 255, 0, 0, + 255, 255, 0, + 255, 255, 255, + + 0, 255, 0, + 255, 255, 0, + 255, 255, 255, + + 0, 0, 255, + 255, 0, 255, + 255, 255, 255, + + 0, 0, 200, + 40, 80, 255, + 100, 200, 255, + + 80, 90, 140, + 140, 150, 180, + 255, 230, 200, + + 20, 40, 180, + 255, 160, 0, + 255, 255, 100 +}; + +void +set_flame_col (int j) +{ + flame_col (colors[j], colors[j + 1], colors[j + 2], colors[j + 3], + colors[j + 4], colors[j + 5], colors[j + 6], colors[j + 7], + colors[j + 8]); + rr = colors[j]; + gg = colors[j + 1]; + bb = colors[j + 2]; + if (rr == 0) + rr = 1; + if (gg == 0) + gg = 1; + if (bb == 0) + bb = 1; +} + +void +flame_col (int r1, int g1, int b1, int r2, int g2, int b2, int r3, int g3, + int b3) +{ + int i; + + for (i = 0; i < 25; i++) + { + rm[i] = (r1 * i) / 25; + gm[i] = (g1 * i) / 25; + bm[i] = (b1 * i) / 25; + } + for (i = 0; i < 25; i++) + { + rm[25 + i] = ((r2 * i) + (r1 * (25 - i))) / 25; + gm[25 + i] = ((g2 * i) + (g1 * (25 - i))) / 25; + bm[25 + i] = ((b2 * i) + (b1 * (25 - i))) / 25; + } + for (i = 0; i < 25; i++) + { + rm[50 + i] = ((r3 * i) + (r2 * (25 - i))) / 25; + gm[50 + i] = ((g3 * i) + (g2 * (25 - i))) / 25; + bm[50 + i] = ((b3 * i) + (b2 * (25 - i))) / 25; + } + for (i = 75; i < 255; i++) + { + rm[i] = rm[74]; + gm[i] = gm[74]; + bm[i] = bm[74]; + } +} + +/* I use this to black-out the rgb-buf */ +/* There must be a faster way, but I'm not used to this stuff yet */ +void +blank_buf (void) +{ + int x, y; + unsigned char *rgb, *rptr; + + for (y = 0; y < 40; y++) + { + rgb = Epplet_get_rgb_pointer (buf); + rptr = rgb + (y * 40 * 3); + for (x = 0; x < 40; x++) + { + rptr[0] = rptr[1] = rptr[2] = 0; + rptr += 3; + } + } +} + +/* Same as blank_buf, but not black ;-) */ +void +color_buf (unsigned char rr, unsigned char gg, unsigned char bb) +{ + int x, y; + unsigned char *rgb, *rptr; + + for (y = 0; y < 40; y++) + { + rgb = Epplet_get_rgb_pointer (buf); + rptr = rgb + (y * 40 * 3); + for (x = 0; x < 40; x++) + { + rptr[0] = rr; + rptr[1] = gg; + rptr[2] = bb; + rptr += 3; + } + } +} + +/* Used to fade out the buf a bit before each draw */ +/* Helps the radar look right */ +void +fade_buf (int percentage) +{ + int x, y; + unsigned char *rgb, *rptr; + + for (y = 0; y < 40; y++) + { + rgb = Epplet_get_rgb_pointer (buf); + rptr = rgb + (y * 40 * 3); + for (x = 0; x < 40; x++) + { + rptr[0] = rptr[0] * percentage / 100; + rptr[1] = rptr[1] * percentage / 100; + rptr[2] = rptr[2] * percentage / 100; + rptr += 3; + } + } +} + +/* RasterFire :) */ +void +draw_flame (void) +{ + unsigned char *rgb, *rptr; + int x, y, *ptr, val1, val2, val3; + + if (!flame) + { + vspread = malloc (40 * sizeof (int)); + hspread = malloc (40 * sizeof (int)); + residual = malloc (40 * sizeof (int)); + flame = malloc (sizeof (int) * 40 * 40); + memset (flame, 0, sizeof (int) * 40 * 40); + } + + ptr = flame + (39 * 40); + for (x = 0; x < 40; x++) + { + vspread[x] = VSPREAD + (load_val / 50); + hspread[x] = HSPREAD + (load_val / 50); + residual[x] = RESIDUAL + (load_val / 50); + ptr[x] = (rand () % (load_val + 155)); + if (ptr[x] > MAX) + ptr[x] = 0; + else if (ptr[x] < 0) + ptr[x] = 0; + } + for (y = 39; y >= 2; y--) + { + ptr = flame + (y * 40); + for (x = 1; x < 39; x++) + { + val1 = (ptr[x] * vspread[x]) >> 8; + val2 = (ptr[x] * hspread[x]) >> 8; + val3 = (ptr[x] * residual[x]) >> 8; + + ptr[x - 1] += val2; + if (ptr[x - 1] > MAX) + ptr[x - 1] = MAX; + ptr[x - 40] += val1; + if (ptr[x - 40] > MAX) + ptr[x - 40] = MAX; + ptr[x + 1] += val2; + if (ptr[x + 1] > MAX) + ptr[x + 1] = MAX; + ptr[x] = val3; + } + } + for (x = 0; x < 40; x++) + flame[x] = 0; + for (x = 0; x < 40; x++) + flame[40 + x] /= 2; + for (y = 0; y < 40; y++) + flame[y * 40] = 0; + for (y = 0; y < 40; y++) + flame[(y * 40) + 39] = 0; + for (y = 0; y < 40; y++) + flame[(y * 40) + 38] /= 2; + rgb = Epplet_get_rgb_pointer (buf); + for (y = 0; y < 40; y++) + { + ptr = flame + (y * 40) + 1; + rptr = rgb + (y * 40 * 3); + for (x = 0; x < 40; x++) + { + val1 = ptr[x] & 0xff; + rptr[0] = rm[val1]; + rptr[1] = gm[val1]; + rptr[2] = bm[val1]; + rptr += 3; + } + } +} + +/* Radar thing */ + +#define RADIUS 50 +static double radar_x[RADIUS]; +static double radar_r[RADIUS]; + +void +draw_radar (void) +{ + int i; + char *ptr; + unsigned int tempX = 0; + unsigned int tempY = 0; + static int setup = 0; + double d = 0.0; + + if (!setup) + { + blank_buf (); + d = rand () % 360; + for (i = 0; i < RADIUS; i++) + { + radar_x[i] = d; + radar_r[i] = i; + } + setup = 1; + } + + fade_buf (92); + + for (i = 0; i < RADIUS; i++) + { + radar_x[i] += 0.07; + + tempX = 19 + radar_r[i] * cos (radar_x[i]) / 3; + tempY = 19 + radar_r[i] * sin (radar_x[i]) / 3; + ptr = + (buf)->im->rgb_data + ((buf)->im->rgb_width * 3 * (tempY)) + + (3 * tempX); + + ptr[0] = (unsigned char) 55; + ptr[1] = (unsigned char) 255; + ptr[2] = (unsigned char) 75; + } +} + +/* AA radar :) Fading doesn't look good for it though, so I disabled it */ +void +draw_aa_radar (void) +{ + int x2, y2; + static double x = 0.0; + + x += 0.1; + + x2 = 19 + RADIUS * cos (x) / 3; + y2 = 19 + RADIUS * sin (x) / 3; + + blank_buf (); + aa_line (19, 19, x2, y2, 255, 0, 255, 0); +} + +/* Scanner type thing */ +void +draw_scanner (void) +{ + static int y = 0; + static int down = 1; + static int setup = 0; + + if (!setup) + { + blank_buf (); + setup = 1; + } + + if (down) + y += 1; + else + y -= 1; + + if (y == 39) + { + y = 38; + down = 0; + } + else if (y == 0) + { + y = 1; + down = 1; + } + + fade_buf (85); + aa_line (0, y, 38, y, 255, 255, 0, 0); +} + + +/* Lame, but easy :) */ +void +draw_aa_triangle (void) +{ + int x1, y1; + int x2, y2; + int x3, y3; + static double x = 0.0; + + x += 0.1; + + x1 = 19 + RADIUS * cos (x) / 3; + y1 = 19 + RADIUS * sin (x) / 3; + x2 = 19 + RADIUS * cos (x + (2 * M_PI / 3)) / 3; + y2 = 19 + RADIUS * sin (x + (2 * M_PI / 3)) / 3; + x3 = 19 + RADIUS * cos (x + (4 * M_PI / 3)) / 3; + y3 = 19 + RADIUS * sin (x + (4 * M_PI / 3)) / 3; + + blank_buf (); + aa_line (x1, y1, x2, y2, 255, 0, 0, 255); + aa_line (x2, y2, x3, y3, 255, 0, 0, 255); + aa_line (x3, y3, x1, y1, 255, 0, 0, 255); +} + +/* Two triangles. Possible lamer :) */ +void +draw_aa_star (void) +{ + int x1, y1; + int x2, y2; + int x3, y3; + int x4, y4; + int x5, y5; + int x6, y6; + static double x = 0.0; + + x += 0.1; + + x1 = 19 + RADIUS * cos (x) / 3; + y1 = 19 + RADIUS * sin (x) / 3; + x2 = 19 + RADIUS * cos (x + (2 * M_PI / 3)) / 3; + y2 = 19 + RADIUS * sin (x + (2 * M_PI / 3)) / 3; + x3 = 19 + RADIUS * cos (x + (4 * M_PI / 3)) / 3; + y3 = 19 + RADIUS * sin (x + (4 * M_PI / 3)) / 3; + + x4 = 19 + RADIUS * cos (x + (M_PI / 3)) / 3; + y4 = 19 + RADIUS * sin (x + (M_PI / 3)) / 3; + x5 = 19 + RADIUS * cos (x + (3 * M_PI / 3)) / 3; + y5 = 19 + RADIUS * sin (x + (3 * M_PI / 3)) / 3; + x6 = 19 + RADIUS * cos (x + (5 * M_PI / 3)) / 3; + y6 = 19 + RADIUS * sin (x + (5 * M_PI / 3)) / 3; + + blank_buf (); + + aa_line (x1, y1, x2, y2, 255, 255, 255, 0); + aa_line (x2, y2, x3, y3, 255, 255, 255, 0); + aa_line (x3, y3, x1, y1, 255, 255, 255, 0); + + aa_line (x4, y4, x5, y5, 255, 255, 255, 0); + aa_line (x5, y5, x6, y6, 255, 255, 255, 0); + aa_line (x6, y6, x4, y4, 255, 255, 255, 0); +} + + +/* Ok, I'm getting a bit carried away now... */ +/* This thing rotates a curved mesh around, very inefficiently ;-) */ +static double ox[49]; +static double oy[49]; +static double oz[49]; +static double x[49]; +static double y[49]; +static double z[49]; + +void +draw_rotator (void) +{ + int xx = 19; + int yy = 19; + static int setup = 0; + double theta1inc = 0.05; + double theta2inc = 0.10; + double theta3inc = 0.03; + static double theta1 = 0.00; + static double theta2 = 0.00; + static double theta3 = 0.00; + int i; + double tx, ty; + double xcopy, ycopy, zcopy; + int from[84] = + { 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 21, 22, + 23, 24, 25, 26, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39, 40, 42, 43, + 44, 45, 46, 47, 0, 7, 14, 21, 28, 35, 1, 8, 15, 22, 29, 36, 2, 9, 16, + 23, 30, 37, 3, 10, 17, 24, 31, 38, 4, 11, 18, 25, 32, 39, 5, 12, 19, 26, + 33, 40, 6, 13, 20, 27, 34, 41 + }; + int to[84] = + { 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 22, 23, + 24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 41, 43, 44, + 45, 46, 47, 48, 7, 14, 21, 28, 35, 42, 8, 15, 22, 29, 36, 43, 9, 16, 23, + 30, 37, 44, 10, 17, 24, 31, 38, 45, 11, 18, 25, 32, 39, 46, 12, 19, 26, + 33, 40, 47, 13, 20, 27, 34, 41, 48 + }; + + if (!setup) + { + for (i = 0; i < 49; i++) + { + x[i] = 0; + y[i] = 0; + z[i] = 0; + + ox[i] = ((i % 7) - 3) * 75; + oy[i] = ((i / 7) - 3) * 75; + tx = (i % 7) - 3; + ty = (i / 7) - 3; + oz[i] = 50 - (-9 * tx * tx + 9 * ty * ty); + } + setup = 1; + } + + theta1 += theta1inc; + theta2 += theta2inc; + theta3 += theta3inc; + + blank_buf (); + + for (i = 0; i < 49; i++) + { + x[i] = ox[i]; + y[i] = oy[i]; + z[i] = oz[i]; + + xcopy = x[i]; + x[i] = (x[i] * cos (theta1) - y[i] * sin (theta1)); + y[i] = (xcopy * sin (theta1) + y[i] * cos (theta1)); + + ycopy = y[i]; + y[i] = (y[i] * cos (theta2) - z[i] * sin (theta2)); + z[i] = (ycopy * sin (theta2) + z[i] * cos (theta2)); + + zcopy = z[i]; + z[i] = (z[i] * cos (theta3) - x[i] * sin (theta3)); + x[i] = (zcopy * sin (theta3) + x[i] * cos (theta3)); + + /* add perspective */ + x[i] = (29 * x[i] / (550 - z[i])); + y[i] = (29 * y[i] / (550 - z[i])); + } + + for (i = 0; i < 84; i++) + { + aa_line (xx + x[from[i]], yy + y[from[i]], + xx + x[to[i]], yy + y[to[i]], (unsigned char) 255, 0, 255, + 255); + } +} + +/* Can I fit a starfield into a 40x40 window? */ +/* Gotta be worth a try! */ +#define NUM_STARS 60 +double star_x[NUM_STARS]; +double star_y[NUM_STARS]; +double star_z[NUM_STARS]; +double star_zv[NUM_STARS]; + +double star_screenx[NUM_STARS]; +double star_screeny[NUM_STARS]; + +void +draw_starfield (void) +{ + int i; + unsigned char b; + static int setup = 0; + + if (!setup) + { + for (i = 1; i < NUM_STARS; i++) + { + /* Never got the hang of random numbers under unix... */ + /* This can't be the way to do it... */ + star_x[i] = ((double) rand () / RAND_MAX * 2000) - 1000.0; + star_y[i] = ((double) rand () / RAND_MAX * 2000) - 1000.0; + star_z[i] = ((double) rand () / RAND_MAX * 600) + 400.0; + star_zv[i] = (((double) rand () / RAND_MAX * 45) + 5) / 10; + } + setup = 1; + } + + blank_buf (); + + for (i = 1; i < NUM_STARS; i++) + { + star_z[i] = star_z[i] - star_zv[i]; + + star_screenx[i] = star_x[i] / star_z[i] * 100 + 19; + star_screeny[i] = star_y[i] / star_z[i] * 100 + 19; + + if ((star_screenx[i] > 39) || (star_screenx[i] < 0) + || (star_screeny[i] > 39) || (star_screeny[i] < 0) + || (star_z[i] < 1)) + { + star_x[i] = ((double) rand () / RAND_MAX * 2000) - 1000.0; + star_y[i] = ((double) rand () / RAND_MAX * 2000) - 1000.0; + star_z[i] = ((double) rand () / RAND_MAX * 600) + 400.0; + star_zv[i] = (((double) rand () / RAND_MAX * 45) + 5) / 10; + } + else + { + b = ((255 / 5) * star_zv[i]) * (1000 / star_z[i]); + set_col_pixel (star_screenx[i], star_screeny[i], b, 255, 255, 255); + } + } +} + +/* AA too? Why not? */ +void +draw_aa_starfield (void) +{ + int i; + unsigned char b; + static int setup = 0; + + if (!setup) + { + for (i = 1; i < NUM_STARS; i++) + { + star_x[i] = ((double) rand () / RAND_MAX * 2000) - 1000.0; + star_y[i] = ((double) rand () / RAND_MAX * 2000) - 1000.0; + star_z[i] = ((double) rand () / RAND_MAX * 600) + 400.0; + star_zv[i] = (((double) rand () / RAND_MAX * 45) + 5) / 10; + } + blank_buf (); + setup = 1; + } + + fade_buf (80); + + for (i = 1; i < NUM_STARS; i++) + { + star_z[i] = star_z[i] - star_zv[i]; + + star_screenx[i] = star_x[i] / star_z[i] * 100 + 19; + star_screeny[i] = star_y[i] / star_z[i] * 100 + 19; + + if ((star_screenx[i] > 39) || (star_screenx[i] < 0) + || (star_screeny[i] > 39) || (star_screeny[i] < 0) + || (star_z[i] < 1)) + { + star_x[i] = ((double) rand () / RAND_MAX * 2000) - 1000.0; + star_y[i] = ((double) rand () / RAND_MAX * 2000) - 1000.0; + star_z[i] = ((double) rand () / RAND_MAX * 600) + 400.0; + star_zv[i] = (((double) rand () / RAND_MAX * 45) + 5) / 10; + } + else + { + b = ((255 / 5) * star_zv[i]) * (1000 / star_z[i]); + aa_pixel (star_screenx[i], star_screeny[i], b, 255, 255, 255); + } + } +} + + +/* Cheesy, but easy */ +void +draw_colorwarp (void) +{ + static int setup = 0; + static int rr = 0; + static int gg = 0; + static int bb = 0; + static int d_rr = 2; + static int d_gg = -3; + static int d_bb = 1; + + if (!setup) + { + /* setup */ + rr = rand () % 255; + gg = rand () % 255; + bb = rand () % 255; + setup = 1; + } + + rr += d_rr; + gg += d_gg; + bb += d_bb; + + if (rr <= 0) + { + d_rr = -d_rr; + rr = 0; + } + if (rr >= 255) + { + d_rr = -d_rr; + rr = 255; + } + if (gg <= 0) + { + d_gg = -d_gg; + gg = 0; + } + if (gg >= 255) + { + d_gg = -d_gg; + gg = 255; + } + if (bb <= 0) + { + d_bb = -d_bb; + bb = 0; + } + if (bb >= 255) + { + d_bb = -d_bb; + bb = 255; + } + + color_buf (rr, gg, bb); +} + + +/* Bouncing ball */ +void +draw_ball (void) +{ + static int setup = 0; + static double ball_x, ball_y; + static double d_x, d_y; + + if (!setup) + { + ball_x = rand () % 39; + ball_y = rand () % 39; + while (abs (d_x) < 0.5) + d_x = ((double) rand () / RAND_MAX * 4) - 2.0; + while (abs (d_y) < 0.5) + d_y = ((double) rand () / RAND_MAX * 4) - 2.0; + blank_buf (); + setup = 1; + } + + ball_x += d_x; + ball_y += d_y; + + if (ball_x < 0) + { + ball_x = 0; + d_x = -d_x; + } + else if (ball_x > 38) + { + ball_x = 38; + d_x = -d_x; + } + + if (ball_y < 0) + { + ball_y = 0; + d_y = -d_y; + } + else if (ball_y > 38) + { + ball_y = 38; + d_y = -d_y; + } + + fade_buf (93); + + set_col_pixel (ball_x, ball_y, 255, 255, 0, 0); + set_col_pixel (ball_x + 1, ball_y, 255, 255, 0, 0); + set_col_pixel (ball_x, ball_y + 1, 255, 255, 0, 0); + set_col_pixel (ball_x + 1, ball_y + 1, 255, 255, 0, 0); +} + +#define NUM_ATOMS 8 +static double atom_x[NUM_ATOMS]; +static double atom_y[NUM_ATOMS]; +static double atom_d_x[NUM_ATOMS]; +static double atom_d_y[NUM_ATOMS]; + +/* Bouncing atoms */ +void +draw_atoms (void) +{ + static int setup = 0; + int i; + + if (!setup) + { + for (i = 0; i < NUM_ATOMS; i++) + { + atom_x[i] = rand () % 39; + atom_y[i] = rand () % 39; + while (abs (atom_d_x[i]) < 0.5) + atom_d_x[i] = ((double) rand () / RAND_MAX * 3) - 1.5; + while (abs (atom_d_y[i]) < 0.5) + atom_d_y[i] = ((double) rand () / RAND_MAX * 3) - 1.5; + blank_buf (); + setup = 1; + } + } + else + fade_buf (83); + + for (i = 0; i < NUM_ATOMS; i++) + { + atom_x[i] += atom_d_x[i]; + atom_y[i] += atom_d_y[i]; + + if (atom_x[i] < 0) + { + atom_x[i] = 0; + atom_d_x[i] = -atom_d_x[i]; + } + else if (atom_x[i] > 38) + { + atom_x[i] = 38; + atom_d_x[i] = -atom_d_x[i]; + } + + if (atom_y[i] < 0) + { + atom_y[i] = 0; + atom_d_y[i] = -atom_d_y[i]; + } + else if (atom_y[i] > 38) + { + atom_y[i] = 38; + atom_d_y[i] = -atom_d_y[i]; + } + aa_pixel (atom_x[i], atom_y[i], 255, 255, 255, 0); + } +} +/* ************************* */ +/* Utility drawing functions */ +/* ************************* */ + +/* Maybe I'll optimise this later ;-) */ +static void +aa_line (int x1, int y1, int x2, int y2, unsigned char b, + unsigned char rr, unsigned char gg, unsigned char bb) +{ + double grad, line_width, line_height, xgap, ygap, xend, yend, yf, xf, + brightness1, brightness2, db, xm, ym; + int ix1, ix2, iy1, iy2, i; + int temp; + + unsigned char c1, c2; + + line_width = (x2 - x1); + line_height = (y2 - y1); + + if (abs (line_width) > abs (line_height)) + { + if (x1 > x2) + { + temp = x1; + x1 = x2; + x2 = temp; + temp = y1; + y1 = y2; + y2 = temp; + line_width = (x2 - x1); + line_height = (y2 - y1); + } + + /* This is currently broken for lines that don't + * span more than one pixel */ + if (abs (line_width) < 0.1) + { + x2 = x1 + 0.5; + x1 -= 0.5; + grad = 0; + } + else + { + grad = line_height / line_width; + if (line_width < 1) + { + xm = (x1 + x2) / 2; + ym = (y1 + y2) / 2; + + x1 = xm - 0.5; + x2 = xm + 0.5; + y1 = ym - (grad / 2); + y2 = ym + (grad / 2); + + line_width = 1; + line_height = grad; + } + } + + xend = (int) x1 + 0.5; + yend = y1 + grad * (xend - x1); + + xgap = (1 - modf (x1 + 0.5, &db)); + ix1 = (int) xend; + iy1 = (int) yend; + + brightness1 = (1 - modf (yend, &db)) * xgap; + brightness2 = modf (yend, &db) * xgap; + + c1 = (unsigned char) (brightness1 * b); + c2 = (unsigned char) (brightness2 * b); + + set_col_pixel (ix1, iy1, c1, rr, gg, bb); + set_col_pixel (ix1, iy1 + 1, c2, rr, gg, bb); + + yf = yend + grad; + + xend = (int) (x2 + .5); + yend = y2 + grad * (xend - x2); + + xgap = 1 - modf (x2 - .5, &db); + + ix2 = (int) xend; + iy2 = (int) yend; + + brightness1 = (1 - modf (yend, &db)) * xgap; + brightness2 = modf (yend, &db) * xgap; + + c1 = (unsigned char) (brightness1 * b); + c2 = (unsigned char) (brightness2 * b); + + set_col_pixel (ix2, iy2, c1, rr, gg, bb); + set_col_pixel (ix2, iy2 + 1, c2, rr, gg, bb); + + for (i = ix1 + 1; i < ix2; i++) + { + brightness1 = (1 - modf (yf, &db)); + brightness2 = modf (yf, &db); + + c1 = (unsigned char) (brightness1 * b); + c2 = (unsigned char) (brightness2 * b); + + set_col_pixel (i, (int) yf, c1, rr, gg, bb); + set_col_pixel (i, (int) yf + 1, c2, rr, gg, bb); + + yf = yf + grad; + } + } + else + { + if (y2 < y1) + { + temp = x1; + x1 = x2; + x2 = temp; + temp = y1; + y1 = y2; + y2 = temp; + line_width = (x2 - x1); + line_height = (y2 - y1); + } + + /* This is currently broken */ + if (abs (line_height) < 0.1) + { + y2 = y1 + 0.5; + y1 -= 0.5; + grad = 0; + } + else + { + grad = line_width / line_height; + if (line_height < 1) + { + xm = (x1 + x2) / 2; + ym = (y1 + y2) / 2; + + x1 = xm - (grad / 2); + x2 = xm + (grad / 2); + y1 = ym - 0.5; + y2 = ym + 0.5; + + line_height = 1; + line_width = grad; + } + } + + yend = (int) (y1 + 0.5); + xend = x1 + grad * (yend - y1); + + ygap = (1 - modf (y1 + 0.5, &db)); + ix1 = (int) xend; + iy1 = (int) yend; + + brightness1 = (1 - modf (xend, &db)) * ygap; + brightness2 = modf (xend, &db) * ygap; + + c1 = (unsigned char) (brightness1 * b); + c2 = (unsigned char) (brightness2 * b); + + set_col_pixel (ix1, iy1, c1, rr, gg, bb); + set_col_pixel (ix1 + 1, iy1, c2, rr, gg, bb); + + xf = xend + grad; + + yend = (int) (y2 + .5); + xend = x2 + grad * (yend - y2); + + ygap = 1 - modf (y2 - .5, &db); + + ix2 = (int) xend; + iy2 = (int) yend; + + brightness1 = (1 - modf (xend, &db)) * ygap; + brightness2 = modf (xend, &db) * ygap; + + c1 = (unsigned char) (brightness1 * b); + c2 = (unsigned char) (brightness2 * b); + + set_col_pixel (ix2, iy2, c1, rr, gg, bb); + set_col_pixel (ix2 + 1, iy2, c2, rr, gg, bb); + + for (i = iy1 + 1; i < iy2; i++) + { + brightness1 = (1 - modf (xf, &db)); + brightness2 = modf (xf, &db); + + c1 = (unsigned char) (brightness1 * b); + c2 = (unsigned char) (brightness2 * b); + + set_col_pixel ((int) xf, i, c1, rr, gg, bb); + set_col_pixel ((int) (xf + 1), i, c2, rr, gg, bb); + + xf += grad; + } + } +} + +static void +aa_pixel (double wx, double wy, unsigned char c, unsigned char rrr, + unsigned char ggg, unsigned char bbb) +{ + int x, y; + double fx, fy; + int btl, btr, bbl, bbr; + + x = (int) wx; + y = (int) wy; + fx = (double) wx - x; + fy = (double) wy - y; + + btl = ((1.0 - fx) * (1.0 - fy)) * c; + btr = ((fx) * (1.0 - fy)) * c; + bbl = ((1.0 - fx) * (fy)) * c; + bbr = (fx * fy) * c; + + set_col_pixel (x, y, btl, rrr, ggg, bbb); + set_col_pixel (x + 1, y, btr, rrr, ggg, bbb); + set_col_pixel (x, y + 1, bbl, rrr, ggg, bbb); + set_col_pixel (x + 1, y + 1, bbr, rrr, ggg, bbb); +} + +static void +set_col_pixel (int x, int y, unsigned char c, unsigned char rrr, + unsigned char ggg, unsigned char bbb) +{ + char *ptr; + + if ((((int) c) == 0) || (x < 0) || (y < 0) || (x > 39) || (y > 39)) + return; + + ptr = (buf)->im->rgb_data + ((buf)->im->rgb_width * 3 * (y)) + (3 * x); + ptr[0] = ((double) rrr / 255 * (double) c); + ptr[1] = ((double) ggg / 255 * (double) c); + ptr[2] = ((double) bbb / 255 * (double) c); +} + +static void +set_pixel (int x, int y, unsigned char c) +{ + char *ptr; + + if ((((int) c) == 0) || (x < 0) || (y < 0) || (x > 39) || (y > 39)) + return; + + ptr = (buf)->im->rgb_data + ((buf)->im->rgb_width * 3 * (y)) + (3 * x); + ptr[0] = c; + ptr[1] = c; + ptr[2] = c; +} diff --git a/epplets/cloak.h b/epplets/cloak.h new file mode 100644 index 0000000..b7a63b5 --- /dev/null +++ b/epplets/cloak.h @@ -0,0 +1,21 @@ +/* Just blank the epplet, kind of like the blank-screen screensaver */ +void blank_buf (void); +/* Draw a flame on the epplet, a la Raster's E-Cpu.epplet*/ +void draw_flame (void); +void set_flame_col (int j); +void flame_col (int r1, int g1, int b1, int r2, int g2, int b2, int r3, + int g3, int b3); +/* Radar thing by me */ +void draw_radar (void); +void draw_aa_radar (void); +/* Triangle thingummy */ +void draw_aa_triangle (void); +/* Star thingummys */ +void draw_aa_star (void); +void draw_starfield (void); +void draw_aa_starfield (void); +void draw_rotator (void); +void draw_scanner (void); +void draw_colorwarp (void); +void draw_ball(void); +void draw_atoms(void); diff --git a/epplets/utils.c b/epplets/utils.c new file mode 100644 index 0000000..1dac815 --- /dev/null +++ b/epplets/utils.c @@ -0,0 +1,66 @@ +#include +#include "utils.h" + +/* Sorry about these next two functions... + * I kind of needed them to do a quick port... + * I'll fix this up later :) + */ + +char * +_Strdup (char *s) +{ + char *ss; + int len; + + if (!s) + return NULL; + len = strlen (s); + ss = malloc (len + 1); + memcpy (ss, s, len + 1); + return ss; +} + +char * +_Strjoin (const char *separator, ...) +{ + char *string, *s; + va_list args; + int len; + int separator_len; + + if (separator == NULL) + separator = ""; + + separator_len = strlen (separator); + va_start (args, separator); + s = va_arg (args, char *); + + if (s) + { + len = strlen (s); + s = va_arg (args, char *); + while (s) + { + len += separator_len + strlen (s); + s = va_arg (args, char *); + } + va_end (args); + string = malloc (sizeof (char) * (len + 1)); + *string = 0; + va_start (args, separator); + s = va_arg (args, char *); + strcat (string, s); + s = va_arg (args, char *); + while (s) + { + strcat (string, separator); + strcat (string, s); + s = va_arg (args, char *); + } + } + else + string = _Strdup (""); + va_end (args); + + return string; +} diff --git a/epplets/utils.h b/epplets/utils.h new file mode 100644 index 0000000..a6112a1 --- /dev/null +++ b/epplets/utils.h @@ -0,0 +1,2 @@ +char *_Strdup (char *s); +char *_Strjoin (const char *separator, ...);