user2977294
user2977294

Reputation:

Function within a function

This is what I have:

def function1(pixel, color):
  setColor(pixel,color)


def function2(pixel):
  x = min(getRed(pixel), getGreen(pixel), getBlue(pixel))
  ???
  function1(pixel,color)

The 1st function I am just changing an individual pixel in a picture to a built in color.

In the 2nd function I am trying to set an individual pixel to a shade of grey, by getting the lowest of the pixels origin values and setting them all the same. Easy enough by itself, but I can't figure out what to stick in between my first and last lines of function2 while still using function1 in it. Everything I try gives me an error in function1. I know I could just make it setColor(pix,makeColor(x,x,x) but function1 is restricting me.

Upvotes: 0

Views: 71

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1121396

If setColor(pix, makeColor(x, x, x)) works, why not just pass those arguments that work to function1() then?

function1(pixel, makeColor(x, x, x))

The result of makeColor(x, x, x) is an object too, and will be passed to function1 as the color argument.

Upvotes: 1

Related Questions