Weekly Qbasic and Qb64 Lesson Topics
April 23, 2018, 04:28:51 pm
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
  Home Help Search Arcade Links Staff List Login Register  

Print curved text editor


Pages: [1]
  Print  
Author Topic: Print curved text editor  (Read 458 times)
Dustie Bear
Full Member
***
Posts: 115


« on: March 11, 2011, 08:05:10 pm »


This prog will print curved text such as a rainbow shape

Just answer a couple questions such as enter some text, size, color, and couple more things
then it prints it all out.  Long sentences may not look great if you select to large of a circle.

this was my first atempt at using circles to do things other than draw circles!
Code:
CONST Middle = 269
CONST KEY_KP_UP& = 200008
CONST KEY_KP_LEFT& = 200004
CONST KEY_KP_RIGHT& = 200006
'Red
CONST KEY_KP1& = 100257
CONST KEY_KP3& = 100259
'Green
CONST KEY_KP4& = 100260
CONST KEY_KP6& = 100262
'Blue
CONST KEY_KP7& = 100263
CONST KEY_KP9& = 100265
'Center text on screen
CONST CenterX = 400
CONST CenterY = 390
'Holds color of curved words, underline
DIM SHARED w AS LONG
DIM SHARED uw AS LONG

SCREEN _NEWIMAGE(800, 700, 32)
_SCREENMOVE _MIDDLE
COLOR _RGB(0, 0, 0), _RGB(200, 200, 200)
CLS
LOCATE 20, 22
PRINT "The Length of your sentence will depend a lot on the";
LOCATE 21, 21
PRINT "Radius of the circle you decide to use. so experment!";
LOCATE 22, 21
PRINT "I find this quite fun to mess with.I will probably  ";
LOCATE 23, 21
PRINT "add a few more options like Strike through text etc.";
LOCATE 24, 21
PRINT "It already has an underline option.";

LOCATE 25, 21
PRINT "Feel free to add or edit this program!";
LOCATE 28, 26
PRINT "Press a key to start using it!";
DO WHILE a$ = "": a$ = INKEY$: LOOP
CLS
DO
   COLOR _RGB(0, 0, 0), _RGB(200, 200, 200)

   LOCATE 22, 25
   f$ = ""
   LINE INPUT "Enter some Text ? : ", f$
   IF f$ = "" THEN f$ = "You didn't enter any text."
   CLS
   LOCATE 22, 20
   INPUT "Enter radius between 50 and 310 ? :  ", Radius
   IF Radius > 250 THEN Dot = 2 ELSE Dot = 1 ' size of the dots to look best
   IF Radius = 0 THEN Radius = 250
   IF Radius < 50 THEN Radius = 50
   IF Radius > 310 THEN Radius = 310

   UL$ = "": ST$ = ""
   CLS: LOCATE 22, 18
   INPUT "Enter 1=Underline 2=StrikeThrough 3 = Both - else just enter"; USB
   IF USB = 1 THEN UL$ = "y"
   IF USB = 2 THEN ST$ = "y"
   IF USB = 3 THEN UL$ = "y": ST$ = "y"

   '--- get a color to use

   Select_Clr tr, tg, tb
   w = _RGB(tr, tg, tb) 'color of letters
   uw = _RGB(tr, tg, tb) ' color of underline and strike through
   '==========================
   COLOR w: CLS: LOCATE 1, 2: PRINT f$; w
   '==========================


   a = LEN(f$): a = a * 8: WordLength = a: temp = WordLength / 2
   LeftSide = Middle - temp: RightSide = Middle + temp

   FOR t = 16 TO 0 STEP -1
      Radius = Radius + 4
      DO UNTIL DEGREE = RightSide
         DEGREE = DEGREE + 1
         RADIAN = DEGREE / 57.2958
         x = COS(RADIAN) * Radius
         y = SIN(RADIAN) * Radius
         IF DEGREE > LeftSide AND DEGREE < RightSide + 1 THEN

            ' ----- Write the curved text
            w = POINT(a + 8, t)
            CIRCLE (CenterX + x, CenterY + y), Dot, w
            PAINT (CenterX + x, CenterY + y), w, w
            a = a + 1: IF a > WordLength - 1 THEN a = 0

            '----- Draw the underline if selected
            IF UL$ = "y" THEN
               IF t = 16 THEN
                  CIRCLE (CenterX + x, CenterY + y), Dot, uw
                  PAINT (CenterX + x, CenterY + y), uw, uw
               END IF
            END IF
            IF ST$ = "y" THEN
               IF t = 8 THEN
                  CIRCLE (CenterX + x, CenterY + y), Dot, uw
                  PAINT (CenterX + x, CenterY + y), uw, uw
               END IF
            END IF
         END IF
      LOOP
      DEGREE = 0
   NEXT t
   LINE (0, 0)-(800, 15), _RGB(200, 200, 200), BF
   COLOR _RGB(0, 0, 0)
   LOCATE 43, 25
   PRINT "Press a key to do another one. - q Exits ? : ";

   _DISPLAY
   q$ = ""
   DO WHILE q$ = ""
      q$ = INKEY$
   LOOP
   IF LCASE$(q$) = "q" THEN SYSTEM
   CLS
LOOP
SYSTEM

'======================================================
'------------------------------------------------------
SUB Select_Clr (R_Slide, G_Slide, B_Slide)
CLS
'Green mover
GL = 75: GR = 77
'Red Mover
RL = 75: RR = 77
'Blue mover
BL = 75: BR = 77
'Colored Moving pieces
R_Slide = 190: G_Slide = 30: B_Slide = 120

COLOR _RGB(0, 0, 0), _RGB(200, 200, 200)
CLS
LOCATE 14, 37: PRINT "Select a Color for your text!";
LOCATE 18, 24: PRINT "Use the number keypad with the numbers shown on selecters.";
LOCATE 19, 31: PRINT "If it doesnt work, your NumLock may be on!";
LOCATE 21, 31: PRINT "<- 7";
LOCATE 23, 31: PRINT "<- 4";
LOCATE 25, 31: PRINT "<- 1";
LOCATE 21, 69: PRINT "9 ->";
LOCATE 23, 69: PRINT "6 ->";
LOCATE 25, 69: PRINT "3 ->";

'------------------------------------------
LINE (363, 410)-(452, 435), _RGB(0, 0, 0), B 'Box around color box
LINE (279, 321)-(540, 335), _RGB(0, 0, 0), B 'red indicater box
LINE (279, 353)-(540, 367), _RGB(0, 0, 0), B 'Green indicater box
LINE (279, 385)-(540, 399), _RGB(0, 0, 0), B 'Blue indicater box
DO
   '  foo = _KEYHIT
   LINE (280 + R_Slide, 332)-(283 + R_Slide, 324), _RGB(200, 200, 200), BF

   ' ----- RED
   IF _KEYDOWN(KEY_KP7&) THEN R_Slide = R_Slide - 1
   IF _KEYDOWN(KEY_KP9&) THEN R_Slide = R_Slide + 1
   IF R_Slide > 255 THEN R_Slide = 255
   IF R_Slide < 1 THEN R_Slide = 1
   LINE (280 + R_Slide, 332)-(283 + R_Slide, 324), _RGB(250, 0, 0), BF

   ' ----- GREEN
   LINE (280 + G_Slide, 356)-(283 + G_Slide, 364), _RGB(200, 200, 200), BF
   IF _KEYDOWN(KEY_KP4&) THEN G_Slide = G_Slide - 1
   IF _KEYDOWN(KEY_KP6&) THEN G_Slide = G_Slide + 1
   IF G_Slide > 255 THEN G_Slide = 255
   IF G_Slide < 1 THEN G_Slide = 1
   LINE (280 + G_Slide, 356)-(283 + G_Slide, 364), _RGB(0, 200, 0), BF

   ' ----- BLUE
   LINE (280 + B_Slide, 388)-(283 + B_Slide, 396), _RGB(200, 200, 200), BF
   IF _KEYDOWN(KEY_KP1&) THEN B_Slide = B_Slide - 1
   IF _KEYDOWN(KEY_KP3&) THEN B_Slide = B_Slide + 1
   IF B_Slide > 255 THEN B_Slide = 255
   IF B_Slide < 1 THEN B_Slide = 1
   LINE (280 + B_Slide, 388)-(283 + B_Slide, 396), _RGB(0, 0, 200), BF
   ' ----- Indicater

   LINE (365, 412)-(450, 433), _RGB32(R_Slide, G_Slide, B_Slide), BF

   a$ = INKEY$

   _DISPLAY
   _DELAY .005

LOOP UNTIL a$ = CHR$(13)

END SUB




Report Spam   Logged

Social Buttons


Pages: [1]
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Buy traffic for your forum/website
traffic-masters
Powered by SMF | SMF © 2016, Simple Machines