Are you a spammer

Please note, that the first 3 posts you make, will need to be approved by a forum Administrator or Moderator before they are publicly viewable.
Each application to join this forum is checked at the Stop Forum Spam website. If the email or IP address appears there when checked, you will not be allowed to join this forum.
If you get past this check and post spam on this forum, your posts will be immediately deleted and your account inactivated.You will then be banned and your IP will be submitted to your ISP, notifying them of your spamming. So your spam links will only be seen for an hour or two at most. In other words, don't waste your time and ours.

This forum is for the use and enjoyment of the members and visitors looking to learn about and share information regarding the topics listed. It is not a free-for-all advertising venue. Your time would be better spent pursuing legitimate avenues of promoting your websites.

Parallax Usplash

Source code I have written openly published for your viewing pleasure.


Parallax Usplash

Postby red_team316 » Sat Sep 20, 2008 4:33 am

Hey all, I finally completed my parallax usplash and thought I would share:

You can download the full source HERE

parallax-theme.c posted for reference
Code: Select all
/* usplash
 *
 * parallax-theme.c
 * Copyright © 2008 red_team316
 * Original Code found throughout Copyright © 2006 Dennis Kaarsemaker
 *
 * Notes: Includes pallete index bugfix see URL below.
 * https://bugs.launchpad.net/ubuntu/+source/usplash/+bug/66760
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */

#include <usplash-theme.h>
/* Needed for the custom drawing functions */
#include <usplash_backend.h>

extern struct usplash_pixmap pixmap_usplash_640x480;
extern struct usplash_pixmap pixmap_usplash_800x600;
extern struct usplash_pixmap pixmap_usplash_1024x768;
extern struct usplash_pixmap pixmap_usplash_1280x1024;

/* Parallax Pixmaps */
extern struct usplash_pixmap pixmap_logo;
extern struct usplash_pixmap pixmap_strip1_640x480;
extern struct usplash_pixmap pixmap_strip2_640x480;
extern struct usplash_pixmap pixmap_strip1_800x600;
extern struct usplash_pixmap pixmap_strip2_800x600;
extern struct usplash_pixmap pixmap_strip1_1024x768;
extern struct usplash_pixmap pixmap_strip2_1024x768;
extern struct usplash_pixmap pixmap_strip1_1280x1024;
extern struct usplash_pixmap pixmap_strip2_1280x1024;

extern struct usplash_pixmap pixmap_throbber_back;
extern struct usplash_pixmap pixmap_throbber_fore;
extern struct usplash_font font_helvB10;

void t_init(struct usplash_theme* theme);
void t_clear_progressbar(struct usplash_theme* theme);
void t_draw_progressbar(struct usplash_theme* theme, int percentage);
void t_animate_step(struct usplash_theme* theme, int pulsating);

struct usplash_theme usplash_theme_640x480;
struct usplash_theme usplash_theme_800x600;
struct usplash_theme usplash_theme_1024x768;
struct usplash_theme usplash_theme_1280x1024;

/* Theme definition */
struct usplash_theme usplash_theme = {
   .version = THEME_VERSION,
   .next = &usplash_theme_800x600,
   .ratio = USPLASH_4_3,

   /* Background and font */
   .pixmap = &pixmap_usplash_640x480,
   .font   = &font_helvB10,

   /* Palette indexes */
   .background             = 0,
   .progressbar_background = 0,
   .progressbar_foreground = 30,
   .text_background        = 0,
   .text_foreground        = 125,
   .text_success           = 125,
   .text_failure           = 215,

   /* Progress bar position and size in pixels */
   .progressbar_x      = 212, /* 640/2-216/2 */
   .progressbar_y      = 290, /* (strip2 height)+(logo height)+3 */
   .progressbar_width  = 216,
   .progressbar_height = 8,

   /* Text box position and size in pixels */                          /*                          */
   .text_x      = 100, /* 100+440+100=640 */                           /*   x,y-----------------   */
   .text_y      = 310, /* Fit between progressbar and strip1 */        /*   |                  |   */
   .text_width  = 440,                                                 /*   -----------------w,h   */
   .text_height = 105, /* 7 lines */                                   /*                          */

   /* Text details */
   .line_height  = 15,   /* Height of line in pixels */
   .line_length  = 32,   /* Length of line in characters */
   .status_width = 64,   /* Number of RHS pixels for status */

    /* Functions */
    .init = t_init,
    .clear_progressbar = t_clear_progressbar,
    .draw_progressbar = t_draw_progressbar,
    .animate_step = t_animate_step,
};

struct usplash_theme usplash_theme_800x600 = {
   .version = THEME_VERSION,
   .next = &usplash_theme_1024x768,
   .ratio = USPLASH_4_3,

   /* Background and font */
   .pixmap = &pixmap_usplash_800x600,
   .font   = &font_helvB10,

   /* Palette indexes */
   .background             = 0,
   .progressbar_background = 0,
   .progressbar_foreground = 30,
   .text_background        = 0,
   .text_foreground        = 125,
   .text_success           = 125,
   .text_failure           = 215,

   /* Progress bar position and size in pixels */
   .progressbar_x      = 292, /* 800/2 - 216/2 */
   .progressbar_y      = 335, /* (strip2 height)+(logo height)+5 */
   .progressbar_width  = 216,
   .progressbar_height = 8,

   /* Text box position and size in pixels */
   .text_x      = 100, /* 100+600+100=800 */
   .text_y      = 345, /* Fit between progressbar and strip1 */
   .text_width  = 600,
   .text_height = 165, /* 11 lines */

   /* Text details */
   .line_height  = 15,
   .line_length  = 32,
   .status_width = 64,

    /* Functions */
    .init = t_init,
    .clear_progressbar = t_clear_progressbar,
    .draw_progressbar = t_draw_progressbar,
    .animate_step = t_animate_step,
};

struct usplash_theme usplash_theme_1024x768 = {
   .version = THEME_VERSION,
   .next = &usplash_theme_1280x1024,
   .ratio = USPLASH_4_3,

   /* Background and font */
   .pixmap = &pixmap_usplash_1024x768,
   .font   = &font_helvB10,

   /* Palette indexes */
   .background             = 0,
   .progressbar_background = 0,
   .progressbar_foreground = 30,
   .text_background        = 0,
   .text_foreground        = 125,
   .text_success           = 125,
   .text_failure           = 215,

   /* Progress bar position and size in pixels */
   .progressbar_x      = 404, /* 1024/2 - 216/2 */
   .progressbar_y      = 390, /* (strip2 height)+(logo height)+3 */
   .progressbar_width  = 216,
   .progressbar_height = 8,

   /* Text box position and size in pixels */
   .text_x      = 200, /* 200+624+200=1024 */
   .text_y      = 400, /* Fit between progressbar and strip1 */
   .text_width  = 624,
   .text_height = 270, /* 18 lines */

   /* Text details */
   .line_height  = 15,
   .line_length  = 32,
   .status_width = 64,

    /* Functions */
    .init = t_init,
    .clear_progressbar = t_clear_progressbar,
    .draw_progressbar = t_draw_progressbar,
    .animate_step = t_animate_step,
};

struct usplash_theme usplash_theme_1280x1024 = {
   .version = THEME_VERSION,
   .next = NULL,
   .ratio = USPLASH_4_3,

   /* Background and font */
   .pixmap = &pixmap_usplash_1280x1024,
   .font   = &font_helvB10,

   /* Palette indexes */
   .background             = 0,
   .progressbar_background = 0,
   .progressbar_foreground = 30,
   .text_background        = 0,
   .text_foreground        = 125,
   .text_success           = 125,
   .text_failure           = 215,

   /* Progress bar position and size in pixels */
   .progressbar_x      = 532, /* 1280/2 - 216/2 */
   .progressbar_y      = 460, /* (strip2 height)+(logo height)+6 */
   .progressbar_width  = 216,
   .progressbar_height = 8,

   /* Text box position and size in pixels */
   .text_x      = 200, /* 200+880+200=1280 */
   .text_y      = 475, /* Fit between progressbar and strip1 */
   .text_width  = 880,
   .text_height = 420, /* 28 lines */

   /* Text details */
   .line_height  = 15,
   .line_length  = 32,
   .status_width = 64,

    /* Functions */
    .init = t_init,
    .clear_progressbar = t_clear_progressbar,
    .draw_progressbar = t_draw_progressbar,
    .animate_step = t_animate_step,
};

void t_init(struct usplash_theme *theme) {
    int x, y;
    usplash_getdimensions(&x, &y);
    theme->progressbar_x = (x - theme->pixmap->width)/2 + theme->progressbar_x;
    theme->progressbar_y = (y - theme->pixmap->height)/2 + theme->progressbar_y;
}

void t_clear_progressbar(struct usplash_theme *theme) {
    t_draw_progressbar(theme, 0);
}

void t_draw_progressbar(struct usplash_theme *theme, int percentage) {
    int w = (pixmap_throbber_back.width * percentage / 100);
    usplash_put(theme->progressbar_x, theme->progressbar_y, &pixmap_throbber_back);

    if(percentage == 0)
        return;
    if(percentage < 0)
        usplash_put_part(theme->progressbar_x - w, theme->progressbar_y, pixmap_throbber_back.width + w,
                         pixmap_throbber_back.height, &pixmap_throbber_fore, -w, 0);
    else
        usplash_put_part(theme->progressbar_x, theme->progressbar_y, w, pixmap_throbber_back.height,
                         &pixmap_throbber_fore, 0, 0);
}

void t_animate_step(struct usplash_theme* theme, int pulsating) {

    static int pulsate_step = 0;
    static int pulse_width = 28;
    static int step_width = 2;
    static int num_steps = (216 - 28)/2;
    int x1;

    if (pulsating) {
        t_draw_progressbar(theme, 0);

        if(pulsate_step < num_steps/2+1)
            x1 = 2 * step_width * pulsate_step;
        else
            x1 = 216 - pulse_width - 2 * step_width * (pulsate_step - num_steps/2+1);

        usplash_put_part(theme->progressbar_x + x1, theme->progressbar_y, pulse_width,
                         pixmap_throbber_fore.height, &pixmap_throbber_fore, x1, 0);

        pulsate_step = (pulsate_step + 1) % num_steps;
    }

    /* Parallax Code */         /* Variable Descriptions*/
    static short firstrun = 1;  /* firstrun = ensure this block of code is only run once */
    static short ani1 = 0;      /* ani1 = pixel offset for scrolling strip1 */
    static short ani2 = 0;      /* ani2 = pixel offset for scrolling strip2 */

    static short resX = 640;    /* resX  = holds the x value of the resolution  */
    static short resY = 480;    /* resY  = holds the y value of the resolution  */
    static short px1 = 0;       /* px1   = upper left coord of strip1 */
    static short px2 = 0;       /* px2   = upper left coord of strip2 */
    static short py1 = 420;     /* py1   = upper left coord of strip1 */
    static short py2 = 0;       /* py2   = upper left coord of strip2 */
    static short pw1 = 640;     /* pw1   = half the width of strip image, for tessellation effect */
    static short pw2 = 640;     /* pw2   = half the width of strip image, for tessellation effect */
    static short ph1 = 60;      /* ph1   = we want to draw the full height of strip */
    static short ph2 = 168;     /* ph2   = we want to draw the full height of strip */
    static short logoX = 92;    /* logoX = centered (ResWidth/2 - logoWidth/2) */
    static short logoY = 170;   /* logoY = strip2 height + 1 */

    if(firstrun)
    {
        firstrun = 0;
        int x, y;
        usplash_getdimensions(&x, &y);
        if(x == 800 && y == 600)
        {
            resX = 800; resY = 600; logoX = 172; logoY = 210;
            px1 = 0; py1 = 525; pw1 = 800; ph1 = 75;
            px2 = 0; py2 = 0;   pw2 = 800; ph2 = 209;
        }
        else if(x == 1024 && y == 768)
        {
            resX = 1024; resY = 768; logoX = 284; logoY = 269;
            px1 = 0; py1 = 672; pw1 = 1024; ph1 = 96;
            px2 = 0; py2 = 0;   pw2 = 1024; ph2 = 268;
        }
        else if(x == 1280 && y == 1024)
        {
            resX = 1280;  resY = 1024; logoX = 412; logoY = 336;
            px1 = 0; py1 = 904; pw1 = 1280; ph1 = 120;
            px2 = 0; py2 = 0;   pw2 = 1280; ph2 = 335;
        }
    }

    /* Move this strip fast */
    if(ani1 < pw1) ani1 += 5;
    else           ani1  = 0;

    /* Move this strip slow */
    if(ani2 < pw2) ani2 += 1;
    else           ani2  = 0;

    /* Draw the scrolling strips */
    if(resX == 640 && resY == 480)
    {
        usplash_put_part(px1, py1, pw1, ph1, &pixmap_strip1_640x480, ani1, 0); /* GRASS */
        usplash_put_part(px2, py2, pw2, ph2, &pixmap_strip2_640x480, ani2, 0); /* SKY */
    }
    else if(resX == 800 && resY == 600)
    {
        usplash_put_part(px1, py1, pw1, ph1, &pixmap_strip1_800x600, ani1, 0);
        usplash_put_part(px2, py2, pw2, ph2, &pixmap_strip2_800x600, ani2, 0);
    }
    else if(resX == 1024 && resY == 768)
    {
        usplash_put_part(px1, py1, pw1, ph1, &pixmap_strip1_1024x768, ani1, 0);
        usplash_put_part(px2, py2, pw2, ph2, &pixmap_strip2_1024x768, ani2, 0);
    }
    else if(resX == 1280 && resY == 1024)
    {
        usplash_put_part(px1, py1, pw1, ph1, &pixmap_strip1_1280x1024, ani1, 0);
        usplash_put_part(px2, py2, pw2, ph2, &pixmap_strip2_1280x1024, ani2, 0);
    }
    /* Draw the logo */
    usplash_put(logoX, logoY, &pixmap_logo);
}



parallax-theme-function.c posted for reference
Code: Select all
/* usplash
 *
 * parallax-theme.c
 * Copyright © 2008 red_team316
 * Original Code found throughout Copyright © 2006 Dennis Kaarsemaker
 *
 * Notes: Includes pallete index bugfix see URL below.
 * https://bugs.launchpad.net/ubuntu/+source/usplash/+bug/66760
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */

#include <usplash-theme.h>
/* Needed for the custom drawing functions */
#include <usplash_backend.h>

extern struct usplash_pixmap pixmap_usplash_640x480;
extern struct usplash_pixmap pixmap_usplash_800x600;
extern struct usplash_pixmap pixmap_usplash_1024x768;
extern struct usplash_pixmap pixmap_usplash_1280x1024;

/* Parallax Pixmaps */
extern struct usplash_pixmap pixmap_logo;
extern struct usplash_pixmap pixmap_strip1_640x480;
extern struct usplash_pixmap pixmap_strip2_640x480;
extern struct usplash_pixmap pixmap_strip1_800x600;
extern struct usplash_pixmap pixmap_strip2_800x600;
extern struct usplash_pixmap pixmap_strip1_1024x768;
extern struct usplash_pixmap pixmap_strip2_1024x768;
extern struct usplash_pixmap pixmap_strip1_1280x1024;
extern struct usplash_pixmap pixmap_strip2_1280x1024;

extern struct usplash_pixmap pixmap_throbber_back;
extern struct usplash_pixmap pixmap_throbber_fore;
extern struct usplash_font font_helvB10;

void t_init(struct usplash_theme* theme);
void t_clear_progressbar(struct usplash_theme* theme);
void t_draw_progressbar(struct usplash_theme* theme, int percentage);
void t_animate_step(struct usplash_theme* theme, int pulsating);
void t_parallax(short px1, short px2, short py1, short py2, short pw1, short pw2, short ph1, short ph2, short logoX, short logoY, short Res);

struct usplash_theme usplash_theme_640x480;
struct usplash_theme usplash_theme_800x600;
struct usplash_theme usplash_theme_1024x768;
struct usplash_theme usplash_theme_1280x1024;

/* Theme definition */
struct usplash_theme usplash_theme = {
   .version = THEME_VERSION,
   .next = &usplash_theme_800x600,
   .ratio = USPLASH_4_3,

   /* Background and font */
   .pixmap = &pixmap_usplash_640x480,
   .font   = &font_helvB10,

   /* Palette indexes */
   .background             = 0,
   .progressbar_background = 0,
   .progressbar_foreground = 30,
   .text_background        = 0,
   .text_foreground        = 125,
   .text_success           = 125,
   .text_failure           = 215,

   /* Progress bar position and size in pixels */
   .progressbar_x      = 212, /* 640/2-216/2 */
   .progressbar_y      = 290, /* (strip2 height)+(logo height)+3 */
   .progressbar_width  = 216,
   .progressbar_height = 8,

   /* Text box position and size in pixels */                          /*                          */
   .text_x      = 100, /* 100+440+100=640 */                           /*   x,y-----------------   */
   .text_y      = 310, /* Fit between progressbar and strip1 */        /*   |                  |   */
   .text_width  = 440,                                                 /*   -----------------w,h   */
   .text_height = 105, /* 7 lines */                                   /*                          */

   /* Text details */
   .line_height  = 15,   /* Height of line in pixels */
   .line_length  = 32,   /* Length of line in characters */
   .status_width = 64,   /* Number of RHS pixels for status */

    /* Functions */
    .init = t_init,
    .clear_progressbar = t_clear_progressbar,
    .draw_progressbar = t_draw_progressbar,
    .animate_step = t_animate_step,
};

struct usplash_theme usplash_theme_800x600 = {
   .version = THEME_VERSION,
   .next = &usplash_theme_1024x768,
   .ratio = USPLASH_4_3,

   /* Background and font */
   .pixmap = &pixmap_usplash_800x600,
   .font   = &font_helvB10,

   /* Palette indexes */
   .background             = 0,
   .progressbar_background = 0,
   .progressbar_foreground = 30,
   .text_background        = 0,
   .text_foreground        = 125,
   .text_success           = 125,
   .text_failure           = 215,

   /* Progress bar position and size in pixels */
   .progressbar_x      = 292, /* 800/2 - 216/2 */
   .progressbar_y      = 335, /* (strip2 height)+(logo height)+5 */
   .progressbar_width  = 216,
   .progressbar_height = 8,

   /* Text box position and size in pixels */
   .text_x      = 100, /* 100+600+100=800 */
   .text_y      = 345, /* Fit between progressbar and strip1 */
   .text_width  = 600,
   .text_height = 165, /* 11 lines */

   /* Text details */
   .line_height  = 15,
   .line_length  = 32,
   .status_width = 64,

    /* Functions */
    .init = t_init,
    .clear_progressbar = t_clear_progressbar,
    .draw_progressbar = t_draw_progressbar,
    .animate_step = t_animate_step,
};

struct usplash_theme usplash_theme_1024x768 = {
   .version = THEME_VERSION,
   .next = &usplash_theme_1280x1024,
   .ratio = USPLASH_4_3,

   /* Background and font */
   .pixmap = &pixmap_usplash_1024x768,
   .font   = &font_helvB10,

   /* Palette indexes */
   .background             = 0,
   .progressbar_background = 0,
   .progressbar_foreground = 30,
   .text_background        = 0,
   .text_foreground        = 125,
   .text_success           = 125,
   .text_failure           = 215,

   /* Progress bar position and size in pixels */
   .progressbar_x      = 404, /* 1024/2 - 216/2 */
   .progressbar_y      = 390, /* (strip2 height)+(logo height)+3 */
   .progressbar_width  = 216,
   .progressbar_height = 8,

   /* Text box position and size in pixels */
   .text_x      = 200, /* 200+624+200=1024 */
   .text_y      = 400, /* Fit between progressbar and strip1 */
   .text_width  = 624,
   .text_height = 270, /* 18 lines */

   /* Text details */
   .line_height  = 15,
   .line_length  = 32,
   .status_width = 64,

    /* Functions */
    .init = t_init,
    .clear_progressbar = t_clear_progressbar,
    .draw_progressbar = t_draw_progressbar,
    .animate_step = t_animate_step,
};

struct usplash_theme usplash_theme_1280x1024 = {
   .version = THEME_VERSION,
   .next = NULL,
   .ratio = USPLASH_4_3,

   /* Background and font */
   .pixmap = &pixmap_usplash_1280x1024,
   .font   = &font_helvB10,

   /* Palette indexes */
   .background             = 0,
   .progressbar_background = 0,
   .progressbar_foreground = 30,
   .text_background        = 0,
   .text_foreground        = 125,
   .text_success           = 125,
   .text_failure           = 215,

   /* Progress bar position and size in pixels */
   .progressbar_x      = 532, /* 1280/2 - 216/2 */
   .progressbar_y      = 460, /* (strip2 height)+(logo height)+6 */
   .progressbar_width  = 216,
   .progressbar_height = 8,

   /* Text box position and size in pixels */
   .text_x      = 200, /* 200+880+200=1280 */
   .text_y      = 475, /* Fit between progressbar and strip1 */
   .text_width  = 880,
   .text_height = 420, /* 28 lines */

   /* Text details */
   .line_height  = 15,
   .line_length  = 32,
   .status_width = 64,

    /* Functions */
    .init = t_init,
    .clear_progressbar = t_clear_progressbar,
    .draw_progressbar = t_draw_progressbar,
    .animate_step = t_animate_step,
};

void t_init(struct usplash_theme *theme) {
    int x, y;
    usplash_getdimensions(&x, &y);
    theme->progressbar_x = (x - theme->pixmap->width)/2 + theme->progressbar_x;
    theme->progressbar_y = (y - theme->pixmap->height)/2 + theme->progressbar_y;
}

void t_clear_progressbar(struct usplash_theme *theme) {
    t_draw_progressbar(theme, 0);
}

void t_draw_progressbar(struct usplash_theme *theme, int percentage) {
    int w = (pixmap_throbber_back.width * percentage / 100);
    usplash_put(theme->progressbar_x, theme->progressbar_y, &pixmap_throbber_back);

    if(percentage == 0)
        return;
    if(percentage < 0)
        usplash_put_part(theme->progressbar_x - w, theme->progressbar_y, pixmap_throbber_back.width + w,
                         pixmap_throbber_back.height, &pixmap_throbber_fore, -w, 0);
    else
        usplash_put_part(theme->progressbar_x, theme->progressbar_y, w, pixmap_throbber_back.height,
                         &pixmap_throbber_fore, 0, 0);
}

