This email list is read-only.  Emails sent to this list will be discarded
----------------------------------
 apple/apple.desktop    |    1 +
 colortext/Makefile.am  |    3 +-
 colortext/colortext.c  |  406 ++++++++++++++++++++++++++++++++++++++++++++++++
 colortext/configure.ac |   39 -----
 colortext/main.c       |  406 ------------------------------------------------
 5 files changed, 408 insertions(+), 447 deletions(-)

New commits:
commit 8f066d32d1f9039b4c66d66b8d4957225016ab37
Author: Bob Spencer <[EMAIL PROTECTED]>
Date:   Wed Aug 13 14:33:15 2008 -0700

    Updated colortext -- removed configure.ac, tweaked Makefile.am
    changed main.c to colortext.c to be consistent


Diff in this email is a maximum of 400 lines.
diff --git a/apple/apple.desktop b/apple/apple.desktop
index 142d232..25c0fe0 100644
--- a/apple/apple.desktop
+++ b/apple/apple.desktop
@@ -3,6 +3,7 @@ Version=0.1
 Encoding=UTF-8
 Name=Clutter Apple
 Type=Application
+Categories=Utility
 Icon=clutter_apple
 Exec=apple
 Name[en_US]=Clutter Apple
diff --git a/colortext/Makefile.am b/colortext/Makefile.am
index 2c6273d..c646431 100644
--- a/colortext/Makefile.am
+++ b/colortext/Makefile.am
@@ -1,7 +1,5 @@
 bin_PROGRAMS = colortext
 
-colortextdir = $(datadir)/colortext
-
 AM_CFLAGS = $(CLUTTER_CFLAGS) \
        $(GCC_CFLAGS) \
        -D_GNU_SOURCE
@@ -12,6 +10,7 @@ colortext_SOURCES = main.c
 desktopdir = $(datadir)/applications
 desktop_DATA = colortext.desktop
 
+colortextdir = $(datadir)/colortext
 colortext_DATA = word_file
 
 icondir = $(datadir)/icons/hicolor/48x48/apps
