Liberty BASIC Community Forum
« LBGfx, graphics box replacement »

Welcome Guest. Please Login or Register.
Mar 26th, 2017, 1:56pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1 2 3  ...  6 Notify Send Topic Print
 veryhotthread  Author  Topic: LBGfx, graphics box replacement  (Read 4262 times)
Dan Teel
Guru
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1116
xx LBGfx, graphics box replacement
« Thread started on: Feb 3rd, 2016, 11:33pm »

Hello,

I've been working on a graphics box replacement that is very similar to the native graphic box, but is double buffered so you can have flicker free graphics without adding a lot of complexity to your code to not only draw the buffers, but also having a timer to refresh that buffer.

All the functions/subs/commands are documented in http://zptr.net/software/LBGfx.pdf

If you want to handle mouse and keyboard events like you would with a native graphicbox, its really easy. You setup a dummy graphicbox in your window, and pass that handle to the function that creates the LBGfx box. You do the mouseMove/leftButtonDown/etc commands the dummy box, and when an event happens to the LBGfx box, it will be sent also to the dummy box so you can process those events.

The zip with the DLL, source code to the DLL, and BAS example files is here for you to download and mess around with.
http://zptr.net/software/LBGfxV10.zip

Its open source/public domain, do whatever you want with it.

I'm continuing work on it and would love any feedback anyone has.

Last update version 10, 3Mar17
-Added loadImage function, load a jpg/png/gif
-Added saveImage function, save an HBITMAP as a jpg/png/gif


If you're havin issues, take a look at these guys:
-I'm setting a scroll area bigger then my screen, but stuff I draw to it isnt showing up.
Possible reason: When you set the scroll area with scrollyon or scrollxon, at that point it resizes the buffer, so if you were drawing outside of the screen size before using scrollxyon, you wont be able to see those graphics. You should set the scroll area before drawing to those areas.

-I cant see nothing
Possible reason: Dont forget to issue the 'flip' command.


Thanks,

Dan
« Last Edit: Mar 3rd, 2017, 8:51pm by Dan Teel » User IP Logged

ZPtr.net
Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5216
xx Re: LBGfx, graphics box replacement
« Reply #1 on: Feb 4th, 2016, 04:57am »

Very impressive. Lots of reasons for this to be useful. No segments, graphics that stick without flush and no flicker. It seems to be quite fast at rendering, is it faster than Liberty?. Does it use memory?, it must I suppose, need more time to play.

Must also check if you have solved the pie drawing bug.

One thing, running fractals, the size of the graphicbox was off on my PC it wasn't quite wide or tall enough to be full screen.

On the same vein, its always been an irritation to me when using Liberty that you never get the visible pixels you ask for. So if you open a 800x600 window you are likely to get 780x560 or so visible pixels. When I am drawing I like precision. Would it be possible to ask for 800x600 and get 800x600 with the frame and title expanded to allow that?

Hope more folks try this.

User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5216
xx Re: LBGfx, graphics box replacement
« Reply #2 on: Feb 4th, 2016, 06:22am »

Wow, just found test1.bas the particles are fantastic smiley
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5216
xx Re: LBGfx, graphics box replacement
« Reply #3 on: Feb 4th, 2016, 12:10pm »

If you do nothing else this evening download and run test1.bas and enjoy these stunning computed graphics.

The link is in the first post.
« Last Edit: Feb 5th, 2016, 04:38am by Rod » User IP Logged

Dan Teel
Guru
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1116
xx Re: LBGfx, graphics box replacement
« Reply #4 on: Feb 4th, 2016, 3:01pm »

on Feb 4th, 2016, 04:57am, Rod wrote:
Very impressive. Lots of reasons for this to be useful. No segments, graphics that stick without flush and no flicker. It seems to be quite fast at rendering, is it faster than Liberty?. Does it use memory?, it must I suppose, need more time to play.