void t_animate_step(struct usplash_theme* theme, int pulsating) {

    static int pulsate_step = 0;
    static int pulse_width = 28;
    static int step_width = 2;
    static int num_steps = (216 - 28)/2;
    int x1;

    if (pulsating) {
        t_draw_progressbar(theme, 0);

        if(pulsate_step < num_steps/2+1)
            x1 = 2 * step_width * pulsate_step;
        else
            x1 = 216 - pulse_width - 2 * step_width * (pulsate_step - num_steps/2+1);

        usplash_put_part(theme->progressbar_x + x1, theme->progressbar_y, pulse_width,
                         pixmap_throbber_fore.height, &pixmap_throbber_fore, x1, 0);

        pulsate_step = (pulsate_step + 1) % num_steps;
    }

    /* Parallax Code */
    static short firstrun = 1;
    static int x = 640;
    static int y = 480;

    if(firstrun)
    {
        firstrun = 0;
        usplash_getdimensions(&x, &y);
    }
    /* Call the parallax function */
    if(x == 640 && y == 480)        t_parallax(0, 0, 420, 0,  640,  640,  60, 168,  92, 170, 1);
    else if(x == 800 && y == 600)   t_parallax(0, 0, 525, 0,  800,  800,  75, 209, 172, 210, 2);
    else if(x == 1024 && y == 768)  t_parallax(0, 0, 672, 0, 1024, 1024,  96, 268, 284, 269, 3);
    else if(x == 1280 && y == 1024) t_parallax(0, 0, 904, 0, 1280, 1280, 120, 335, 412, 336, 4);
}

/* Variable Descriptions*/
/* px = upper left coord of strip */
/* py = upper left coord of strip */
/* pw = half the width of strip image, for tessellation effect */
/* ph = we want to draw the full height of strip */
/* logoX = centered (ResWidth/2 - logoWidth/2) */
/* logoY = strip2 + 1 */

void t_parallax(short px1, short px2, short py1, short py2, short pw1, short pw2, short ph1, short ph2, short logoX, short logoY, short Res)
{

    static short ani1 = 0;
    static short ani2 = 0;

    /* Move this strip fast */
    if(ani1 < pw1) ani1 += 5;
    else           ani1  = 0;

    /* Move this strip slow */
    if(ani2 < pw2) ani2 += 1;
    else           ani2  = 0;

    /* Draw the scrolling strips */
    if(Res == 1)
    {
        usplash_put_part(px1, py1, pw1, ph1, &pixmap_strip1_640x480, ani1, 0); /* GRASS */
        usplash_put_part(px2, py2, pw2, ph2, &pixmap_strip2_640x480, ani2, 0); /* SKY */
    }
    else if(Res == 2)
    {
        usplash_put_part(px1, py1, pw1, ph1, &pixmap_strip1_800x600, ani1, 0);
        usplash_put_part(px2, py2, pw2, ph2, &pixmap_strip2_800x600, ani2, 0);
    }
    else if(Res == 3)
    {
        usplash_put_part(px1, py1, pw1, ph1, &pixmap_strip1_1024x768, ani1, 0);
        usplash_put_part(px2, py2, pw2, ph2, &pixmap_strip2_1024x768, ani2, 0);
    }
    else if(Res == 4)
    {
        usplash_put_part(px1, py1, pw1, ph1, &pixmap_strip1_1280x1024, ani1, 0);
        usplash_put_part(px2, py2, pw2, ph2, &pixmap_strip2_1280x1024, ani2, 0);
    }
    /* Draw the logo */
    usplash_put(logoX, logoY, &pixmap_logo);
}
Core i7 920(working on a decent OC), x58 ASUS P6T Deluxe V2, 6GB DDR3 1600, EVGA 8800GTS512, Silencer 750W PSU, CoolerMaster V8, Red Antec900
Image
User avatar
red_team316
U.E. College Professor
U.E. College Professor
 
Posts: 288
Joined: Mon Jan 07, 2008 12:37 am
Age: 39
Operating System: Ultimate Edition 3.2 64 BIT



Re: Parallax Usplash

Postby TheeMahn » Mon Oct 27, 2008 4:19 pm

red_team316 wrote:Hey all, I finally completed my parallax usplash and thought I would share:

You can download the full source HERE

parallax-theme.c posted for reference
Code: Select all
/* usplash
 *
 * parallax-theme.c
 * Copyright © 2008 red_team316
 * Original Code found throughout Copyright © 2006 Dennis Kaarsemaker
 *
 * Notes: Includes pallete index bugfix see URL below.
 * https://bugs.launchpad.net/ubuntu/+source/usplash/+bug/66760
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */

#include <usplash-theme.h>
/* Needed for the custom drawing functions */
#include <usplash_backend.h>

extern struct usplash_pixmap pixmap_usplash_640x480;
extern struct usplash_pixmap pixmap_usplash_800x600;
extern struct usplash_pixmap pixmap_usplash_1024x768;
extern struct usplash_pixmap pixmap_usplash_1280x1024;

/* Parallax Pixmaps */
extern struct usplash_pixmap pixmap_logo;
extern struct usplash_pixmap pixmap_strip1_640x480;
extern struct usplash_pixmap pixmap_strip2_640x480;
extern struct usplash_pixmap pixmap_strip1_800x600;
extern struct usplash_pixmap pixmap_strip2_800x600;
extern struct usplash_pixmap pixmap_strip1_1024x768;
extern struct usplash_pixmap pixmap_strip2_1024x768;
extern struct usplash_pixmap pixmap_strip1_1280x1024;
extern struct usplash_pixmap pixmap_strip2_1280x1024;

extern struct usplash_pixmap pixmap_throbber_back;
extern struct usplash_pixmap pixmap_throbber_fore;
extern struct usplash_font font_helvB10;

void t_init(struct usplash_theme* theme);
void t_clear_progressbar(struct usplash_theme* theme);
void t_draw_progressbar(struct usplash_theme* theme, int percentage);
void t_animate_step(struct usplash_theme* theme, int pulsating);

struct usplash_theme usplash_theme_640x480;
struct usplash_theme usplash_theme_800x600;
struct usplash_theme usplash_theme_1024x768;
struct usplash_theme usplash_theme_1280x1024;

/* Theme definition */
struct usplash_theme usplash_theme = {
   .version = THEME_VERSION,
   .next = &usplash_theme_800x600,
   .ratio = USPLASH_4_3,

   /* Background and font */
   .pixmap = &pixmap_usplash_640x480,
   .font   = &font_helvB10,

   /* Palette indexes */
   .background             = 0,
   .progressbar_background = 0,
   .progressbar_foreground = 30,
   .text_background        = 0,
   .text_foreground        = 125,
   .text_success           = 125,
   .text_failure           = 215,

   /* Progress bar position and size in pixels */
   .progressbar_x      = 212, /* 640/2-216/2 */
   .progressbar_y      = 290, /* (strip2 height)+(logo height)+3 */
   .progressbar_width  = 216,
   .progressbar_height = 8,

   /* Text box position and size in pixels */                          /*                          */
   .text_x      = 100, /* 100+440+100=640 */                           /*   x,y-----------------   */
   .text_y      = 310, /* Fit between progressbar and strip1 */        /*   |                  |   */
   .text_width  = 440,                                                 /*   -----------------w,h   */
   .text_height = 105, /* 7 lines */                                   /*                          */

