VGAclocks


Author Message
dddns
Guru

Joined: 20/09/2024
Location: Germany
Posts: 353
Posted: 06:58pm 18 Apr 2025      

Hello :)

I posted the above at 6 in the morning sitting 18 hours non stop in fron of my PC doing that. I must be crazy but I think it was worth it.
MM Basic is so incredible superb I cant find words. Thank you!

This is the skeleton of the library I will use. Have fun let the 2 scroll and scale with your cursor keys :)) Here we go:

Option explicit
Option angle degrees
'Option console serial
Dim integer x = MM.HRES / 2
Dim integer y = MM.VRES / 2

Dim integer count,count1,count2
Dim float clk_draw_scaled = 1
Dim float angle = 0

Dim integer clk_ttf_arc_x_1(3) = (0, -15.5, -7.9, 18.6)
Dim integer clk_ttf_arc_y_1(3) = (29.5, 41, -29, -35.7)
Dim float   clk_ttf_R1_1(3) = (11.5, 0, 0, 0) ' as object count of VGAclocks starts at 1, label name is according
Dim integer clk_ttf_R2_1(3) = (26.5, 7.52, 15, 7.5)
Dim integer clk_ttf_A1_1(3) = (352,105, 106, 44)
Dim integer clk_ttf_A2_1(3) = (62, 85, 84, 69)
Dim integer clk_ttf_poly_x_1(6) = (  8.5, 21.6,-7.9,18.6,18.6,-7.9,-20.3) 'from upper left
Dim integer clk_ttf_poly_y_1(6) = (-23.3,-14.5,28.3,28.3,44,44,19.9) 'to bottom left clockwise
Dim integer clk_ttf_center(1) = (0, 4 - 1)
Dim integer clk_ttf_polyc(1) =  (0, 7 - 1)



MODE 3
Dim a$
FRAMEBUFFER create
FRAMEBUFFER write f

Do
a$ = Inkey$
If a$ <> "" Then
If a$ = "+" Then Inc angle, 5
If a$ = "-" Then Inc angle, -5
If a$ = "." Then Inc clk_draw_scaled, 0.1
If a$ = "," Then Inc clk_draw_scaled,-0.1

End If
Timer = 0


VGAdraw(1,400,300,clk_draw_scaled,angle)'clk_draw_scaled,angle)
Print @(50,50);Timer
FRAMEBUFFER copy f,n
CLS
Loop



Sub VGAdraw(ttf_object, x, y, scaled, angle, style, clk_debug)

Local integer arct_x(clk_ttf_center(ttf_object)), arct_y(clk_ttf_center(ttf_object))
Local integer polyt_x(clk_ttf_polyc(ttf_object)), polyt_y(clk_ttf_polyc(ttf_object))
Local integer arc_R1t(clk_ttf_center(ttf_object)), arc_R2t(clk_ttf_center(ttf_object))
Local integer arc_A1t(clk_ttf_center(ttf_object)), arc_A2t(clk_ttf_center(ttf_object))

'MATH SHIFT inarray%(),nbr, outarray%() [,U]
Execute "Math shift clk_ttf_A1_" + Str$(ttf_object) + "(), " + Str$(clk_ttf_center(ttf_object)) + ", arc_A1t()" 'number of centers
Execute "Math shift clk_ttf_A2_" + Str$(ttf_object) + "(), " + Str$(clk_ttf_center(ttf_object)) + ",arc_A2t()"
'MATH SCALE in(), scale, out() ' first scale, as it combines a shif and need to be done anyway
Execute "Math scale clk_ttf_R1_" + Str$(ttf_object) + " ()," + Str$(scaled) + ",  arc_R1t()" 'get the right value out of database
Execute "Math scale clk_ttf_R2_" + Str$(ttf_object) + " ()," + Str$(scaled) + ",  arc_R2t()"
Execute "Math scale clk_ttf_arc_x_" + Str$(ttf_object) + " ()," + Str$(scaled) + ",  arct_x()"
Execute "Math scale clk_ttf_arc_y_" + Str$(ttf_object) + " ()," + Str$(-scaled) + ",  arct_y()"
Execute "Math scale clk_ttf_poly_x_" + Str$(ttf_object) + " ()," + Str$(scaled) + ",  polyt_x()" 'corners of polygon
Execute "Math scale clk_ttf_poly_y_" + Str$(ttf_object) + " ()," + Str$(scaled) + ",  polyt_y()"
'Math V_ROTATE x, y, a,xin(), yin(), xout(), yout()
Math V_ROTATE 0, 0, angle, arct_x(), arct_y(), arct_x() , arct_y() 'rotate the constructed coordinates
Math V_rotate 0, 0, angle, polyt_x(), polyt_y(), polyt_x(), polyt_y()
'MATH ADD in(), num ,out()
Math ADD arct_x(), x, arct_x() 'add an offset as construction is centered at x = 0  y = 0
Math ADD arct_y(), y, arct_y()
Math ADD polyt_x(), x, polyt_x()
Math ADD polyt_y(), y, polyt_y()
'ARC x,y,r1,[r2],a1,a2[, c]
For count = 0 To 3
Arc arct_x(count), arct_y(count), arc_R1t(count), arc_R2t(count), arc_A1t(count) + angle, arc_A2t(count) + angle, RGB(green)' adjust inner angle
Next count
'POLYGON n, xarray%(),yarray%() [, bordercolour] [,fillcolour]
Polygon 7, polyt_x(), polyt_y(), RGB(green), RGB(green)
If a$ = "s" Then Save image "b:funpic.bmp"
End Sub

Have Fun!!