Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

zoomable images for gamelist and art corner forum.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Castle Paradox Forum Index -> Site Suggestions
View previous topic :: View next topic  
Author Message
NeoTA
Idiomatic Nomenclature




Joined: 15 Mar 2004
Posts: 165

PostPosted: Sun Jul 18, 2004 7:48 pm    Post subject: zoomable images for gamelist and art corner forum. Reply with quote

in high resolutions screenshots and sprites can be hard to see. i suggest adding this javascript to the gamelist and possibly the forums (just the art corner if possible), so to also make posting sprites easier.

this javascript is by Jeiel Aranal and is under the Creative Commons License. the version of it shown here is taken directly from Pixelation, so i can verify it works. it must be inlined though -- some browsers don't seem to understand src="filename" attributes for scripts.

EDIT: Clarified. INSTRUCTIONS HERE:

It Works Like:
+ to Zoom Into an image, Click on it.
+ to Zoom Out, hold one of (Ctrl,Shift,Alt) and Click on it.
+ Zoom Factor doesn't go below 100%.
+ Zooming In/Out modifies the Zoom Factor by 1x. .

to enable this behaviour for an image, insert ' class ="zoomable"' in the
Code:
<img>
tag like this:
Code:
 <img src="image.png" class="zoomable">


the messageboard "[img]" tag can be modified to produce this by default.

Code:

<script language="Javascript" type="text/javascript">
<!--

   if ( 0 )
   {
      window.open('privmsg.php?mode=newpm', '_phpbbprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');;
   }

var zoomableClass = "zoomable";
var zoomedClass = "x2";
var zoomables, origWidth, origHeight;

/*
This function initializes the zoomer by putting all zoomable elements into
the zoomables array.
*/
function initZoomer() {
   // Find all zoomed elements and put in array zoomed
   zoomed = document.getElementsByClass(zoomedClass);
   // loop through the zoomed array
   for (i=0;i<zoomed.length;i++) {
      // calculate what the height and width should be
      zoomHeight = zoomed[i].height*2;
      zoomWidth = zoomed[i].width*2
      // stick these into the zoomed elements height/width property
      zoomed[i].width = zoomWidth;
      zoomed[i].height = zoomHeight;
   }
   // Find all zoomable elements and put in array zoomables
   zoomables = document.getElementsByClass(zoomableClass);
   // create arrays to remember the original height/width of the zoomable elements
   origWidth = new Array();
   origHeight = new Array();
   // loop through zoomables array
   for (i=0;i < zoomables.length;i++) {
      // Assign the onclick event to zoomImg
      if (document.addEventListener)
         zoomables[i].addEventListener('click',zoomImg,false);
      else
         zoomables[i].onclick = zoomImg;
      // Remember the original dimensions of the zoomable element
      origWidth[i] = zoomables[i].width;
      origHeight[i] = zoomables[i].height;
   }
}

/*
This function is for assigning images to become a zoomable. Not as elegant as the class method but it might
make script exectution speedier if you wish customize the script. Just go to the last line of the script and
either comment it out or remove it. This will stop the script from running through all the images in the page
looking for the classes. However, doing so will disable zooming by class.
*/
function zoom(e) {
  if (document.addEventListener)
    e.addEventListener('click',zoomImg,false);
  else
   e.onclick = zoomImg;
}

/*
This function just increases the image size by 2
*/
function x2(e) {
   zoomHeight = e.height*2;
   zoomWidth = e.width*2
   e.width = zoomWidth;
   e.height = zoomHeight;

}

