Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > Programming Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Gradients made easy!
Natch's Avatar
Natch
Join Date: Nov 2002
Posts: 851

 

Australia
Show Printable Version Email this Page Subscription
Natch Natch is offline 07-21-2004, 10:00 PM

OK - now we all know how to make gradients using our weapon-of-choice image editor, but surely it could be easier than that ?

Well from the guy who brought you PNG24 transparent images in IE without that grey box rendering effect comes the next big thing - gradients on the fly! Dynamic images, that will be cached by your browser and can be written to the server if required (not yet implemented).

All you need is a text editor, and an array of Hex colour codes to match your forum, and you are ready to rock and roll.

Upload the following new files:

forumroot/images/gradients/gradient.php
forumroot/includes/class.gradient_image.php

The forumroot/images/gradients/gradient.php file has instructions for usage in the comments - the class I have used is from phpclasses.org - please read the licensing requirements if you plan on using this in a for-profit situation.

Demo: Demonstration of three different styles of gradient, with four different colours each - take a look @ the html source for how I am doing each image...

Any questions?
Attached Files
File Type: zip gradienter.zip (3.8 KB, 245 views)
Reply With Quote
  #2  
Old 07-24-2004, 06:57 AM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thing is.. your two php files total 12 k... my gradient image can be 1/2 that or less. I'll stick with an image. it get's cached and only needs to be downloaded once as opposed to a repeated download of 12k for the php files every time a gradient is called.
Reply With Quote
  #3  
Old 07-24-2004, 10:00 AM
Natch's Avatar
Natch Natch is offline
 
Join Date: Nov 2002
Location: Australia
Posts: 851
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Natch
Dynamic images, that will be cached by your browser
Also for those that DON'T have access to a gfx proggie like Photoshop, a tool like this might be useful, no?

Thanks for your considered answer tho'

EDIT// a futher note: (for those that are not put off by ScottW's ill-considered remarks):

The only thing downloaded by the client machine is the generated gradient image - the processing of the scripts (unless PHP has changed it's behaviour) is done server-side...

So there will be no difference between gradient images created using this script and any created by a graphics proggie... except maybe you will find the images created by this script to be MUCH SMALLER! example any of the gradients on my demo page above will be between around 150-200 bytes in size! and are cached by the browser ...

I really thought that this would be useful - I have found it useful - and if you are really worried about the size of the PHP scripts you can reduce them in size by removing the comments...

:shrugs: ah well - back to the basement ...
Reply With Quote
  #4  
Old 08-05-2004, 04:20 PM
Reeve of shinra's Avatar
Reeve of shinra Reeve of shinra is offline
 
Join Date: Oct 2001
Location: NYC
Posts: 1,896
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is cool to have. I can think of things this would be usual for.
Reply With Quote
  #5  
Old 09-01-2004, 01:53 PM
KW802's Avatar
KW802 KW802 is offline
 
Join Date: Jul 2003
Location: A galaxy far, far away...
Posts: 1,450
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anybody have any thoughts on how to make the height dynamic based upon the height of a table row that it may be used in?

What I'm thinking is that for a table row that, based upon the contents of it, may be 75px but others with just small content may be 50px high so it'd be pretty cool to have the height of the gradient dynamically be set based upon the actual height of the row.
Reply With Quote
  #6  
Old 11-11-2004, 04:27 AM
Natch's Avatar
Natch Natch is offline
 
Join Date: Nov 2002
Location: Australia
Posts: 851
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Unfortunately, you cannot pass javascript DOM values to a PHP script, as the PHP is parsed server-side, and the javascript DOM parsing is done client-side...

I've thought about things like this before, but it's really not possible...

What you would have to do is change the structure of the script to pas in height variables externally, rather then having them hard-coded....
Reply With Quote
  #7  
Old 12-20-2004, 04:39 AM
kbothe kbothe is offline
 
Join Date: Oct 2004
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Natch, great work man!
Reply With Quote
  #8  
Old 10-15-2006, 12:33 AM
HPIA HPIA is offline
 
Join Date: Jul 2006
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The link doesn't seem to work...
Reply With Quote
  #9  
Old 11-10-2006, 08:13 PM
deejayh deejayh is offline
 
Join Date: May 2006
Location: Nottingham, England, UK
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

HPIA,

If you look at the date = 22. Jul 2004 04:56
It is some time ago!!!:surprised:
Reply With Quote
  #10  
Old 11-19-2006, 10:53 PM
Josh1 Josh1 is offline
 
Join Date: Mar 2006
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The link works perfectly lol.
Reply With Quote
Reply


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 On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:48 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04563 seconds
  • Memory Usage 2,310KB
  • Queries Executed 24 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete