Using pie chart as interface

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Georgine
Regular
Posts: 55
Joined: Fri Jan 24, 2014 7:47 am
Contact:

Using pie chart as interface

#1 Post by Georgine »

Hi everyone,

I'm working on a life simulator game that requires the player to decide how to budget their time each day, which obviously makes it a perfect fit for DSE. However, instead of displaying a button for each possible activity the player can spend a period doing, I would like to use a pie chart- one circle broken into 10-15 wedges, with each wedge constituting an activity. My first thought was to simply hard-code the screen coords for each wedge, but since pie slices aren't rectangular that seems like a very dicey solution.

Is there a better way to implement this that I'm missing?

Tsapas
Regular
Posts: 69
Joined: Mon Oct 14, 2013 8:18 am
Contact:

Re: Using pie chart as interface

#2 Post by Tsapas »

One way would be to use the alpha True property in your imagemap, that does not focus transparent areas in your imagemap even if they are inside a hotspot, but for a pie chart hotspots would overlap probably, so don't know if this would work.

Or else, you could use an imagebutton for each chart slice with the focus_mask = True argument, so transparent areas in each button do not gain focus.

Check this thread as well, in the last post there are examples for each approach with accompanying buttons and code, so you can see what suits you best.

Georgine
Regular
Posts: 55
Joined: Fri Jan 24, 2014 7:47 am
Contact:

Re: Using pie chart as interface

#3 Post by Georgine »

Ooh thank you for the citation, I'll try implementing it and report back... this probably won't work, but I'm reading about imagebuttons and if I were to make multiple .pngs, with each .png being one wedge of a circle with a transparent background, would hover and selected idle/active trigger when the user moused over the invisible transparent background?

Tsapas
Regular
Posts: 69
Joined: Mon Oct 14, 2013 8:18 am
Contact:

Re: Using pie chart as interface

#4 Post by Tsapas »

If the imagebutton has the "focus_mask = True" argument, no it should not. Only opaque pixels trigger those states.

Georgine
Regular
Posts: 55
Joined: Fri Jan 24, 2014 7:47 am
Contact:

Re: Using pie chart as interface

#5 Post by Georgine »

Oh that's excellent to know, now I know that I have at least one option if all else fails.. thank you very much for the advice + clarification, I'll post back later when I've tried the original suggestion. ^^

User avatar
i1abnrk
Regular
Posts: 38
Joined: Wed Nov 20, 2013 1:50 pm
Projects: Critter Corral, Haremu Kikkemu Mo
IRC Nick: i1abnrk
Deviantart: i1abnrk
Github: i1abnrk
Location: Wisconsin
Contact:

Re: Using pie chart as interface

#6 Post by i1abnrk »

If I were to tackle this I would start with a single image of an arc segment. Then I would apply a transformation of the arc segment and make n copies, each one rotated i * angle about the center point. Where n is the number of slices, i is a loop counter and angle is n/360 degrees.
The other way is to directly render a drawing to a canvas, specifically the renpy window. Here you would need to calculate points which can be formulated with the "unit circle" (see wikipedia). Essentially, the points are: center, the two angles in radians times the radius. The x-coordinate is sine(angle) and the y-coordinate is cosine(angle). (Or maybe it's the other way around :p) Last to convert radians to degrees is multiply by 360/pi.
So basically you need use trigonometry like my examples.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Using pie chart as interface

#7 Post by xela »

i1abnrk wrote:If I were to tackle this I would start with a single image of an arc segment. Then I would apply a transformation of the arc segment and make n copies, each one rotated i * angle about the center point. Where n is the number of slices, i is a loop counter and angle is n/360 degrees.
The other way is to directly render a drawing to a canvas, specifically the renpy window. Here you would need to calculate points which can be formulated with the "unit circle" (see wikipedia). Essentially, the points are: center, the two angles in radians times the radius. The x-coordinate is sine(angle) and the y-coordinate is cosine(angle). (Or maybe it's the other way around :p) Last to convert radians to degrees is multiply by 360/pi.
So basically you need use trigonometry like my examples.
How is this "thing" still not b@nned... ?

Apologies, odd username and this reply confused the hell out of me...
Like what we're doing? Support us at:
Image

Post Reply

Who is online

Users browsing this forum: No registered users