How to Make an Apple Style Icon in GIMP

This tutorial was originally posted on stykz.net. I have since placed it in a few other places.

Without further ado, here it is:


The video form of the tutorial. Before you ask, yes it is slightly different than the written version.

This is the end result:
End Result

To begin, we will create a 100×100 image (Avatar size) But your image can be any size you would like Picture

Now zoom in to 400% by clicking the little menu on the bottom (Or any other zoom that suites you)

For the sake of ease, I will be doing a simple red sphere, but you can make whatever shape you want. Create a new layer over the background and name it “Sphere” Picture

Next select the circle select tool and drag a circular selection where your sphere will be. Leave sufficient room underneath for the dropshadow. Picture

Select the bucket fill tool and choose a good color (Gradients work too but are more advanced and require the gradient tool instead of the bucket fill tool) I chose a red to dark red gradient. Fill the selection with your color. Picture

Click Select>Grow from the menubar and choose about 2-4 pixels. Fill the resulting selection in with black on a new layer named “Sphere Outline 1” and move it’s layer below the original layer Picture

Create another new layer on the bottom (Above the background) and name this one “Sphere Outline 2”. Click Select>Grow And grow it by about the same amount as the last, but it can be higher. This time though, you will use a dark grey to black gradient. Stroke from top to bottom. Picture

Right click the “Sphere” layer and choose Alpha to selection and click the circle select tool again and choose the intersect mode. On a new layer above everything else, named “Gloss”, fill the selection in with a white to transparency gradient and adjust the opacity of the layer to about 90% Picture

On a final layer below the rest named “Shadow”, use the circle select tool again (set to replace not intersect) to choose a fitting shadow area. Select what looks good and choose a darker grey color. Fill in the selection and click Filters>Blur>Gaussian Blur and choose somewhere from 5 to 15 pixels depending on what looks good. click ok, adjust the positioning of the shadow to fit better and viola! You can optionally delete the background layer for a cool effect when used anywhere. Picture

Advertisements

GimpKnowHow.com is Online

This is somewhat of old news, but GimpKnowHow’s website is now up and running. It’s a forum with a pretty large userbase. Most of the people are helpful and creative. Many tutorials for both GIMP and Photoshop have been posted there. Go and check it out at GimpKnowHow.com. My username is DarkFlame there.

PyGameEngine Release 1 Now Available!

The source for PyGameEngine release 1 is now available at pyedpypers.org. There is also a discussion topic there. The highlight of this first release is the camera class.
The camera class is designed to work seamlessly with the game class provided by the game engine. It allows you to focus on one point at a time. It comes with a useful function just for centering on a set of coordinates. It also can be constrained to not pass too far off the screen. There’s much more to come as well.

The project’s page is located at http://pyedpypers.org/index.php?page=project&projectid=45&view=true

PyGameEngine

I began work today on a new game engine for use with Pygame. Right now, it only has classes and functions to facilitate cameras and camera movement. There’s also a working demo for the camera class. It is in a pre-alpha version and has many known bugs. Including ones as simple as making a background larger than the camera. But it seems more stable than many other engines out there.

Here’s an example of a simple use of the game engine:

from PyGameEngine import *

class NewSprite(GameSprite):

...

def main():
background = pygame.surface.Surface((800,600))
background.fill((65,0,0))
pygame.draw.line(background, (255,255,255), (0,0), (background.get_rect().width-1, 0), 9)
pygame.draw.line(background, (255,255,255), (background.get_rect().width-1, background.get_rect().height-1), (background.get_rect().width-1, 0), 9)
pygame.draw.line(background, (255,255,255), (0, background.get_rect().height-1), (background.get_rect().width-1, background.get_rect().height-1), 9)
pygame.draw.line(background, (255,255,255), (0, 0), (0, background.get_rect().height-1), 9)

game = Game(screensize=(800, 600), caption="PyGameEngine testing", background=background, bgcolor=Color(40,0,0), backgroundfixed=False, fullscreen=False, maxfps=30, debug=True)

spritesurf = pygame.surface.Surface((32, 32))
spritesurf.fill((255,255,255))
testSprite = NewSprite(game, image=spritesurf, bounds=Rect(0,0, 800,600))
game.centerOn = testSprite
testSprite.centerOn(Rect(0,0, 800,600).center)
testGroup = GameSpriteGroup(game, [testSprite])
game.addGroup(testGroup)
game.playersprite = game.groups[0].sprites()[0]

game.run()

if __name__ == '__main__':
main()

I will upload the source code as soon as I feel it’s ready. I may upload a video of the working demo though.

Multiple Python installations on one computer (Part 2)

Update: There is a possibly critical flaw with this technique. After setting this up, simply typing “apythonfile.py PARAMS” would not supply to params to sys.argv. Instead, I had to type “python apythonfile.py PARAMS”. I will update with a fix as soon as I find one, but it may involve registry editing.

Update2: Make sure not to REPLACE your PATH variable, if you do, just add

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem

to it and it should fix it. (This is for Vista)

In part 1 of this series, I showed you the basics of having multiple Python installations on one computer without spending too much time.

In this part, I will show some useful techniques for enabling easier use of your installations.

So I’ll start off by showing you the basics of installing several versions at once. The first step is to decide which versions you want, a combination of 3.x and 2.x is a good idea. Once you’ve decided this, you should go to their various pages on the python website. After downloading the installers, be sure to run them in order of [b]least used to most used[/b]. Meaning that if you want Python26 to be your main (default) installation, run the 2.6 installer last. This will add certain file associations (Most of which will get overwritten in later parts of this series anyway, but whatever).

