Filter löschen
Filter löschen

Randomizing of an Oval Color

1 Ansicht (letzte 30 Tage)
Brett
Brett am 9 Nov. 2012
How do I randomize the color of a oval?
My code:
[window, rect] = Screen('OpenWindow', screenNum, 1);
[X,Y] = RectCenter(rect);
disc1 = [X-80,Y-80,X+80,Y+80]+250;
Screen('FillOval',window,[200,200,200], disc1');
Screen('Flip',window);
I figure I need to place variable for [200,200,200], but I'm not sure how to do it.
Please help and thank you, Brett
  1 Kommentar
Image Analyst
Image Analyst am 10 Nov. 2012
I can't run your code. What are Screen(), screenNum, and RectCenter? I guess they must be in some toolbox that you have (and didn't list) and I don't have.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 10 Nov. 2012
Bearbeitet: Image Analyst am 10 Nov. 2012
Can you adapt the FAQ http://matlab.wikia.com/wiki/FAQ#How_do_I_create_a_circle.3F to create an ellipse?
EDIT: Actually I've just added a section on "How do I create an ellipse" to the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_create_an_ellipse.3F so that might help you.
  2 Kommentare
Brett
Brett am 10 Nov. 2012
I'm using Psychtoolbox. The oval isn't really the issue, the above function creates the oval, I'm just not sure how to randomize its colour. I think I need code that basically says something like:
1) randomizes a number within a parameter: RANDOMCOLOR = rand(1:4) 2) something like if RANDOMCOLOR = 1, then RBG[169,169,0] 3) insert into RANDOMCOLOUR into 'colour': "Screen('FillOval',window, [colour'], disc1');"
I'm just really knew to Matlab and programming so I just don't know how to make it happen.
Image Analyst
Image Analyst am 10 Nov. 2012
Bearbeitet: Image Analyst am 10 Nov. 2012
I don't remember seeing that toolbox here. The 'Color' property is a very common input argument in many, many functions. Try
Screen('FillOval',window, 'Color', rand(1,3), disc1');

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Elementary Math finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by