Slick Forums
http://slick.ninjacave.com/forum/

RFE: Filtered ImageSheared
http://slick.ninjacave.com/forum/viewtopic.php?f=4&t=2961
Page 1 of 1

Author:  Virenerus [ Sun Jan 09, 2011 7:36 pm ]
Post subject:  RFE: Filtered ImageSheared

Hey,
there is no possibility in Slick to draw a sheared Image colored. The setColors function doesn't seem to work with drawSheared and there is no version of drawSheared with a filter parameter.

Thus I added this simple function:

Code:
/**
    * Draw this image at a specified location and size
    *
    * @param x The x location to draw the image at
    * @param y The y location to draw the image at
    * @param hshear The amount to shear the bottom points by horizontally
    * @param vshear The amount to shear the right points by vertically
    * @param filter The colour filter to adapt the image with
    */
    public void drawSheared(float x,float y, float hshear, float vshear, Color filter) {
       if (alpha != 1) {
          if (filter == null) {
             filter = Color.white;
          }
          
          filter = new Color(filter);
          filter.a *= alpha;
       }
        if (filter != null) {
            filter.bind();
        }
       
        texture.bind();
       
        GL.glTranslatef(x, y, 0);
        if (angle != 0) {
           GL.glTranslatef(centerX, centerY, 0.0f);
           GL.glRotatef(angle, 0.0f, 0.0f, 1.0f);
           GL.glTranslatef(-centerX, -centerY, 0.0f);
        }
       
        GL.glBegin(SGL.GL_QUADS);
           init();
      
          GL.glTexCoord2f(textureOffsetX, textureOffsetY);
         GL.glVertex3f(0, 0, 0);
         GL.glTexCoord2f(textureOffsetX, textureOffsetY + textureHeight);
         GL.glVertex3f(hshear, height, 0);
         GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY
               + textureHeight);
         GL.glVertex3f(width + hshear, height + vshear, 0);
         GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY);
         GL.glVertex3f(width, vshear, 0);
        GL.glEnd();
       
        if (angle != 0) {
           GL.glTranslatef(centerX, centerY, 0.0f);
           GL.glRotatef(-angle, 0.0f, 0.0f, 1.0f);
           GL.glTranslatef(-centerX, -centerY, 0.0f);
        }
        GL.glTranslatef(-x, -y, 0);
    }

Author:  Kova [ Sun Jan 09, 2011 7:55 pm ]
Post subject: 

nice, but rename it to RFE: something...

Author:  kevglass [ Wed Mar 09, 2011 2:33 pm ]
Post subject: 

Added in SVN.

Kev

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/