Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 493
» Latest member: peadenaw@gmail.com
» Forum threads: 2,837
» Forum posts: 26,588

Full Statistics

Latest Threads
Aloha from Maui guys.
Forum: General Discussion
Last Post: bplus
1 hour ago
» Replies: 10
» Views: 196
another variation of "10 ...
Forum: Programs
Last Post: JRace
11 hours ago
» Replies: 18
» Views: 219
Box_Bash game
Forum: Works in Progress
Last Post: bplus
Today, 01:18 AM
» Replies: 1
» Views: 38
1990's 3D Doom-Like Walls...
Forum: Programs
Last Post: a740g
Yesterday, 09:31 PM
» Replies: 5
» Views: 164
Sound Effects Generator (...
Forum: Petr
Last Post: a740g
Yesterday, 09:05 PM
» Replies: 1
» Views: 56
_SndRaw and _MemFree
Forum: General Discussion
Last Post: a740g
Yesterday, 09:04 PM
» Replies: 1
» Views: 49
Problems with QBJS
Forum: Help Me!
Last Post: bplus
Yesterday, 06:30 PM
» Replies: 4
» Views: 95
which day of the week
Forum: Programs
Last Post: bplus
Yesterday, 06:19 PM
» Replies: 31
» Views: 714
sleep command in compiler...
Forum: General Discussion
Last Post: SMcNeill
Yesterday, 02:57 PM
» Replies: 3
» Views: 92
Another Dir/File compare ...
Forum: Utilities
Last Post: eoredson
Yesterday, 03:48 AM
» Replies: 0
» Views: 47

 
  An hash array dictonary step by step
Posted by: TempodiBasic - 03-14-2023, 12:21 AM - Forum: Programs - Replies (32)

Step1  Presentation of project


Just to keep in theme of the dictionary structure data made by array in QB64, here we attempt to build a dictionary with hash  index.

We start from here

Code: (Select All)
'Assosziatives Array: https://jeff.win/qbhash/
'28. Feb. 2023

Type element
    tag As String * 10
    value As String * 10
End Type
Dim Shared aa(10) As element
Dim Shared aalast ' Last occupied AA() element


setvalue "foo", "bar"
setvalue "foo", "coffee"

Print getvalue$("foo") ' prints bar also after adding coffee
End

Function getvalue$ (tag As String)
    tag = LTrim$(RTrim$(tag))
    tag = tag + String$(10 - Len(tag), " ")
    For i = 0 To aalast
        If (tag = aa(i).tag) Then
            getvalue$ = aa(i).value
            Exit Function
        End If
    Next
End Function

Sub setvalue (tag As String, value As String)
    aa(aalast).tag = tag
    aa(aalast).value = value
    aalast = aalast + 1
End Sub

this code has been taken from this article on this webpage QBHash

this demo is very simple and with many limitations that cannot let us think about it like a real dictonary data structure.
What is the data structure coded has these features:  you can store more than one value linked to the tag value; moreover these collisions (new values linked to the tag) are stored into different cells of the array.  The author to get this result used an external index/counter  (AALAST). In the while the GetValue SUB is broken because it returns only the first value linked to the string index.

However here more information.

Issues:
1 the value stored can fit only 10 characters (ASCII values)
Code: (Select All)
Type element
    tag As String * 10  ' <----- hash value stored as a string of 10 characters that is searched sequentially
    value As String * 10  '<----- max 10 character for value
End Type

2 the hash index is not direct but searched rowly from the start to the end of arrayList

Code: (Select All)
Function getvalue$ (tag As String)
    tag = LTrim$(RTrim$(tag))
    tag = tag + String$(10 - Len(tag), " ")
    For i = 0 To aalast
        If (tag = aa(i).tag) Then
            getvalue$ = aa(i).value
            Exit Function
        End If
    Next
End Function

3 the store value routine does not avoid that the hashindex value has no duplicates.
Code: (Select All)
Sub setvalue (tag As String, value As String)
    aa(aalast).tag = tag
    aa(aalast).value = value
    aalast = aalast + 1
End Sub

4 the search value routine get the first cell of the array that has the hashvalue searched
Code: (Select All)
  If (tag = aa(i).tag) Then
            getvalue$ = aa(i).value
            Exit Function
        End If
Now we try to work to solve these issues.

Print this item

  Non-orthogonal grids?
Posted by: James D Jarvis - 03-13-2023, 07:13 PM - Forum: Help Me! - Replies (6)

Anyone know a good source for math (or even code) for designing non-orthogonal grids? I did a searches on two different search engines and was not impressed with the results.

Print this item

  Pete
Posted by: Dimster - 03-12-2023, 03:08 PM - Forum: Site Suggestions - Replies (6)

For a guy who was so active on this forum daily to be completely inactive for many months, I feel the loss. I was wondering if it might be an idea to have a Wall of Fame, for those who have contributed so much and are gone. Maybe Pete could have his own Prolific Programmer where we could access all his witty posts and code suggestions. Or, if not all his posts. then a selection of those that captured his talent and wit. Maybe it's too early to even consider this as we have many examples of coders who disappear for many months and turn up again. Maybe a Wall of Fame would be for those who we know are no longer with us.

Print this item

  Running Graph
Posted by: Petr - 03-12-2023, 10:14 AM - Forum: Petr - Replies (2)

Input values are considered in the range -1 to 1, the input is not guarded (internal checking is disabled) so using higher values will render outside the intended range. I think it might be useful for someone.


[Image: Runnig-Graph.png]



Code: (Select All)
_Title "Running Graph"
'Wroted by Petr Preclik, 11.March 2023
Type RG
    position As Integer
    SO As Long 'array in array StartOffset for RG_HELPER
    Recs As Long 'how much records graph contains (record lenght in array RG_Helper)
End Type

ReDim Shared RG(0) As RG
ReDim Shared RG_Helper(0) As Single


Screen _NewImage(800, 600, 256)
test = NewRG(1, 500)
test2 = NewRG(1, 203)
test3 = NewRG(1, 300) 'test, test2, test3 is returned index record from array RG

Do
    i = i + .1
    j = j + .012
    t = Sin(i)
    UpdateRG test, t 'update values in array RG_Helper using array RG in RG_Helper SUB
    v = Cos(j)
    UpdateRG test2, v
    UpdateRG test3, (v + t) 'both previous


    ShowRG 100, 150, test, "Sinus"
    ShowRG 100, 300, test2, "Cosinus" 'Draw it - use RG array to drive RG_Helper array and show values RG_Helper array on the screen
    ShowRG 100, 450, test3, "Both mixed"
    _Display
    _Limit 200
Loop

Function NewRG (value, records) 'create new graph handle, reserve place in RG_Helper, write to RG_Helper array first value and this value position in RG_Helper array
    u = records
    u2 = UBound(RG_Helper)
    u3 = UBound(RG)
    RG(u3).SO = u2
    RG(u3).Recs = u
    RG(u3).position = 1
    NewRG = u3
    RG_Helper(u2) = value
    ReDim _Preserve RG_Helper(u2 + u + 1) As Single
    ReDim _Preserve RG(u3 + 1) As RG
End Function

Sub UpdateRG (identity, value) ' update and shift values in RG_Helper array using RG array (identity is RG array index)
    Id = identity
    V = value
    If RG(Id).position < RG(Id).Recs Then
        RG(Id).position = RG(Id).position + 1
        i2 = RG(Id).position
        u = RG(Id).SO
        RG_Helper(u + i2) = value
        Exit Sub
    Else
        shift = RG(Id).SO
        Do Until shift = RG(Id).SO + RG(Id).Recs
            RG_Helper(shift) = RG_Helper(shift + 1)
            shift = shift + 1
        Loop
        RG_Helper(RG(Id).SO + RG(Id).Recs) = value
    End If
End Sub

Sub ShowRG (x, y, id, index$) ' Draw graph to screen
    xx = x
    s2 = RG(id).Recs
    s = RG(id).SO
    _PrintMode _KeepBackground

    p = xx - 10 + s2 / 2 - _PrintWidth(index$) / 2 'printstring X
    Line (xx - 20, y - 70)-(xx + 20 + s2, y + 50), 30, BF
    Line (xx - 17, y - 67)-(xx + 17 + s2, y + 47), , B
    C = _DefaultColor
    Color 0
    _PrintString (p, y - 64), index$
    Color C
    _PrintMode _FillBackground
    Line (xx - 20, y - 70)-(xx + 20 + s2, y + 50), , B
    Line (xx - 17, y - 47)-(xx + 17 + s2, y + 47), , B

    ss = s
    Do Until ss = s2 + s - 1
        v = RG_Helper(ss)
        v2 = RG_Helper(ss + 1)
        GoTo notthis
        If Abs(v) > 1 Then
            Do Until Abs(v) <= 1
                v = v / 2
            Loop
        End If
        notthis:
        xx = xx + 1
        Line (xx, y + v * 15)-(xx + 1, y + v2 * 15), 0
        ss = ss + 1
    Loop
    xx = 0
End Sub

Print this item

  Serial Numbers
Posted by: AtomicSlaughter - 03-11-2023, 11:40 PM - Forum: Utilities - Replies (1)

Well hello again, I'm here with another bit of code, I was pondering the idea of a way to add serial codes and code checks to my programs, and this is what i came up with to generate a serial number>

Code: (Select All)
Function genCode$
    Dim As Single one, two, three: one = 8: two = 7: three = 4
    Dim code As String
    '1
    Do
        For i = 1 To 5
            x$ = x$ + _Trim$(Str$(Int(Rnd * 10)))
        Next
        If Val(x$) Mod one = 0 Then
            Exit Do
        Else
            x$ = ""
        End If
    Loop
    code = x$
    x$ = ""
    '2
    Do
        For i = 1 To 7
            x$ = x$ + _Trim$(Str$(Int(Rnd * 10)))
        Next
        If Val(x$) Mod two = 0 Then
            Exit Do
        Else
            x$ = ""
        End If
    Loop
    code = code + "-" + x$
    x$ = ""
    '3
    Do
        For i = 1 To 5
            x$ = x$ + _Trim$(Str$(Int(Rnd * 10)))
        Next
        If Val(x$) Mod three = 0 Then
            Exit Do
        Else
            x$ = ""
        End If
    Loop

and this is what checks to see if the code is valid, and then returns a 1 for valid and a 0 for invalid>
Code: (Select All)
Function checkcode (d As String)
    Dim As Single one, two, three: one = 8: two = 7: three = 4
    Dim As String a, b, c

    If InStr(d, "-") = 0 Then
        a = Mid$(d, 1, 5)
        b = Mid$(d, 6, 7)
        c = Mid$(d, 13, 5)
        Print a, b, c
    End If

    a = Left$(d, InStr(d, "-") - 1)
    b = Mid$(d, InStr(d, "-") + 1, 7)
    c = Right$(d, 5)

    If Val(a) Mod one = 0 And Val(b) Mod two = 0 And Val(c) Mod three = 0 Then
        If d = "" Then checkcode = 0: Exit Function
        checkcode = 1
    Else
        checkcode = 0
    End If
End Function



Attached Files
.bm   serial.bm (Size: 1.46 KB / Downloads: 39)
Print this item

  BAM: [new] _MAPSET and _MAPGET
Posted by: CharlieJV - 03-11-2023, 06:46 PM - Forum: QBJS, BAM, and Other BASICs - Replies (8)

https://basicanywheremachine-news.blogsp...apget.html

Print this item

  Seven Bubble sort for you: which do you choose?
Posted by: TempodiBasic - 03-11-2023, 02:22 AM - Forum: Programs - Replies (32)

Hi QB64 Community

I have heard in the air a spealing that said "Bubble sort!"
It let me remember a old fashioned book of programming in Pascal. An just then this the "bubble gum".
So while I go to Psychoanalyst to set up better my mind here a Demonstration of different ways to build up a Bubble Sort routine...
in sum their are seven different routines... the first is the classical version, then it follows the last_index decreasing, the last_index swaped, the split & compact with different dimensions for splitting and one of the two index optimized manners...
run and choose you preferred BUBBLE SORT algorithm...
here I show the result got running the following code


[Image: image.png]

and here the code:

Code: (Select All)
Const max = 32767
Randomize Timer

Type DATATYPE
    a As Integer
    b As Integer
    c As Integer
End Type

ReDim SortedList(1 To max) As DATATYPE, t(1 To max) As DATATYPE

'The sort will only be done on the value of 'a' (SortedList().a) and the values can range from 1 to 32767.
init SortedList() ' this is the original array created at random
initT SortedList(), t() ' this copies the first array into the second array

Print "output the first and the last 2 items ";
Print t(1).a; " "; t(max - 1).a; " "; t(max).a
t# = Timer(.001)
Print "ordering...";
bubble t()
Print t(1).a, t(max - 1).a, t(max).a
Color 1
Print " Bubble 1 order"
Print (Timer(.001) - t#)
Color 7

initT SortedList(), t() ' so we use the identical array to be ordered
Print "output the first and the last 2 items ";
Print t(1).a; " "; t(max - 1).a; " "; t(max).a
t# = Timer(.001)
Print "ordering...";
bubble2 t()
Print t(1).a, t(max - 1).a, t(max).a
Color 2
Print " Bubble 2 order"
Print (Timer(.001) - t#)
Color 7

initT SortedList(), t()
Print "output the first and the last 2 items ";
Print t(1).a; " "; t(max - 1).a; " "; t(max).a
t# = Timer(.001)
Print "ordering...";
bubble3 t()
Print t(1).a, t(max - 1).a, t(max).a
Color 3
Print " Bubble 3 order"
Print (Timer(.001) - t#)
Color 7

initT SortedList(), t()
Print "output the first and the last 2 items ";
Print t(1).a; " "; t(max - 1).a; " "; t(max).a
t# = Timer(.001)
Print "ordering...";
bubble4 t()
Print t(1).a, t(max - 1).a, t(max).a
Color 4
Print " Bubble 4 order"
Print (Timer(.001) - t#)
Color 7

initT SortedList(), t()
Print "output the first and the last 2 items ";
Print t(1).a; " "; t(max - 1).a; " "; t(max).a
t# = Timer(.001)
Print "ordering...";
bubble5 t()
Print t(1).a, t(max - 1).a, t(max).a
Color 5
Print " Bubble 5 order"
Print (Timer(.001) - t#)
Color 7

initT SortedList(), t()
Print "output the first and the last 2 items ";
Print t(1).a; " "; t(max - 1).a; " "; t(max).a
t# = Timer(.001)
Print "ordering...";
bubble6 t()
Print t(1).a, t(max - 1).a, t(max).a
Color 6
Print " Bubble 6 order"
Print (Timer(.001) - t#)
Color 7


End

Sub bubble (a() As DATATYPE)
    ' bubblesort
    ' we compare 2 sequential elements of a set of elements until no swap has been performed
    ' while the first element is higher/lower (increasing/decreasing order) than the second element we swap the 2 elements
    NoSwap = 0
    While NoSwap = 0
        NoSwap = -1
        For count = 1 To max - 1
            If a(count).a > a(count + 1).a Then Swap a(count), a(count + 1): NoSwap = 0
        Next count
    Wend
End Sub

Sub bubble2 (a() As DATATYPE)
    ' bubblesort
    ' we compare 2 sequential elements of a set of elements until no swap has been performed
    ' but we ignore the last elements because they has been already ordered
    ' while the first element is higher/lower (increasing/decreasing order) than the second element we swap the 2 elements
    NoSwap = 0
    Fmax = max
    While NoSwap = 0
        NoSwap = -1
        Fmax = Fmax - 1
        For count = 1 To Fmax
            If a(count).a > a(count + 1).a Then Swap a(count), a(count + 1): NoSwap = 0
        Next count
    Wend
End Sub

Sub bubble3 (a() As DATATYPE)
    ' bubblesort
    ' we compare 2 sequential elements of a set of elements until no swap has been performed
    ' but we ignore the last elements because they has been already ordered by swap
    ' while the first element is higher/lower (increasing/decreasing order) than the second element we swap the 2 elements
    NoSwap = 0
    Last = max - 1
    While NoSwap = 0
        NoSwap = -1
        For count = 1 To Last
            If a(count).a > a(count + 1).a Then Swap a(count), a(count + 1): NoSwap = 0: Last = count
        Next count
    Wend
End Sub

Sub bubble4 (a() As DATATYPE)
    ' this is multibubble
    ' we split the array if too big into many subarray ordered by bubble sort
    ' using as max bubble dimension to order 3200 item for array
    stepB = UBound(a) / 3200
    For index = 1 To (UBound(a) - stepB) Step stepB

        ' bubble2 type
        NoSwap = 0
        First = index
        Last = index + stepB - 1
        While NoSwap = 0
            NoSwap = -1
            Last = Last - 1
            For count = First To Last
                If a(count).a > a(count + 1).a Then Swap a(count), a(count + 1): NoSwap = 0
            Next count
        Wend

    Next
    bubble2 a() ' the last ordering operation
End Sub



Sub bubble5 (a() As DATATYPE)
    ' this is multibubble
    ' we split the array if too big into many subarray ordered by bubble sort
    ' using as max bubble dimension to order 100 item for array
    stepB = UBound(a) / 100
    For index = 1 To (UBound(a) - stepB) Step stepB

        ' bubble3 type
        NoSwap = 0
        First = index
        Last = index + stepB - 1
        While NoSwap = 0
            NoSwap = -1
            For count = First To Last
                If a(count).a > a(count + 1).a Then Swap a(count), a(count + 1): NoSwap = 0: Last = count
            Next count
        Wend

    Next
    bubble3 a() ' the last ordering operation
End Sub





Sub bubble6 (a() As DATATYPE)
    ' this is multibubble
    ' we split the array if too big into many subarray ordered by bubble sort
    ' using as max bubble dimension to order 1000 item for array
    stepB = UBound(a) / 1000
    For index = 1 To (UBound(a) - stepB) Step stepB

        ' bubble3 type
        NoSwap = 0
        First = index
        Last = index + stepB - 1
        While NoSwap = 0
            NoSwap = -1
            For count = First To Last
                If a(count).a > a(count + 1).a Then Swap a(count), a(count + 1): NoSwap = 0: Last = count
            Next count
        Wend

    Next
    bubble3 a() ' the last ordering operation
End Sub

Sub initT (b() As DATATYPE, a() As DATATYPE)
    For count = 1 To max
        a(count).a = b(count).a
    Next count
End Sub

Sub init (a() As DATATYPE)
    For count = 1 To max
        a(count).a = (Rnd * max - 1) + 1
    Next count
End Sub

Sub ShowArray (A() As DATATYPE)
    For count = 1 To max
        Print A(count).a
    Next count
End Sub

Thanks to make your choice!

Print this item

  linebricks or brickfill
Posted by: James D Jarvis - 03-10-2023, 04:24 PM - Forum: Utilities - Replies (6)

Here's a couple routines to create randomly varying brickfill patterns. There are briefer and mathematically slicker ways to do simple brick patterns but if you want to add a little variation in color and style the code can get a little longer. If you can make use of it feel free.

Code: (Select All)
'linebricks
'playing with brick patterns drawn with the line command
'fills whole screen and 2 other area with a colored brick pattern that can randomly vary from brick to brick
'press any key for brickish wonder    or esc to quit
Screen _NewImage(800, 500, 32)
_Title "Linebricks a brickfill demo"
Randomize Timer
Do
    'this randomly sey bw (brick width) bh (brick height) and mw (mortar width) for the purposes of demonstration
    bw = 4 + 4 * Int(Rnd * 8)
    bh = (bw * 3) / 5
    mw = bh / (4 + Rnd * 8)
    If mw < .5 Then mw = .5
    brickfill 0, 0, _Width, _Height, bw, bh, mw, _RGB32(240, 40, 40), _RGB32(100, 100, 100), 49, 12
    brickfill 0, 0, 200, 150, bw, bh, mw, _RGB32(40, 40, 40), _RGB32(100, 100, 100), 50, 6
    brickfill 200, 160, 400, 350, bw * 2, bh * 2, mw, _RGB32(40, 240, 40), _RGB32(100, 100, 100), 20, 10
Loop Until waitanykey$ = Chr$(27)
Function waitanykey$
    _KeyClear
    Do
        _Limit 60
        kk$ = InKey$
    Loop Until kk$ <> ""
    waitanykey$ = kk$
End Function
Sub brick (x, y, w, h, mwid, brickcolor As _Unsigned Long, mortarcolor As _Unsigned Long, cv)
    'draw a brick
    'each brick has color variation randomly picked in side the raneg defiend by cv
    'each brick may be randonly standard, have a lightened highlight  or a deep shadow and a higlight
    Dim tcolor As _Unsigned Long
    tred = _Red32(brickcolor) + Int(Rnd * cv) - Int(Rnd * cv)
    tgreen = _Green32(brickcolor) + Int(Rnd * cv) - Int(Rnd * cv)
    tblue = _Blue32(brickcolor) + Int(Rnd * cv) - Int(Rnd * cv)
    If tred < 0 Then tred = 0
    If tgreen < 0 Then tgreen = 0
    If tblue < 0 Then tblue = 0
    If tred > 255 Then tred = 255
    If tgreen > 255 Then tgreen = 255
    If tblue > 255 Then tblue = 255
    tcolor = _RGB32(tred, tgreen, tblue)
    Line (x, y)-(x - 1 + w, y - 1 + h), mortarcolor, BF
    Select Case Int(1 + Rnd * 14)
        Case 1, 2, 3, 4, 5, 6 'plain brick
            Line (x + mwid, y + mwid)-(x - 1 + w - mwid, y - 1 + h - mwid), tcolor, BF
        Case 7, 8 'sahdow and highlight brick
            tred = tred - Int(cv / 2 + Rnd * cv)
            tgreen = tgreen - Int(cv / 2 + Rnd * cv)
            tblue = tblue - Int(cv / 2 + Rnd * cv)
            If tred < 0 Then tred = 0
            If tgreen < 0 Then tgreen = 0
            If tblue < 255 Then tblue = 0
            tcolor = _RGB32(tred, tgreen, tblue)
            Line (x + mwid, y + mwid)-(x - 1 + w - mwid, y - 1 + h - mwid), tcolor, BF
            tred = tred + Int(2 + Rnd * cv)
            tgreen = tgreen + Int(2 + Rnd * cv)
            tblue = tblue + Int(2 + Rnd * cv)
            If tred > 255 Then tred = 255
            If tgreen > 255 Then tgreen = 255
            If tblue > 255 Then tblue = 255
            tcolor = _RGB32(tred, tgreen, tblue)
            sv = (10 + Rnd * 20) / 10
            Line (x + (mwid * sv), y + mwid)-(x - 1 + w - mwid, y - 1 + h - (mwid * sv)), tcolor, BF

        Case Else 'highlight brick
            Line (x + mwid, y + mwid)-(x - 1 + w - mwid, y - 1 + h - mwid), tcolor, BF
            tred = tred + Int(Rnd * (cv * .65))
            tgreen = tgreen + Int(Rnd * (cv * .65))
            tblue = tblue + Int(Rnd * (cv * .65))
            If tred > 255 Then tred = 255
            If tgreen > 255 Then tgreen = 255
            If tblue > 255 Then tblue = 255
            tcolor = _RGB32(tred, tgreen, tblue)
            sv = (10 + Rnd * 20) / 10
            Line (x + (mwid * sv), y + mwid)-(x - 1 + w - mwid, y - 1 + h - (mwid * sv)), tcolor, BF
    End Select
End Sub

Sub brickfill (sx, sy, ex, ey, bw, bh, mwid, brickcolor As _Unsigned Long, mortarcolor As _Unsigned Long, cv, crackrange)
    'crackrange is the raw maximum rnd range used to add cracks to the wall
    Dim zag(1 To 10, 1 To 2)
    b = 0
    For y = sy To ey Step bh
        b = b + 1
        For x = sx To ex Step bw
            If b Then
                brick x - (bw \ 2), y, bw, bh, mwid, brickcolor, mortarcolor, cv
            Else
                brick x, y, bw, bh, mwid, brickcolor, mortarcolor, cv
            End If
        Next x
        If b = 1 Then b = -1
    Next y
    cracks = Int(Rnd * crackrange)
    For c = 1 To cracks
        cx = Int(sx + Rnd * (ex - sx)): cy = Int(sy + Rnd * (ey - sy))
        zag(1, 1) = cx: zag(1, 2) = cy
        xshift = Int(-3 + Rnd * 6)
        yshift = Int(-3 + Rnd * 6)
        If xshift = 0 Then xshift = -1
        If yshift = 0 Then yshift = -1
        For z = 2 To 10
            zag(z, 1) = zag(z - 1, 1) + xshift * Int(Rnd * ((ex - sx) / 20))
            zag(z, 2) = zag(z - 1, 2) + yshift * Int(Rnd * ((ey - sy) / 20))
        Next z
        For z = 1 To 9
            If zag(z, 1) > 0 And zag(z, 2) > 0 Then
                If zag(z + 1, 1) <= ex And zag(z + 1, 2) <= ey Then Line (zag(z, 1), zag(z, 2))-(zag(z + 1, 1), zag(z + 1, 2)), _RGB32(90, 90, 90)
            End If
        Next z
    Next c
End Sub

Print this item

  where my square pixels at?
Posted by: James D Jarvis - 03-09-2023, 04:53 PM - Forum: Help Me! - Replies (5)

So is it me, my screen, an optical resolution, or how _putimage works that leads to me not actually getting square pixels with this little bit of code?   The red dots created at 15,15 and 16,16 in the sample image just aren't the same size when I run this code:

Code: (Select All)
Screen _NewImage(200, 200, 32)
_FullScreen _SquarePixels
rawtile& = _NewImage(32, 32, 32)
_Dest rawtile&

Line (0, 14)-(31, 17), _RGB32(100, 100, 100), BF
Line (14, 0)-(17, 31), _RGB32(100, 100, 100), BF
Line (0, 15)-(31, 16), _RGB32(255, 255, 255), BF
Line (15, 0)-(16, 31), _RGB32(255, 255, 255), BF
PSet (15, 15), _RGB32(250, 0, 0)
PSet (16, 16), _RGB32(250, 0, 0)
_Dest 0

_PutImage (51, 51), rawtile&
_PutImage (51, 100), rawtile&
_PutImage (101, 100), rawtile&
_PutImage (100, 51), rawtile&

Print this item

  So frustrating!
Posted by: PhilOfPerth - 03-09-2023, 07:30 AM - Forum: Help Me! - Replies (12)

Ok, so this is probably quite simple, but it's frustrating the heck out of me!  Huh
[Image: A.jpg] This is A.jpg

(Please try to keep response simple).

Code: (Select All)
Screen _NewImage(1000, 800, 256)
Print "Why is line 8 returning Illegal function call?"
Sleep 2
h = 200: v = 200 '                                            horiz and vert position for pic
ReDim pic(4) As Long
im(1) = _LoadImage("RecPics/" + Chr$(65) + ".jpg")
Print: Print "im(1) is"; im(1); "                                  (if less than -1, this handle should be ok)"
_PutImage (h, v), im(1)
Sleep
_FreeImage (im(1))

Print this item