Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Drawing Tools Subs or Functions with Demo
#24
PaintImage - just like Paint to a Border, you can Paint and image

Here is a demo:
Code: (Select All)
_Title "Brick Pattern Tile, click a spot to spray paint a brick image."
' 2019-11-22 new and improved use of BC to eliminate Border lines.

Const xmax = 800, ymax = 600
Screen _NewImage(xmax, ymax, 32)
_ScreenMove 300, 40
'make brick pattern
brickpat& = _NewImage(16, 16, 32)
_Dest brickpat&
Line (0, 0)-(_Width(brickpat&) - 1, _Height(brickpat&) - 1), _RGB32(128, 0, 0), BF
Line (0, 0)-(_Width(brickpat&) - 1, 0), _RGB32(200, 200, 200), BF
Line (0, 7)-(_Width(brickpat&) - 1, 8), _RGB32(200, 200, 200), BF
Line (0, 15)-(_Width(brickpat&) - 1, 15), _RGB32(200, 200, 200), BF
Line (0, 0)-(1, 8), _RGB32(200, 200, 200), BF
Line (7, 8)-(8, 15), _RGB32(200, 200, 200), BF

_Dest 0
Dim Shared BC As _Unsigned Long
BC = _RGB32(119, 17, 2)

While _KeyDown(27) = 0
    While _MouseInput: Wend
    mx = _MouseX: my = _MouseY: mb = _MouseButton(1)
    If mb Then
        r = r + 1
        If r > 20 Then r = 1
        Circle (mx, my), 50, BC
        paintImage mx, my, BC, 0, brickpat&
    End If
    _Display
    _Limit 60
Wend

Sub paintImage (x, y, Border~&, destHandle&, imageHandle&)
    d = _Dest: s = _Source
    _Dest destHandle&
    Paint (x, y), BC, Border~&
    For y = 0 To _Height(destHandle&)
        For x = 0 To _Width(destHandle&)
            _Source destHandle&
            If Point(x, y) = BC Then
                _Source imageHandle&
                PSet (x, y), Point(x Mod _Width(imageHandle&), y Mod _Height(imageHandle&))
            End If
        Next
    Next
    _Dest d: _Source s
End Sub

   
b = b + ...
Reply


Messages In This Thread
RE: Drawing Tools Subs or Functions with Demo - by bplus - 11-29-2022, 03:36 PM



Users browsing this thread: 1 Guest(s)