QB64 Phoenix Edition
Boxing accident - Printable Version

+- QB64 Phoenix Edition (https://staging.qb64phoenix.com)
+-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3)
+---- Forum: Programs (https://staging.qb64phoenix.com/forumdisplay.php?fid=7)
+---- Thread: Boxing accident (/showthread.php?tid=409)



Boxing accident - James D Jarvis - 05-14-2022

So writing a sub to draw rectangles with line thickness and the first one I knocked out revealed a curious and happy surprise:


Code: (Select All)
'Boxing accident
Screen _NewImage(800, 500, 32)
Dim Shared pencolor As _Unsigned Long
pencolor = _RGB32(250, 250, 250)

box 2, 2, 140, 80, 3, &HFFFFFFFF

box 152, 2, 250, 100, 3, &HFF

box 300, 2, 400, 200, 9, &HF0F0F0F

box 30, 200, 90, 400, 20, &HF00F00F

Locate 20, 20: Print "A happy accident using line styles"
Locate 21, 20: Print "and a simple algorithm"
Sub box (x1, y1, x2, y2, thickness, style)
    xa = x1: xb = x2: ya = y1: yb = y2
    For l = 1 To thickness
        Line (xa, ya)-(xb, yb), pencolor, B , style
        xa = xa + 1: xb = xb - 1
        ya = ya + 1: yb = yb - 1
    Next l
End Sub