   /* Text details */
   .line_height  = 15,   /* Height of line in pixels */
   .line_length  = 32,   /* Length of line in characters */
   .status_width = 64,   /* Number of RHS pixels for status */

    /* Functions */
    .init = t_init,
    .clear_progressbar = t_clear_progressbar,
    .draw_progressbar = t_draw_progressbar,
    .animate_step = t_animate_step,
};

struct usplash_theme usplash_theme_800x600 = {
   .version = THEME_VERSION,
   .next = &usplash_theme_1024x768,
   .ratio = USPLASH_4_3,

   /* Background and font */
   .pixmap = &pixmap_usplash_800x600,
   .font   = &font_helvB10,

   /* Palette indexes */
   .background             = 0,
   .progressbar_background = 0,
   .progressbar_foreground = 30,
   .text_background        = 0,
   .text_foreground        = 125,
   .text_success           = 125,
   .text_failure           = 215,

   /* Progress bar position and size in pixels */
   .progressbar_x      = 292, /* 800/2 - 216/2 */
   .progressbar_y      = 335, /* (strip2 height)+(logo height)+5 */
   .progressbar_width  = 216,
   .progressbar_height = 8,

   /* Text box position and size in pixels */
   .text_x      = 100, /* 100+600+100=800 */
   .text_y      = 345, /* Fit between progressbar and strip1 */
   .text_width  = 600,
   .text_height = 165, /* 11 lines */

   /* Text details */
   .line_height  = 15,
   .line_length  = 32,
   .status_width = 64,

    /* Functions */
    .init = t_init,
    .clear_progressbar = t_clear_progressbar,
    .draw_progressbar = t_draw_progressbar,
    .animate_step = t_animate_step,
};

struct usplash_theme usplash_theme_1024x768 = {
   .version = THEME_VERSION,
   .next = &usplash_theme_1280x1024,
   .ratio = USPLASH_4_3,

   /* Background and font */
   .pixmap = &pixmap_usplash_1024x768,
   .font   = &font_helvB10,

   /* Palette indexes */
   .background             = 0,
   .progressbar_background = 0,
   .progressbar_foreground = 30,
   .text_background        = 0,
   .text_foreground        = 125,
   .text_success           = 125,
   .text_failure           = 215,

   /* Progress bar position and size in pixels */
   .progressbar_x      = 404, /* 1024/2 - 216/2 */
   .progressbar_y      = 390, /* (strip2 height)+(logo height)+3 */
   .progressbar_width  = 216,
   .progressbar_height = 8,

   /* Text box position and size in pixels */
   .text_x      = 200, /* 200+624+200=1024 */
   .text_y      = 400, /* Fit between progressbar and strip1 */
   .text_width  = 624,
   .text_height = 270, /* 18 lines */

   /* Text details */
   .line_height  = 15,
   .line_length  = 32,
   .status_width = 64,

    /* Functions */
    .init = t_init,
    .clear_progressbar = t_clear_progressbar,
    .draw_progressbar = t_draw_progressbar,
    .animate_step = t_animate_step,
};

struct usplash_theme usplash_theme_1280x1024 = {
   .version = THEME_VERSION,
   .next = NULL,
   .ratio = USPLASH_4_3,

   /* Background and font */
   .pixmap = &pixmap_usplash_1280x1024,
   .font   = &font_helvB10,

   /* Palette indexes */
   .background             = 0,
   .progressbar_background = 0,
   .progressbar_foreground = 30,
   .text_background        = 0,
   .text_foreground        = 125,
   .text_success           = 125,
   .text_failure           = 215,

   /* Progress bar position and size in pixels */
   .progressbar_x      = 532, /* 1280/2 - 216/2 */
   .progressbar_y      = 460, /* (strip2 height)+(logo height)+6 */
   .progressbar_width  = 216,
   .progressbar_height = 8,

   /* Text box position and size in pixels */
   .text_x      = 200, /* 200+880+200=1280 */
   .text_y      = 475, /* Fit between progressbar and strip1 */
   .text_width  = 880,
   .text_height = 420, /* 28 lines */

   /* Text details */
   .line_height  = 15,
   .line_length  = 32,
   .status_width = 64,

    /* Functions */
    .init = t_init,
    .clear_progressbar = t_clear_progressbar,
    .draw_progressbar = t_draw_progressbar,
    .animate_step = t_animate_step,
};

void t_init(struct usplash_theme *theme) {
    int x, y;
    usplash_getdimensions(&x, &y);
    theme->progressbar_x = (x - theme->pixmap->width)/2 + theme->progressbar_x;
    theme->progressbar_y = (y - theme->pixmap->height)/2 + theme->progressbar_y;
}

void t_clear_progressbar(struct usplash_theme *theme) {
    t_draw_progressbar(theme, 0);
}

void t_draw_progressbar(struct usplash_theme *theme, int percentage) {
    int w = (pixmap_throbber_back.width * percentage / 100);
    usplash_put(theme->progressbar_x, theme->progressbar_y, &pixmap_throbber_back);

    if(percentage == 0)
        return;
    if(percentage < 0)
        usplash_put_part(theme->progressbar_x - w, theme->progressbar_y, pixmap_throbber_back.width + w,
                         pixmap_throbber_back.height, &pixmap_throbber_fore, -w, 0);
    else
        usplash_put_part(theme->progressbar_x, theme->progressbar_y, w, pixmap_throbber_back.height,
                         &pixmap_throbber_fore, 0, 0);
}

void t_animate_step(struct usplash_theme* theme, int pulsating) {

    static int pulsate_step = 0;
    static int pulse_width = 28;
    static int step_width = 2;
    static int num_steps = (216 - 28)/2;
    int x1;

    if (pulsating) {
        t_draw_progressbar(theme, 0);

        if(pulsate_step < num_steps/2+1)
            x1 = 2 * step_width * pulsate_step;
        else
            x1 = 216 - pulse_width - 2 * step_width * (pulsate_step - num_steps/2+1);

        usplash_put_part(theme->progressbar_x + x1, theme->progressbar_y, pulse_width,
                         pixmap_throbber_fore.height, &pixmap_throbber_fore, x1, 0);

        pulsate_step = (pulsate_step + 1) % num_steps;
    }

    /* Parallax Code */         /* Variable Descriptions*/
    static short firstrun = 1;  /* firstrun = ensure this block of code is only run once */
    static short ani1 = 0;      /* ani1 = pixel offset for scrolling strip1 */
    static short ani2 = 0;      /* ani2 = pixel offset for scrolling strip2 */

    static short resX = 640;    /* resX  = holds the x value of the resolution  */
    static short resY = 480;    /* resY  = holds the y value of the resolution  */
    static short px1 = 0;       /* px1   = upper left coord of strip1 */
    static short px2 = 0;       /* px2   = upper left coord of strip2 */
    static short py1 = 420;     /* py1   = upper left coord of strip1 */
    static short py2 = 0;       /* py2   = upper left coord of strip2 */
    static short pw1 = 640;     /* pw1   = half the width of strip image, for tessellation effect */
    static short pw2 = 640;     /* pw2   = half the width of strip image, for tessellation effect */
    static short ph1 = 60;      /* ph1   = we want to draw the full height of strip */
    static short ph2 = 168;     /* ph2   = we want to draw the full height of strip */
    static short logoX = 92;    /* logoX = centered (ResWidth/2 - logoWidth/2) */
    static short logoY = 170;   /* logoY = strip2 height + 1 */

    if(firstrun)
    {
        firstrun = 0;
        int x, y;
        usplash_getdimensions(&x, &y);
        if(x == 800 && y == 600)
        {
            resX = 800; resY = 600; logoX = 172; logoY = 210;
            px1 = 0; py1 = 525; pw1 = 800; ph1 = 75;
            px2 = 0; py2 = 0;   pw2 = 800; ph2 = 209;
        }
        else if(x == 1024 && y == 768)
        {
            resX = 1024; resY = 768; logoX = 284; logoY = 269;
            px1 = 0; py1 = 672; pw1 = 1024; ph1 = 96;
            px2 = 0; py2 = 0;   pw2 = 1024; ph2 = 268;
        }
        else if(x == 1280 && y == 1024)
        {
            resX = 1280;  resY = 1024; logoX = 412; logoY = 336;
            px1 = 0; py1 = 904; pw1 = 1280; ph1 = 120;
            px2 = 0; py2 = 0;   pw2 = 1280; ph2 = 335;
        }
    }

    /* Move this strip fast */
    if(ani1 < pw1) ani1 += 5;
    else           ani1  = 0;

    /* Move this strip slow */
    if(ani2 < pw2) ani2 += 1;
    else           ani2  = 0;

    /* Draw the scrolling strips */
    if(resX == 640 && resY == 480)
    {
        usplash_put_part(px1, py1, pw1, ph1, &pixmap_strip1_640x480, ani1, 0); /* GRASS */
        usplash_put_part(px2, py2, pw2, ph2, &pixmap_strip2_640x480, ani2, 0); /* SKY */
    }
    else if(resX == 800 && resY == 600)
    {
        usplash_put_part(px1, py1, pw1, ph1, &pixmap_strip1_800x600, ani1, 0);
        usplash_put_part(px2, py2, pw2, ph2, &pixmap_strip2_800x600, ani2, 0);
    }
    else if(resX == 1024 && resY == 768)
    {
        usplash_put_part(px1, py1, pw1, ph1, &pixmap_strip1_1024x768, ani1, 0);
        usplash_put_part(px2, py2, pw2, ph2, &pixmap_strip2_1024x768, ani2, 0);
    }
    else if(resX == 1280 && resY == 1024)
    {
        usplash_put_part(px1, py1, pw1, ph1, &pixmap_strip1_1280x1024, ani1, 0);
        usplash_put_part(px2, py2, pw2, ph2, &pixmap_strip2_1280x1024, ani2, 0);
    }
    /* Draw the logo */
    usplash_put(logoX, logoY, &pixmap_logo);
}



parallax-theme-function.c posted for reference
Code: Select all
/* usplash
 *
 * parallax-theme.c
 * Copyright © 2008 red_team316
 * Original Code found throughout Copyright © 2006 Dennis Kaarsemaker
 *
 * Notes: Includes pallete index bugfix see URL below.
 * https://bugs.launchpad.net/ubuntu/+source/usplash/+bug/66760
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */

#include <usplash-theme.h>
/* Needed for the custom drawing functions */
#include <usplash_backend.h>

extern struct usplash_pixmap pixmap_usplash_640x480;
extern struct usplash_pixmap pixmap_usplash_800x600;
extern struct usplash_pixmap pixmap_usplash_1024x768;
extern struct usplash_pixmap pixmap_usplash_1280x1024;

/* Parallax Pixmaps */
extern struct usplash_pixmap pixmap_logo;
extern struct usplash_pixmap pixmap_strip1_640x480;
extern struct usplash_pixmap pixmap_strip2_640x480;
extern struct usplash_pixmap pixmap_strip1_800x600;
extern struct usplash_pixmap pixmap_strip2_800x600;
extern struct usplash_pixmap pixmap_strip1_1024x768;
extern struct usplash_pixmap pixmap_strip2_1024x768;
extern struct usplash_pixmap pixmap_strip1_1280x1024;
extern struct usplash_pixmap pixmap_strip2_1280x1024;

extern struct usplash_pixmap pixmap_throbber_back;
extern struct usplash_pixmap pixmap_throbber_fore;
extern struct usplash_font font_helvB10;

void t_init(struct usplash_theme* theme);
void t_clear_progressbar(struct usplash_theme* theme);
void t_draw_progressbar(struct usplash_theme* theme, int percentage);
void t_animate_step(struct usplash_theme* theme, int pulsating);
void t_parallax(short px1, short px2, short py1, short py2, short pw1, short pw2, short ph1, short ph2, short logoX, short logoY, short Res);

struct usplash_theme usplash_theme_640x480;
struct usplash_theme usplash_theme_800x600;
struct usplash_theme usplash_theme_1024x768;
struct usplash_theme usplash_theme_1280x1024;

/* Theme definition */
struct usplash_theme usplash_theme = {
   .version = THEME_VERSION,
   .next = &usplash_theme_800x600,
   .ratio = USPLASH_4_3,

   /* Background and font */
   .pixmap = &pixmap_usplash_640x480,
   .font   = &font_helvB10,

   /* Palette indexes */
   .background             = 0,
   .progressbar_background = 0,
   .progressbar_foreground = 30,
   .text_background        = 0,
   .text_foreground        = 125,
   .text_success           = 125,
   .text_failure           = 215,

   /* Progress bar position and size in pixels */
   .progressbar_x      = 212, /* 640/2-216/2 */
   .progressbar_y      = 290, /* (strip2 height)+(logo height)+3 */
   .progressbar_width  = 216,
   .progressbar_height = 8,

   /* Text box position and size in pixels */                          /*                          */
   .text_x      = 100, /* 100+440+100=640 */                           /*   x,y-----------------   */
   .text_y      = 310, /* Fit between progressbar and strip1 */        /*   |                  |   */
   .text_width  = 440,                                                 /*   -----------------w,h   */
   .text_height = 105, /* 7 lines */                                   /*                          */

   /* Text details */
   .line_height  = 15,   /* Height of line in pixels */
   .line_length  = 32,   /* Length of line in characters */
   .status_width = 64,   /* Number of RHS pixels for status */

    /* Functions */
    .init = t_init,
    .clear_progressbar = t_clear_progressbar,
    .draw_progressbar = t_draw_progressbar,
    .animate_step = t_animate_step,
};

struct usplash_theme usplash_theme_800x600 = {
   .version = THEME_VERSION,
   .next = &usplash_theme_1024x768,
   .ratio = USPLASH_4_3,

   /* Background and font */
   .pixmap = &pixmap_usplash_800x600,
   .font   = &font_helvB10,

   /* Palette indexes */
   .background             = 0,
   .progressbar_background = 0,
   .progressbar_foreground = 30,
   .text_background        = 0,
   .text_foreground        = 125,
   .text_success           = 125,
   .text_failure           = 215,

   /* Progress bar position and size in pixels */
   .progressbar_x      = 292, /* 800/2 - 216/2 */
   .progressbar_y      = 335, /* (strip2 height)+(logo height)+5 */
   .progressbar_width  = 216,
   .progressbar_height = 8,

   /* Text box position and size in pixels */
   .text_x      = 100, /* 100+600+100=800 */
   .text_y      = 345, /* Fit between progressbar and strip1 */
   .text_width  = 600,
   .text_height = 165, /* 11 lines */

   /* Text details */
   .line_height  = 15,
   .line_length  = 32,
   .status_width = 64,

    /* Functions */
    .init = t_init,
    .clear_progressbar = t_clear_progressbar,
    .draw_progressbar = t_draw_progressbar,
    .animate_step = t_animate_step,
};

struct usplash_theme usplash_theme_1024x768 = {
   .version = THEME_VERSION,
   .next = &usplash_theme_1280x1024,
   .ratio = USPLASH_4_3,

   /* Background and font */
   .pixmap = &pixmap_usplash_1024x768,
   .font   = &font_helvB10,

