Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Yellow notebook paper background (scales to fit font setting)
#15
Quickly added a spiral paper, before heading of to work.  This is the first time I ever used CIRCLE for something other than drawing a whole circle.  Always something to learn.

- Dav

Code: (Select All)

'notebookpapers2.bas

'yellow, white & spiral background notebook paper.
'by Dav, OCT/2023

Screen _NewImage(800, 600, 32)

'Here's where you can load another font you want to use....
fnt& = _LoadFont("lucon.ttf", 24, "monospace")
_Font fnt&

'Call the SUB, with your title$ message
'YellowPaper "John's QB64-PE Code Notebook" '<< this one for yellow paper
'WhitePaper "John's QB64-PE Code Notebook" '<< this one for white paper
SpiralPaper "John's Spiral Notebook" '<< use this one for spiral paper
Sleep
End

'You need to call below so PRINTing text doesn't destroy background.
_PrintMode _KeepBackground

'=== show some sample information....
Color _RGB(64, 64, 64)
For y = 5 To 16
    Locate y, 2: Print Date$;
    Locate , 16: Print "Random Data ="; Rnd; RN;
Next: Print

'Use location 2 to print in left column, 16 for printing in the text lines.

Print
Locate , 16: Print "This is another line."
Print
Locate , 2: Print "Tuesday:"
Locate , 16: Print "Dear diary, today I wrote this...."
Sleep

Sub YellowPaper (title$)

    'This SUB draws yellow notebook paper, scaled to fit current font settings.
    'It also prints and centers title$ in the top title area.

    fw = _FontWidth: fh = _FontHeight 'get current font width/height settings
    '(the fw & fh we will use to calculate LINE drawing so they line up right with PRINT)

    Cls , _RGB(255, 245, 154) 'clear screen to yellow color

    'draw the two vertical brown lines, to make column/text area
    Line (fw * 12, 0)-(fw * 12, _Height), _RGB(205, 185, 98)
    Line (fw * 12.5, 0)-(fw * 12.5, _Height), _RGB(205, 185, 98)

    'draw the text lines to bottom of screen
    For y = fh - 1 To _Height Step fh
        Line (0, y)-(_Width, y), _RGB(152, 160, 74)
    Next

    If title$ <> "" Then

        'draw top brown tile area (remove this if not wanted)
        Line (0, 0)-(_Width, fh * 3), _RGB(102, 19, 15), BF '<< enough for 3 lines
        Color _RGB(255, 255, 0), _RGB(102, 19, 15)

        'Next we print title$, centering the text in the top area
        'For this we need to calcuale how many letters fit on one line, INT(_WIDTH/fw) / 2.
        'I divided that by 2 to find the center spot on the line.
        'So, subtract half of the title$ length from that spot to make it centered nice.
        Locate 2, Int((_Width / fw) / 2) - Int(Len(title$) / 2)
        Print title$; 'finally, PRINT the title$
    End If

End Sub

Sub WhitePaper (title$)
    'This SUB draws white notebook paper, scaled to fit current font settings.

    fw = _FontWidth: fh = _FontHeight 'get current font width/height settings
    '(the fw & fh we will use to calculate LINE drawing so they line up right with PRINT)

    Cls , _RGB(240, 240, 240) 'clear screen to white color

    'draw three holes
    Circle (fw * 8, fh * 8), fw * 2, _RGB(210, 210, 210)
    Paint (fw * 8 + 1, fh * 8 - 1), _RGB(210, 210, 210)

    Circle (fw * 8, fh * 20), fw * 2, _RGB(210, 210, 210)
    Paint (fw * 8 + 1, fh * 20 - 1), _RGB(210, 210, 210)

    Circle (fw * 8, fh * 32), fw * 2, _RGB(210, 210, 210)
    Paint (fw * 8 + 1, fh * 32 - 1), _RGB(210, 210, 210)

    'draw the vertical line, to make column/text area
    Line (fw * 12, 0)-(fw * 12, _Height), _RGB(219, 135, 151)

    'draw the text lines to bottom of screen
    For y = fh * 5 To _Height Step fh
        Line (0, y)-(_Width, y), _RGB(139, 179, 204)
    Next

    If title$ <> "" Then
        'Next we print title$, centering the text in the top area
        'For this we need to calcuale how many letters fit on one line, INT(_WIDTH/fw) / 2.
        'I divided that by 2 to find the center spot on the line.
        'So, subtract half of the title$ length from that spot to make it centered nice.
        Locate 2, Int((_Width / fw) / 2) - Int(Len(title$) / 2)
        Color _RGB(0, 0, 0), _RGB(240, 240, 240)
        Print title$; 'finally, PRINT the title$
    End If

End Sub

Sub SpiralPaper (title$)
    'This SUB draws spiral white notebook paper, scaled to fit current font settings.

    fw = _FontWidth: fh = _FontHeight 'get current font width/height settings
    '(the fw & fh we will use to calculate LINE drawing so they line up right with PRINT)

    Cls , _RGB(32, 32, 32)
    Line (fw * 3.5, 0)-(_Width, _Height), _RGB(240, 240, 240), BF
    For y = 0 To _Height Step fh
        Circle (fw * 4, y), fw * 2, _RGB(164, 164, 164), .6, _Pi * 1.4
        Circle (fw * 5.6, y + (fh / 3)), fw / 2, _RGB(0, 0, 0)
        Paint (fw * 5.6 + 2, y + (fh / 3) - 2), _RGB(0, 0, 0)
    Next

    'draw the vertical line, to make column/text area
    Line (fw * 16, 0)-(fw * 16, _Height), _RGB(219, 135, 151)

    'draw the text lines to bottom of screen
    For y = fh * 5 To _Height Step fh
        Line (fw * 3.5, y)-(_Width, y), _RGB(139, 179, 204)
    Next

    If title$ <> "" Then
        'Next we print title$, centering the text in the top area
        'For this we need to calcuale how many letters fit on one line, INT(_WIDTH/fw) / 2.
        'I divided that by 2 to find the center spot on the line.
        'So, subtract half of the title$ length from that spot to make it centered nice.
        Locate 2, Int((_Width / fw) / 2) - Int(Len(title$) / 2) + 4 '<< added 4 for spiral offset
        Color _RGB(0, 0, 0), _RGB(240, 240, 240)
        Print title$; 'finally, PRINT the title$
    End If

End Sub

Find my programs here in Dav's QB64 Corner
Reply


Messages In This Thread
RE: Yellow notebook paper background (scales to fit font setting) - by Dav - 10-11-2023, 05:44 PM



Users browsing this thread: 5 Guest(s)