Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Yellow notebook paper background (scales to fit font setting)
#4
Thanks!  That's  a good idea, bplus.  This morning I added a white paper for him too.  I think I need to come up with a way to figure out the hole placement/size for the white paper one.  As it is now it only looks ok in 800x600. Removed the PRINTMODE stuff in the SUB, just used COLOR for the background.  Here's the updated one that has Yellow & White notebook paper SUB's.  Made title$ printing and IF option.  If no title$ then the paper is just blank.

- Dav

Code: (Select All)
'notebookpapers.bas
'yellow & white background notepaper.
'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

'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

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, 03:54 PM



Users browsing this thread: 11 Guest(s)