[Tutor] writing function changeColor

Aditi Pai aditipai1227 at gmail.com
Wed Jul 18 21:07:03 CEST 2012


Hey Emile! Thanks for the advice. I think maybe I should have combined the
two parts of my email. The function is just called changeColor. I don't
actually want to change the color as much as alter the color. I'm working
off of this example:

def decreaseRed(picture):
for p in getPixels(picture):
value=getRed(p)
setRed(p,value*0.5)

Except for me, I am asked to also make the argument so that it accepts an
integer and a float. Not sure how to assign different colors and do that.

On Wed, Jul 18, 2012 at 2:05 PM, Emile van Sebille <emile at fenx.com> wrote:

> On 7/18/2012 10:10 AM Aditi Pai said...
>
>  Hello,
>>
>> I am trying to write a function changeColor for an assignment.
>>
>
> I'd look in the documentation of whatever it is you're trying to change
> the color of.  It should be explained there how to set and change colors.
>
> You're going to end up with something that could look like:
>
> def change_color_to(new_color):
>     color_of_thing = new_color
>
> def modify_color_of_thing(by_n_**pct):
>     color_of_thing = old_color_of_thing * by_n_pct
>
> where the docs of the thing you're changing provide the names and handling
> of modifying the color.
>
> HTH,
>
> Emile
>
>
>  Two
>> things that I am unsure about for this assignment are how to assign
>> different colors to integers so that, red will be 1, blue will be 2,
>> etc. Also, I learned python so that if I were to put in 0.9, it'd
>> decrease red by 10%. The way this function needs to be written, -0.1
>> decreases red by 10%
>>
>> Where can I find information on these two topics?
>>
>>
>> ______________________________**_________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>>
>>
>
>
> ______________________________**_________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120718/b935aff2/attachment-0001.html>


More information about the Tutor mailing list