From a3ffa4630661c67ded469e19a83441b75d118a89 Mon Sep 17 00:00:00 2001 From: Kris Kennaway Date: Sat, 25 Aug 2001 09:55:44 +0000 Subject: Add xworld-2.0 XWorld displays a pretty picture of our earth as it would look if viewed from the direction of the sun. The window is regularly updated. You can use xworld in lieu of a clock. Obtained from: OpenBSD --- astro/Makefile | 1 + astro/xworld/Makefile | 27 ++++++++ astro/xworld/distinfo | 1 + astro/xworld/files/patch-xworld_c | 140 ++++++++++++++++++++++++++++++++++++++ astro/xworld/pkg-comment | 1 + astro/xworld/pkg-descr | 3 + astro/xworld/pkg-plist | 1 + 7 files changed, 174 insertions(+) create mode 100644 astro/xworld/Makefile create mode 100644 astro/xworld/distinfo create mode 100644 astro/xworld/files/patch-xworld_c create mode 100644 astro/xworld/pkg-comment create mode 100644 astro/xworld/pkg-descr create mode 100644 astro/xworld/pkg-plist (limited to 'astro') diff --git a/astro/Makefile b/astro/Makefile index f4eaf81851a3..64770e8e092a 100644 --- a/astro/Makefile +++ b/astro/Makefile @@ -38,5 +38,6 @@ SUBDIR += xphoon SUBDIR += xplanet SUBDIR += xtide + SUBDIR += xworld .include diff --git a/astro/xworld/Makefile b/astro/xworld/Makefile new file mode 100644 index 000000000000..a0340918af1d --- /dev/null +++ b/astro/xworld/Makefile @@ -0,0 +1,27 @@ +# Ports collection makefile for: xworld +# Date created: 24 Aug 2001 +# Whom: Kris Kennaway diff --git a/astro/xworld/distinfo b/astro/xworld/distinfo new file mode 100644 index 000000000000..195b7c74ac1f --- /dev/null +++ b/astro/xworld/distinfo @@ -0,0 +1 @@ +MD5 (xworld-2.0.tar.gz) = 226cbd2b0698d8d9e5f56851d9c90e5e diff --git a/astro/xworld/files/patch-xworld_c b/astro/xworld/files/patch-xworld_c new file mode 100644 index 000000000000..63cc59e8a531 --- /dev/null +++ b/astro/xworld/files/patch-xworld_c @@ -0,0 +1,140 @@ +--- xworld.c.orig Wed Jul 28 17:39:11 1999 ++++ xworld.c Sat Aug 11 21:23:01 2001 +@@ -63,6 +63,8 @@ + #define BORDER 5 + #define SLEEP 120 + ++#define MIN(x,y) (((x)<(y))?(x):(y)) ++ + char *MainTitle[] = {"Hello, world"}; + char *IconTitle[] = {"xworld"}; + +@@ -92,6 +94,26 @@ usage() + exit(1); + } + ++ ++static char * ++alloc_image(XImage *image) ++{ ++ char *Map; ++ int ix, iy, j; ++ Map = (char *)malloc(image->height * image->bytes_per_line); ++ if (Map == NULL) { ++ fprintf(stderr, "xworld: not enough memory\n"); ++ exit(1); ++ } ++ image->data = Map; ++ ++ for(j = 0, ix = 0; ix < image->width; ix++) ++ for (iy = 0; iy < image->height; iy++) ++ XPutPixel(image, ix, iy, j++ % NCOLORS); ++ ++ return Map; ++} ++ + int + main(int argc, char **argv) + { +@@ -305,29 +327,16 @@ main(int argc, char **argv) + xcolor[i].blue = color[i].blue; + if (XAllocColor(display, cmap, &xcolor[i]) == 0) { + fprintf(stderr, "xworld: can't allocate colors\n"); ++#if 0 + exit(-1); ++#endif + } + } + + /* + * generate startup image + */ +- Map = (char *)malloc(size*size*sizeof(char)); +- if (Map == NULL) { +- fprintf(stderr, "xworld: not enough memory\n"); +- exit(1); +- } +- +- j = 0; +- for (iy = 0; iy < size; iy++) { +- i = iy % (NCOLORS + 1); +- for (ix = 0; ix < size; ix++) { +- *(Map + j++) = xcolor[i].pixel; +- if (i++ >= NCOLORS) i = 0; +- } +- } +- +- image->data = Map; ++ Map = alloc_image(image); + + gc = XCreateGC(display, win, 0, 0); + +@@ -414,21 +423,21 @@ main(int argc, char **argv) + * Map elevations to colors + */ + if (i != SOK) { +- *(Map + j) = xcolor[BLACK].pixel; ++ XPutPixel(image, ix, iy, xcolor[BLACK].pixel); + continue; + } + if (Value > level[NLEVELS - 1]) { +- *(Map + j) = xcolor[HIGH].pixel; ++ XPutPixel(image, ix, iy, xcolor[HIGH].pixel); + continue; + } + for (i = 0; i <= NLEVELS - 1; i++) { + if (Value <= level[i]) { +- *(Map + j) = xcolor[i].pixel; ++ XPutPixel(image, ix, iy, xcolor[i].pixel); + break; + } + } + } else +- *(Map + j) = xcolor[BLACK].pixel; ++ XPutPixel(image, ix, iy, xcolor[BLACK].pixel); + } + } + XPutImage(display, win, gc, image, 0, 0, 0, 0, size, size); +@@ -444,8 +453,12 @@ main(int argc, char **argv) + ConfigureEvent = (XConfigureEvent *)&event; + size = ConfigureEvent->width; + if (ConfigureEvent->height != size) { ++#if 0 + fprintf(stderr, "xworld: error: width != height\n"); + exit(1); ++#else ++ size = MIN(size, ConfigureEvent->height); ++#endif + } + if (size != old_size) { + old_size = size; +@@ -453,28 +466,14 @@ main(int argc, char **argv) + r1 = n/2; + r2 = size/2; + XDestroyImage(image); +- free(Map); + image = XCreateImage(display, visual, depth, format, + 0, 0, size, size, bitmap_pad, 0); + if (image == NULL) { + fprintf(stderr, "xworld: can't create XImage\n"); + exit(1); + } +- Map = (char *)malloc(size*size*sizeof(char)); +- if (Map == NULL) { +- fprintf(stderr, "xworld: not enough memory\n"); +- exit(1); +- } +- image->data = Map; ++ Map = alloc_image(image); + +- j = 0; +- for (iy = 0; iy < size; iy++) { +- i = iy % (NCOLORS + 1); +- for (ix = 0; ix < size; ix++) { +- *(Map + j++) = xcolor[i].pixel; +- if (i++ >= NCOLORS) i = 0; +- } +- } + XPutImage(display, win, gc, image, 0, 0, 0, 0, + size, size); + break; diff --git a/astro/xworld/pkg-comment b/astro/xworld/pkg-comment new file mode 100644 index 000000000000..ec23472901ce --- /dev/null +++ b/astro/xworld/pkg-comment @@ -0,0 +1 @@ +Earth as seen from the direction of the sun diff --git a/astro/xworld/pkg-descr b/astro/xworld/pkg-descr new file mode 100644 index 000000000000..69615586e314 --- /dev/null +++ b/astro/xworld/pkg-descr @@ -0,0 +1,3 @@ +XWorld displays a pretty picture of our earth as it would look if +viewed from the direction of the sun. The window is regularly updated. +You can use xworld in lieu of a clock. diff --git a/astro/xworld/pkg-plist b/astro/xworld/pkg-plist new file mode 100644 index 000000000000..efe8c508b8c2 --- /dev/null +++ b/astro/xworld/pkg-plist @@ -0,0 +1 @@ +bin/xworld -- cgit v1.2.3