Author Topic: UPDATED SOFTRENDER LIB FOR BEGINNERS  (Read 6207 times)

0 Members and 1 Guest are viewing this topic.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
UPDATED SOFTRENDER LIB FOR BEGINNERS
« on: March 01, 2007 »
This library is going to form the basis for all my tutorials in Freebasic. It is a selection of stock routines that I have written to provide some basic drawing functions to tinyptc, even if you have no programming knowledge.
There is nothing to install, all you need to do is use the file attached on this post as the base code of your programs.
My tutorials in the future will assume that you have this file.

Believe me it makes everything a lot easier and I have supported 7 basic commands to start with, though this will increase as I develop the lib to include spectrum style user defined gfx etc..

Here is a command summary.

The lib is attached to the post, should run in any version of freebasic.

Quote
'-------------------------------------------------------------------------------
' SUPPORTED COMMANDS:
'-------------------------------------------------------------------------------
' TRIANGLE() <- DRAWS A FILLED TRIANGLE
' USE:
' TRIANGLE( X1 , Y1 , X2 , Y2 , X3 , Y3 , R , G , B )
' R,G AND B ARE COLOUR VALUES BETWEEN 0 AND 255
'-------------------------------------------------------------------------------
' CIRC() <- DRAWS A FILLED CIRCLE
' USE:
' CIRC( X , Y , RADIUS , R , G , B )
' X AND Y ARE THE CENTER X AND Y POINTS, RADIUS IS IN PIXELS.
' R,G AND B ARE COLOUR VALUES BETWEEN 0 AND 255
'-------------------------------------------------------------------------------
' RECT() <- DRAWS A FILLED RECTANCLE
' USE:
' RECT( X , Y , WIDTH , HEIGHT , R , G , B )
' X AND Y ARE THE LEFT CORNER, WIDTH AND HEIGHT ARE IN PIXELS.
' R,G AND B ARE COLOUR VALUES BETWEEN 0 AND 255
'-------------------------------------------------------------------------------
' EDGE() <- DRAWS A STRAIGHT LINE
' USE:
' EDGE ( X1 , Y1 , X2 , Y2 , R , G , B )
' X1,Y1 POINT 1
' X2,Y2 POINT 2
' THIS ROUTINE DRAWS A LINE BETWEEN THE TWO POINTS.
' R,G AND B ARE COLOUR VALUES BETWEEN 0 AND 255
'-------------------------------------------------------------------------------
' DOT() <- PLOTS A PIXEL
' USE:
' DOT (X,Y,R,G,B)
' X,Y ARE THE CO-ORDINATES TO PLOT.
' R,G AND B ARE COLOUR VALUES BETWEEN 0 AND 255
'-------------------------------------------------------------------------------
' TEXT()<- DRAWS UPPERCASE TEXT ONTO THE SCREEN.
' USE:
' TEXT ( X , Y , "YOUR TEXT" , R , G , B)
' X,Y TOP LEFT CORNER
' "YOUR TEXT" ANYTHING IN THESE QUOTES IS PRINTED
' R,G AND B ARE COLOUR VALUES BETWEEN 0 AND 255
'-------------------------------------------------------------------------------
' CURVE() <- DRAW A LOW RES BEZIER CURVE
' USE:
' CURVE( X1,Y1 , X2, Y2 ,C1,C2 , C3 , C4 , R , G , B)
' X1,Y1 THE START POINTS OF THE CURVE
' X2,Y2 THE END POINTS OF THE CURVE
' C1,C2 ARE CONTROL POINTS (X AND Y) THE CURVE WILL BEND TOWARDS THIS POINT FROM X1,Y1
' C3,C4 ARE CONTROL POINTS (X AND Y) THE CURVE WILL BEND TOWARDS THIS AS IT ENDS.
' R,G AND B ARE COLOUR VALUES BETWEEN 0 AND 255
' NB. THIS CURVE USES THE "EDGE" CALL, THE CURVE IS LOW RESOLUTION AND THE POINTS
' ARE JOINED WITH THE EDGE COMMAND, THIS MEANS THAT THERE WILL NEVER BE GAPS IN THE CURVE
' AND IT IS A LOT FASTER FOR DEMO EFFECTS.
'-------------------------------------------------------------------------------


Shockwave ^ Codigos
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: UPDATED SOFTRENDER LIB FOR BEGINNERS
« Reply #1 on: March 20, 2007 »
Cool lib mate, nice one :)
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: UPDATED SOFTRENDER LIB FOR BEGINNERS
« Reply #2 on: March 20, 2007 »
Looks good. Should be very useful.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: UPDATED SOFTRENDER LIB FOR BEGINNERS
« Reply #3 on: March 20, 2007 »
Most of the functions in my lib have a smattering of assembly language thrown in for speed, I'm using this framework to write most of my own stuff now.. I think there is one bug left in that there's no y clipping on the text, but I'll get around to fixing that and adding more commands soon :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: UPDATED SOFTRENDER LIB FOR BEGINNERS
« Reply #4 on: September 10, 2007 »
If anyone has any other requests for commands, please post them :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: UPDATED SOFTRENDER LIB FOR BEGINNERS
« Reply #5 on: September 11, 2007 »
I used some of this 'your' code last nite . . . had an idea for a rainstorm sort of effect . . . I did it years ago on the amiga in AMOS!! and it looked good back then - did it in freebasic last nite and it looked a little sad . . . will try to get it looking better and let people see soon! Thanks for the lib though shockwave - very useful indeed.

Drew  :goodpost:
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: UPDATED SOFTRENDER LIB FOR BEGINNERS
« Reply #6 on: September 12, 2007 »
Hello again - tis me DrewPee!?!?

Is it possible to alter/edit the circle draw routine to draw an oval (filled or unfilled)?
Can anybody help?

DrewPee
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: UPDATED SOFTRENDER LIB FOR BEGINNERS
« Reply #7 on: September 12, 2007 »
I'll add an oval function and post here when it's done :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: UPDATED SOFTRENDER LIB FOR BEGINNERS
« Reply #8 on: September 12, 2007 »
A quickly made oval function, you need to make the following changes to the framework;

Put this line where all the subs are declared;

Code: [Select]
        DECLARE SUB OVAL(BYVAL CX AS INTEGER , BYVAL CY AS INTEGER , BYVAL R1 AS INTEGER,  BYVAL R2 AS INTEGER,  BYVAL QU AS INTEGER, BYVAL CR AS INTEGER,BYVAL CG AS INTEGER,BYVAL CB AS INTEGER)

Put this sub at the end of the program;

Code: [Select]
SUB OVAL(BYVAL CX AS INTEGER , BYVAL CY AS INTEGER , BYVAL R1 AS INTEGER,  BYVAL R2 AS INTEGER,  BYVAL QU AS INTEGER, BYVAL CR AS INTEGER,BYVAL CG AS INTEGER,BYVAL CB AS INTEGER)
        DIM AS DOUBLE RAD2DEG
        RAD2DEG = ((4*ATN(1)) / 180 )
        DIM AS INTEGER X1,X2,Y1,Y2,X

            X2=CX+(R1*SIN((-QU)*RAD2DEG))
            Y2=CY+(R2*COS((-QU)*RAD2DEG))
           
        FOR X=0 TO 359+QU STEP QU
           
            X1=CX+(R1*SIN(X*RAD2DEG))
            Y1=CY+(R2*COS(X*RAD2DEG))
           
            TRIANGLE(X1,Y1,X2,Y2,CX,CY,CR,CG,CB)
            X2=X1
            Y2=Y1
        NEXT

END SUB

And use it like this;

OVAL ( CENTRE X , CENTRE Y , RADIUS 1 , RADIUS 2 , QUALITY , R , G , B )

Nb. Quality of 1 is highest quality ovals, Quality of 5 is less high quality but still acceptable.

It works by using the filled triangle function.

If you want wire frame change this line;

Code: [Select]
            TRIANGLE(X1,Y1,X2,Y2,CX,CY,CR,CG,CB)

To ;

Code: [Select]
            EDGE(X1,Y1,X2,Y2,CR,CG,CB)

Hope that helps :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: UPDATED SOFTRENDER LIB FOR BEGINNERS
« Reply #9 on: September 13, 2007 »
Wow! Thanks shockwave again! I will let you see the final 'thing' when it is done - it's looking like an exact copy of a demo i did in about 1989 on the amiga in amos!!

Thanks again!

Drew
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: UPDATED SOFTRENDER LIB FOR BEGINNERS
« Reply #10 on: September 14, 2007 »
Sounds interesting Drew :) Looking forwrd to it!
Shockwave ^ Codigos
Challenge Trophies Won:

Offline bikerboy

  • Amiga 1200
  • ****
  • Posts: 349
  • Karma: 12
    • View Profile
Re: UPDATED SOFTRENDER LIB FOR BEGINNERS
« Reply #11 on: December 07, 2008 »
does this lib work for --> System: FBIde: 0.4.6 - fbc: FreeBASIC Compiler - Version 0.20.0


Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: UPDATED SOFTRENDER LIB FOR BEGINNERS
« Reply #12 on: December 07, 2008 »
It should work for any version of freebasic Bikerboy, it's just a set of routines I made to draw curves, triangles, circles, text etc, they are all self contained subroutines that you can just copy and paste into your program.
Shockwave ^ Codigos
Challenge Trophies Won: