I wanted to make a basic header image for my website, normally I would just use python/PIL but I made the rash decision to jump out of my comfort zone and went for Perl/OpenGL. Very simple but I'm proud of it.
BEGIN{ unshift(@INC,"../blib"); } # in case OpenGL is built but not i +nstalled BEGIN{ unshift(@INC,"../blib/arch"); } # 5.002 gamma needs this BEGIN{ unshift(@INC,"../blib/lib"); } # 5.002 gamma needs this use OpenGL; use warnings; glpOpenWindow; glClearColor(0,0,0,1); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-3,3,-3,3,-3,3); glColor3f(1,0,0); sub rect{ if(defined($_[5])){$green =$_[5]}else{$green =0;} glColor3f(($i/(180*$loops)/2,$green,abs(100-($i/360))/2)); if(defined($_[4])){$rot =int($_[4]);$rot*= 0.017453;}else{$rot =0;} my@topleft=($_[0],$_[1]);my@bottomright=($_[2],$_[3]); glBegin(GL_POLYGON); @offset=(cos($rot)/2.5,sin($rot)/2.5); glVertex2f($topleft[0]-$offset[0],$topleft[1]+$offset[1]); glVertex2f($topleft[0]-$offset[0],$bottomright[1]+$offset[1]); glVertex2f($bottomright[0]+$offset[0],$bottomright[1]-$offset[1]); glVertex2f($bottomright[0]+$offset[0],$topleft[1]-$offset[1]); glEnd(); glpFlush(); } $loops=6;$radius=2.5; for ($i=0;$i<180*$loops;$i++){ $radius =$radius/1.00061;$yoff=cos($i/157); rect(-1*$radius,-1*$yoff*1.5,1*$radius,1*$yoff*1.5,$i);} rect(-2.5,-1,2.5,1,0,.2); rect(-2.47,-.97,2.47,.97,0,0); rect(-2.4,-.94,2.43,.943,0,.2); glpMainLoop;
if I 'use strict' it returns for every variable, global symbol $x requires an explicit package name. Am I doing something wrong?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A Small Perl Graphical Header
by jdporter (Paladin) on Mar 20, 2012 at 04:57 UTC |