I was hoping someone would know how to create the following code → because i just don’t know how.
I am conducting a visual analysis of motion by using dots. The image I attached expresses what i am trying to produce with the code - which is explained below:
the red dot moves along the negative of the x,y axis on the yellow arrow
the red dot then returns back to its origin (depicted by the yellow curved arrow - yellow arrow is not part of code)
the red dot is to repeat this 25% of the time (the time being 7 seconds) so 25% of every 7 seconds
all the gray dots are slowly moving, amongst themselves in small circles, constantly at all times (depicted by the blue arrow) sort of like an orbit
Here is a starter for 10. Probably not exactly what you were after, but should give you enough of an idea to get going
-- Dots
viewer.mode=FULLSCREEN
-- Use this function to perform your initial setup
function setup()
redDot=vec2(WIDTH/2,HEIGHT/2) --initial position of red dot
dotSize=100 --size of dots
redDotSpd=3 --speed of red dot
redDotTravel=0 --how far the red dot has travelled
redDotTravelLimit=100 --the limit after which the red dot disappears
--adjust the redDotSpd and RedDotTravel to be 1/4 of 7s
greyDots={vec2(200,400),vec2(300,600),vec2(400,800),vec2(700,900),vec2(900,800),vec2(1100,600),vec2(800,300)} --centre of each grey dot
greyDotSpd=3 --orbital speed of grey dots
greyOrbitSize=20 --the size of the grey dot orbit
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(40, 40, 50)
noStroke()
redDotTravel = redDotTravel + 1
fill(255,0,0)
ellipse(redDot.x,redDot.y,dotSize)
if redDotTravel<redDotTravelLimit then
redDot.x = redDot.x - redDotSpd
redDot.y = redDot.y - redDotSpd
else
redDot=vec2(WIDTH/2,HEIGHT/2)
end
if redDotTravel>4*redDotTravelLimit then
redDotTravel=0
end
fill(200)
for i, g in pairs(greyDots) do
ellipse(g.x+greyOrbitSize*math.sin(ElapsedTime*greyDotSpd),g.y+greyOrbitSize*math.cos(ElapsedTime*greyDotSpd),dotSize)
end
end