diff --git a/colortext/colortext.c b/colortext/colortext.c
new file mode 100644
index 0000000..9da476a
--- /dev/null
+++ b/colortext/colortext.c
@@ -0,0 +1,406 @@
+/* main.c */
+
+#include <clutter/clutter.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#define FILENAME "/usr/local/share/colortext/word_file"
+#define LENGTH_LIMIT 12
+#define NUM_ACTORS 20
+#define NUM_COLORS 20
+
+#define CRIMSON     { 0xDC, 0x14, 0x3C, 0xff };
+#define HOTPINK     { 0xFF, 0x14, 0x93, 0xff };
+#define VIOLET      { 0x80, 0x00, 0x80, 0xff };
+#define INDIGO      { 0x4B, 0x00, 0x82, 0xff };
+#define SLATEBLUE   { 0x48, 0x3D, 0x8B, 0xff };
+
+#define COBALT      { 0x3D, 0x59, 0xAB, 0xff };
+#define CORNFLOWER  { 0x64, 0x95, 0xED, 0xff };
+#define SKYBLUE     { 0x00, 0xBF, 0xFF, 0xff };
+#define PEACOCK     { 0x33, 0xA1, 0xC9, 0xff };
+#define AQUAMARINE  { 0x7F, 0xFF, 0xD4, 0xff };
+
+#define SPRINGGREEN { 0x00, 0xFF, 0x7F, 0xff };
+#define EMERALD     { 0x32, 0xCD, 0x32, 0xff };
+#define CHARTREUSE  { 0x7F, 0xFF, 0x00, 0xff };
+#define OLIVE       { 0x6B, 0x8E, 0x23, 0xff };
+#define GOLD        { 0xFF, 0xFF, 0x00, 0xff };
+
+#define ORANGE      { 0xFF, 0xA5, 0x00, 0xff };
+#define CADMIUM     { 0xCD, 0x85, 0x00, 0xff };
+#define CORAL       { 0xFF, 0x7F, 0x50, 0xff };
+#define ROSYBROWN   { 0xFF, 0xC1, 0xC1, 0xff };
+#define FIREBRICK   { 0xEE, 0x2C, 0x2C, 0xff };
+
+
+ClutterActor *actors[NUM_ACTORS]; //array to pointers of clutter actors
+ClutterColor colors[NUM_COLORS];
+
+ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff };
+ClutterColor letter_color = { 0xf0, 0xf0, 0xf0, 0x39 };
+
+ClutterActor *stage;
+ClutterTimeline *rand_timeline;
+ClutterTimeline *word_timeline;
+ClutterScore *score;
+
+FILE *fp;
+
+int color_word = 0;
+int curr_char = ' ';
+int word_countdown = 0;
+
+
+
+/*
+   Select a random letter within the range
+   of lowercase letters and assign to the
+   given actor.
+ */
+void give_random_letter(ClutterActor *label)
+{
+  int stay = 1;
+  int random_int = 0;
+  while (stay == 1)
+  {
+     random_int = (rand() % 122);
+     if (random_int < 26) {
+         random_int += 97;
+         stay = 0;
+     }
+  }
+  char *text;
+  switch (random_int)
+  {
+    case 97: text = "a"; break;
+    case 98: text = "b"; break;
+    case 99: text = "c"; break;
+    case 100: text = "d"; break;
+    case 101: text = "e"; break;
+    case 102: text = "f"; break;
+    case 103: text = "g"; break;
+    case 104: text = "h"; break;
+    case 105: text = "i"; break;
+    case 106: text = "j"; break;
+    case 107: text = "k"; break;
+    case 108: text = "l"; break;
+    case 109: text = "m"; break;
+    case 110: text = "n"; break;
+    case 111: text = "o"; break;
+    case 112: text = "p"; break;
+    case 113: text = "r"; break;
+    case 114: text = "r"; break;
+    case 115: text = "s"; break;
+    case 116: text = "t"; break;
+    case 117: text = "u"; break;
+    case 118: text = "v"; break;
+    case 119: text = "w"; break;
+    case 120: text = "x"; break;
+    case 121: text = "y"; break;
+    case 122: text = "z"; break;
+    default: text = "a";
+  }  
+  clutter_label_set_text((ClutterLabel*)label, text);
+  return;
+
+}//end give_random_letter
+
+
+
+/*
+   Reads a color-name, char by char, from FILENAME 
+   and assigns each char to an actor and sets the
+   appropriate color corresponding to the color
+   name.
+ */
+void display_word()
+{
+  char curr_word[LENGTH_LIMIT];
+  memset(curr_word, 0, sizeof(char) * LENGTH_LIMIT);
+  char *ptr;
+  curr_char = fgetc(fp);
+  int k;
+  
+  //pause the timeline so that we can see the word
+  clutter_timeline_set_delay(rand_timeline, 1000);
+  clutter_timeline_pause(rand_timeline);
+
+  for (k = 4; k < NUM_ACTORS; k++)
+  {
+      if (curr_char != ' '){
+           clutter_label_set_text((ClutterLabel*)actors[k], 
(gchar*)&curr_char);
+           clutter_label_set_color((ClutterLabel*)actors[k], 
+                                    &colors[color_word]);
+           curr_char = fgetc(fp);
+      }
+      else {
+           k = NUM_ACTORS;
+      }
+  }
+
+  clutter_timeline_start(rand_timeline);
+  ++color_word;
+
+  if (curr_char == '$')
+  {
+       clutter_timeline_stop(word_timeline);
+  }
+
+  return;
+}//end display_word
+
+
+
+/*
+   Makes the call to randomize the letter displayed by each of
+   the actors and resets the base color (letter_color).
+ */
+void randomize_the_letters(ClutterTimeline *timeline, guint frame_num)
+{
+  int i;
+  for (i = 0; i < NUM_ACTORS; i++)
+  {
+       give_random_letter(actors[i]);
+       clutter_label_set_color((ClutterLabel*)actors[i], &letter_color);
+  }
+  return;
+} //end randomize_the_letters
+
+
+
+/*
+   Initialize all actors (which are individual letters of the
+   alphabet).
+ */
+void init_actors()
+{
+
+  /* Add first actor */
+  actors[0] = clutter_label_new_full("Sans 32", "i", &letter_color);
+  clutter_actor_set_size(actors[0], 30, 30);
+  clutter_actor_set_position(actors[0], 25, 250);
+  clutter_container_add_actor(CLUTTER_CONTAINER(stage), actors[0]);
+  clutter_actor_show(actors[0]);
+
+  actors[1]  = clutter_label_new_full("Sans 32", "f", &letter_color);
+  actors[2]  = clutter_label_new_full("Sans 32", "e", &letter_color);
+  actors[3]  = clutter_label_new_full("Sans 32", "l", &letter_color);
+  actors[4]  = clutter_label_new_full("Sans 32", "i", &letter_color);
+  actors[5]  = clutter_label_new_full("Sans 32", "c", &letter_color);
+  actors[6]  = clutter_label_new_full("Sans 32", "i", &letter_color);
+  actors[7]  = clutter_label_new_full("Sans 32", "a", &letter_color);
+  actors[8]  = clutter_label_new_full("Sans 32", "d", &letter_color);
+  actors[9]  = clutter_label_new_full("Sans 32", "e", &letter_color);
+  actors[10] = clutter_label_new_full("Sans 32", "c", &letter_color);
+  actors[11] = clutter_label_new_full("Sans 32", "k", &letter_color);
+  actors[12] = clutter_label_new_full("Sans 32", "e", &letter_color);
+  actors[13] = clutter_label_new_full("Sans 32", "r", &letter_color);
+  actors[14] = clutter_label_new_full("Sans 32", "0", &letter_color);
+  actors[15] = clutter_label_new_full("Sans 32", "7", &letter_color);
+  actors[16] = clutter_label_new_full("Sans 32", "3", &letter_color);
+  actors[17] = clutter_label_new_full("Sans 32", "1", &letter_color);
+  actors[18] = clutter_label_new_full("Sans 32", "0", &letter_color);
+  actors[19] = clutter_label_new_full("Sans 32", "8", &letter_color);
+
+  int i;
+  int start_width = 25;
+  for (i = 1; i < NUM_ACTORS; i++)
+  {
+      start_width += 50;
+      clutter_actor_set_size(actors[i], 30, 30);
+      clutter_actor_set_position(actors[i], start_width, 250);
+      clutter_container_add_actor(CLUTTER_CONTAINER(stage), actors[i]);
+      clutter_actor_show(actors[i]);
+  }
+  return;
+
+}//end init_actors
+
+
+
+/*
+   Initialize the colors array to the following NUM_COLORS
+   colors.
+   For some reason a line like this:
+   colors[0] = { 0x00, 0x00, 0x00, 0xff };
+   was not allowed. 
+ */
+void init_colors()
+{
+  ClutterColor color_crimson     = { 0xDC, 0x14, 0x3C, 0xff };
+  ClutterColor color_hotpink     = { 0xFF, 0x14, 0x93, 0xff };
+  ClutterColor color_violet      = { 0x80, 0x00, 0x80, 0xff };
+  ClutterColor color_indigo      = { 0x4B, 0x00, 0x82, 0xff };
+  ClutterColor color_slateblue   = { 0x48, 0x3D, 0x8B, 0xff };
+  ClutterColor color_cobalt      = { 0x3D, 0x59, 0xAB, 0xff };
+  ClutterColor color_cornflower  = { 0x64, 0x95, 0xED, 0xff };
+  ClutterColor color_steelblue   = { 0x00, 0xBF, 0xFF, 0xff };
+  ClutterColor color_peacock     = { 0x33, 0xA1, 0xC9, 0xff };
+  ClutterColor color_aquamarine  = { 0x7F, 0xFF, 0xD4, 0xff };
+  ClutterColor color_springgreen = { 0x00, 0xFF, 0x7F, 0xff };
+  ClutterColor color_emerald     = { 0x32, 0xCD, 0x32, 0xff };
+  ClutterColor color_chartreuse  = { 0x7F, 0xFF, 0x00, 0xff };
+  ClutterColor color_olive       = { 0x6B, 0x8E, 0x23, 0xff };
+  ClutterColor color_gold        = { 0xFF, 0xFF, 0x00, 0xff };
+  ClutterColor color_orange      = { 0xFF, 0xA5, 0x00, 0xff };
+  ClutterColor color_cadmium     = { 0xCD, 0x85, 0x00, 0xff };
+  ClutterColor color_coral       = { 0xFF, 0x7F, 0x50, 0xff };
+  ClutterColor color_rosybrown   = { 0xFF, 0xC1, 0xC1, 0xff };
+  ClutterColor color_firebrick   = { 0xEE, 0x2C, 0x2C, 0xff };
+
+  colors[0]  = color_crimson;
+  colors[1]  = color_hotpink;
+  colors[2]  = color_violet;
+  colors[3]  = color_indigo;
+  colors[4]  = color_slateblue;
+  colors[5]  = color_cobalt;
+  colors[6]  = color_cornflower;
+  colors[7]  = color_steelblue;
+  colors[8]  = color_peacock;
+  colors[9]  = color_aquamarine;
+  colors[10] = color_springgreen;
+  colors[11] = color_emerald;
+  colors[12] = color_chartreuse;
+  colors[13] = color_olive;
+  colors[14] = color_gold;
+  colors[15] = color_orange;
+  colors[16] = color_cadmium;
+  colors[17] = color_coral;
+  colors[18] = color_rosybrown;
+  colors[19] = color_firebrick;
+
+  return;
+
+}//end init_colors
+
+
+
+/*
+   Stop the word timeline once we have
+   gone through all the colors.
+ */
+void stop_word_timeline()
+{
+  ++word_countdown;
+  if (word_countdown == NUM_COLORS)
+      clutter_timeline_stop(word_timeline);
+
+  return;
+}//end stop_word_timeline
+
+
+
+/*
+   Last effect, once both timelines are stopped.
+ */
+void end_effect()
+{
+  int k;
+
+  for (k = 1; k < NUM_ACTORS; k++)
+  {
+      clutter_label_set_color((ClutterLabel*)actors[k], &colors[k]);
+  }
+
+  ClutterColor color_black = { 0xff, 0xff, 0xff, 0xff };
+  clutter_label_set_color((ClutterLabel*)actors[0], &color_black);
+  clutter_label_set_color((ClutterLabel*)actors[NUM_ACTORS - 1], &color_black);
+
+  clutter_label_set_text((ClutterLabel*)actors[0],  "{");
+  clutter_label_set_text((ClutterLabel*)actors[1],  "c");
+  clutter_label_set_text((ClutterLabel*)actors[2],  "o");
+  clutter_label_set_text((ClutterLabel*)actors[3],  "l");
+  clutter_label_set_text((ClutterLabel*)actors[4],  "o");
+  clutter_label_set_text((ClutterLabel*)actors[5],  "r");
+  clutter_label_set_text((ClutterLabel*)actors[6],  "s");
+  clutter_label_set_text((ClutterLabel*)actors[7],  "o");
+  clutter_label_set_text((ClutterLabel*)actors[8],  "f");
+  clutter_label_set_text((ClutterLabel*)actors[9],  "t");
+  clutter_label_set_text((ClutterLabel*)actors[10], "h");
+  clutter_label_set_text((ClutterLabel*)actors[11], "e");
+  clutter_label_set_text((ClutterLabel*)actors[12], "r");
+  clutter_label_set_text((ClutterLabel*)actors[13], "a");
+  clutter_label_set_text((ClutterLabel*)actors[14], "i");
+  clutter_label_set_text((ClutterLabel*)actors[15], "n");
+  clutter_label_set_text((ClutterLabel*)actors[16], "b");
+  clutter_label_set_text((ClutterLabel*)actors[17], "o");
+  clutter_label_set_text((ClutterLabel*)actors[18], "w");
+  clutter_label_set_text((ClutterLabel*)actors[19], "}");
+
+}//end end_effect
+
+
+
+/* 
+   Stop the random timeline when we have
+   gone through all the colors. 
+ */
+void stop_rand_timeline()
+{
+  if (word_countdown == NUM_COLORS)
+  {
+      clutter_timeline_stop(rand_timeline);
+      end_effect();
+  }
+  return;
+
+}//end stop_rand_timeline
+
+
+
+/*
+
+ */
+int main(int argc, char *argv[])
+{
+  clutter_init(&argc, &argv);
+
+  fp = fopen(FILENAME, "r");
+  if (fp == NULL) {
+     fprintf(stderr, "Error: %s could not be opened.\n", FILENAME);
_______________________________________________
Commits mailing list
[email protected]
https://www.moblin.org/mailman/listinfo/commits

Reply via email to