WladekProd
WladekProd

Reputation: 1

Python (Ren'Py Engine) How to implement a smooth style change?

I want to implement a smooth style change like in css. That-so that when you hover over the text smoothly changed the color parameter.

Example

Is it possible to create a custom textbutton class for a similar task or is it easier to implement than mine ?

utils.rpy:

transform smooth_button(text_color, outline_color, text_zoom, smooth_time):
    zoom text_zoom
    on idle:
        matrixcolor ColorizeMatrix(outline_color[1], text_color[1])
        linear smooth_time matrixcolor ColorizeMatrix(outline_color[0], text_color[0])
    on hover:
        matrixcolor ColorizeMatrix(outline_color[0], text_color[0])
        linear smooth_time matrixcolor ColorizeMatrix(outline_color[1], text_color[1])
screen stextbutton(text, action_func = Return(), style_class = None, smooth_time = .1, text_zoom = 1.0, text_color = [gui.selected_color, gui.hover_color_smooth], outline_color = [gui.outline_color, gui.outline_color]):
    textbutton (text) action action_func at smooth_button(text_color, outline_color, text_zoom, smooth_time):
        style style_class

screens.rpy: use stextbutton(_("Exit"), Quit(confirm=not main_menu))

Upvotes: 0

Views: 46

Answers (0)

Related Questions