/*
This function handles the mouse clicking. It detects whether any of the zoom-out keys are pressed and
zooms out or in according to this.
*/
function zoomImg(e) {

   // Check if the browser supports this method of checking whether the zoom-out keys are pressed
   if (e) {
      // If any of the zoomout keys are pressed the variables will be assigned true
      ctrlKey = e.ctrlKey;
      altKey = e.altKey;
      shiftKey = e.shiftKey;
   }
   // If the browser does not support the method, use IE's method
   else {
      // If any of the zoomout keys are pressed the variables will be assigned true
      ctrlKey = event.ctrlKey;
      altKey = event.altKey;
      shiftKey = event.shiftKey;
   }

   // Loop an infinite loop. Break inside.
   for (i=0;true;i++) {
      // 'this' keyword refers to the element that called this function.
      // Check if the element that called the function is inside zoomable array.
      // If it is, zoom in or out.
      if (this == zoomables[i]) {
        if (ctrlKey || altKey || shiftKey) zoomOut(i)// If any zoomed out key is pressed, zoom out (duh)
        else zoomIn(i) // Else zoom in (again, duh)
        break // break infinite loop
      }
      // Check if 'i' has passed out of zoomables array's range. If it has
      // add the element to the zoomables array.
       if (i == zoomables.length) {
        // this will be the index of the zoomable element in the zoomables array
        index = zoomables.length;
        // Put the element into zoomables array, remember the original dimensions of this element
        zoomables[index] = this;
        origWidth[index] = this.width;
        origHeight[index] = this.height;
        // Go back by one in variable 'i'. In doing so, the element will pass the zoomables array check
        // and take appropriate action
        i--;
      }
   }

}

// This function does the actual work of zooming in. It takes in the index of the element in the zoomables array
function zoomIn(i) {
   // Calculate the current zoom value by taking the current width and dividing by original width
   zoomValue = zoomables[i].width/origWidth[i];
   // Increase the zoom value
   zoomValue++;
   // Zoom image by multiplying original dimensions by zoom value
   zoomables[i].width = origWidth[i]*zoomValue;
   zoomables[i].height = origHeight[i]*zoomValue;
}

// This function zooms out image. Takes in index of the element in the zoomables array.
function zoomOut(i) {
   // Calculate the current zoom value by taking the current width and dividing by original width
    zoomValue = zoomables[i].width/origWidth[i];
   // Decrease zoom value
   zoomValue--;
   // Check that the zoom value does not go to zero to prevent images from going below 1x
   if (zoomValue != 0) {
   zoomables[i].width = origWidth[i]*zoomValue;
   zoomables[i].height = origHeight[i]*zoomValue;
   }
}

/*
This function finds all the elements with the class name 'name'
*/
document.getElementsByClass = function ( name ) {
    var all, ret = new Array();
    all = document.body.getElementsByTagName('IMG');
    for ( i = 0; i < all.length; i++ ) {
        if ( all[i].className.toLowerCase() == name.toLowerCase() )
            ret[ret.length] = all[i];
    }
    return ret;
}

/*
This initializes the script and allows it to find all the images that have class="zoomable".
If you wish, this line can be commented out for faster execution time. However, this will disable zooming by
class="zoomable".
*/
window.onload = initZoomer;


//-->
</script>


it needs to be placed inside the <head> section.

if this is implemented i can help with any installation difficulties, as i've installed it in my personal gallery previously.


Last edited by NeoTA on Thu Jul 22, 2004 8:00 pm; edited 4 times in total
Back to top
View user's profile Send private message
Velduanga
I heard there were bagels here...




Joined: 25 Jul 2003
Posts: 112
Location: A town away from White Owl, I kid you not, unless he moved.

PostPosted: Sun Jul 18, 2004 7:56 pm    Post subject: Reply with quote

Wouldnt it be easier to download the image you want and zoom in on it in MSPaint?
_________________
If you hit a plane with the soccer, could you afford to fix it? - Shaolin Soccer

"If it's worth shooting, it's worth shooting twice"-Tom Clancy
Back to top
View user's profile Send private message Visit poster's website
NeoTA
Idiomatic Nomenclature




Joined: 15 Mar 2004
Posts: 165

PostPosted: Sun Jul 18, 2004 8:02 pm    Post subject: Reply with quote

go to pixelation and try it out, then tell me that again if you still believe it.
Back to top
View user's profile Send private message
Inferior Minion
Metric Ruler



Joined: 03 Jan 2003
Posts: 741
Location: Santa Barbara, CA

PostPosted: Mon Jul 19, 2004 6:57 am    Post subject: Reply with quote

That shouldn't be too hard to implement. Unless someone feels this shouldn't be added, I'll see if I can get it working after I get home from work this evening.
_________________
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
NeoTA
Idiomatic Nomenclature




Joined: 15 Mar 2004
Posts: 165

