/help

I'm trying to create a program with javaFX which generates 10 different shapes (lines, squares and ellipses) everytime I press a buttom. The shapes suppose to get a random color. I already managed to create the code which generates 10 different shapes as asked BUT I don't manage to color them no matter what I do. How can I color them? ------------------------------------------------------------------------------------------------------------------------------------------------ I'n the picture I sent, this is the code which generates ellipses, it generates them black, now I just need to color it. I've made 3 variables which get values between 0 to 255 to represents the RGB shades. I don't know which command color it, I tried to find an answer for hours thanks!
No description
26 Replies
JavaBot
JavaBotβ€’12mo ago
βŒ› This post has been reserved for your question.
Hey @Yarden! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
noComment | Kez
noComment | Kezβ€’12mo ago
Of what type is your shape object?
Yarden
YardenOPβ€’12mo ago
Oval I did gc.fillOval(...) I guess i'm missing your question
noComment | Kez
noComment | Kezβ€’12mo ago
the object gc
Yarden
YardenOPβ€’12mo ago
canvas
noComment | Kez
noComment | Kezβ€’12mo ago
what type is it
Yarden
YardenOPβ€’12mo ago
If it can help But yeah the object is canvas type
No description
Yarden
YardenOPβ€’12mo ago
Or maybe you mean GraphicsContext?
noComment | Kez
noComment | Kezβ€’12mo ago
hm
Yarden
YardenOPβ€’12mo ago
gc is a graphicContext But I initialized in with canvas So when I use gc, I'm actually mianly drawing on the canvas that's what I meanπŸ™
noComment | Kez
noComment | Kezβ€’12mo ago
this also doesnt work with a hard coded colour?
Yarden
YardenOPβ€’12mo ago
Why do you mean hard coded colour? Sorry I'm fresh with javaFX
noComment | Kez
noComment | Kezβ€’12mo ago
Color.BLUE for example
Yarden
YardenOPβ€’12mo ago
It doesm but I need a random color does* When I do the RGB it causes the shapes to disappear
noComment | Kez
noComment | Kezβ€’12mo ago
does it also work with hard coded values like Color.rgb(255, 191, 0)
Yarden
YardenOPβ€’12mo ago
I'm stupid... I coded it wrongly in the color generator... it works
noComment | Kez
noComment | Kezβ€’12mo ago
yeah thought so πŸ˜„
Yarden
YardenOPβ€’12mo ago
I wrongly did int color = random.nextInt() * 255; instead of int color = random.nextInt(255);
noComment | Kez
noComment | Kezβ€’12mo ago
when you have a problem like this
Yarden
YardenOPβ€’12mo ago
thank you very much and sorry for wasting your time you helped me much
JavaBot
JavaBotβ€’12mo ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
noComment | Kez
noComment | Kezβ€’12mo ago
try to make it less complex first
Yarden
YardenOPβ€’12mo ago
I will thank you!
noComment | Kez
noComment | Kezβ€’12mo ago
so you can figure out where the problem lays no worries good luck in the future
Yarden
YardenOPβ€’12mo ago
thank you!
JavaBot
JavaBotβ€’12mo ago
Post Closed
This post has been closed by <@218019068219883520>.
Want results from more Discord servers?
Add your server