GUI Code
  Home arrow GUI Code arrow Color Center
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
GUI CODE

Color Center
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2002-06-16

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    This is some code I designed to generate a random color or test another color (hex values) against itself or against another. It also keeps a list of liked colors and descriptions and displays them on the side. It will then, upon pressing the compile button, put the codes in an array-friendly format for easy transportation to the file. I've left some of the colors in the array for display purposes. It also requires an empty file called colors.html (with correct permissions) to function (for list-saving to work). - Kate, webmaster@griflet.com

    By : kate2587

    <?php
    $colors = array(
    "D4D0B4" => "light tan",
    "A69E5E" => "gold",
    "666644" => "hunting brown",
    "4E4439" => "less dark brown",
    "3B3632" => "really dark brown",
    "583324" => "dark brown",
    "641504" => "brick red",
    "7C0605" => "brick red",
    );
    ?>
    <html>
    <head>

    <style type="text/css">
    table.show {border-width: 0; width: 300; height: 20; cellpadding: 10; font-weight: bold;}
    body {font-family: 'Trebuchet MS', Verdana, 'Comic Sans MS';}
    input {border-width: 1; border-color: black; background: white; color: black;}
    td {text-valign: top;}
    body , table , table.show {color: <?php echo $font_color; ?>;}
    a {text-decoration: none; color: <?php if(isset($font_color)) {echo "$font_color";} if (empty($font_color)) {echo "black";} ?>;}
    </style>

    <title>Color Center</title>
    </head>

    <?php
    foreach($GLOBALS as $varname => $value)
    {$$varname = $value;}

    //RANDOM
    function random()
    {
    global $bgcolor;
    $num[1] = rand(0,15);
    $num[2] = rand(0,15);
    $num[3] = rand(0,15);
    $num[4] = rand(0,15);
    $num[5] = rand(0,15);
    $num[6] = rand(0,15);
    foreach($num As $letter)
    {
    if ($letter == "10") {$letter = "A";}
    elseif ($letter == "11") {$letter = "B";}
    elseif ($letter == "12") {$letter = "C";}
    elseif ($letter == "13") {$letter = "D";}
    elseif ($letter == "14") {$letter = "E";}
    elseif ($letter == "15") {$letter = "F";}
    else {$letter = $letter;}
    $bgcolor = $bgcolor . $letter
    ;}
    return $bgcolor;
    }

    $file = "colors.html";

    //ADD
    if ($action == "add")
    {
    $fp = fopen($file,"a");
    $toAdd = "<br>\"$added\" => \"$descrip\"";
    fwrite($fp, $toAdd);
    fclose($fp);
    $bgcolor = $added;
    }

    //ERASE
    if ($action == "erase")
    {
    $fp = fopen($file,"w");
    fclose($fp);
    $action = "random";
    }

    //COMPILE
    if ($action == "compile")
    {
    if(empty($bgcolor)) {$bgcolor = "FFFFFF";}
    if(empty($font_color)) {$font_color = "000000";}
    }
    function compile()
    {
    echo "<form><textarea cols='35' rows='5' wrap>";
    $file_for_me = "colors.html";
    $fp = fopen($file_for_me,"r");
    $file_lines = fread($fp,"20000");
    $lines = explode("<br>", $file_lines);
    unset($lines[0]);
    foreach ($lines As $spot)
    {
    $list = $list . "\n$spot, ";
    }
    echo "$list</textarea></form>";
    }

    //MORE ON RANDOM
    if ($action == "random") {random();}

    if (empty($font_color)) {$font_color = "000000";}
    if (empty($bgcolor)) {$bgcolor = "FFFFFF";}
    ?>



    <body bgcolor="#<?php echo $bgcolor; ?>">
    <font color="#<?php echo $font_color; ?>">

    <!--start table-->
    <table border="0">
    <tr><td width="300" valign="top">

    <?php if ($action == "compile") {compile();} ?>

    <script language="javascript">
    function clear_em()
    {
    window.document.test_form.bgcolor.value = "";
    window.document.test_form.font_color.value = "";
    window.document.test_form.test_color.value = "";
    }
    </script>

    <form action="<?php echo $PHP_SELF;?>" method="get" name="test_form">
    <b>bgcolor</b> <input type="text" name="bgcolor" value="<?php echo $bgcolor; ?>"><br>
    <b>font color</b> <input type="text" name="font_color" value="<?php echo $font_color; ?>"><br>
    <b>test color</b> <input type="text" name="test_color" value="<?php echo $test_color; ?>"><br>

    <input type="submit" value="test"> &nbsp; <input type="button" value="clear" onClick="clear_em()"><br>
    </form>

    <form action="<?php echo $PHP_SELF; ?>" method="get">
    <input type="submit" value="random">
    <input type="hidden" value="random" name="action">
    </form>

    <form action="<?php echo $PHP_SELF; ?>" method="get">
    <b>add a color<br>
    color code <input type="text" name="added" value="<?php echo $bgcolor;?>"><br>
    description</b> <input type="text" name="descrip" value="<?php echo $descrip;?>"><br>
    <input type="submit" value="add to list">
    <input type="hidden" value="add" name="action">
    </form>

    <br>

    <?php
    echo "<b>background</b> = $bgcolor<br>";
    echo "<b>text color</b> = $font_color<br><br>";
    ?>

    <form action="<?php echo "$PHP_SELF"; ?>" method="get">
    <input type="submit" value="original page">
    </form>

    <!--NEXT COLUMN-->
    </td><td width="225" valign="top">
    <b>List</b><br>

    <?php
    include "colors.html";
    ?>

    <!--ERASE CONFIRM-->
    <script language="javascript">
    function erase_yesno()
    {
    if (confirm("Do you really want to erase the values?"))
    {window.location.href="<?php echo "$PHP_SELF?action=erase";?>"}
    else {window.location.href="<?php echo "$PHP_SELF?action=random";?>"};
    }
    </script>

    <!--compile submit-->
    <form action="<?php echo $PHP_SELF ?>" method="get">
    <input type="submit" value="compile">
    <input type="hidden" value="compile" name="action">
    </form>

    <!--erase submit-->
    <form action="<?php echo $PHP_SELF ?>" method="get">
    <input type="button" value="erase list" onClick="erase_yesno(); return erase_yesno;">
    <input type="hidden" value="erase" name="action">
    </form>

    <!--write test?-->
    <?php
    if ($test_color != "")
    {
    echo("<table bgcolor=\"$test_color\" border='0' width='200' height='500'><tr><td><br> <br></td></tr></table>");
    }
    ?>

    <!--start new column-->
    <td valign="top">
    <?php
    foreach($colors as $color => $def)
    { echo "<table class=\"show\" bgcolor=\"";
    echo $color;
    echo "\"><tr><td><a href=\"";
    $path = "$PHP_SELF?bgcolor=$color&descrip=$def";
    echo "$path\">$color - $def</a></td><td width='40'><a href=\"$PHP_SELF?bgcolor=$bgcolor&font_color=$font_color&test_color=$color\">test</a></td></tr></table><br>";
    }
    ?>

    </td></tr></table>

    </font>
    </body>
    </html>
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More GUI Code Articles
    More By Codewalkers

     

    IBM® developerWorks developerWorks - FREE Tools!


    NEW! Cook up Web sites fast with CakePHP, Part 4: Use CakePHP&apos;s Session and Request Handler components

    CakePHP is a stable production-ready, rapid-development aid for building Web sites in PHP. This "Cook up Web sites fast with CakePHP" series shows you how to build an online product catalog using CakePHP.
    FREE! Go There Now!


    NEW! Did you say mainframe? e-kit

    Learn how you can extend modern application lifecycle management to IBM System z through the IBM Rational Software Delivery Platform (SDP). The Did you say mainframe? e-kit includes podcasts, webcasts, tutorials, white and red papers, demos, and articles designed to help ease the challenges of modernizing your enterprise. This complimentary kit for mainframe developers is a practical, how-to guide for making the most of an existing development environment, including the skills and infrastructure already in place at an established enterprise.
    FREE! Go There Now!


    NEW! Download a free trial of Lotus Quickr 8.0

    Visit IBM developerWorks to download a free trial version of Lotus Quickr 8.0, which enables collaboration by transforming the way everyday business content such as documents, rich media, photos, and video can be shared. Lotus Quickr makes it faster and easier to share content of all types (not just documents) within virtual teams. It is designed to make it easier to collaborate across organizational boundaries, while continuing to work within the context of familiar desktop applications.
    FREE! Go There Now!


    NEW! Download DB2 Express-C 9.5

    Visit IBM developerWorks to download IBM DB2 Express-C 9.5, a no-charge version of DB2 Express 9 database server. DB2 Express-C offers the same core data server base features as other DB2 Express editions and provides a solid base to build and deploy applications developed using C/C++, Java, .NET, PHP, and other programming languages.
    FREE! Go There Now!


    NEW! Download IBM Data Studio V1.1

    Visit IBM developerWorks to download the latest trial version of IBM Data Studio V1.1 at no cost. IBM Data Studio is a comprehensive data management solution that helps you effectively design, develop, deploy and manage your data, databases, and database applications throughout the data management life cycle utilizing a consistent and integrated user interface. Unlike other client-side data management solutions that focus on only one aspect of the application lifecycle or database administration, Data Studio complements the Rational Software Delivery platform, providing unparalleled flexibility for a heterogeneous data server environment across platforms.
    FREE! Go There Now!


    NEW! IBM Enterprise Modernization Sandbox for System z: Architecture

    Analysts, architects, and developers who have existing COBOL or PL/I skills and want to extend those skills to deploy new workloads on the mainframe can use the IBM Enterprise Modernization Sandbox for System z to find hands-on walkthroughs of common real world scenarios. The scenarios provide examples of how to rapidly design, create, assemble, test, and deploy high-quality Web, Web services, portal, and SOA applications for IBM CICS, IBM IMS, and IBM WebSphere Application Server.
    FREE! Go There Now!


    NEW! IBM Rational ClearCase Innovator's Series

    Learn from the best! Find out how developers use Rational ClearCase to be more flexible, innovative and deliver higher quality code in the Rational ClearCase Power Users eKit. This complimentary eKit provides a collection of materials, like articles, whitepapers, and demos that can help you become a power user of Rational ClearCase.
    FREE! Go There Now!


    NEW! Improve your build process with IBM Rational Build Forge, Part 2: Automate builds for a real-world Tomcat project

    Learn how Rational Build Forge can extend a simple compile and package build process by adding customization and deployment capability. Go from a manual method to automating: checking for code changes; getting the latest source; compiling and packaging; customizing; copying to and restarting a deployment server; and sending e-mail notification that a new version is available.
    FREE! Go There Now!


    NEW! Using IBM Rational Developer for System z and IBM Rational ClearCase together to manage application development

    Whether you are creating new applications or modifying existing ones, managing integration of new components with traditional z/OS elements is a critical part of building and deploying modern applications. Listen to this webcast to see how IBM can help you optimize your development process using an IDE like Rational Developer for System z that integrates with management tools, such as ClearCase to manage your application development on mainframes.
    FREE! Go There Now!


    NEW! Webcast: Striking the right balance between manual and automated testing

    Join this webcast to learn how IBM Rational's Functional Testing solution enables you to implement automation your way, at your pace, with your existing staff. In this webcast, you’ll learn how you can eliminate redundancy of manual test scripts, reduce errors, and increase test coverage through test automation. After this presentation you will understand how IBM Rational Functional Testing solution can streamline your manual testing and make test automation easily attainable.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    GUI CODE ARTICLES

    - PHP Image Manipulation Class 1.0
    - Simple PHP-CAPTCHA,
    - dPhoto
    - nice looking dir index'r
    - Colorpicker
    - Exposure Gallery build 1226
    - Dynamic "AQUA" Buttons
    - AdminTool|1.0 for Exposure Gallery
    - Exposure Gallery v1.2
    - Crop Canvas
    - Display all available background colours
    - Exposure Gallery v1.0
    - JPEG Directory Thumbnail system (Apect ratio)
    - JPEG Directory thumbnail system
    - Change Background Color each day





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek