How to fill-in a diamond without PAINT
#20
Drawing a filled diamond using the draw command.
Two subs each using X,Y, for the top corner, W for width, H for height, ANG for angle from X,Y and color KLR
Draw_diamond can leave gaps at some angles

Code: (Select All)
Screen _NewImage(800, 500, 256)
draw_diamond 300, 100, 60, 100, 45, 6
paint_diamond 450, 100, 60, 100, 25, 6
Input "Enter anything to continue", a$
Cls
For r = 0 To 360 Step 3
    _Limit 100
    Cls
    paint_diamond 450, 100, 60, 200, r, 10
    _Display
Next r

Sub draw_diamond (x, y, w, h, ang, klr)
    Draw "s4 bm" + Str$(x) + "," + Str$(y) + " ta" + Str$(ang)
    y2 = h / 2
    x2 = -(w / 2)
    x3 = (w / 2)
    For n = x2 To x3 Step 0.25
        Draw "bm" + Str$(x) + "," + Str$(y)
        If n < 0 Then
            Draw "m-" + Str$(Abs(n)) + ",+" + Str$(y2) + "m+" + Str$(Abs(n)) + "," + Str$(y2)
        End If
        If n >= 0 Then
            Draw "m+" + Str$(n) + ",+" + Str$(y2) + "m-" + Str$(n) + "," + Str$(y2)
        End If

    Next

    Draw "ta0"
End Sub

Sub paint_diamond (x, y, w, h, ang, klr)
    Draw "s4 bm" + Str$(x) + "," + Str$(y) + " ta" + Str$(ang)
    yc = h / 2
    xc = (w / 2)
    Draw "m-" + Str$(xc) + ",+" + Str$(yc) + " m+" + Str$(xc) + ", +" + Str$(yc) + "m+" + Str$(xc) + ",-" + Str$(yc) + "m-" + Str$(xc) + ",-" + Str$(yc) + "bm +0,+" + Str$(yc) + " P" + Str$(klr) + "," + Str$(klr)
    Draw "ta0"
End Sub
Reply


Messages In This Thread
RE: How to fill-in a diamond without PAINT - by James D Jarvis - 08-21-2022, 03:11 AM



Users browsing this thread: 5 Guest(s)