Ok, now that we have that out of the way, we need to set up our Python environment. Notice that at this point, with a fresh Python installation, using

python

will run a python interactive interpreter with your “default” version. We’re about to add to that. The first step is to create a directory with a meaningful name that you can’t forget. I chose C:/cmds. Once you have your directory picked out, you need to run any text editor, even notepad will do. Now, add to the file the line:

C:\Python26\python.exe %*

(If you are running on a system older than XP, you can use a neat little trick which is to add a @ before the “C”, this mutes the output of this file.) If you are running a different version as your default, then change the version numbers accordingly (Or if you have them in completely different directories for that matter, just make sure it points to a valid python interpreter.) Now save this file as “python.bat” in your chosen directory. Next, make a new .bat file called “pythonw.bat” and add a ‘w’ to the end of the “python” in the exe.

Now, you shouldn’t notice any real difference, that’s ok, we’ll fix that soon.

Next, you should go to your control panel and go to the edit environment variables section. To get there, go to System>Advanced System Settings (On the left)>The Environment Variables button (On the bottom right). Now you will see a sort of complicated window with useful variables that Windows uses. Let’s not hang around here too long. On the top, there should be a “PATH” variable (Under user variables). Select it and choose “Edit”. You may want to take note of the current path before changing it for later. Now change it to your chosen directory (Not that you could have also just put your commands in the old directory, but the new one is in a place you can easily edit). Now go ahead and click OK here to accept your changes. Now if you go back to the command line and type the command “python” you should see that it opens an interactive interpreter with your “default” python version. Now that’s not all we’re going to do here.

Now what we need to do is add commands like:

python26 apython26file.py

python31 apython31file.py

To achieve this, we need to create some more .bat files in our directory. This part is pretty simple but can get repetitive. Start by opening up your original python.bat file and save it as a different version of Python. Example:

python26.bat

C:\Python26\python.exe %*

Now do the same for a “pythonw26.bat” file. (This time change “python.exe” to “pythonw.exe”)

If you have any more versions, do the same for them. You should end up with two .bat files for every Python version, which an extension to reflect the versions, plus two default ones with no version suffixes.

At this point, we’re done with the necessary stuff, but I’ve got a bonus for you! We’re going to be making it possible to use

apythonfile

instead of

apythonfile.py

It’s really unneeded, but can make typing in the command line easier later on.

So, to start, re-open that environment variables window you had open earlier. This time use the bottom panel and scroll down until you see the variable “PATHEXT”. This one we don’t want to completely override, instead, we need to append two things to it. To get an idea for just what you’re doing, look at the current contents. You will see that there are various file extensions in all caps separated by semicolons (“;”s). What we need to do is add the two extensions “.PY” and “.PYW”. When you’re done, you should have something like:

.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW

as the variable’s value. (Notice that your PATHEXT variable will likely be different from mine). Now click OK, open a new command line window (Did I mention that the changes won’t affect currently open windows?) and navigate to a python script. Try running it by just typing the filename minus the extension. It SHOULD work. If it didn’t work, you have a problem with file associations, which is a little more complicated than I think this already long post should go.

In Part 3, I will be addressing file extensions and setting their defaults, possibly with some more information.

Setuptools and easy_install

If you’re like me, then you encountered modules asking you to use

easy_install

to install them. At first, it made no sense to me, but as I gained knowledge in Python, I finally understood it.

What you need to do is first install the setuptools.py scripts from PyPI. Go to http://pypi.python.org/pypi/setuptools and follow the simple installation instructions.

Once you have setuptools in your Python Scripts folder, you are meant to be able to simply call

easy_install <PACKAGE>

from the command line, but for some reason this didn’t work on my machine. Instead, I had to navigate to my Python installation directory’s scripts. for me it was

C:\Python26\Scripts\

Once in this directory, you can either type just

easy_install <PACKAGE>

or

easy_install.exe <PACKAGE>

depending on your preference.

Now let’s test our new installation of setuptools. Open up a command line and navigate to your Python Scripts directory, then type:

easy_install pygame

(No worries, this should not harm your pygame installation, in fact it may help you!)

You will get some output similar to:

C:\Python26\Scripts>easy_install pygame
Searching for pygame
Best match: pygame 1.9.1
Adding pygame 1.9.1 to easy-install.pth file

Using c:\python26\lib\site-packages
Processing dependencies for pygame

Note that if you do not already have the latest version of the chosen package, it will ouput a little more.

Basically what this program does is check the PyPI (Or cheeseshop) for your selected package. If it finds it, it scans the dependencies and files for it and installs them. If not, it looks harder and usually fails.

In case you see a module for Python that says it is on the PyPI, you can try using easy_install before manual installation, it really is easy.

Multiple Python installations on one computer (Part 1)

So, I now have four different Python installations running at the same time, they are:

Python 2.5

Python 2.6 (My preference)

Python 2.7a

Python 3.1

So far, I have not met any problems on this setup, except for a slight pain. .py files and friends are all associated with Python 2.6, which is what I want, but the “python” command line command is associated with Python 2.5. So, if I want to run a program in 2.5, I just type the python prefix, else, I just type the filename. There seems to be no real benefit nor drawback to having multiple installations as you will most likely end up only using one anyway. Even so, if you can properly manage your installations, I recommend having a setup similar to my own.

Keep in mind I’m still working this out, once I get it, I’ll be sure to post an update with the new info.
I also plan on making this into a series with useful info about this.