   /* Palette indexes */
   .background             = 0,
   .progressbar_background = 0,
   .progressbar_foreground = 30,
   .text_background        = 0,
   .text_foreground        = 125,
   .text_success           = 125,
   .text_failure           = 215,

   /* Progress bar position and size in pixels */
   .progressbar_x      = 404, /* 1024/2 - 216/2 */
   .progressbar_y      = 390, /* (strip2 height)+(logo height)+3 */
   .progressbar_width  = 216,
   .progressbar_height = 8,

   /* Text box position and size in pixels */
   .text_x      = 200, /* 200+624+200=1024 */
   .text_y      = 400, /* Fit between progressbar and strip1 */
   .text_width  = 624,
   .text_height = 270, /* 18 lines */

   /* Text details */
   .line_height  = 15,
   .line_length  = 32,
   .status_width = 64,

    /* Functions */
    .init = t_init,
    .clear_progressbar = t_clear_progressbar,
    .draw_progressbar = t_draw_progressbar,
    .animate_step = t_animate_step,
};

struct usplash_theme usplash_theme_1280x1024 = {
   .version = THEME_VERSION,
   .next = NULL,
   .ratio = USPLASH_4_3,

   /* Background and font */
   .pixmap = &pixmap_usplash_1280x1024,
   .font   = &font_helvB10,

   /* Palette indexes */
   .background             = 0,
   .progressbar_background = 0,
   .progressbar_foreground = 30,
   .text_background        = 0,
   .text_foreground        = 125,
   .text_success           = 125,
   .text_failure           = 215,

   /* Progress bar position and size in pixels */
   .progressbar_x      = 532, /* 1280/2 - 216/2 */
   .progressbar_y      = 460, /* (strip2 height)+(logo height)+6 */
   .progressbar_width  = 216,
   .progressbar_height = 8,

   /* Text box position and size in pixels */
   .text_x      = 200, /* 200+880+200=1280 */
   .text_y      = 475, /* Fit between progressbar and strip1 */
   .text_width  = 880,
   .text_height = 420, /* 28 lines */

   /* Text details */
   .line_height  = 15,
   .line_length  = 32,
   .status_width = 64,

    /* Functions */
    .init = t_init,
    .clear_progressbar = t_clear_progressbar,
    .draw_progressbar = t_draw_progressbar,
    .animate_step = t_animate_step,
};

void t_init(struct usplash_theme *theme) {
    int x, y;
    usplash_getdimensions(&x, &y);
    theme->progressbar_x = (x - theme->pixmap->width)/2 + theme->progressbar_x;
    theme->progressbar_y = (y - theme->pixmap->height)/2 + theme->progressbar_y;
}

void t_clear_progressbar(struct usplash_theme *theme) {
    t_draw_progressbar(theme, 0);
}

void t_draw_progressbar(struct usplash_theme *theme, int percentage) {
    int w = (pixmap_throbber_back.width * percentage / 100);
    usplash_put(theme->progressbar_x, theme->progressbar_y, &pixmap_throbber_back);

    if(percentage == 0)
        return;
    if(percentage < 0)
        usplash_put_part(theme->progressbar_x - w, theme->progressbar_y, pixmap_throbber_back.width + w,
                         pixmap_throbber_back.height, &pixmap_throbber_fore, -w, 0);
    else
        usplash_put_part(theme->progressbar_x, theme->progressbar_y, w, pixmap_throbber_back.height,
                         &pixmap_throbber_fore, 0, 0);
}

void t_animate_step(struct usplash_theme* theme, int pulsating) {

    static int pulsate_step = 0;
    static int pulse_width = 28;
    static int step_width = 2;
    static int num_steps = (216 - 28)/2;
    int x1;

    if (pulsating) {
        t_draw_progressbar(theme, 0);

        if(pulsate_step < num_steps/2+1)
            x1 = 2 * step_width * pulsate_step;
        else
            x1 = 216 - pulse_width - 2 * step_width * (pulsate_step - num_steps/2+1);

        usplash_put_part(theme->progressbar_x + x1, theme->progressbar_y, pulse_width,
                         pixmap_throbber_fore.height, &pixmap_throbber_fore, x1, 0);

        pulsate_step = (pulsate_step + 1) % num_steps;
    }

    /* Parallax Code */
    static short firstrun = 1;
    static int x = 640;
    static int y = 480;

    if(firstrun)
    {
        firstrun = 0;
        usplash_getdimensions(&x, &y);
    }
    /* Call the parallax function */
    if(x == 640 && y == 480)        t_parallax(0, 0, 420, 0,  640,  640,  60, 168,  92, 170, 1);
    else if(x == 800 && y == 600)   t_parallax(0, 0, 525, 0,  800,  800,  75, 209, 172, 210, 2);
    else if(x == 1024 && y == 768)  t_parallax(0, 0, 672, 0, 1024, 1024,  96, 268, 284, 269, 3);
    else if(x == 1280 && y == 1024) t_parallax(0, 0, 904, 0, 1280, 1280, 120, 335, 412, 336, 4);
}

/* Variable Descriptions*/
/* px = upper left coord of strip */
/* py = upper left coord of strip */
/* pw = half the width of strip image, for tessellation effect */
/* ph = we want to draw the full height of strip */
/* logoX = centered (ResWidth/2 - logoWidth/2) */
/* logoY = strip2 + 1 */

void t_parallax(short px1, short px2, short py1, short py2, short pw1, short pw2, short ph1, short ph2, short logoX, short logoY, short Res)
{

    static short ani1 = 0;
    static short ani2 = 0;

    /* Move this strip fast */
    if(ani1 < pw1) ani1 += 5;
    else           ani1  = 0;

    /* Move this strip slow */
    if(ani2 < pw2) ani2 += 1;
    else           ani2  = 0;

    /* Draw the scrolling strips */
    if(Res == 1)
    {
        usplash_put_part(px1, py1, pw1, ph1, &pixmap_strip1_640x480, ani1, 0); /* GRASS */
        usplash_put_part(px2, py2, pw2, ph2, &pixmap_strip2_640x480, ani2, 0); /* SKY */
    }
    else if(Res == 2)
    {
        usplash_put_part(px1, py1, pw1, ph1, &pixmap_strip1_800x600, ani1, 0);
        usplash_put_part(px2, py2, pw2, ph2, &pixmap_strip2_800x600, ani2, 0);
    }
    else if(Res == 3)
    {
        usplash_put_part(px1, py1, pw1, ph1, &pixmap_strip1_1024x768, ani1, 0);
        usplash_put_part(px2, py2, pw2, ph2, &pixmap_strip2_1024x768, ani2, 0);
    }
    else if(Res == 4)
    {
        usplash_put_part(px1, py1, pw1, ph1, &pixmap_strip1_1280x1024, ani1, 0);
        usplash_put_part(px2, py2, pw2, ph2, &pixmap_strip2_1280x1024, ani2, 0);
    }
    /* Draw the logo */
    usplash_put(logoX, logoY, &pixmap_logo);
}

Good job, I will have to "play" with it ;) I am not sure how intrepid based Ultimate Edition 2.0 will view it, will let you know.
Home of Ultimate Edition. Got a question? Please review the F.A.Q. Browse the How to section.

Main O/S: Builder of O/S Guess.
Mainboard: ASUS Hero VI (AM4)
CPU: AMD 1700X water cooled (Deepcool Captain Genome Cooling tower)
Ram: 16 GB GSkill Trident RGB Series Dual Channel DDR4 3200
Video: MSI RX470 8GB Gaming card.
Hard Disks: MASSIVE on the network.(10 Gigabit, 48 port, multiple servers)
Monitors: Dual 4K 43" LG, 4K Samsung 28"
750 Watt modular PSU (Rosswell)
1100 Watt Amp & 4 X 600 Watt speakers