PostPosted: Wed Jul 21, 2004 5:48 pm    Post subject: Reply with quote

hello Happy
what is going on regarding the installation of this script? is assistance required?
I just tried saving a forum page in full(inc images) and making the logo zoomable, and it was quite straightforward.
Back to top
View user's profile Send private message
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Wed Jul 21, 2004 6:56 pm    Post subject: zoooom Reply with quote

just tried out that feature on http://pixelation.cjb.net/

that is seven kinds of awesome, including three previous underscribed by science.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Inferior Minion
Metric Ruler



Joined: 03 Jan 2003
Posts: 741
Location: Santa Barbara, CA

PostPosted: Thu Jul 22, 2004 6:25 am    Post subject: Reply with quote

Oh...sorry....I did implement it...just didn't post about it.... Oookay...

Try clicking on my signature

_________________
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
NeoTA
Idiomatic Nomenclature




Joined: 15 Mar 2004
Posts: 165

PostPosted: Thu Jul 22, 2004 6:45 am    Post subject: Reply with quote

testing..


SWISH!

woohoo, thanks!!
Back to top
View user's profile Send private message
rpgspotKahn
Lets see...




Joined: 16 May 2004
Posts: 720
Location: South Africa

PostPosted: Thu Jul 22, 2004 6:48 am    Post subject: Reply with quote

HOW DO I MAKE IT SMALLER!!! Ahhh! The giant fish guy! Save me!
_________________

2nd Edition out now!
Back to top
View user's profile Send private message Send e-mail MSN Messenger
jabbercat
Composer




Joined: 04 Sep 2003
Posts: 823
Location: Oxford

PostPosted: Thu Jul 22, 2004 7:40 am    Post subject: Reply with quote

Please implement a control (Like shift + left click) to zoom out. Big grin
Beautiful script! Raspberry!
Back to top
View user's profile Send private message MSN Messenger
Inferior Minion
Metric Ruler



Joined: 03 Jan 2003
Posts: 741
Location: Santa Barbara, CA

PostPosted: Thu Jul 22, 2004 9:44 am    Post subject: Re: zoomable images for gamelist and art corner forum. Reply with quote

NeoTA wrote:

it works like:
to zoom into an image, click on it.
to zoom out, hold one of (ctrl,shift,alt) and click on it. zoom
doesn't go below 100%.
zooming in/out modifies the zoom factor by 100%.


It's already there!!
_________________
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Me
HI.




Joined: 30 Mar 2003
Posts: 870
Location: MY CUSTOM TITLE CAME BACK

PostPosted: Thu Jul 22, 2004 12:38 pm    Post subject: Reply with quote

I like this. No more saving pictures tiny sprites, zooming in, and deleting, just to comment on them. No more creating resized versions of EVERYTHING. Yayness.
_________________
UP DOWN UP DOWN LEFT LEFT RIGHT RIGHT A B START
Back to top
View user's profile Send private message AIM Address
jabbercat
Composer




Joined: 04 Sep 2003
Posts: 823
Location: Oxford

PostPosted: Thu Jul 22, 2004 1:24 pm    Post subject: Reply with quote

Wonderful script! I can now zoom alot. All I need now are things to zoom in on Raspberry! !

PS: That post was a hint for Mr.Kahn Raspberry! .
Back to top
View user's profile Send private message MSN Messenger
Ysoft_Entertainment
VB Programmer




Joined: 23 Sep 2003
Posts: 810
Location: Wherever There is a good game.

PostPosted: Thu Jul 22, 2004 7:16 pm    Post subject: Reply with quote

yo guys, you might want to set the limit on how much the picture is to be zoomed in, because I tried it, made the picture so big, that it disappeared and the entire post was messed up, but when I zoomed out, it went the post went back to normal.

Just a suggestion ignore it at will Happy
_________________
Try my OHR exporter/importer.
OHRGFX
Striving to become better pixel artist then Fenrir Lunaris. Unfortunately the laziness gets in the way of my goals.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Thu Jul 22, 2004 9:59 pm    Post subject: Reply with quote

Wow! Amazingly simple but useful function! Thanks, Neo, IM!

That's strange, Ysoft? I try zooming in an extreme amount, and I never had any problems.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> Site Suggestions All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group