Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I love the jaggies!
#2
Code: (Select All)
''num = fake character code (bits will be checked)
''siz = point size of the whole "rectangle"
''wd = number of pixels across
''ht = number of pixels vertically
''xx, yy = coordinates of top-left corner (desired to avoid this and "co")
''co = 32-bit color value
''eg. TRS-80 monochrome graphics, wd = 2 and ht = 3, graphics 128 x 48
''for Tandy Coco as well "num" must start at zero but graphics chars started at CHR$(128)
sub block (num as _unsigned integer, siz as integer, wd as integer, ht as integer, xx as single, yy as single, co as long)
    static as integer x, y, k
    static as _byte p
    static as long m
    static as single w, h
    w = siz / wd
    h = siz / ht
    p = 0
    for y = 0 to ht - 1
        for x = 0 to wd - 1
            m = 2 ^ p
            if num and m then
                line(xx + x * w, yy + y * h)-step(w, h), co, bf
            end if
            p = p + 1
        next
    next
end sub

Don't understand the use of STATIC in this sub. Static should be used to preserve values between calls to the Sub. 
Here every single variable is reassigned by the code, nothing is reused between calls ie a normal Dim (or ReDim) would be fine for declaring these variables for Option _Explicit.

I know this doesn't effect the functioning of the sub but it is a tiny bit less efficient to preserve values of variables between calls to a sub ie it uses more memory.

Just curious if you knew?
b = b + ...
Reply


Messages In This Thread
I love the jaggies! - by mnrvovrfc - 10-26-2022, 03:17 PM
RE: I love the jaggies! - by bplus - 10-26-2022, 04:24 PM
RE: I love the jaggies! - by mnrvovrfc - 10-26-2022, 07:15 PM
RE: I love the jaggies! - by James D Jarvis - 10-26-2022, 04:47 PM
RE: I love the jaggies! - by mnrvovrfc - 10-26-2022, 07:20 PM
RE: I love the jaggies! - by mnrvovrfc - 10-27-2022, 06:06 PM
RE: I love the jaggies! - by bplus - 10-27-2022, 06:34 PM
RE: I love the jaggies! - by mnrvovrfc - 10-27-2022, 11:38 PM
RE: I love the jaggies! - by mnrvovrfc - 11-01-2022, 11:07 PM
RE: I love the jaggies! - by bplus - 11-01-2022, 11:38 PM
RE: I love the jaggies! - by mnrvovrfc - 11-02-2022, 01:10 AM



Users browsing this thread: 1 Guest(s)