Jump to content

What is the easiest way in creating a border around a picture object that is 7 wide on each side.

 

Without repeating this 28 times:

 

for a in range(getWidth(picture)):

setColor(getPixel(picture, a, 0), blue)

 

or this 4 times


    w = getWidth(pic)
    col=0
    while col<w:
        row=0
        while row<7:
            pixel = getPixel(pic,col,row)
            setColor(pixel,red)
            row=row+1
        col=col+1
   

|CPU: Intel 5960X|MOBO:Rampage V Extreme|GPU:EVGA 980Ti SC 2 - Way SLI|RAM:G-Skill 32GB|CASE:900D|PSU:CorsairAX1200i|DISPLAY :Dell U2412M X3|SSD Intel 750 400GB, 2X Samsung 850 Pro|

Peripherals : | MOUSE : Logitech G602 | KEYBOARD: K70 RGB (Cherry MX Brown) | NAS: Synology DS1515+  - WD RED 3TB X 5|ROUTER: AC68U

Sound : | HEADPHONES: Sennheiser HD800 SPEAKERS: B&W CM9 (Front floorstanding) ,  B&W CM Center 2 (Centre) | AV RECEIVER : Denon 3806 | MY X99 BUILD LOG!

 

Link to comment
https://linustechtips.com/topic/583568-python-help/
Share on other sites

Link to post
Share on other sites

I'd guess the best thing to do is just define a function that does that, and then call it later to save re-typing out the code:

def make_border(pic):
    for a in range(getWidth(pic)):
        setColor(getPixel(pic, a, 0), blue)

But without knowing anything about what you're doing, I don't know if there might be a better way to go about it.  Just defining a function you can call later is definitely a good place to start though, based on what you've given.

Link to comment
https://linustechtips.com/topic/583568-python-help/#findComment-7613927
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×