Current location: Hot Scripts Forums » Programming Languages » PHP » Drawing GIF images with sized bands


Drawing GIF images with sized bands

Reply
  #1 (permalink)  
Old 06-08-09, 02:18 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Drawing GIF images with sized bands

I'm not sure how to describe what I'm trying to do, but let me give it a shot and see if anyone here has some sample code or can point me towards some resources on the web....

What I need to do is represent a 24-hour timeline with "on-off " states in it. Basically a long horizontal GIF with two colors, with one color representing the "on" state and one color representing the "off" state. There could be any number of "on/off" periods on the timeline, similar to the attached image. (The "on" and "off" text is just for illustration, there wouldn't be any text drawn on the actual image.) For example, I might need to draw a 3-hour "on" band, a 12-hour "off" band, a 4-hour "on" band, and so on across the full 24 hours of the timeline.

Does anyone have any sample code for creating images like this, or is there a web page or tutorial that covers something similar? Is there a script that already does something similar to this? (I'm aware of the Simile Timeline tool from MIT, but it's way more than what I need- using it would be like driving an aircraft carrier to the mini-market. I just need something basic, or some basic code to start with.)
Attached Images
File Type: jpg timeline1.jpg (4.0 KB, 90 views)
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-08-09, 06:19 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
ImageMagick commands.

This is a rating demo - but the basic idea is the same, assembly of an image from components.

Rating Demo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 06-08-09, 07:05 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
... after more thought ...

I'd create a sprite - an image consisting of ON and OFF, and use a series of <span> tags to indicate the state.

HTML Code:
<style type="text/css">
span {width:50px;height:50px;}
.on {background:yellow url('state.gif') no-repeat 0 0;}
.off {background:#000 url('state.gif') no-repeat -50px 0;}
</style>

<div id="state">
<?php
foreach ($aState as $k=>$v)
  echo '<span class="'.$v['state']?'on':'off'.'" style="width:'.$v['duration'].'">&nbsp;</span>';
?>
</div>
The basic idea is to use a single image (state.gif) and shift it to display the correct state. I don't know if the &nbsp; is actually required - but it won't do any harm (other than waste 6*state bytes of bandwidth).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Flash: Unable to load Images from other subdomain Robd75 Flash & ActionScript 1 08-05-08 02:49 PM
Creating Animated GIF Images VB.NET 2008 mattthetoadwart Windows .NET Programming 3 06-19-08 12:38 AM
uploading images in a single directory or not? macintosh PHP 15 03-16-08 08:41 AM


All times are GMT -5. The time now is 07:14 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.