Servers in the basement.
User avatar
TheeMahn
Site Admin
 
Posts: 4201
Joined: Fri Oct 12, 2007 10:02 am
Location: U.S.A.
Age: 53
Operating System: Ultimate Edition Developer



Re: Parallax Usplash

Postby slowflow » Tue Oct 28, 2008 6:10 am

Great idea RT-316 :o

Just out of curiosity, how many parallax planes are you using/aiming for?
Abit KN9s, 1GB 4870, 4GB A-DATA Vitesta @ 1033Mhz, Athlon 6000 X2, running Ultimate 2.2 64bit
Win7 x64 (for Gaming)
Xp x64 (for music production & Editing)
User avatar
slowflow
U.E. Newbie
U.E. Newbie
 
Posts: 19
Joined: Sun Oct 28, 2007 8:40 am



Re: Parallax Usplash

Postby red_team316 » Tue Oct 28, 2008 8:00 pm

It just uses 2, 1 for the grass and 1 for the sky. The logo and progress bars are stationary in the middle of the screen as a normal usplash would be. Sure, I could have added more planes/layers to increase the parallaxing effect, but it would have taken much longer to produce. Getting the textbox to fit in the correct place and calculating line heights and positioning took the most time because I had to do it for each resolution. If someone wants to re-use it with different (height) graphics, then they will need to recalculate all the positioning to make it look good in verbose mode.

To be honest, I was planning on using more layers and actually overlapping them, but it appears that usplash likes to flicker when 1 graphic is blitted on top of the other, so it would have looked glitchy even though my code was correct. You've probably noticed that most normal usplashes flicker slightly while the progress bar is pulsating, well, that is what I mean, but imagine it all over the screen where the parallax layers would overlap. Thats why I stuck with a simple 2 layer design and made sure that nothing overlapped. I personally would consider it a bug and really hope that the usplash devs fix that flickering in the future.


I remember Thee said he had some sort of Pi/circular usplash a long time ago but I dont think it ever saw the light of day. I too have a Pi/circular type of usplash but havent released anything on it due to the flickering bug described above.
Core i7 920(working on a decent OC), x58 ASUS P6T Deluxe V2, 6GB DDR3 1600, EVGA 8800GTS512, Silencer 750W PSU, CoolerMaster V8, Red Antec900
Image
User avatar
red_team316
U.E. College Professor
U.E. College Professor
 
Posts: 288
Joined: Mon Jan 07, 2008 12:37 am
Age: 39
Operating System: Ultimate Edition 3.2 64 BIT



Re: Parallax Usplash

Postby slowflow » Wed Oct 29, 2008 9:25 am

Thanks for the reply RT_316

Parallax effects in a usplash is such a sweet idea! <BREW>
Flickering, however slight is to be avoided, as people will just call your efforts glitchy & buggy. I await the finished article, I'd have compiled it from the source you provided already, however I'm on holiday & away from my PC for another week. :evil:

In advance, may I say that, I appreciate your efforts RT_316 :D
Abit KN9s, 1GB 4870, 4GB A-DATA Vitesta @ 1033Mhz, Athlon 6000 X2, running Ultimate 2.2 64bit
Win7 x64 (for Gaming)
Xp x64 (for music production & Editing)
User avatar
slowflow
U.E. Newbie
U.E. Newbie
 
Posts: 19
Joined: Sun Oct 28, 2007 8:40 am



Re: Parallax Usplash

Postby red_team316 » Wed Oct 29, 2008 1:47 pm

Well, you shouldn't see any flickering in it. Thats the main reason I made sure nothing overlapped. If you experience any flickering at all, it will be in the progress bar when it is pulsating, and that is no different that a standard ubuntu cd shipped from canonical so if someone things it's buggy for that, then they need to look at canonical.

I suppose that brings up another point though, maybe there should be an alternate way of drawing the progress bar at least until someone addresses the flickering issue.

It pretty much is finished unless I decide to add more layers later or someone comes up with a real neat idea to add to it. I am planning on coming out with more types of usplashes just to show whats possible with usplash, so if you've got ideas for something new and different, let me know and I'll see if it's feasible.

There should be 32 and 64 bit usplashes already compiled in the download. You can install it easy with usplash-switcher but the preview will not look right but it will install fine. Thats not my fault, as usplash-switcher is just a hacked up program made by Dennis to make things easy. His prog just assumes that everything is going to be a standard usplash :P
Core i7 920(working on a decent OC), x58 ASUS P6T Deluxe V2, 6GB DDR3 1600, EVGA 8800GTS512, Silencer 750W PSU, CoolerMaster V8, Red Antec900
Image
User avatar
red_team316
U.E. College Professor
U.E. College Professor
 
Posts: 288
Joined: Mon Jan 07, 2008 12:37 am
Age: 39
Operating System: Ultimate Edition 3.2 64 BIT



Re: Parallax Usplash

Postby NacIK » Wed Oct 29, 2008 4:31 pm

Parallax???!? What is it?
NacIK
U.E. Newbie
U.E. Newbie
 
Posts: 21
Joined: Thu Oct 23, 2008 4:10 pm
Location: Ft Bragg, NC
Age: 40
Operating System: Ultimate Edition 2.1 32 BIT



Re: Parallax Usplash

Postby pch.shot » Wed Oct 29, 2008 4:49 pm

Systems Windows XP Pro 32 bit & various Linux in Virtual Box and VMWare Player
Intel i7 2600K cpu with built in Intel 3000 video
1 OCZ Vertex 3 120 gig ssd(System)
1 Western Digital 2 Terabyte Green internal hard drive(Storage)
Kingston ddr3 1333 ram(4 gig)
MSI Z68A-GD80(G3)mobo w/hdmi video and optical audio
Realtek HD audio
Realtek lan
1 LG sata optical drive
Antec Sonata IV case/620 watt psu
50 inch LG plasma tv/monitor
Sony surround sound amp
Axiom speakers
optical sound
User avatar
pch.shot
U.E. God
U.E. God
 
Posts: 3685
Joined: Sat Feb 02, 2008 12:28 pm
Location: Chippawa, Canada
Age: 69
Operating System: Microsoft Windows



Re: Parallax Usplash

Postby NacIK » Wed Oct 29, 2008 4:51 pm

Sorry, brainfart.
NacIK
U.E. Newbie
U.E. Newbie
 
Posts: 21
Joined: Thu Oct 23, 2008 4:10 pm
Location: Ft Bragg, NC
Age: 40
Operating System: Ultimate Edition 2.1 32 BIT



Re: Parallax Usplash

Postby red_team316 » Sat Nov 08, 2008 9:05 am

I have updated my parallax usplash to be Intrepid Ibex (8.10) compatible.
It can be found here:
http://www.kde-look.org/content/show.ph ... tent=89780
Core i7 920(working on a decent OC), x58 ASUS P6T Deluxe V2, 6GB DDR3 1600, EVGA 8800GTS512, Silencer 750W PSU, CoolerMaster V8, Red Antec900
Image
User avatar
red_team316
U.E. College Professor
U.E. College Professor
 
Posts: 288
Joined: Mon Jan 07, 2008 12:37 am
Age: 39
Operating System: Ultimate Edition 3.2 64 BIT

Next

Return to Programming

Who is online

Users browsing this forum: No registered users and 11 guests