Position image along a curve based on variable?

I wanna make a little gadget that shows the time of day by positioning a sun and/or moon along a curved path. I can do it and have already, except what I can do is manually position the image for every single possible state it could be in. Not-optimal. If I want a position for every 15 minutes that's 96 positions, more would be impractical. If I want to resize or change image I have to adjust each manually.
Ideally I'd like to be able to set a curve and have the position of the image be placed along that curve based on a variable number. An invisible circle or parabola that acts like a slider where position is set via variable.
Even better if the curve can be set to automatically adjust size and shape overlaid on an image so the image can be resized, changed out, or moved and have the curve stay consistent to the paired image.
Does anybody know of a script or plugin I might use to achieve this effect? I'm sure it could be mathed out in JS, but idk how. If only I paid more attention to the graph based math stuff in school, ahh.
Thanks for your consideration 🙂
You are using show picture now to show your “clock”? It shouldn’t be too hard to script the relative positions of the disk, the sun, and the moon, but it’d help if you showed us how you have it implemented now.

Or maybe just show the graphics that you want to use for this.
Hmmm, if you want pics to move along a circle, you can increase a variable (reset when goes above 360) and then get points on the circumference with the basic formulas you can google, like an example (with picture id 1 and variable id 16 to store the angle):

const radius = 50;
const originX = 400;
const originY = 300;
let angle = $gameVariables.value(16);
angle = angle * Math.PI / 180;
const x = radius * Math.cos(angle) + originX;
const y = radius * Math.sin(angle) + originY;

$gameScreen.movePicture(1, 1, x, y, 100, 100, 255, 0, 1);

EDIT: Oh yeah, those originX and originY are the origin of the imaginary circle that forms the path. EDIT2: Or like the center point or whatever you call it.
If you want to use @rpgLord69's approach, you need to be careful to consider the coordinate system: +Y moves down, +X moves left => left-handed system. Starting point may also be relevant, depending on how you handle the values internally.

E.g. for angle = 0° to be 12 o'clock, and angle = 90° to be 3 o'clock:
JavaScript:
const x = originX + radius * Math.sin(angle);
const y = originY - radius * Math.cos(angle);
I would also add that the event can look something like this if you would like an ellipse pattern instead of a circle. Change wait times as needed and remove the "shift" key if you would like for the player to not be able to cancel its orbit:
1758989841376.png

1758990272224.png


Edit: The counter is set to be 6 degrees for each iteration of the process and starts over when it gets to 360. I made the center of the ellipse be the center of the screen, the x-axis of the ellipse 300 pixels (600 total round trip), and the y-axis 150 pixels (300 round trip).

I also used the script call to set the ._data property of the variables to avoid the possibility of rounding of the values when using setValue(). You probably don't need the float values so setValue could work better:

1758991608598.png


It moves to the point over the course of 15 frames and then starts again with a possible cancellation of the picture and orbit by simply holding down the shift key.
Cool, my trigonometry is a bit rusty, I just tested that it rotated (clockwise) in a proper way and decided that they could set the starting position in show picture by giving the angle/variable an original value that's not 0.
Hmmm, if you want pics to move along a circle, you can increase a variable (reset when goes above 360) and then get points on the circumference with the basic formulas you can google, like an example (with picture id 1 and variable id 16 to store the angle):

const radius = 50;
const originX = 400;
const originY = 300;
let angle = $gameVariables.value(16);
angle = angle * Math.PI / 180;
const x = radius * Math.cos(angle) + originX;
const y = radius * Math.sin(angle) + originY;

$gameScreen.movePicture(1, 1, x, y, 100, 100, 255, 0, 1);

EDIT: Oh yeah, those originX and originY are the origin of the imaginary circle that forms the path. EDIT2: Or like the center point or whatever you call it.
Took a bit of jiggering, but I used your method with caethryl's correction and it works like a charm, I've got this going:

◆Show Picture:#100, TimeShow, Center (108,56), (75%,75%), 255, Normal
◆Control Variables:#0063 Time Degrees = Time
◆Control Variables:#0063 Time Degrees /= 4
◆If:Script:$gameVariables.value(80) >= 1056 || $gameVariables.value(80) <= 384
◆Show Picture:#98, TimeMoon, Center (0,0), (100%,100%), 255, Normal
◆
:End
◆If:Script:$gameVariables.value(80) >= 336 && $gameVariables.value(80) <= 1106
◆Show Picture:#99, TimeSun, Center (0,0), (100%,100%), 255, Normal
◆
:End
◆Script:const radius = 96;
:Script:const originX = 108;
:Script:const originY = 110;
:Script:let angle = $gameVariables.value(63);
:Script:angle = angle * Math.PI / 180;
:Script:const x = originX - radius * Math.sin(angle);
:Script:const y = originY + radius * Math.cos(angle);
:Script:$gameScreen.movePicture(99, 1, x, y, 100, 100, 255, 0, 1);
◆Script:const radius = 96;
:Script:const originX = 108;
:Script:const originY = 110;
:Script:let angle = $gameVariables.value(63);
:Script:angle = angle * Math.PI / 180;
:Script:const x = originX + radius * Math.sin(angle);
:Script:const y = originY - radius * Math.cos(angle);
:Script:$gameScreen.movePicture(98, 1, x, y, 100, 100, 255, 0, 1);

Which looks like this in-game:
Timeshow.png

This shows midnight and 6:xx PM (forgor, something like 6:50ish)
The graphics I'm using are a little basic, but I can always change that later now that the time system works smoothly.
Thanks for everybody's help!

Original thread: https://forums.rpgmakerweb.com/threads/position-image-along-a-curve-based-on-variable.180319/