I would say that its a bit faster depending on what you want to do. If you were to do a "flip" command after every dot drawing in the fractal example, it would be very much slower, but if you include the timer like I did and do a flip every X ms, it is considerably faster while still giving you the animation feeling.

Quote:
Must also check if you have solved the pie drawing bug.
I've never use pie in any of my LB programs, so I'm not aware of this bug.

Quote:
One thing, running fractals, the size of the graphicbox was off on my PC it wasn't quite wide or tall enough to be full screen.

I think I know what might have caused this, do you have 2 monitors? Is one monitor bigger then the other one? When creating the back buffer bitmap, the DLL sets the size to the width and height of the primary monitor, to allow for any future size and you wont have to reallocate memory constantly for resizing of the graphic box.

To fix this, I can just enumerate all displays and get the largest width and height from those instead of using the primary display, if this is even whats causing your problem.

Quote:
On the same vein, its always been an irritation to me when using Liberty that you never get the visible pixels you ask for. So if you open a 800x600 window you are likely to get 780x560 or so visible pixels. When I am drawing I like precision. Would it be possible to ask for 800x600 and get 800x600 with the frame and title expanded to allow that?

Hope more folks try this.

To help with the size irregularities, you can use this function right after you open your window by passing the hwnd() and the WindowWidth and WindowHeight, it should make the client size the size you want.
Code:
sub FixWindowSize hwnd,width,height
    struct fixrect,left as long,top as long,right as long,bottom as long
    hwnd=hwnd(#main)
    calldll #user32,"GetClientRect",hwnd as ulong,fixrect as struct,ret as void
    width=width-fixrect.right.struct+width
    height=height-fixrect.bottom.struct+height
    calldll #user32,"GetWindowRect",hwnd as ulong,fixrect as struct,ret as void
    x=fixrect.left.struct
    y=fixrect.top.struct
    calldll #user32,"MoveWindow",hwnd as ulong,x as long,y as long,width as long,height as long,1 as long,ret as void
end sub
 


Currently, my custom control does not have any border, but I suppose I should let the user define one. To go with what your saying, I could make it adjust the size of it border so you have a defined drawing area, but I think this might conflict with other peoples desires to have a control take up x/y/x2/y2 and not overflow onto other controls. So it would be a little added complexity for the user to create a switch so you can alternate between this fixed client size and fixed control size operation, but it is doable.
User IP Logged

ZPtr.net
robmcal
Senior Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 384
xx Re: LBGfx, graphics box replacement
« Reply #5 on: Feb 4th, 2016, 4:06pm »

Nicely done Dan User Image
User IP Logged

Definition of an Upgrade: Take old bugs out, put new ones in.
Dan Teel
Guru
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1116
xx Re: LBGfx, graphics box replacement
« Reply #6 on: Feb 4th, 2016, 4:10pm »

Just updated it to possibly address rods issue where the gfxbox was not large enough.

And fixed a parsing error where it was not properly reading the command delimiter if there was more than one if a row, like such ";;;".

Also in the update, added the command "drawbmp hbmp x y [x2 y2]", and also added getBmp() and destroyBmp() functions.



Looking to the future, I'm going to implement the commands poly/polyfilled, floodfill, and setpixel. And implement the functions getPixel. You would use poly/pollyfilled like so
Code:
    poly$=""
    for i = 1 to 10
        poly$=poly$;rnd(1)*WindowWidth;" ";rnd(1)*WindowHeight;" "
    next i
    call printCmds hLBGfx,"size 5;color darkgray;poly ";poly$
 
« Last Edit: Feb 4th, 2016, 7:26pm by Dan Teel » User IP Logged

ZPtr.net
michael
Team Liberty BASIC


member is offline

Avatar




PM


Posts: 111
xx Re: LBGfx, graphics box replacement
« Reply #7 on: Feb 4th, 2016, 9:02pm »

Sounds promising. If a solution can be found that doesn't add complexity or code size issues it will greatly enhance game or quality app making.

We need to bring more powerful controls that are extremely compact and BASIC.

The Blitter issues can be overcome.

I am currently working on a gaming POV style graphics art library that is customizable in a powerful IDE. The hardest part is making it easy to use and flexible so that anyone can quickly make unique creations that make their apps professional.



User IP Logged

I like making program generators and reinventing the wheel.. I never make mistakes.. Not ever.. (lie)
Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5216
xx Re: LBGfx, graphics box replacement
« Reply #8 on: Feb 5th, 2016, 04:33am »

That fixed my window size, using WindowWidth and WindowHeight gives me full screen graphics with no title bar or frame that I can see. Just like window popup. Since this is a graphicbox replacement that's just the behaviour I want.

Amazing to see we can now shrink or stretch our bmps at will. Wow mirroring and flipping works too!

Code:
call printCmds hLBGfx,"drawbmp ";atMouseBmp;" 200 200 -200 -200;color white;text 0 0 200 200 0 'Click to Exit';flip" 


Now what would be truly amazing is if we could optionally render that bmp transparently. So If there were an additional color parameter at the end of the drawbmp call it would know to use transparentBlt ?

With that functionality all sorts of game graphics become possible, not quite a sprite engine but very flexible indeed.
User IP Logged

Dan Teel
Guru
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1116
xx Re: LBGfx, graphics box replacement
« Reply #9 on: Feb 5th, 2016, 04:43am »

on Feb 5th, 2016, 04:33am, Rod wrote:
That fixed my window size, using WindowWidth and WindowHeight gives me full screen graphics with no title bar or frame that I can see. Just like window popup. Since this is a graphicbox replacement that's just the behaviour I want.

Amazing to see we can now shrink or stretch our bmps at will. Wow mirroring and flipping works too!

Code:
call printCmds hLBGfx,"drawbmp ";atMouseBmp;" 200 200 -200 -200;color white;text 0 0 200 200 0 'Click to Exit';flip" 


Now what would be truly amazing is if we could optionally render that bmp transparently. So If there were an additional color parameter at the end of the drawbmp call it would know to use transparentBlt ?

With that functionality all sorts of game graphics become possible, not quite a sprite engine but very flexible indeed.
That wouldnt be hard to incorporate, but I think I would make a new command and call it transbmp with the same parameters as drawbmp except there will be a color field at the end that will designate the color not to draw.

I just finished adding the poly/polyfilled, floodfill, and autoresizeon/autoresizeoff commands. I'll work on anchorOn/anchorOff tomorrow along with transbmp command and put out a new release.

And I would also like to note that you can have as many of these in your program as you want, all the data for each control is allocated and handled separately. For example, you can have a graphics box that will draw a game map, and then to the right of it you can have a graphics box that shows the character inventory, or something like that.
« Last Edit: Feb 5th, 2016, 04:46am by Dan Teel » User IP Logged

ZPtr.net
Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5216
xx Re: LBGfx, graphics box replacement
« Reply #10 on: Feb 5th, 2016, 05:45am »

You have solved the pie bug, Liberty skews the slices, your own are perfectly aligned.

Code:
 nomainwin
    WindowWidth = DisplayWidth
    WindowHeight = DisplayHeight
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)

    graphicbox #gr.lbgfxhandler, -100,-100,0,0
    open "LBGfx Test" for window_popup as #gr
    #gr.lbgfxhandler "when leftButtonDown [quit]"
    #gr.lbgfxhandler "when rightButtonDown [quit]"
    open DefaultDir$+"\LBGfx.dll" for dll as #lbgfx
    hwnd=hwnd(#gr)
    hLBGfx=CreateLBGfx(0,0,WindowWidth,WindowHeight,hwnd(#gr),hwnd(#gr.lbgfxhandler))

    call printCmds hLBGfx,"fill white"
    x=WindowWidth/2
    y=WindowHeight/2

    radius = 600
    call printCmds hLBGfx,"color red ; line ";x+radius/2;" ";y;" ";x;" ";y
    for angle = 15 to 360 step 30
    call printCmds hLBGfx, "backcolor red ; piefilled ";x-radius/2;" ";y-radius/2;" ";x+radius/2;" ";y+radius/2;" ";angle;" ";angle+15
    next
    for angle = 0 to 360 step 15
        r=radius/2
        fi=angle/180*acs(-1)
        xx=x+r*cos(fi)
        yy=y+r*sin(fi)
        call printCmds hLBGfx, "color black ; line ";xx;" ";yy;" ";x;" ";y
    next
    call printCmds hLBGfx, "flip"
    wait

[quit]
    call DestroyLBGfx hLBGfx
    close #lbgfx
    close #gr

sub printCmds hwnd,text$
    calldll #lbgfx,"graphicCommand",hwnd as ulong,text$ as ptr,ret as void
end sub


function CreateLBGfx(x,y,w,h,hParent,hMessageHandler)'Returns 0 if fail, hWnd if pass
    calldll #lbgfx,"CreateLBGfx",x as long,y as long,w as long,h as long,_
    hParent as ulong,hMessageHandler as ulong,CreateLBGfx as ulong
end function

sub DestroyLBGfx hwnd
    calldll #lbgfx,"DestroyLBGfx",hwnd as ulong,ret as void
end sub

 


This from the bug tracker site
Code:
nomainwin
open "test" for graphics_nsb_fs as #gr
#gr "trapclose [quit]"
#gr "home"
#gr "posxy x y"
#gr "down"
radius = 600
'radius = 656
#gr "color red"
#gr "line ";x+radius/2;" ";y;" ";x;" ";y
for angle = 0 to 360 step 30
#gr "backcolor red ; color yellow"
#gr "piefilled ";radius;" ";radius;" ";angle;" ";15
next
for angle = 0 to 360 step 15
r=radius/2
fi=angle/180*acs(-1)
xx=x+r*cos(fi)
yy=y+r*sin(fi)
#gr "color black"
#gr "line ";xx;" ";yy;" ";x;" ";y
next
#gr "flush"
wait
[quit]
close #gr

 
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5216
xx Re: LBGfx, graphics box replacement
« Reply #11 on: Feb 5th, 2016, 08:23am »

As an experiment I embedded Dan's graphicbox in a fairly complex GUI that has native graphicboxes and a lot going on. Works great, no need to use the draw over technique just cls and redraw, much simpler.

Code:
    nomainwin

    global x,y,z,Dist,Perspective,MidX,MidY,degtorad,MaxPoints,barpos,scaledvalue, hLBGfx
    x=1
    y=2
    z=3
    Dist = 180          'distance
    Perspective = 30    'perspective
    MidX = 250
    MidY = 250          'center of screen
    degtorad=asn(1) / 90   'degrees x degtorad=radians

    WindowWidth = 800
    WindowHeight = 600
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)
    graphicbox #w.lbgfxhandler, -100,-100,0,0
    graphicbox #w.g1, 520, 20, 182, 19
    statictext #w.st11, "0", 520, 5, 40, 15
    statictext #w.st12, "180", 600, 5, 40, 15
    statictext #w.st13, "359    X Axis", 680, 5, 140, 15
    checkbox   #w.c1, "Rot", set, reset,715,20,50,20
    graphicbox #w.g2, 520, 60, 182, 19
    statictext #w.st21, "0", 520, 45, 40, 15
    statictext #w.st22, "180", 600, 45, 40, 15
    statictext #w.st23, "359    Y Axis", 680, 45, 140, 15
    checkbox   #w.c2, "Rot", set, reset,715,60,50,20
    graphicbox #w.g3, 520, 100, 182, 19
    statictext #w.st31, "0", 520, 85, 40, 15
    statictext #w.st32, "180", 600, 85, 40, 15
    statictext #w.st33, "359    Z Axis", 680, 85, 140, 15
    checkbox   #w.c3, "Rot", set, reset,715,100,50,20
    graphicbox #w.g4, 520, 140, 182, 19
    statictext #w.st41, "-90", 520, 125, 40, 15
    statictext #w.st42, "0", 600, 125, 40, 15
    statictext #w.st43, "90     X Translate", 680, 125, 140, 15
    graphicbox #w.g5, 520, 180, 182, 19
    statictext #w.st51, "-90", 520, 165, 40, 15
    statictext #w.st52, "0", 600, 165, 40, 15
    statictext #w.st53, "90     Y Translate", 680, 165, 140, 15
    graphicbox #w.g6, 520, 220, 182, 19
    statictext #w.st61, "-90", 520, 205, 40, 15
    statictext #w.st62, "0", 600, 205, 40, 15
    statictext #w.st63, "90     Z Translate", 680, 205, 140, 15
    graphicbox #w.g7, 520, 260, 182, 19
    statictext #w.st71, "-180", 520, 245, 40, 15
    statictext #w.st72, "0", 600, 245, 30, 15
    statictext #w.st73, "180   Distance", 680, 245, 140, 15
    graphicbox #w.g8, 520, 300, 182, 19
    statictext #w.st81, "-90", 520, 285, 40, 15
    statictext #w.st82, "0", 600, 285, 30, 15
    statictext #w.st83, "90     Perspective", 680, 285, 140, 15
    open "3D Rotation" for window as #w
    #w "trapclose quit"


    #w.lbgfxhandler "when leftButtonDown [quit]"
    #w.lbgfxhandler "when rightButtonDown [quit]"
    open DefaultDir$+"\LBGfx.dll" for dll as #lbgfx
    hwnd=hwnd(#w)
    hLBGfx=CreateLBGfx(10,10,500,500,hwnd(#w),hwnd(#w.lbgfxhandler))


    sliders=8
    dim slide(sliders,2) 'slide bar position and scaledvalued value, barpos,scaledvalue
    barpos=1
    scaledvalue=2
    'set the starting positions that are not zero
    slide(4,barpos)=90
    slide(5,barpos)=90
    slide(6,barpos)=90
    slide(7,barpos)=Dist
    slide(8,barpos)=Perspective+90

    'using handle variable set all slider fonts postions and events
    for n= 1 to sliders
        s$="#w.g"+str$(n)
        st1$="#w.st"+str$(n)+"1"
        st2$="#w.st"+str$(n)+"2"
        st3$="#w.st"+str$(n)+"3"

        #st1$ "!font arial 10"
        #st2$ "!font arial 10"
        #st3$ "!font arial 10"

        #s$ "down ; backcolor black"
        call display s$

        #s$ "when leftButtonMove mouse"
        #s$ "when leftButtonUp mouse"
        #s$ "when characterInput key"

    next

    'load point and line data
    restore [PointData] 'Set pointer to read from label PointData.
    read MaxPoints 'Reads MaxPoints from appended data.
    dim color$(MaxPoints)
    dim pointData(MaxPoints,3) 'x,y,z planet coordinates
    dim pData(MaxPoints,3) 'pixels drawn to screen
    dim oData(MaxPoints,3) 'old pixel data to erase
    dim order(MaxPoints)    'kind of z-order, to draw
    for i = 1 to MaxPoints
        read xp,yp,zp
        pointData(i,x)=xp
        pointData(i,y)=yp
        pointData(i,z)=zp
        read c$
        color$(i)=c$

    next
    call draw
    wait





sub draw

    'if the checkbox is set rotate the x,y or z axis
    #w.c1 "value? result$"
    if result$="set" then
        slide(x,barpos)=slide(x,barpos)+1'x
        if slide(x,barpos)=181 then slide(x,barpos)=0
        call display "#w.g1"
    end if

    #w.c2 "value? result$"
    if result$="set" then
        slide(y,barpos)=slide(y,barpos)+1'y
        if slide(y,barpos)=181 then slide(y,barpos)=0
        call display "#w.g2"
    end if

    #w.c3 "value? result$"
    if result$="set" then
        slide(z,barpos)=slide(z,barpos)+1'z
        if slide(z,barpos)=181 then slide(z,barpos)=0
        call display "#w.g3"
    end if

    '#w.g "discard"
    call printCmds hLBGfx, "backcolor white ;cls"
    'core code from WIRE3DUO.BAS by Matt Bross, 1997
    '*********************************ROTATION******************************
    'set R1 R2 or R3 in any combination to rotate x,y,z plane 360o
    R1 = slide(x,scaledvalue) 'rotate around the x axis 0 to 359
    R2 = slide(y,scaledvalue) 'rotate around the y axis 0 to 359
    R3 = slide(z,scaledvalue) 'rotate around the z axis 0 to 359

    '********************************TRANSLATION****************************
    'set mmX mmY and mmZ to translate (slide) points on x,y,z plane
    mmX=slide(4,scaledvalue) 'translate x -90 to +90
    mmY=slide(5,scaledvalue) 'translate y -90 to +90
    mmZ=slide(6,scaledvalue) 'translate z -90 to +90
    Dist=slide(7,scaledvalue)
    Perspective=slide(8,scaledvalue)

    '******************************ROTATE POINTS****************************
    S1 = sin(R1*degtorad): S2 = sin(R2*degtorad): S3 = sin(R3*degtorad)
    C1 = cos(R1*degtorad): C2 = cos(R2*degtorad): C3 = cos(R3*degtorad)
    for i = 1 to MaxPoints
        'Rotate points around the y axis.
        tempX = (pointData(i,x) * C2 - pointData(i,z) * S2)
        tempZ = (pointData(i,x) * S2 + pointData(i,z) * C2)
        'Rotate points around the x axis.
        pData(i,z) = (tempZ * C1 - pointData(i,y) * S1)
        tempY = (tempZ * S1 + pointData(i,y) * C1)
        'Rotate points around the z axis.
        pData(i,x) = (tempX * C3 + tempY * S3)
        pData(i,y) = (tempY * C3 - tempX * S3)
        '*****************************CONVERT 3D TO 2D**************************
        tempZ = pData(i,z) + mmZ - Perspective
        if tempZ < 0 then  'calculate points visible to the viewer
            pData(i,x) = (pData(i,x) + mmX) * Dist / tempZ + MidX
            pData(i,y) = (pData(i,y) + mmY) * Dist / tempZ + MidY
            pData(i,z) = 50-abs(tempZ)
        end if
    next
    '******************************DRAW PLANETS****************************
    'sort by size - pData(i,z)
    for i = 1 to MaxPoints
        order(i)=i
    next
    for i = MaxPoints-1 to 1 step -1
        for j = 1 to i
            if pData( order(j),z) > pData( order(j+1),z) then
                 tmp = order(j)
                  order(j) =  order(j+1)
                  order(j+1) = tmp
            end if
        next
    next
    for j = 1 to MaxPoints
         i = order(j)   'use z-order
        call printCmds hLBGfx, "color ";color$(i);"; backcolor ";color$(i);"; circlefilled ";pData(i,x);" ";pData(i,y);" ";pData(i,z)
    next
    call printCmds hLBGfx, "flip"
    call delay
end sub


sub delay
    'timer must be encased with a sub to function properly
    timer 16,[done]
    wait
    [done]
    timer 0
    call draw
end sub

sub quit handle$
    'close the program
    timer 0
    call DestroyLBGfx hLBGfx
    close #lbgfx
    close #w
    end
end sub

sub key handle$,c$

    'react to left and right cursor on the currently selected slider
    key=asc(right$(c$,1))
    s=val(right$(handle$,1))
    if key=_VK_LEFT then slide(s,barpos)=slide(s,barpos)-(slide(s,barpos)>0)
    if key=_VK_RIGHT then slide(s,barpos)=slide(s,barpos)+(slide(s,barpos)<180)
    call display handle$
end sub


sub mouse handle$,xpos,ypos
    'react to mouse movement and left button up on the selected slider
    s=val(right$(handle$,1))
    if xpos>=0 and xpos<=180 then slide(s,barpos)=xpos
    call display handle$
end sub

sub display handle$
    'update the slider display and save the new scaled values
    s=val(right$(handle$,1))
    if s<4 then
        slide(s,scaledvalue)=slide(s,barpos)*2
    else
        if s=7 then
        slide(s,scaledvalue)=slide(s,barpos)*2-180
        else
        slide(s,scaledvalue)=slide(s,barpos)-90
        end if
    end if
    st$="#w.st"+str$(s)+"2"
    #st$ slide(s,barpos)
    #handle$ "discard"
    #handle$ "fill darkgray"
    #handle$ "line 0 8 180 8"
    #handle$, "place ";slide(s,barpos)-4;" 0 ; boxfilled  ";slide(s,barpos)+4;" 17"
end sub

sub printCmds hwnd,text$
    calldll #lbgfx,"graphicCommand",hwnd as ulong,text$ as ptr,ret as void
end sub

function CreateLBGfx(x,y,w,h,hParent,hMessageHandler)'Returns 0 if fail, hWnd if pass
    calldll #lbgfx,"CreateLBGfx",x as long,y as long,w as long,h as long,_
    hParent as ulong,hMessageHandler as ulong,CreateLBGfx as ulong
end function

sub DestroyLBGfx hwnd
    calldll #lbgfx,"DestroyLBGfx",hwnd as ulong,ret as void
end sub


[PointData]
DATA 8
'Location of points (x, y, z)
DATA -10,10,-10,"red",-10,-10,-10,"green",-10,10,10,"blue",-10,-10,10,"cyan"
DATA  10,10,10,"black",10,-10,10,"brown",10,10,-10,"darkred",10,-10,-10,"pink"
 
User IP Logged

G. Rahman
Guru
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1130
xx Re: LBGfx, graphics box replacement
« Reply #12 on: Feb 5th, 2016, 12:04pm »



I like where this is going to .....

Gordon

I guess Carl is watching this too.
User IP Logged

Gordon Rahman

http://www.libertybasic.nl
cundo
Guru
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 602
xx Re: LBGfx, graphics box replacement
« Reply #13 on: Feb 5th, 2016, 6:59pm »

Thanks for sharing Dan. Do you plan to add more commands to it? I'm thinking in a command to modify a bitmap color on screen, like a brightness control of some sort, maybe a color change (R G B), not sure if it possible.
User IP Logged

cundo
Dan Teel
Guru
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1116
xx Re: LBGfx, graphics box replacement
« Reply #14 on: Feb 5th, 2016, 11:35pm »

Well cundo, I was playing with your idea and made a subroutine call adjustBmpBrightness. It goes through each pixel and adjusts the color value by a percentage you specify.

Added commands
-transbmp
-floodfill
-autoresizeon/autoresizeoff
-poly/polyfilled

Added routines
-adjustBmpBrightness

Added functions
-getPixel

Transbmp is identical to drawbmp except it expects a color for obvious reasons. It also will flip/mirror as drawbmp will.

AutoResizeOn for the graphic box will determine its size in relation to its parent and automatically adjust when its resized to fit. The default autoresize state is off. When its turned off, it just goes back to acting like a regular control (but it will stay the size its currently at).


Test1.bas has been updated to demonstrate the commands I've added (except for floodfill). Its suppose to look like the bottom half of the screen is water reflecting the night sky with sparks flying out of the mouse.
User Image
« Last Edit: Feb 6th, 2016, 04:18am by Dan Teel » User IP Logged

ZPtr.net
Pages: 1 2 3  ...  6 Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls