And a slight mod to the above, to give the "cogs" directionality, so that they appear as if they'd actually be turning as we'd expect to see in a machine.
DEFLNG A-Z
SCREEN _NEWIMAGE(640, 480, 32)
DIM Colors(-1 TO 0)
Colors(-1) = &HFFFF0000 'Red
Colors(0) = &HFF0000FF 'Blue
FOR i = 0 TO 8
k = NOT k
x = 25 * SIN(_D2R(30 * i)) + 50
y = 25 * COS(_D2R(30 * i)) + 50
CIRCLE (x, y), 25, Colors(k)
PAINT (x, y), Colors(k)
NEXT
halfimage = _NEWIMAGE(50, 100, 32)
_PUTIMAGE , 0, halfimage, (50, 0)-(100, 100)
fullimage = _NEWIMAGE(100, 100, 32)
_DEST fullimage
DisplayImage halfimage, 50, 0, 0, 1
DisplayImage halfimage, 0, 0, 180, 4
_DEST 0
CLS ', Colors(-1)
DO
angle = (angle + 1) MOD 360
FOR y = -50 TO _HEIGHT + 50 STEP 82
Insert = NOT Insert
IF Insert THEN direction = -1 ELSE direction = 1
FOR x = -50 TO _WIDTH + 50 STEP 100
DisplayImage fullimage, x + Insert * 50, y, direction * angle, 0
NEXT
NEXT
_DISPLAY
LOOP UNTIL _KEYHIT
SUB PlacePattern (Xwhere, Ywhere, WhichPattern)
DisplayImage WhichPattern, Xwhere, Ywhere, 0, 1
DisplayImage tempimage, Xwhere - 50, Ywhere, 180, 4
END SUB
SUB DisplayImage (Image AS LONG, x AS INTEGER, y AS INTEGER, angle AS SINGLE, mode AS _BYTE)
'Image is the image handle which we use to reference our image.
'x,y is the X/Y coordinates where we want the image to be at on the screen.
'angle is the angle which we wish to rotate the image.
'mode determines HOW we place the image at point X,Y.
'Mode 0 we center the image at point X,Y
'Mode 1 we place the Top Left corner of oour image at point X,Y
'Mode 2 is Bottom Left
'Mode 3 is Top Right
'Mode 4 is Bottom Right
DIM px(3) AS INTEGER, py(3) AS INTEGER, w AS INTEGER, h AS INTEGER
DIM sinr AS SINGLE, cosr AS SINGLE, i AS _BYTE
w = _WIDTH(Image): h = _HEIGHT(Image)
SELECT CASE mode
CASE 0 'center
px(0) = -w \ 2: py(0) = -h \ 2: px(3) = w \ 2: py(3) = -h \ 2
px(1) = -w \ 2: py(1) = h \ 2: px(2) = w \ 2: py(2) = h \ 2
CASE 1 'top left
px(0) = 0: py(0) = 0: px(3) = w: py(3) = 0
px(1) = 0: py(1) = h: px(2) = w: py(2) = h
CASE 2 'bottom left
px(0) = 0: py(0) = -h: px(3) = w: py(3) = -h
px(1) = 0: py(1) = 0: px(2) = w: py(2) = 0
CASE 3 'top right
px(0) = -w: py(0) = 0: px(3) = 0: py(3) = 0
px(1) = -w: py(1) = h: px(2) = 0: py(2) = h
CASE 4 'bottom right
px(0) = -w: py(0) = -h: px(3) = 0: py(3) = -h
px(1) = -w: py(1) = 0: px(2) = 0: py(2) = 0
END SELECT
sinr = SIN(angle / 57.2957795131): cosr = COS(angle / 57.2957795131)
FOR i = 0 TO 3
x2 = (px(i) * cosr + sinr * py(i)) + x: y2 = (py(i) * cosr - px(i) * sinr) + y
px(i) = x2: py(i) = y2
NEXT
_MAPTRIANGLE (0, 0)-(0, h - 1)-(w - 1, h - 1), Image TO(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
_MAPTRIANGLE (0, 0)-(w - 1, 0)-(w - 1, h - 1), Image TO(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
END SUB