Library for drawing turtle type (Logo turtle)

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
Post Reply
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Re: Pendule Spring (Prototipe Turtle 8)

Post by lrcvs »

hi:

Pendule Spring (Prototipe Turtle 8)

https://www.youtube.com/watch?v=ivH5UuGxYtc


Regards
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Turtle 8 (Prototype #2 in Tests.)

Post by lrcvs »

Hi:


Turtle 8 (Prototype #2 in Tests.)



See test, a Star rotating.:

https://www.youtube.com/watch?v=9jPU1WGItYI

Turtle 8 (Prototype #2 in Tests.)

Code: Select all

'Turtle 8 basica >>> Prototype #2'
'lrcvs 03.Nov.15'

DECLARE FUNCTION t_ang (BYVAL t_x1 AS DOUBLE, BYVAL t_y1 AS DOUBLE, BYVAL t_x2 AS DOUBLE,BYVAL t_y2 AS DOUBLE) AS DOUBLE
DECLARE FUNCTION t_apothem (BYVAL t_numsides AS INTEGER, BYVAL t_radius AS DOUBLE) AS DOUBLE
DECLARE FUNCTION t_degrees (BYVAL t_rad AS DOUBLE) AS DOUBLE
DECLARE FUNCTION t_long (BYVAL t_x1 AS DOUBLE, BYVAL t_y1 AS DOUBLE, BYVAL t_x2 AS DOUBLE, BYVAL t_y2 AS DOUBLE) AS DOUBLE
DECLARE FUNCTION t_radians (BYVAL t_angle AS DOUBLE) AS DOUBLE
DECLARE FUNCTION t_side (BYVAL t_position_x AS DOUBLE, BYVAL t_position_y AS DOUBLE, BYVAL t_radius AS DOUBLE,  BYVAL t_numsides AS INTEGER) AS DOUBLE

DECLARE SUB t_active_pattern_off ()
DECLARE SUB t_active_pattern_on ()
DECLARE SUB t_active_primary_off ()
DECLARE SUB t_active_primary_on ()
DECLARE SUB t_active_secondary_off ()
DECLARE SUB t_active_secondary_on ()
DECLARE SUB t_axes ()
DECLARE SUB t_bk (BYVAL t_distance AS DOUBLE)
DECLARE SUB t_color (BYVAL t_ink AS INTEGER )
DECLARE SUB t_fd (BYVAL t_distance AS DOUBLE)
DECLARE SUB t_grid_1 (BYVAL t_step_grid AS DOUBLE)
DECLARE SUB t_grid_2 (BYVAL t_step_grid AS DOUBLE)
DECLARE SUB t_grid_3 (BYVAL t_step_grid AS DOUBLE)
DECLARE SUB t_grid_4 (BYVAL t_step_grid AS DOUBLE)
DECLARE SUB t_gt (BYVAL t_position_x AS DOUBLE, BYVAL t_position_y AS DOUBLE)
DECLARE SUB t_home
DECLARE SUB t_init ()
DECLARE SUB t_init_style_line ()
DECLARE SUB t_init_pattern ()
DECLARE SUB t_lt (BYVAL t_angle AS DOUBLE)
DECLARE SUB t_orient_l (BYVAL t_angle AS DOUBLE)
DECLARE SUB t_orient_r (BYVAL t_angle AS DOUBLE)
DECLARE SUB t_pattern_color (BYVAL t_distance AS DOUBLE)
DECLARE SUB t_photo ()
DECLARE SUB t_pos (BYVAL t_position_x AS DOUBLE, BYVAL t_position_x AS DOUBLE)
DECLARE SUB t_pos_rot_xy(BYVAL t_pos_rot_x AS DOUBLE, BYVAL t_pos_rot_y AS DOUBLE)
DECLARE SUB t_rot_cir_l (BYVAL t_distance AS DOUBLE,BYVAL t_angle AS DOUBLE)
DECLARE SUB t_rot_cir_r (BYVAL t_distance AS DOUBLE,BYVAL t_angle AS DOUBLE)
DECLARE SUB t_rt (BYVAL t_angle AS DOUBLE)
DECLARE SUB t_style_line_off ()
DECLARE SUB t_style_line_on ()
DECLARE SUB t_turtle_off ()
DECLARE SUB t_turtle_on ()
DECLARE SUB t_circle (BYVAL t_r1 AS DOUBLE)
DECLARE SUB t_arc_sec_cir (BYVAL t_r1 AS DOUBLE , BYVAL t_ini AS DOUBLE , BYVAL t_end AS DOUBLE , BYVAL t_ang_rot AS DOUBLE , BYVAL t_arc_sec_circle AS INTEGER) 'draw a arc / sector of circle
DECLARE SUB t_rot_ellip_l (BYVAL t_r1 AS DOUBLE, BYVAL t_r2 AS DOUBLE, BYVAL t_angle AS DOUBLE)
DECLARE SUB t_rot_ellip_r (BYVAL t_r1 AS DOUBLE, BYVAL t_r2 AS DOUBLE, BYVAL t_angle AS DOUBLE)
DECLARE SUB t_ellipse (BYVAL t_r1 AS DOUBLE , BYVAL t_r2 AS DOUBLE , BYVAL t_ang_rot AS DOUBLE)
declare SUB t_arc_sec_ellip (BYVAL t_r1 AS DOUBLE , BYVAL t_r2 AS DOUBLE , BYVAL t_ini AS DOUBLE , BYVAL t_end AS DOUBLE , BYVAL t_ang_rot AS DOUBLE , BYVAL t_arc_sec_circle AS INTEGER) 'draw a arc / sector of circle
declare SUB T_POLY (BYVAL T_Long_Side AS DOUBLE, BYVAL t_num_sides AS INTEGER, BYVAL t_ang_rot AS DOUBLE)
declare sub t_ovoid (byval t_r1 as double, byval t_r2 as double, byval t_ang_rot as double) 
declare SUB T_STAR (BYVAL T_NP AS INTEGER , BYVAL T_RG AS DOUBLE , BYVAL T_RP AS DOUBLE , BYVAL T_ANG_ROT AS DOUBLE)
declare SUB T_SPRING (T_NS AS INTEGER , T_RS AS DOUBLE , T_LO AS DOUBLE) 'DRAW A T_SPRING


CONST pi AS DOUBLE = 3.1415926535897932
CONST pi2 AS DOUBLE = 2 * pi

DIM SHARED AS INTEGER t_rot, t_active_pattern , t_active_primary , t_active_secondary , t_c1 , t_c2 , t_c3 , t_center_screen_x , t_center_screen_y , t_h , t_inverse_pattern , t_style_line , t_turtle , t_w

DIM SHARED AS DOUBLE t_angle , t_distance , t_heading , t_new_position_x , t_new_position_y , t_pc , t_pos_rot_x , t_pos_rot_y , t_po_ro_x , t_po_ro_y ,t_pos_x , t_pos_y , t_position_x , t_position_y , t_radio , t_scale , t_thick

DIM SHARED AS STRING t_model
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'A/a = 1   F/f = 6    K/k = 11    P/p = 16    V/v = 21
'B/b = 2   G/g = 7    L/l = 12    Q/q = 17    W/w = 22
'C/c = 3   H/h = 8    M/m = 13    R/r = 18    X/x = 23
'D/d = 4   I/i = 9    N/n = 14    T/t = 19    Y/y = 24
'E/e = 5   J/j = 10   O/o = 15    U/u = 20    Z/z = 25
'Uppers = On/1, Lowers = Off/0

DIM SHARED AS STRING t_pattern (19)
t_pattern (1) =  "A"        :   t_pattern (10) =  "Fc"
t_pattern (2) =  "Aa"       :   t_pattern (11) =  "FcAc"
t_pattern (3) =  "Bb"       :   t_pattern (12) =  "FcAcAc"
t_pattern (4) =  "Cc"       :   t_pattern (13) =  "FcAcAcAc"
t_pattern (5) =  "Ee"       :   t_pattern (14) =  "FcFcAc"
t_pattern (6) =  "Ff"       :   t_pattern (15) =  "FcFcAcAc"
t_pattern (7) =  "CcAc"     :   t_pattern (16) =  "FcFcAcAcAc"
t_pattern (8) =  "CcAcAc"   :   t_pattern (17) =  "FcFcFcAc"
t_pattern (9) =  "CcAcAcAc" :   t_pattern (18) =  "FcFcFcAcAc"
t_pattern (19) =  "LfLfLfAfAfAf"
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'Colors Basics t_color, see sub t_color
'8  Black    10 Blue    12 Brown     79 Fuchsia  51 Green     50 Grey
'57 Ivory    76 Lime    95 Navy      97 Olive    99  Orange  109 Pink 112 Purple
'113 Red    122 Silver 123 Sky Blue 134 Violet  136 White    138 Yellow
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
FUNCTION t_ang (BYVAL t_x1 AS DOUBLE, BYVAL t_y1 AS DOUBLE, BYVAL t_x2 AS DOUBLE, BYVAL t_y2 AS DOUBLE) AS DOUBLE
	DIM AS DOUBLE t_fang
	IF t_x1 < t_x2 AND t_y1 < t_y2 THEN t_fang = t_degrees(ACOS((t_x2 - t_x1)/SQR (((t_x2 - t_x1)^2) + ((t_y2 - t_y1)^2))))
	IF t_x1 > t_x2 AND t_y1 < t_y2 THEN t_fang = t_degrees(ACOS((t_x2 - t_x1)/SQR (((t_x2 - t_x1)^2) + ((t_y2 - t_y1)^2))))
	IF t_x1 > t_x2 AND t_y1 > t_y2 THEN t_fang = 360 - (t_degrees(ACOS((t_x2 - t_x1)/SQR (((t_x2 - t_x1)^2) + ((t_y2 - t_y1)^2)))))
	IF t_x1 < t_x2 AND t_y1 > t_y2 THEN t_fang = 360 - (t_degrees(ACOS((t_x2 - t_x1)/SQR (((t_x2 - t_x1)^2) + ((t_y2 - t_y1)^2)))))
	IF t_x1 < t_x2 AND t_y1 = t_y2 THEN t_fang = 0
	IF t_x1 = t_x2 AND t_y1 < t_y2 THEN t_fang = 90
	IF t_x1 > t_x2 AND t_y1 = t_y2 THEN t_fang = 180
	IF t_x1 = t_x2 AND t_y2 < t_y1 THEN t_fang = 270
	t_ang = t_fang
END FUNCTION

FUNCTION t_apothem (BYVAL t_numsides AS INTEGER, BYVAL t_radius AS DOUBLE) AS DOUBLE
	t_apothem = (COS(t_radians((360/t_numsides)/2)) * t_radius)
END FUNCTION

FUNCTION t_degrees (BYVAL t_rad AS DOUBLE) AS DOUBLE
	t_degrees = (t_rad * 57.295779513082320876798154814105)
END FUNCTION

FUNCTION t_long (BYVAL t_x1 AS DOUBLE, BYVAL t_y1 AS DOUBLE, BYVAL t_x2 AS DOUBLE, BYVAL t_y2 AS DOUBLE) AS DOUBLE
	t_long = SQR(ABS((t_x1 - t_x2)^2) + ABS((t_y1 - t_y2)^2))
END FUNCTION

FUNCTION t_radians (BYVAL t_angle AS DOUBLE) AS DOUBLE
	t_radians  =  (t_angle * 0.01745329251994329576923690768489 )
END FUNCTION

FUNCTION t_side (BYVAL t_position_x AS DOUBLE, BYVAL t_position_y AS DOUBLE, BYVAL t_radius AS DOUBLE,  BYVAL t_numsides AS INTEGER) AS DOUBLE
	DIM AS DOUBLE t_rgrad, t_x0, t_y0, t_x1, t_y1
	t_rgrad = t_radians(0)
	t_x0 = (t_radius * COS (t_rgrad)) + t_position_x
	t_y0 = (t_radius * SIN (t_rgrad)) + t_position_y
	t_rgrad = t_radians(360 / t_numsides)
	t_x1 = (t_radius * COS (t_rgrad)) + t_position_x
	t_y1 = (t_radius * SIN (t_rgrad)) + t_position_y
	t_side= t_long (t_x0, t_y0, t_x1, t_y1)
END FUNCTION

SUB t_active_pattern_off
	t_active_pattern = 0
END SUB

SUB t_active_pattern_on
	t_active_pattern = 1
END SUB

SUB t_active_primary_off
	t_active_primary = 0
END SUB

SUB t_active_primary_on
	t_active_primary = 1
END SUB

SUB t_active_secondary_off
	t_active_secondary = 0
END SUB

SUB t_active_secondary_on
	t_active_secondary = 1
END SUB

SUB t_axes ()
    LINE(-T_W/2  , T_CENTER_SCREEN_Y) - ( T_W/2 , T_CENTER_SCREEN_Y ) 
    LINE( T_CENTER_SCREEN_X ,-T_H/2 ) - ( T_CENTER_SCREEN_X , T_H/2 ) 
END SUB

SUB t_bk (BYVAL t_distance AS DOUBLE)
	DIM AS INTEGER t_a, t_vm, t_dist
    DIM AS DOUBLE t_x2, t_y2, t_x3, t_y3
    
	IF t_turtle = 0 THEN
		t_new_position_x = t_position_x - ((t_distance * t_scale) * COS(t_heading))
		t_new_position_y = t_position_y + ((t_distance * t_scale) * SIN(t_heading))
		t_position_x = t_new_position_x
		t_position_y = t_new_position_y
    END IF
	IF t_turtle = 1 AND t_style_line = 0 THEN
		t_new_position_x = t_position_x - ((t_distance * t_scale) * COS(t_heading))
		t_new_position_y = t_position_y + ((t_distance * t_scale) * SIN(t_heading))
		LINE (t_position_x, t_position_y)-(t_new_position_x, t_new_position_y)
		t_position_x = t_new_position_x
		t_position_y = t_new_position_y
    END IF
	IF t_turtle = 1 AND t_style_line = 1 THEN
        t_a = LEN(t_model)
        FOR  t_dist =   1  TO  t_distance
            t_vm = (ASC (MID(t_model,t_c1, 1)))
            IF  t_vm > 64  AND t_vm < 91 THEN 
                t_x2 = t_position_x - ((t_dist* t_scale) * COS(t_heading))
                t_y2 = t_position_y + ((t_dist* t_scale) * SIN(t_heading))
                IF t_thick = 0 THEN
                    PSET (t_x2, t_y2)
                ELSE
                    CIRCLE (t_x2, t_y2), t_thick,,,,,f
                END IF
                t_c2 = t_c2 + 1
                IF t_c2 > (t_vm -64) THEN t_c2 =  1 : t_c1 = t_c1 +1
                IF t_c1 >  t_a THEN t_c1 =1
            END IF
            
            IF  t_vm > 96 AND t_vm < 123  THEN 
                t_x3 = t_position_x - ((t_dist* t_scale) * COS(t_heading))
                t_y3 = t_position_y + ((t_dist* t_scale) * SIN(t_heading))
                IF t_thick = 0 THEN
                    'pset (t_x3, t_y3)
                ELSE
                    'circle (t_x3, t_y3), t_thick,,,,,f
                END IF
                t_c3 = t_c3 + 1
                IF t_c3 > (t_vm -96) THEN t_c3 =  1 : t_c1 = t_c1 +1
                IF t_c1 >  t_a THEN t_c1 =1
            END IF
        NEXT t_dist
        t_position_x =  t_position_x + ((t_distance * t_scale) * COS(t_heading))
        t_position_y =  t_position_y - ((t_distance * t_scale) * SIN(t_heading))
    END IF
    
END SUB

SUB t_color (BYVAL t_ink AS INTEGER)
	IF t_ink = 1  THEN COLOR RGB (240,248,255)  'alice blue
	IF t_ink = 2  THEN COLOR RGB (250,235,215)  'antique white
	IF t_ink = 3  THEN COLOR RGB (0,255,255)    'aqua
	IF t_ink = 4  THEN COLOR RGB (127,255,212)  'aqua marine
	IF t_ink = 5  THEN COLOR RGB (240,255,255)  'azure
	IF t_ink = 6  THEN COLOR RGB (245,245,220)  'beige
	IF t_ink = 7  THEN COLOR RGB (255,228,196)  'bisque
	IF t_ink = 8  THEN COLOR RGB (0,0,0)        'black
	IF t_ink = 9  THEN COLOR RGB (255,235,205)  'blanched almond
	IF t_ink = 10 THEN COLOR RGB (0,0,255)      'blue
	IF t_ink = 11 THEN COLOR RGB (138,43,226)   'blue violet
	IF t_ink = 12 THEN COLOR RGB (165,42,42)    'brown
	IF t_ink = 13 THEN COLOR RGB (222,184,135)  'burly wood
	IF t_ink = 14 THEN COLOR RGB (95,158,160)   'cadet blue
	IF t_ink = 15 THEN COLOR RGB (127,255,0)    'chart reuse
	IF t_ink = 16 THEN COLOR RGB (210,105,30)   'chocolate
	IF t_ink = 17 THEN COLOR RGB (255,127,80)   'coral
	IF t_ink = 18 THEN COLOR RGB (100,149,237)  'corn flower blue
	IF t_ink = 19 THEN COLOR RGB (255,248,220)  'corn silk
	IF t_ink = 20 THEN COLOR RGB (220,20,60)    'crimson
	IF t_ink = 21 THEN COLOR RGB (0,255,255)    'cyan
	IF t_ink = 22 THEN COLOR RGB (0,0,139)      'dark blue
	IF t_ink = 23 THEN COLOR RGB (0,139,139)    'dark cyan
	IF t_ink = 24 THEN COLOR RGB (184,134,11)   'dark golden rod
	IF t_ink = 25 THEN COLOR RGB (169,169,169)  'dark gray / dark grey
	IF t_ink = 26 THEN COLOR RGB (0,100,0)      'dark green
	IF t_ink = 27 THEN COLOR RGB (189,183,107)  'dark khaki
	IF t_ink = 28 THEN COLOR RGB (139,0,139)    'dark magenta
	IF t_ink = 29 THEN COLOR RGB (85,107,47)    'dark olive green
	IF t_ink = 30 THEN COLOR RGB (255,140,0)    'dark orange
	IF t_ink = 31 THEN COLOR RGB (153,50,204)   'dark orchid
	IF t_ink = 32 THEN COLOR RGB (139,0,0)      'dark red
	IF t_ink = 33 THEN COLOR RGB (233,150,122)  'dark salmon
	IF t_ink = 34 THEN COLOR RGB (143,188,143)  'dark sea green
	IF t_ink = 35 THEN COLOR RGB (72,61,139)    'dark slate blue
	IF t_ink = 36 THEN COLOR RGB (47,79,79)     'dark slate gray
	IF t_ink = 37 THEN COLOR RGB (0,206,209)    'dark turquoise
	IF t_ink = 38 THEN COLOR RGB (148,0,211)    'dark violet
	IF t_ink = 39 THEN COLOR RGB (255,20,147)   'deep pink
	IF t_ink = 40 THEN COLOR RGB (0,191,255)    'deep sky blue
	IF t_ink = 41 THEN COLOR RGB (105,105,105)  'dim gray / dim grey
	IF t_ink = 42 THEN COLOR RGB (30,144,255)   'dodger blue
	IF t_ink = 43 THEN COLOR RGB (178,34,34)    'firebrick
	IF t_ink = 44 THEN COLOR RGB (255,250,240)  'floral white
	IF t_ink = 45 THEN COLOR RGB (34,139,34)    'forest green
	IF t_ink = 46 THEN COLOR RGB (220,220,220)  'gainsboro
	IF t_ink = 47 THEN COLOR RGB (248,248,255)  'ghost white
	IF t_ink = 48 THEN COLOR RGB (255,215,0)    'gold
	IF t_ink = 49 THEN COLOR RGB (218,165,32)   'golden rod
	IF t_ink = 50 THEN COLOR RGB (128,128,128)  'gray
	IF t_ink = 51 THEN COLOR RGB (0,128,0)      'green
	IF t_ink = 52 THEN COLOR RGB (173,255,47)   'green yellow
	IF t_ink = 53 THEN COLOR RGB (240,255,240)  'honeydew
	IF t_ink = 54 THEN COLOR RGB (255,105,180)  'hot pink
	IF t_ink = 55 THEN COLOR RGB (205,92,92)    'indian red
	IF t_ink = 56 THEN COLOR RGB (75,0,130)     'indigo
	IF t_ink = 57 THEN COLOR RGB (255,255,240)  'ivory
	IF t_ink = 58 THEN COLOR RGB (240,230,140)  'khaki
	IF t_ink = 59 THEN COLOR RGB (230,230,250)  'lavender
	IF t_ink = 60 THEN COLOR RGB (255,240,245)  'lavender blush
	IF t_ink = 61 THEN COLOR RGB (124,252,0)    'lawn green
	IF t_ink = 62 THEN COLOR RGB (255,250,205)  'lemon chiffon
	IF t_ink = 63 THEN COLOR RGB (173,216,230)  'light blue
	IF t_ink = 64 THEN COLOR RGB (240,128,128)  'light coral
	IF t_ink = 65 THEN COLOR RGB (224,255,255)  'light cyan
	IF t_ink = 66 THEN COLOR RGB (250,250,210)  'light golden rod yellow
	IF t_ink = 67 THEN COLOR RGB (211,211,211)  'light gray / light grey
	IF t_ink = 68 THEN COLOR RGB (144,238,144)  'light green
	IF t_ink = 69 THEN COLOR RGB (255,182,193)  'light pink
	IF t_ink = 70 THEN COLOR RGB (255,160,122)  'light salmon
	IF t_ink = 71 THEN COLOR RGB (32,178,170)   'light sea green
	IF t_ink = 72 THEN COLOR RGB (135,206,250)  'light sky blue
	IF t_ink = 73 THEN COLOR RGB (119,136,153)  'light slate gray
	IF t_ink = 74 THEN COLOR RGB (176,196,222)  'light steel blue
	IF t_ink = 75 THEN COLOR RGB (255,255,224)  'light yellow
	IF t_ink = 76 THEN COLOR RGB (0,255,0)      'lime
	IF t_ink = 77 THEN COLOR RGB (50,205,50)    'lime green
	IF t_ink = 78 THEN COLOR RGB (250,240,230)  'linen
	IF t_ink = 79 THEN COLOR RGB (255,0,255)    'magenta / fuchsia
	IF t_ink = 80 THEN COLOR RGB (128,0,0)      'maroon
	IF t_ink = 81 THEN COLOR RGB (102,205,170)  'medium aqua marine
	IF t_ink = 82 THEN COLOR RGB (0,0,205)      'medium blue
	IF t_ink = 83 THEN COLOR RGB (186,85,211)   'medium orchid
	IF t_ink = 84 THEN COLOR RGB (147,112,219)  'medium purple
	IF t_ink = 85 THEN COLOR RGB (60,179,113)   'medium sea green
	IF t_ink = 86 THEN COLOR RGB (123,104,238)  'medium slate blue
	IF t_ink = 87 THEN COLOR RGB (0,250,154)    'medium spring green
	IF t_ink = 88 THEN COLOR RGB (72,209,204)   'medium turquoise
	IF t_ink = 89 THEN COLOR RGB (199,21,133)   'medium violet red
	IF t_ink = 90 THEN COLOR RGB (25,25,112)    'midnight blue
	IF t_ink = 91 THEN COLOR RGB (245,255,250)  'mint cream
	IF t_ink = 92 THEN COLOR RGB (255,228,225)  'misty rose
	IF t_ink = 93 THEN COLOR RGB (255,228,181)  'moccasin
	IF t_ink = 94 THEN COLOR RGB (255,222,173)  'navajo white
	IF t_ink = 95 THEN COLOR RGB (0,0,128)      'navy
	IF t_ink = 96 THEN COLOR RGB (253,245,230)  'old lace
	IF t_ink = 97 THEN COLOR RGB (128,128,0)    'olive
	IF t_ink = 98 THEN COLOR RGB (107,142,35)   'olive drab
	IF t_ink = 99 THEN COLOR RGB (255,165,0)    'orange
	IF t_ink = 100 THEN COLOR RGB (255,69,0)    'orange red
	IF t_ink = 101 THEN COLOR RGB (218,112,214) 'orchid
	IF t_ink = 102 THEN COLOR RGB (238,232,170) 'pale golden rod
	IF t_ink = 103 THEN COLOR RGB (152,251,152) 'pale green
	IF t_ink = 104 THEN COLOR RGB (175,238,238) 'pale turquoise
	IF t_ink = 105 THEN COLOR RGB (219,112,147) 'pale violet red
	IF t_ink = 106 THEN COLOR RGB (255,239,213) 'papaya whip
	IF t_ink = 107 THEN COLOR RGB (255,218,185) 'peach puff
	IF t_ink = 108 THEN COLOR RGB (205,133,63)  'peru
	IF t_ink = 109 THEN COLOR RGB (255,192,203) 'pink
	IF t_ink = 110 THEN COLOR RGB (221,160,221) 'plum
	IF t_ink = 111 THEN COLOR RGB (176,224,230) 'powder blue
	IF t_ink = 112 THEN COLOR RGB (128,0,128)   'purple
	IF t_ink = 113 THEN COLOR RGB (255,0,0)     'red
	IF t_ink = 114 THEN COLOR RGB (188,143,143) 'rosy brown
	IF t_ink = 115 THEN COLOR RGB (65,105,225)  'royal blue
	IF t_ink = 116 THEN COLOR RGB (139,69,19)   'saddle brown
	IF t_ink = 117 THEN COLOR RGB (250,128,114) 'salmon
	IF t_ink = 118 THEN COLOR RGB (244,164,96)  'sandy brown
	IF t_ink = 119 THEN COLOR RGB (46,139,87)   'sea green
	IF t_ink = 120 THEN COLOR RGB (255,245,238) 'sea shell
	IF t_ink = 121 THEN COLOR RGB (160,82,45)   'sienna
	IF t_ink = 122 THEN COLOR RGB (192,192,192) 'silver
	IF t_ink = 123 THEN COLOR RGB (135,206,235) 'sky blue
	IF t_ink = 124 THEN COLOR RGB (106,90,205)  'slate blue
	IF t_ink = 125 THEN COLOR RGB (112,128,144) 'slate gray
	IF t_ink = 126 THEN COLOR RGB (255,250,250) 'snow
	IF t_ink = 127 THEN COLOR RGB (0,255,127)   'spring green
	IF t_ink = 128 THEN COLOR RGB (70,130,180)  'steel blue
	IF t_ink = 129 THEN COLOR RGB (210,180,140) 'tan
	IF t_ink = 130 THEN COLOR RGB (0,128,128)   'teal
	IF t_ink = 131 THEN COLOR RGB (216,191,216) 'thistle
	IF t_ink = 132 THEN COLOR RGB (255,99,71)   'tomato
	IF t_ink = 133 THEN COLOR RGB (64,224,208)  'turquoise
	IF t_ink = 134 THEN COLOR RGB (238,130,238) 'violet
	IF t_ink = 135 THEN COLOR RGB (245,222,179) 'wheat
	IF t_ink = 136 THEN COLOR RGB (255,255,255) 'white
	IF t_ink = 137 THEN COLOR RGB (245,245,245) 'white smoke
	IF t_ink = 138 THEN COLOR RGB (255,255,0)   'yellow
	IF t_ink = 139 THEN COLOR RGB (154,205,50)  'yellow green
END SUB

SUB t_fd (BYVAL t_distance AS DOUBLE)
    DIM AS INTEGER t_a, t_vm, t_dist
    DIM AS DOUBLE t_x2, t_y2, t_x3, t_y3
    
    IF t_turtle = 0 AND t_style_line = 0 THEN
        t_new_position_x = t_position_x + ((t_distance * t_scale) * COS(t_heading))
        t_new_position_y = t_position_y - ((t_distance * t_scale) * SIN(t_heading))
        t_position_x = t_new_position_x
        t_position_y = t_new_position_y
    END IF
    IF t_turtle = 1 AND t_style_line = 0 THEN
        t_new_position_x = t_position_x + ((t_distance * t_scale) * COS(t_heading))
        t_new_position_y = t_position_y - ((t_distance * t_scale) * SIN(t_heading))
        LINE (t_position_x, t_position_y)-(t_new_position_x, t_new_position_y)
        t_position_x = t_new_position_x
        t_position_y = t_new_position_y
    END IF
    
    IF t_turtle = 1 AND t_style_line = 1 THEN
        t_a = LEN(t_model)
        FOR  t_dist =   1  TO  t_distance
            t_vm = (ASC (MID(t_model,t_c1, 1)))
            IF  t_vm > 64  AND t_vm < 91 THEN 
                t_x2 = t_position_x + ((t_dist* t_scale) * COS(t_heading))
                t_y2 = t_position_y - ((t_dist* t_scale) * SIN(t_heading))
                IF t_thick = 0 THEN
                    PSET (t_x2, t_y2)
                ELSE
                    CIRCLE (t_x2, t_y2), t_thick,,,,,f
                END IF
                t_c2 = t_c2 + 1
                IF t_c2 > (t_vm -64) THEN t_c2 =  1 : t_c1 = t_c1 +1
                IF t_c1 >  t_a THEN t_c1 =1
            END IF
            
            IF  t_vm > 96 AND t_vm < 123  THEN 
                t_x3 = t_position_x + ((t_dist* t_scale) * COS(t_heading))
                t_y3 = t_position_y - ((t_dist* t_scale) * SIN(t_heading))
                IF t_thick = 0 THEN
                    'pset (t_x3, t_y3)
                ELSE
                    'circle (t_x3, t_y3), t_thick,,,,,f
                END IF
                t_c3 = t_c3 + 1
                IF t_c3 > (t_vm -96) THEN t_c3 =  1 : t_c1 = t_c1 +1
                IF t_c1 >  t_a THEN t_c1 =1
            END IF
        NEXT t_dist
        t_position_x =  t_position_x + ((t_distance * t_scale) * COS(t_heading))
        t_position_y =  t_position_y - ((t_distance * t_scale) * SIN(t_heading))
    END IF
END SUB

SUB t_grid_1 (BYVAL t_step_grid AS DOUBLE)
    DIM t_n AS DOUBLE
    FOR t_n = -t_h TO t_h STEP t_step_grid 
        LINE(-t_w , t_n) - (t_w , t_n),COLOR RGB (128,128,128)   'lineas horizontales
    NEXT t_n
END SUB

SUB t_grid_2 (BYVAL t_step_grid AS DOUBLE)
    DIM t_n AS DOUBLE
    FOR t_n = -t_w TO t_w STEP t_step_grid 
        LINE(t_n , -t_h) - (t_n , t_h),COLOR RGB (128,128,128)  'lineas verticales
    NEXT t_n
END SUB


SUB t_grid_3(BYVAL t_step_grid AS DOUBLE) 
    DIM t_n AS DOUBLE
    FOR t_n = 0 TO t_h STEP t_step_grid 
        CIRCLE (0, 0), t_n ,COLOR RGB (128,128,128) 'dibuja circulos concentricos
    NEXT t_n
END SUB

SUB t_grid_4 (BYVAL t_step_grid AS DOUBLE)
    DIM t_n AS DOUBLE
    t_style_line_off
    COLOR RGB (128,128,128)
    FOR t_n = 0 TO 360 STEP t_step_grid 
        'aqui dibujamos los radios/angulos
        t_orient_l t_n
        t_pos (0 ,0)
        t_fd t_w
    NEXT t_n
    t_style_line_on
END SUB

SUB t_gt (BYVAL t_pos_x AS DOUBLE, BYVAL t_pos_y AS DOUBLE)
	t_position_x = t_center_screen_x + (t_pos_x * t_scale)
	t_position_y = t_center_screen_y + (t_pos_y * t_scale)
END SUB

SUB t_home ()
	t_position_x = t_center_screen_x
	t_position_y = t_center_screen_y
END SUB

SUB t_init ()
	SCREEN 19,32
	SCREENINFO t_w , t_h
	WINDOW (-t_w/2,-t_h/2)-(t_w/2,t_h/2)
	t_active_pattern_on
    t_init_pattern
	t_center_screen_x = 0
	t_center_screen_y = 0
	t_color 136
	t_gt (t_position_x , t_position_y)
	t_init_style_line
	t_model = "Z"
	t_new_position_x = t_position_x
	t_new_position_y = t_position_y
	t_position_x = t_center_screen_x
	t_position_y = t_center_screen_y
	t_scale = 1
	t_style_line_off
	t_thick = 0
	t_turtle_on
    t_active_secondary_on
    t_active_secondary_off
END SUB

SUB t_init_style_line ()
	t_c1 = 1 : t_c2 = 1 : t_c3 = 1
END SUB

SUB t_init_pattern ()
    t_c1 = 1
    t_c2 = 1
    t_c3 = 1
END SUB

SUB t_lt (BYVAL t_angle AS DOUBLE)
	t_heading = t_heading - t_radians (t_angle)
END SUB

SUB t_orient_l (BYVAL t_angle AS DOUBLE)
	t_heading = t_radians (t_angle * (- 1))
END SUB

SUB t_orient_r (BYVAL t_angle AS DOUBLE)
	t_heading = t_radians (t_angle)
END SUB

SUB t_pattern_color (BYVAL t_distance AS DOUBLE)
    DIM AS INTEGER t_a, t_vm
    DIM AS DOUBLE t_x2, t_y2, t_x3, t_y3
    
    t_a = LEN(t_model)
    t_vm = (ASC (MID(t_model,t_c1, 1)))
    IF  t_vm > 64  AND t_vm < 91 THEN 
        t_x2 = t_position_x + ((t_distance * t_scale) * COS(t_heading))
        t_y2 = t_position_y - ((t_distance * t_scale) * SIN(t_heading))
        IF t_thick = 0 THEN
            PSET (t_x2, t_y2)
        ELSE
            CIRCLE (t_x2, t_y2), t_thick,,,,,f
        END IF
        t_c2 = t_c2 + 1
        IF t_c2 > (t_vm -64) THEN t_c2 =  1 : t_c1 = t_c1 +1
        IF t_c1 >  t_a THEN t_c1 =1
    END IF
    
    IF  t_vm > 96 AND t_vm < 123  THEN 
        t_x3 = t_position_x + ((t_distance * t_scale) * COS(t_heading))
        t_y3 = t_position_y - ((t_distance * t_scale) * SIN(t_heading))
        IF t_thick = 0 THEN
            'pset (t_x3, t_y3)
        ELSE
            'circle (t_x3, t_y3), t_thick,,,,,f
        END IF
        t_c3 = t_c3 + 1
        IF t_c3 > (t_vm -96) THEN t_c3 =  1 : t_c1 = t_c1 +1
        IF t_c1 >  t_a THEN t_c1 =1
    END IF
    t_position_x =  t_position_x + ((t_distance * t_scale) * COS(t_heading))
    t_position_y =  t_position_y - ((t_distance * t_scale) * SIN(t_heading))
END SUB 


SUB t_photo ()
	DIM AS INTEGER t_nn, t_long_date_time
	DIM AS STRING t_date_time, t_name_photo, t_photo_y
	t_date_time = DATE
	t_long_date_time = LEN (t_date_time)
	t_name_photo = ""
	t_photo_y = ""
	FOR t_nn = 1 TO t_long_date_time
		t_photo_y= MID(t_date_time,t_nn,1)
		IF t_photo_y <> "-" THEN t_name_photo = t_name_photo + t_photo_y
    NEXT t_nn
	t_name_photo = t_name_photo + "_"
	t_date_time = TIME
	t_long_date_time = LEN (t_date_time)
	t_photo_y = ""
	FOR t_nn = 1 TO t_long_date_time
		t_photo_y= MID(t_date_time,t_nn,1)
		IF t_photo_y <> ":" THEN t_name_photo = t_name_photo + t_photo_y
    NEXT t_nn
	BSAVE t_name_photo+".bmp",0
END SUB

SUB t_pos (BYVAL t_pos_x AS DOUBLE, BYVAL t_pos_y AS DOUBLE)
	t_turtle_off
	t_gt (t_pos_x, t_pos_y)
	t_turtle_on
END SUB

SUB t_pos_rot_xy(BYVAL t_po_ro_x AS DOUBLE, BYVAL t_po_ro_y AS DOUBLE)
	t_pos_rot_x = t_po_ro_x
	t_pos_rot_y = t_po_ro_y
END SUB

SUB t_rot_cir_l (BYVAL t_distance AS DOUBLE, BYVAL t_angle AS DOUBLE)
	t_pos_rot_x = ((t_distance * t_scale) * COS(t_radians (t_angle)))+t_pos_rot_x
	t_pos_rot_y = ((t_distance * t_scale) * SIN(t_radians (t_angle)))+t_pos_rot_y
	t_heading = t_radians (t_angle * (- 1))
    t_position_x = t_pos_rot_x
    t_position_y = t_pos_rot_y
    t_rot = 1
END SUB

SUB t_rot_cir_r (BYVAL t_distance AS DOUBLE, BYVAL t_angle AS DOUBLE)
	t_pos_rot_x = ((t_distance * t_scale) * COS(t_radians (t_angle*-1)))+t_pos_rot_x
	t_pos_rot_y = ((t_distance * t_scale) * SIN(t_radians (t_angle*-1)))+t_pos_rot_y
	t_heading = t_radians (t_angle)
    t_position_x = t_pos_rot_x
    t_position_y = t_pos_rot_y
    t_rot = 1
END SUB

SUB t_rot_ellip_l (BYVAL t_r1 AS DOUBLE, BYVAL t_r2 AS DOUBLE, BYVAL t_angle AS DOUBLE)
	t_pos_rot_x = ((t_r1 * t_scale) * COS(t_radians (t_angle)))+t_pos_rot_x
	t_pos_rot_y = ((t_r2 * t_scale) * SIN(t_radians (t_angle)))+t_pos_rot_y
	t_heading = t_radians (t_angle * (- 1))
    t_position_x = t_pos_rot_x
    t_position_y = t_pos_rot_y
    t_rot = 1
END SUB

SUB t_rot_ellip_r (BYVAL t_r1 AS DOUBLE, BYVAL t_r2 AS DOUBLE, BYVAL t_angle AS DOUBLE)
	t_pos_rot_x = ((t_r1 * t_scale) * COS(t_radians (t_angle*-1)))+t_pos_rot_x
	t_pos_rot_y = ((t_r2 * t_scale) * SIN(t_radians (t_angle*-1)))+t_pos_rot_y
	t_heading = t_radians (t_angle)
    t_position_x = t_pos_rot_x
    t_position_y = t_pos_rot_y
    t_rot = 1
END SUB


SUB t_rt (BYVAL t_angle AS DOUBLE)
	t_heading = t_heading + t_radians (t_angle)
END SUB

SUB t_style_line_off ()
	t_style_line = 0
END SUB

SUB t_style_line_on ()
	t_style_line = 1
END SUB

SUB t_turtle_off ()
	t_turtle = 0
END SUB

SUB t_turtle_on ()
	t_turtle = 1
END SUB

SUB t_circle (BYVAL t_r1 AS DOUBLE)
    DIM AS DOUBLE t_grad , t_grad2, t_x0 , t_y0  
    FOR t_grad = 0 TO 360
        t_grad2 = t_radians(t_grad)
        t_x0 = t_r1 * COS(t_grad2) 
        t_y0 = t_r1 * sin(t_grad2) 
        t_position_x = t_x0 + t_pos_rot_x
        t_position_y = t_y0 + t_pos_rot_y
        t_fd 1
    NEXT t_grad

END SUB

SUB t_arc_sec_cir (BYVAL t_r1 AS DOUBLE , BYVAL t_ini AS DOUBLE , BYVAL t_end AS DOUBLE , BYVAL t_ang_rot AS DOUBLE , BYVAL t_arc_sec_circle AS INTEGER) 'draw a arc / sector of circle
    DIM z AS INTEGER
    DIM AS DOUBLE t_px, t_py , t_grad , t_grad2, t_x0 , t_y0 
    'DRAW A ARC OR SECTOR CIR
    'T_R = RADIUS CIRCLE
    'T_INI = ANGLE INIT
    'T_END = ANGLE END
    'T_ANG_ROT = ANGLE OF ROTATION
    'T_ARC_SEC_CIR = 0 = ARC / 1 = SECTOR

    if t_arc_sec_circle = 1 then
        'radios
        'if t_rot = 1 then t_ang_rot = t_heading
        t_orient_l 0
        t_px = t_pos_rot_x
        t_py = t_pos_rot_y
        t_pos (t_px, t_py)
        t_orient_l t_ang_rot
        t_fd t_r1
        
        t_orient_r 0
        t_pos (t_px, t_py)
        t_ORIENT_l T_END + T_ANG_ROT
        t_fd t_r1
    end if

        t_orient_r 0
        t_pos (t_px, t_py)
        t_ang_rot = t_radians (t_ang_rot)
        'if t_rot = 1 then t_ang_rot = t_heading
    FOR t_grad = t_ini TO t_end
        t_grad2 = t_radians(t_grad)
        t_x0 = (((t_r1) * COS(t_grad2))* COS (t_ang_rot)) - (((t_r1) * SIN(t_grad2)) * SIN (t_ang_rot))
        t_y0 = (((t_r1) * cos(t_grad2))* SIN (t_ang_rot)) + (((t_r1) * SIN(t_grad2)) * COS (t_ang_rot))
        t_position_x = t_x0 + t_pos_rot_x
        t_position_y = t_y0 + t_pos_rot_y
        t_fd 1
    NEXT t_grad
END SUB

SUB t_ellipse (BYVAL t_r1 AS DOUBLE , BYVAL t_r2 AS DOUBLE , BYVAL t_ang_rot AS DOUBLE)
    DIM AS DOUBLE t_grad , t_grad2, t_x0 , t_y0  
        t_ang_rot = t_radians (t_ang_rot)
        if t_rot = 1 then t_ang_rot = t_heading
    FOR t_grad = t_ang_rot TO t_ang_rot + 360
        t_grad2 = t_radians(t_grad)
        t_x0 = ((t_r1 * COS(t_grad2)) * COS (t_ang_rot)) - ((t_r2 * SIN(t_grad2)) * SIN (t_ang_rot))
        t_y0 = ((t_r1 * COS(t_grad2)) * SIN (t_ang_rot)) + ((t_r2 * SIN(t_grad2)) * COS (t_ang_rot))
        t_position_x = t_x0 + t_pos_rot_x
        t_position_y = t_y0 + t_pos_rot_y
        t_fd 1
    NEXT t_grad
END SUB

SUB t_arc_sec_ellip (BYVAL t_r1 AS DOUBLE , BYVAL t_r2 AS DOUBLE , BYVAL t_ini AS DOUBLE , BYVAL t_end AS DOUBLE , BYVAL t_ang_rot AS DOUBLE , BYVAL t_arc_sec_circle AS INTEGER) 'draw a arc / sector of circle
    DIM z AS INTEGER
    DIM AS DOUBLE t_px, t_py , t_grad , t_grad2, t_x0 , t_y0 
    'DRAW A ARC OR SECTOR CIR
    'T_R = RADIUS CIRCLE
    'T_INI = ANGLE INIT
    'T_END = ANGLE END
    'T_ANG_ROT = ANGLE OF ROTATION
    'T_ARC_SEC_CIR = 0 = ARC / 1 = SECTOR

    if t_arc_sec_circle = 1 then
        'radios
        'if t_rot = 1 then t_ang_rot = t_heading
        t_orient_l 0
        t_px = t_pos_rot_x
        t_py = t_pos_rot_y
        t_pos (t_px, t_py)
        t_orient_l t_ang_rot
        t_fd t_r1
        
        t_orient_r 0
        t_pos (t_px, t_py)
        t_ORIENT_l T_END + T_ANG_ROT
        t_fd t_r1
    end if

        t_orient_r 0
        t_pos (t_px, t_py)
        t_ang_rot = t_radians (t_ang_rot)
        'if t_rot = 1 then t_ang_rot = t_heading
    FOR t_grad = t_ini TO t_end
        t_grad2 = t_radians(t_grad)
        t_x0 = (((t_r1) * COS(t_grad2))* COS (t_ang_rot)) - (((t_r2) * SIN(t_grad2)) * SIN (t_ang_rot))
        t_y0 = (((t_r1) * cos(t_grad2))* SIN (t_ang_rot)) + (((t_r2) * SIN(t_grad2)) * COS (t_ang_rot))
        t_position_x = t_x0 + t_pos_rot_x
        t_position_y = t_y0 + t_pos_rot_y
        t_fd 1
    NEXT t_grad
END SUB

SUB T_POLY (BYVAL T_Long_Side AS DOUBLE, BYVAL t_num_sides AS INTEGER, BYVAL t_ang_rot AS DOUBLE)
    DIM t_pol AS DOUBLE
    t_rt t_ang_rot
    FOR t_pol  = 0 TO 360 STEP 360/t_num_sides
        T_FD T_Long_Side
        T_RT 360/t_num_sides
    NEXT t_pol
END SUB

sub t_ovoid (byval t_r1 as double, byval t_r2 as double, byval t_ang_rot as double) 
t_arc_sec_ellip (t_r1,t_r2,0,180,t_ang_rot,0)
t_arc_sec_cir (t_r1,180,360,t_ang_rot,0)
't_arc_sec_ellip (t_r1,t_r2,180,360,t_ang_rot,0)

end sub

SUB T_SPRING (T_NS AS INTEGER , T_RS AS DOUBLE , T_LO AS DOUBLE) 'DRAW A T_SPRING
DIM T_N AS INTEGER
'T_NS = NUMBER OF SPIRALS
'T_RS = STRETCH OF SPIRAL 0...90
'T_LO = LONG OF SPIRAL
FOR T_N = 1 TO T_NS
T_RT T_RS
T_FD T_LO
T_LT T_RS * 2
T_FD T_LO
T_RT T_RS
NEXT T_N
END SUB

sub t_star (byval t_np as integer , byval t_rg as double , byval t_rp as double , byval t_ang_rot as double)

dim as double t_x0,t_y0,t_x1,t_y1,t_c,t_n, t_x2, t_y2
t_c =0

't_x0  = (t_rg  * cos(t_radians(0)))
't_y0 =  (t_rg  * sin(t_radians(0)))

for  t_n = 360/(t_np*2)  to 360  + (360/(t_np*2))+ 360/(t_np*2)  step  360/(t_np*2)
if  t_c mod 2  = 0  then
t_x1 = (t_rg  * cos(t_radians(t_n)))
t_y1 = (t_rg  * sin(t_radians(t_n)))

else
t_x1  = (t_rp  * cos(t_radians(t_n)))
t_y1 =  (t_rp  * sin(t_radians(t_n)))

end if
t_orient_l (t_ang (t_x0,t_y0,t_x1,t_y1)+ t_ang_rot )
t_fd (t_long  (t_x0,t_y0,t_x1,t_y1))

t_x0 = t_x1
t_y0 = t_y1

t_c = t_c  +  1
next t_n
end sub



Code test:

Code: Select all

#include "turtle_8.bi"
DIM AS INTEGER j,n

t_init
color rgb (255,255,255)
t_style_line_oN()
t_thick = 1

for j = 2 to 12
t_style_line_oN()
t_model = t_pattern (j)
FOR N = 0 TO 360
screenlock
CLS
T_POSition_X = 0
T_POSition_Y = 0
color rgb (255,0,0)
CIRCLE (T_POSITION_X, T_POSITION_Y),5+(J*2),,,,,f
color rgb (255,255,255)
T_star (j,n,150-n, N) 
color rgb (0,255,0)
CIRCLE (T_POSITION_X, T_POSITION_Y),5+(J*2),,,,,f
color rgb (255,255,255)
screenunlock
sleep 20
NEXT N
next j
SLEEP
END

Regards
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Library for drawing turtle type (Logo turtle)

Post by D.J.Peters »

in t_color exit sub is missing

Code: Select all

SUB t_color (BYVAL t_ink AS INTEGER)
  IF t_ink = 1  THEN COLOR RGB (240,248,255) : exit sub 'alice blue
  IF t_ink = 2  THEN COLOR RGB (250,235,215) : exit sub  'antique white
  IF t_ink = 3  THEN COLOR RGB (  0,255,255) : exit sub 'aqua
  IF t_ink = 4  THEN COLOR RGB (127,255,212) : exit sub 'aqua marine
  ...
END SUB
or you can use select cas as const

Code: Select all

SUB t_color (BYVAL t_ink AS INTEGER)
  select case as const t_ink
  case 1  : COLOR RGB (240,248,255) 'alice blue
  case 2  : COLOR RGB (250,235,215) 'antique white
  case 3  : COLOR RGB (  0,255,255) 'aqua
  case 4  : COLOR RGB (127,255,212) 'aqua marine
  ...
  case else : COLOR(255,255,255) ' any default color if t_ink is out of range
END SUB
in scope of size you use 139 times the same color command that isn't clever :-)
you can use a satic array of ulong instead

Code: Select all

SUB t_color (BYVAL t_ink AS INTEGER)
  static as ulong colors( 1 to ...) => { _
  RGB (240,248,255), _  'alice blue
  RGB (250,235,215), _  'antique white
  RGB (0,255,255), _    'aqua
  RGB (127,255,212), _  'aqua marine
  RGB (240,255,255), _  'azure
  RGB (245,245,220), _  'beige
  RGB (255,228,196), _  'bisque
  RGB (0,0,0), _        'black
  RGB (255,235,205), _  'blanched almond
  RGB (0,0,255), _      'blue
  RGB (138,43,226), _   'blue violet
  RGB (165,42,42), _    'brown
  RGB (222,184,135), _  'burly wood
  RGB (95,158,160), _   'cadet blue
  RGB (127,255,0), _    'chart reuse
  RGB (210,105,30), _   'chocolate
  RGB (255,127,80), _   'coral
  RGB (100,149,237), _  'corn flower blue
  RGB (255,248,220), _  'corn silk
  RGB (220,20,60), _    'crimson
  RGB (0,255,255), _    'cyan
  RGB (0,0,139), _      'dark blue
  RGB (0,139,139), _    'dark cyan
  RGB (184,134,11), _   'dark golden rod
  RGB (169,169,169), _  'dark gray / dark grey
  RGB (0,100,0), _      'dark green
  RGB (189,183,107), _  'dark khaki
  RGB (139,0,139), _    'dark magenta
  RGB (85,107,47), _    'dark olive green
  RGB (255,140,0), _    'dark orange
  RGB (153,50,204), _   'dark orchid
  RGB (139,0,0), _      'dark red
  RGB (233,150,122), _  'dark salmon
  RGB (143,188,143), _  'dark sea green
  RGB (72,61,139), _    'dark slate blue
  RGB (47,79,79), _     'dark slate gray
  RGB (0,206,209), _    'dark turquoise
  RGB (148,0,211), _    'dark violet
  RGB (255,20,147), _   'deep pink
  RGB (0,191,255), _    'deep sky blue
  RGB (105,105,105), _  'dim gray / dim grey
  RGB (30,144,255), _   'dodger blue
  RGB (178,34,34), _    'firebrick
  RGB (255,250,240), _  'floral white
  RGB (34,139,34), _    'forest green
  RGB (220,220,220), _  'gainsboro
  RGB (248,248,255), _  'ghost white
  RGB (255,215,0), _    'gold
  RGB (218,165,32), _   'golden rod
  RGB (128,128,128), _  'gray
  RGB (0,128,0), _      'green
  RGB (173,255,47), _   'green yellow
  RGB (240,255,240), _  'honeydew
  RGB (255,105,180), _  'hot pink
  RGB (205,92,92), _    'indian red
  RGB (75,0,130), _     'indigo
  RGB (255,255,240), _  'ivory
  RGB (240,230,140), _  'khaki
  RGB (230,230,250), _  'lavender
  RGB (255,240,245), _  'lavender blush
  RGB (124,252,0), _    'lawn green
  RGB (255,250,205), _  'lemon chiffon
  RGB (173,216,230), _  'light blue
  RGB (240,128,128), _  'light coral
  RGB (224,255,255), _  'light cyan
  RGB (250,250,210), _  'light golden rod yellow
  RGB (211,211,211), _  'light gray / light grey
  RGB (144,238,144), _  'light green
  RGB (255,182,193), _  'light pink
  RGB (255,160,122), _  'light salmon
  RGB (32,178,170), _   'light sea green
  RGB (135,206,250), _  'light sky blue
  RGB (119,136,153), _  'light slate gray
  RGB (176,196,222), _  'light steel blue
  RGB (255,255,224), _  'light yellow
  RGB (0,255,0), _      'lime
  RGB (50,205,50), _    'lime green
  RGB (250,240,230), _  'linen
  RGB (255,0,255), _    'magenta / fuchsia
  RGB (128,0,0), _      'maroon
  RGB (102,205,170), _  'medium aqua marine
  RGB (0,0,205), _      'medium blue
  RGB (186,85,211), _   'medium orchid
  RGB (147,112,219), _  'medium purple
  RGB (60,179,113), _   'medium sea green
  RGB (123,104,238), _  'medium slate blue
  RGB (0,250,154), _    'medium spring green
  RGB (72,209,204), _   'medium turquoise
  RGB (199,21,133), _   'medium violet red
  RGB (25,25,112), _    'midnight blue
  RGB (245,255,250), _  'mint cream
  RGB (255,228,225), _  'misty rose
  RGB (255,228,181), _  'moccasin
  RGB (255,222,173), _  'navajo white
  RGB (0,0,128), _      'navy
  RGB (253,245,230), _  'old lace
  RGB (128,128,0), _    'olive
  RGB (107,142,35), _   'olive drab
  RGB (255,165,0), _    'orange
  RGB (255,69,0), _    'orange red
  RGB (218,112,214), _ 'orchid
  RGB (238,232,170), _ 'pale golden rod
  RGB (152,251,152), _ 'pale green
  RGB (175,238,238), _ 'pale turquoise
  RGB (219,112,147), _ 'pale violet red
  RGB (255,239,213), _ 'papaya whip
  RGB (255,218,185), _ 'peach puff
  RGB (205,133,63), _  'peru
  RGB (255,192,203), _ 'pink
  RGB (221,160,221), _ 'plum
  RGB (176,224,230), _ 'powder blue
  RGB (128,0,128), _   'purple
  RGB (255,0,0), _     'red
  RGB (188,143,143), _ 'rosy brown
  RGB (65,105,225), _  'royal blue
  RGB (139,69,19), _   'saddle brown
  RGB (250,128,114), _ 'salmon
  RGB (244,164,96), _  'sandy brown
  RGB (46,139,87), _   'sea green
  RGB (255,245,238), _ 'sea shell
  RGB (160,82,45), _   'sienna
  RGB (192,192,192), _ 'silver
  RGB (135,206,235), _ 'sky blue
  RGB (106,90,205), _  'slate blue
  RGB (112,128,144), _ 'slate gray
  RGB (255,250,250), _ 'snow
  RGB (0,255,127), _   'spring green
  RGB (70,130,180), _  'steel blue
  RGB (210,180,140), _ 'tan
  RGB (0,128,128), _   'teal
  RGB (216,191,216), _ 'thistle
  RGB (255,99,71), _   'tomato
  RGB (64,224,208), _  'turquoise
  RGB (238,130,238), _ 'violet
  RGB (245,222,179), _ 'wheat
  RGB (255,255,255), _ 'white
  RGB (245,245,245), _ 'white smoke
  RGB (255,255,0), _   'yellow
  RGB (154,205,50)}    'yellow green
  ' 1 to 139
  if (t_ink>0) and (t_ink<140) then  COLOR colors(t_ink)
end sub
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Re: Library for drawing turtle type (Logo turtle)

Post by lrcvs »

Hi, D.J.Peters:

Ok, thank you for your good comments, I will have present in my head!

The colors, the copy of a color chart of the network was to provide a little color theme of the figures, possibly remove, take up much code / space program.

These programs are just prototypes, still have to improve many things, add other and do some cleanup code.

The test is simply a sample of the purposes of making a drawing with dotted / dashed lines, it has interesting visual effects.

The system striping, "do not have" any turtle drawing program (I know).

Greetings and thanks for your comments!
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Children playing rope

Post by lrcvs »

Children playing rope

See:

https://www.youtube.com/watch?v=rXcGowDQ5a8

Code: Select all

#include "turtle_8.bi"
Declare Sub men
Dim Shared As Integer j,n,k, p
p = 10
t_init
Color Rgb (255,255,255)
t_style_line_on()
t_init_pattern
t_thick = 1
t_model = t_pattern (5)
k = 0
For j = 1 To 40
    For n = 0 To 180 Step 5
        Screenlock
        Cls
        men
        t_color 16
        Line (-300,-50)-(300,-50)
        t_pos_rot_x = 0
        t_pos_rot_y = k
        t_color 139
        t_arc_sec_ellip (120,n,0,180,0,0)
        k = k + 1
        Screenunlock
        Sleep p
    Next n
    For n = 180 To 0 Step -5
        Screenlock
        Cls
        men
        t_color 16
        Line (-300,-50)-(300,-50)
        t_pos_rot_x = 0
        t_pos_rot_y = k
        t_color 139
        t_arc_sec_ellip (120,n,0,180,0,0)
        k = k - 1
        Screenunlock
        Sleep p
    Next n
    For n = 0 To 50 Step 3
        Screenlock
        Cls
        men
        t_color 16
        Line (-300,-50)-(300,-50)
        t_position_x = 0
        t_position_y = 0
        t_color 139
        t_arc_sec_ellip (120,-n,0,180,0,0)
        Screenunlock
        Sleep p
    Next n
    For n = -50 To 0 Step 5
        Screenlock
        Cls
        men
        t_color 16
        Line (-300,-50)-(300,-50)
        t_position_x = 0
        t_position_y = 0
        t_color 139
        t_arc_sec_ellip (120,n,0,180,0,0)
        Screenunlock
        Sleep p
    Next n
Next j
Sleep
End

Sub men
    t_color 136
    'men l
    Line (160,10)-(160,40)
    Line (160,10)-(150,-20)
    Line (150,-20)-(150,-50)
    Line (160,10)-(170,-20)
    Line (170,-20)-(170,-50)
    Line (150,40)-(170,40)
    Line (160,40)-(160,55)
    Circle (160,65),10 
    Line (170,40)-(180,25)
    Line (180,25)-(190,30)
    Line (150,40)-(t_pos_rot_x+120, t_pos_rot_y)
    'men r
    Line (-160,10)-(-160,40)
    Line (-160,10)-(-150,-20)
    Line (-150,-20)-(-150,-50)
    Line (-160,10)-(-170,-20) 
    Line (-170,-20)-(-170,-50)
    Line (-150,40)-(-170,40)
    Line (-160,40)-(-160,55)
    Circle (-160,65),10 
    Line (-170,40)-(-180,25)
    Line (-180,25)-(-190,30)
    Line (-150,40)-(t_pos_rot_x-120, t_pos_rot_y)
    'men c
    Line (0,40-k)-(0,70-k)
    Line (0,40-k)-(15-(k/2),10-k)
    Line (15-(k/2),10-k)-(15-(k/2),-15-k)
    Line (0,40-k)-(-15+(k/2),10-k) 
    Line (-15+(k/2),10-k)-(-15+(k/2),-15-k)
    Line (-20,70-k)-(20,70-k)
    Line (0,70-k)-(0,85-k)
    Circle (0,95-k),10 
    Line (-20,70-k)-(-40+(k/2),50+(k))
    Line (20,70-k)-(40-(k/2),50+(k))
    End Sub
regards
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Re: Library for drawing turtle type (Logo turtle)

Post by lrcvs »

HI:

Is a experiment:

(Sub T_Star, modify)

A manometer

See:

https://www.youtube.com/watch?v=_2pVG9bH6pY

Greetings

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
The Program: Manometer

Code: Select all

#include "turtle_8.bi"
DIM AS INTEGER j,k,n,z
Dim t as string

t_init
color rgb (255,255,255)
t_style_line_on()
t_init_pattern
t_thick = 0.1
t_model = t_pattern (1)
for j = 1 to 20
    t = Inkey
    If t = Chr$(27) Then z = 1
    If z = 1 Then Exit For

    for n = - 22 to 23
    t = Inkey
    If t = Chr$(27) Then z = 1
    If z = 1 Then Exit For

        screenlock
        cls
locate 1,1:print "Press ESC to Quit"
        color rgb (255,255,255)
        line (-170,120)-(100,-215),,b
        line (-165,110)-(-80,65),,bf

        color rgb (0,0,0)
        for k = -22 to 25 step 5
            t_pos_rot_xy (-123,0)
            t_rot_cir_r(80,k-90)
            t_fd 20
        next k

        circle (0,0),3,,,,,f : color rgb (0,255,0)
        t_orient_l -45
        t_position_x = 0
        t_position_y = 0
        t_arc_star (92, 158,202,100,90,(n/4))
        t_pos_rot_xy (0,0)
        t_ang_cir (90, 158,202,0+(n/4))
        t_position_x = 0
        t_position_y = 0
        t_arc_star (46, -22,25,45,35,(n/4))
        t_pos_rot_xy (0,0)
        t_ang_cir (35, -22,25,(n/4))
        color rgb (255,0,0)
        t_position_x = 53
        t_position_y = (n/4)+10
        t_orient_r 90
        t_spring (3,72,10)
        t_position_x = 54
        t_position_y = (n/4)+10
        t_fd 75
        t_position_x = 14
        t_position_y = (n/4)+10-75
        t_orient_r 0
        color rgb (0,0,255)
        t_fd 80
        t_orient_r 90
        t_spring (5,60-(n/16),30)
        t_orient_l 90
        t_position_x = 14
        t_position_y = -215
        t_spring (5,60-(n/16),30)
        color rgb (0,255,0)
        t_position_x = 14
        t_position_y = -215
        t_orient_l 0
        t_fd 20
        t_rt 90
        t_spring (5,45,5)
        t_orient_l 0
        t_fd 40
        t_lt 90
        t_spring (5,45,5)
        t_orient_l 0
        t_fd 20
        color rgb (0,255,0)
        t_orient_l n/4
        t_pos(0,0)
        t_position_x = -123
        t_position_y = 0
        t_arc_star (23,-90,90,25,15,(-n))
        t_pos_rot_xy (-123,0)
        t_ang_cir (23, -90,90,(-n))
        color rgb (255,255,255): circle (-123,0),3,,,,,f:color rgb (0,255,0)
        t_position_x = -123
        t_position_y = 0
        t_orient_r 270 + (n)
        color rgb (255,0,0):t_fd 100
        screenunlock
        sleep 50
    next n
    
    '::::::::::::::::::::::::::::::::::::::::::::::::
    for n = 23 to -22  step -1
    t = Inkey
    If t = Chr$(27) Then z = 1
    If z = 1 Then Exit For

        screenlock
        cls
locate 1,1:print "Press ESC to Quit"
        color rgb (255,255,255)
        line (-170,120)-(100,-215),,b
        line (-165,110)-(-80,65),,bf
        color rgb (0,0,0)
        for k = -22 to 25 step 5
            t_pos_rot_xy (-123,0)
            t_rot_cir_r(80,k-90)
            t_fd 20
        next k

        circle (0,0),3,,,,,f : color rgb (0,255,0)
        t_orient_l -45
        t_position_x = 0
        t_position_y = 0
        t_arc_star (92, 158,202,100,90,(n/4))
        t_pos_rot_xy (0,0)
        t_ang_cir (90, 158,202,0+(n/4))
        t_position_x = 0
        t_position_y = 0
        t_arc_star (46, -22,25,45,35,(n/4))
        t_pos_rot_xy (0,0)
        t_ang_cir (35, -22,25,(n/4))
        color rgb (255,0,0)
        t_position_x = 53
        t_position_y = (n/4)+10
        t_orient_r 90
        t_spring (3,72,10)
        t_position_x = 54
        t_position_y = (n/4)+10
        t_fd 75
        t_position_x = 14
        t_position_y = (n/4)+10-75
        t_orient_r 0
        color rgb (0,0,255)
        t_fd 80
        t_orient_r 90
        t_spring (5,60-(n/16),30)
        t_orient_l 90
        t_position_x = 14
        t_position_y = -215
        t_spring (5,60-(n/16),30)
        color rgb (0,255,0)
        t_position_x = 14
        t_position_y = -215
        t_orient_l 0
        t_fd 20
        t_rt 90
        t_spring (5,45,5)
        t_orient_l 0
        t_fd 40
        t_lt 90
        t_spring (5,45,5)
        t_orient_l 0
        t_fd 20
        color rgb (0,255,0)
        t_orient_l n/4
        t_pos(0,0)
        t_position_x = -123
        t_position_y = 0
        t_arc_star (23,-90,90,25,15,(-n))
        t_pos_rot_xy (-123,0)
        t_ang_cir (23, -90,90,(-n))
        color rgb (255,255,255): circle (-123,0),3,,,,,f:color rgb (0,255,0)
        t_position_x = -123
        t_position_y = 0
        t_orient_r 270 + (n)
        color rgb (255,0,0):t_fd 100
        screenunlock
        sleep 50
    next n
next j
SLEEP
END
Now The Turtle_8 (Prototype Ver 1.0...X)

Code: Select all

'turtle 8 basica >>> prototype #25'
'lrcvs 29.nov.15'

Declare Function t_ang (Byval t_x1 As Double, Byval t_y1 As Double, Byval t_x2 As Double,Byval t_y2 As Double) As Double
Declare Function t_apothem (Byval t_numsides As Integer, Byval t_radius As Double) As Double
Declare Function t_degrees (Byval t_rad As Double) As Double
Declare Function t_long (Byval t_x1 As Double, Byval t_y1 As Double, Byval t_x2 As Double, Byval t_y2 As Double) As Double
Declare Function t_lradius ( Byval t_long_side As Double, Byval t_num_sides As Integer) As Double
Declare Function t_radians (Byval t_angle As Double) As Double
Declare Function t_side (Byval t_position_x As Double, Byval t_position_y As Double, Byval t_radius As Double,  Byval t_numsides As Integer) As Double

Declare Sub t_active_pattern_off ()
Declare Sub t_active_pattern_on ()
Declare Sub t_active_primary_off ()
Declare Sub t_active_primary_on ()
Declare Sub t_active_secondary_off ()
Declare Sub t_active_secondary_on ()
Declare Sub t_arc_sec_cir (Byval t_r1 As Double , Byval t_ini As Double , Byval t_end As Double , Byval t_ang_rot As Double , Byval t_arc_sec_circle As Integer) 'draw a arc / sector of circle
Declare Sub t_ang_cir (Byval t_r1 As Double , Byval t_ini As Double , Byval t_end As Double , Byval t_ang_rot As Double ) 'draw a angle of circle
Declare Sub t_arc_sec_ellip (Byval t_r1 As Double , Byval t_r2 As Double , Byval t_ini As Double , Byval t_end As Double , Byval t_ang_rot As Double , Byval t_arc_sec_circle As Integer) 'draw a arc / sector of circle
Declare Sub t_axes ()
Declare Sub t_bk (Byval t_distance As Double)
Declare Sub t_circle (Byval t_r1 As Double)
Declare Sub t_ellipse (Byval t_r1 As Double , Byval t_r2 As Double , Byval t_ang_rot As Double)
Declare Sub t_fd (Byval t_distance As Double)
Declare Sub t_grid_1 (Byval t_step_grid As Double)
Declare Sub t_grid_2 (Byval t_step_grid As Double)
Declare Sub t_grid_3 (Byval t_step_grid As Double)
Declare Sub t_grid_4 (Byval t_step_grid As Double)
Declare Sub t_gt (Byval t_position_x As Double, Byval t_position_y As Double)
Declare Sub t_home
Declare Sub t_init ()
Declare Sub t_init_pattern ()
Declare Sub t_init_style_line ()
Declare Sub t_lt (Byval t_angle As Double)
Declare Sub t_orient_l (Byval t_angle As Double)
Declare Sub t_orient_r (Byval t_angle As Double)
Declare Sub t_ovoid (Byval t_r1 As Double, Byval t_r2 As Double, Byval t_ang_rot As Double) 
Declare Sub t_pattern_color (Byval t_distance As Double)
Declare Sub t_photo ()
Declare Sub t_poly (Byval t_long_side As Double, Byval t_num_sides As Integer, Byval t_ang_rot As Double)
Declare Sub t_pos (Byval t_position_x As Double, Byval t_position_x As Double)
Declare Sub t_pos_rot_xy(Byval t_pos_rot_x As Double, Byval t_pos_rot_y As Double)
Declare Sub t_rect_l (Byval t_side_upper As Double, Byval t_side_lower As Double, Byval t_ang_rot As Double)
Declare Sub t_rect_r (Byval t_side_upper As Double, Byval t_side_lower As Double, Byval t_ang_rot As Double)
Declare Sub t_rhombus (Byval t_rg As Double , Byval t_rp As Double , Byval t_ang_rot As Double)
Declare Sub t_rot_cir_l (Byval t_distance As Double,Byval t_angle As Double)
Declare Sub t_rot_cir_r (Byval t_distance As Double,Byval t_angle As Double)
Declare Sub t_rot_ellip_l (Byval t_r1 As Double, Byval t_r2 As Double, Byval t_angle As Double)
Declare Sub t_rot_ellip_r (Byval t_r1 As Double, Byval t_r2 As Double, Byval t_angle As Double)
Declare Sub t_rt (Byval t_angle As Double)
Declare Sub t_arc_star (Byval t_np As Integer , Byval t_ang_ini As Double , Byval t_ang_end As Double , Byval t_rg As Double , Byval t_rp As Double , Byval t_ang_rot As Double)
Declare Sub t_spring (t_ns As Integer , t_rs As Double , t_lo As Double) 'draw a t_spring
Declare Sub t_star (Byval t_np As Integer , Byval t_rg As Double , Byval t_rp As Double , Byval t_ang_rot As Double)
Declare Sub t_style_line_off ()
Declare Sub t_style_line_on ()
Declare Sub t_turtle_off ()
Declare Sub t_turtle_on ()

Const pi As Double = 3.1415926535897932
Const pi2 As Double = 2 * pi
Const t_number_aurum As Double = 1.6180339887498948
Const t_number_e As Double = 2.7182818284590452
Const t_const_radians = 0.01745329251994329576923690768489
Const t_const_degrees = 57.295779513082320876798154814105

Dim Shared As Integer t_c, t_rot, t_active_pattern , t_active_primary , t_active_secondary , t_c1 , t_c2 , t_c3 , t_center_screen_x , t_center_screen_y , t_h , t_inverse_pattern , t_style_line , t_turtle , t_w

Dim Shared As Double t_angle , t_distance , t_heading , t_new_position_x , t_new_position_y , t_pc , t_pos_rot_x , t_pos_rot_y , t_po_ro_x , t_po_ro_y ,t_pos_x , t_pos_y , t_position_x , t_position_y , t_radio , t_scale , t_thick

Dim Shared As String t_model
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Dim Shared As Double pics(18,4)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'A/a = 1   F/f = 6    K/k = 11    P/p = 16    V/v = 21
'B/b = 2   G/g = 7    L/l = 12    Q/q = 17    W/w = 22
'C/c = 3   H/h = 8    M/m = 13    R/r = 18    X/x = 23
'D/d = 4   I/i = 9    N/n = 14    T/t = 19    Y/y = 24
'E/e = 5   J/j = 10   O/o = 15    U/u = 20    Z/z = 25
'Uppers = On/1, Lowers = Off/0

Dim Shared As String t_pattern (19)
t_pattern (1) =  "A"        :   t_pattern (10) =  "Fc"
t_pattern (2) =  "Aa"       :   t_pattern (11) =  "FcAc"
t_pattern (3) =  "Bb"       :   t_pattern (12) =  "FcAcAc"
t_pattern (4) =  "Cc"       :   t_pattern (13) =  "FcAcAcAc"
t_pattern (5) =  "Ee"       :   t_pattern (14) =  "FcFcAc"
t_pattern (6) =  "Ff"       :   t_pattern (15) =  "FcFcAcAc"
t_pattern (7) =  "CcAc"     :   t_pattern (16) =  "FcFcAcAcAc"
t_pattern (8) =  "CcAcAc"   :   t_pattern (17) =  "FcFcFcAc"
t_pattern (9) =  "CcAcAcAc" :   t_pattern (18) =  "FcFcFcAcAc"
t_pattern (19) =  "LfLfLfAfAfAf"
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Function t_ang (Byval t_x1 As Double, Byval t_y1 As Double, Byval t_x2 As Double, Byval t_y2 As Double) As Double
	Dim As Double t_fang
	If t_x1 < t_x2 And t_y1 < t_y2 Then t_fang = t_degrees(Acos((t_x2 - t_x1)/Sqr (((t_x2 - t_x1)^2) + ((t_y2 - t_y1)^2))))
	If t_x1 > t_x2 And t_y1 < t_y2 Then t_fang = t_degrees(Acos((t_x2 - t_x1)/Sqr (((t_x2 - t_x1)^2) + ((t_y2 - t_y1)^2))))
	If t_x1 > t_x2 And t_y1 > t_y2 Then t_fang = 360 - (t_degrees(Acos((t_x2 - t_x1)/Sqr (((t_x2 - t_x1)^2) + ((t_y2 - t_y1)^2)))))
	If t_x1 < t_x2 And t_y1 > t_y2 Then t_fang = 360 - (t_degrees(Acos((t_x2 - t_x1)/Sqr (((t_x2 - t_x1)^2) + ((t_y2 - t_y1)^2)))))
	If t_x1 < t_x2 And t_y1 = t_y2 Then t_fang = 0
	If t_x1 = t_x2 And t_y1 < t_y2 Then t_fang = 90
	If t_x1 > t_x2 And t_y1 = t_y2 Then t_fang = 180
	If t_x1 = t_x2 And t_y2 < t_y1 Then t_fang = 270
	t_ang = t_fang
End Function

Function t_lradius ( Byval t_long_side As Double, Byval t_num_sides As Integer) As Double
    'calculate radius of one polygon
    t_lradius = (t_long_side * Sin(t_radians((180-(360/t_num_sides ))/2)))/Sin(t_radians(360/t_num_sides))
End Function

Function t_apothem (Byval t_numsides As Integer, Byval t_radius As Double) As Double
    'calculate apothem
	t_apothem = (Cos(t_radians((360/t_numsides)/2)) * t_radius)
End Function

Function t_degrees (Byval t_rad As Double) As Double
    'transform radians to degrees
	t_degrees = (t_rad * t_const_degrees)
End Function

Function t_long (Byval t_x1 As Double, Byval t_y1 As Double, Byval t_x2 As Double, Byval t_y2 As Double) As Double
    'calculate long point to point
	t_long = Sqr(Abs((t_x1 - t_x2)^2) + Abs((t_y1 - t_y2)^2))
End Function

Function t_radians (Byval t_angle As Double) As Double
    'transfor degrees to radians
	t_radians  =  (t_angle * t_const_radians )
End Function

Function t_side (Byval t_position_x As Double, Byval t_position_y As Double, Byval t_radius As Double,  Byval t_numsides As Integer) As Double
	Dim As Double t_rgrad, t_x0, t_y0, t_x1, t_y1
	t_rgrad = t_radians(0)
	t_x0 = (t_radius * Cos (t_rgrad)) + t_position_x
	t_y0 = (t_radius * Sin (t_rgrad)) + t_position_y
	t_rgrad = t_radians(360 / t_numsides)
	t_x1 = (t_radius * Cos (t_rgrad)) + t_position_x
	t_y1 = (t_radius * Sin (t_rgrad)) + t_position_y
	t_side= t_long (t_x0, t_y0, t_x1, t_y1)
End Function

Sub t_active_pattern_off
	t_active_pattern = 0
End Sub

Sub t_active_pattern_on
	t_active_pattern = 1
End Sub

Sub t_active_primary_off
	t_active_primary = 0
End Sub

Sub t_active_primary_on
	t_active_primary = 1
End Sub

Sub t_active_secondary_off
	t_active_secondary = 0
End Sub

Sub t_active_secondary_on
	t_active_secondary = 1
End Sub

Sub t_axes ()
    Line(-t_w/2  , t_center_screen_y) - ( t_w/2 , t_center_screen_y ) 
    Line( t_center_screen_x ,-t_h/2 ) - ( t_center_screen_x , t_h/2 ) 
End Sub

Sub t_bk (Byval t_distance As Double)
	Dim As Integer t_a, t_vm, t_dist
    Dim As Double t_x2, t_y2, t_x3, t_y3
    
	If t_turtle = 0 Then
		t_new_position_x = t_position_x - ((t_distance * t_scale) * Cos(t_heading))
		t_new_position_y = t_position_y + ((t_distance * t_scale) * Sin(t_heading))
		t_position_x = t_new_position_x
		t_position_y = t_new_position_y
    End If
	If t_turtle = 1 And t_style_line = 0 Then
		t_new_position_x = t_position_x - ((t_distance * t_scale) * Cos(t_heading))
		t_new_position_y = t_position_y + ((t_distance * t_scale) * Sin(t_heading))
		Line (t_position_x, t_position_y)-(t_new_position_x, t_new_position_y)
		t_position_x = t_new_position_x
		t_position_y = t_new_position_y
    End If
	If t_turtle = 1 And t_style_line = 1 Then
        t_a = Len(t_model)
        For  t_dist =   1  To  t_distance
            t_vm = (Asc (Mid(t_model,t_c1, 1)))
            If  t_vm > 64  And t_vm < 91 Then 
                t_x2 = t_position_x - ((t_dist* t_scale) * Cos(t_heading))
                t_y2 = t_position_y + ((t_dist* t_scale) * Sin(t_heading))
                If t_thick = 0 Then
                    Pset (t_x2, t_y2)
                Else
                    If t_c > 0 Then Circle (t_x2, t_y2), t_thick,,,,,f
                End If
                t_c2 = t_c2 + 1
                If t_c2 > (t_vm -64) Then t_c2 =  1 : t_c1 = t_c1 +1
                If t_c1 >  t_a Then t_c1 =1
            End If
            
            If  t_vm > 96 And t_vm < 123  Then 
                t_x3 = t_position_x - ((t_dist* t_scale) * Cos(t_heading))
                t_y3 = t_position_y + ((t_dist* t_scale) * Sin(t_heading))
                If t_thick = 0 Then
                    'pset (t_x3, t_y3)
                Else
                    'circle (t_x3, t_y3), t_thick,,,,,f
                End If
                t_c3 = t_c3 + 1
                If t_c3 > (t_vm -96) Then t_c3 =  1 : t_c1 = t_c1 +1
                If t_c1 >  t_a Then t_c1 =1
            End If
        Next t_dist
        t_position_x =  t_position_x + ((t_distance * t_scale) * Cos(t_heading))
        t_position_y =  t_position_y - ((t_distance * t_scale) * Sin(t_heading))
    End If
    
End Sub

Sub t_fd (Byval t_distance As Double)
    Dim As Integer t_a, t_vm, t_dist
    Dim As Double t_x2, t_y2, t_x3, t_y3
    
    If t_turtle = 0 And t_style_line = 0 Then
        t_new_position_x = t_position_x + ((t_distance * t_scale) * Cos(t_heading))
        t_new_position_y = t_position_y - ((t_distance * t_scale) * Sin(t_heading))
        t_position_x = t_new_position_x
        t_position_y = t_new_position_y
    End If
    If t_turtle = 1 And t_style_line = 0 and t_c > 0 Then
        t_new_position_x = t_position_x + ((t_distance * t_scale) * Cos(t_heading))
        t_new_position_y = t_position_y - ((t_distance * t_scale) * Sin(t_heading))
        Line (t_position_x, t_position_y)-(t_new_position_x, t_new_position_y)
        t_position_x = t_new_position_x
        t_position_y = t_new_position_y
    End If
    
    If t_turtle = 1 And t_style_line = 1 Then
        t_a = Len(t_model)
        For  t_dist =   1  To  t_distance
            t_vm = (Asc (Mid(t_model,t_c1, 1)))
            If  t_vm > 64  And t_vm < 91 Then 
                t_x2 = t_position_x + ((t_dist* t_scale) * Cos(t_heading))
                t_y2 = t_position_y - ((t_dist* t_scale) * Sin(t_heading))
                If t_thick = 0 Then
                    Pset (t_x2, t_y2)
                    
                Else
                    If t_c > 0 Then Circle (t_x2, t_y2), t_thick,,,,,f

                    
                End If
                t_c2 = t_c2 + 1
                If t_c2 > (t_vm -64) Then t_c2 =  1 : t_c1 = t_c1 +1
                If t_c1 >  t_a Then t_c1 =1
            End If
            
            If  t_vm > 96 And t_vm < 123  Then 
                t_x3 = t_position_x + ((t_dist* t_scale) * Cos(t_heading))
                t_y3 = t_position_y - ((t_dist* t_scale) * Sin(t_heading))
                If t_thick = 0 Then
                    'pset (t_x3, t_y3)
                Else
                    'circle (t_x3, t_y3), t_thick,,,,,f
                End If
                t_c3 = t_c3 + 1
                If t_c3 > (t_vm -96) Then t_c3 =  1 : t_c1 = t_c1 +1
                If t_c1 >  t_a Then t_c1 =1
            End If
            
        Next t_dist
        t_position_x =  t_position_x + ((t_distance * t_scale) * Cos(t_heading))
        t_position_y =  t_position_y - ((t_distance * t_scale) * Sin(t_heading))
        
    End If
    
    If t_turtle = 0 And t_style_line = 1 Then
        t_a = Len(t_model)
        For  t_dist =   1  To  t_distance
            t_vm = (Asc (Mid(t_model,t_c1, 1)))
            If  t_vm > 64  And t_vm < 91 Then 
                t_x2 = t_position_x + ((t_dist* t_scale) * Cos(t_heading))
                t_y2 = t_position_y - ((t_dist* t_scale) * Sin(t_heading))
                'if t_thick = 0 then
                
                'pset (t_x2, t_y2)
                
                'else
                'if t_c > 0 then circle (t_x2, t_y2), t_thick,,,,,f
                
                'end if
                t_c2 = t_c2 + 1
                If t_c2 > (t_vm -64) Then t_c2 =  1 : t_c1 = t_c1 +1
                If t_c1 >  t_a Then t_c1 =1
            End If
            
            If  t_vm > 96 And t_vm < 123  Then 
                t_x3 = t_position_x + ((t_dist* t_scale) * Cos(t_heading))
                t_y3 = t_position_y - ((t_dist* t_scale) * Sin(t_heading))
                'if t_thick = 0 then
                'pset (t_x3, t_y3)
                'else
                'circle (t_x3, t_y3), t_thick,,,,,f
                'end if
                t_c3 = t_c3 + 1
                If t_c3 > (t_vm -96) Then t_c3 =  1 : t_c1 = t_c1 +1
                If t_c1 >  t_a Then t_c1 =1
            End If
            
        Next t_dist
        
        t_position_x =  t_position_x + ((t_distance * t_scale) * Cos(t_heading))
        t_position_y =  t_position_y - ((t_distance * t_scale) * Sin(t_heading))
    End If
End Sub

Sub t_grid_1 (Byval t_step_grid As Double)
    Dim t_n As Double
    For t_n = -t_h To t_h Step t_step_grid 
        Line(-t_w , t_n) - (t_w , t_n),Color Rgb (128,128,128)   'lineas horizontales
    Next t_n
End Sub

Sub t_grid_2 (Byval t_step_grid As Double)
    Dim t_n As Double
    For t_n = -t_w To t_w Step t_step_grid 
        Line(t_n , -t_h) - (t_n , t_h),Color Rgb (128,128,128)  'lineas verticales
    Next t_n
End Sub


Sub t_grid_3(Byval t_step_grid As Double) 
    Dim t_n As Double
    For t_n = 0 To t_h Step t_step_grid 
        Circle (0, 0), t_n ,Color Rgb (128,128,128) 'dibuja circulos concentricos
    Next t_n
End Sub

Sub t_grid_4 (Byval t_step_grid As Double)
    Dim t_n As Double
    t_style_line_off
    Color Rgb (128,128,128)
    For t_n = 0 To 360 Step t_step_grid 
        'aqui dibujamos los radios/angulos
        t_orient_l t_n
        t_pos (0 ,0)
        t_fd t_w
    Next t_n
    t_style_line_on
End Sub

Sub t_gt (Byval t_pos_x As Double, Byval t_pos_y As Double)
	t_position_x = t_center_screen_x + (t_pos_x * t_scale)
	t_position_y = t_center_screen_y + (t_pos_y * t_scale)
End Sub

Sub t_home ()
	t_position_x = t_center_screen_x
	t_position_y = t_center_screen_y
End Sub

Sub t_init ()
	Screen 19,32
	Screeninfo t_w , t_h
	Window (-t_w/2,-t_h/2)-(t_w/2,t_h/2)
	t_active_pattern_on
    t_init_pattern
	t_center_screen_x = 0
	t_center_screen_y = 0
	t_gt (t_position_x , t_position_y)
	t_init_style_line
	t_model = "z"
	t_new_position_x = t_position_x
	t_new_position_y = t_position_y
	t_position_x = t_center_screen_x
	t_position_y = t_center_screen_y
	t_scale = 1
	t_style_line_off
	t_thick = 0
	t_turtle_on
    t_active_secondary_on
    t_active_secondary_off
End Sub

Sub t_init_style_line ()
	t_c1 = 1 : t_c2 = 1 : t_c3 = 1
End Sub

Sub t_init_pattern ()
    t_c1 = 1
    t_c2 = 1
    t_c3 = 1
End Sub

Sub t_lt (Byval t_angle As Double)
	t_heading = t_heading - t_radians (t_angle)
End Sub

Sub t_orient_l (Byval t_angle As Double)
	t_heading = t_radians (t_angle * (- 1))
End Sub

Sub t_orient_r (Byval t_angle As Double)
	t_heading = t_radians (t_angle)
End Sub

Sub t_pattern_color (Byval t_distance As Double)
    Dim As Integer t_a, t_vm
    Dim As Double t_x2, t_y2, t_x3, t_y3
    
    t_a = Len(t_model)
    t_vm = (Asc (Mid(t_model,t_c1, 1)))
    If  t_vm > 64  And t_vm < 91 Then 
        t_x2 = t_position_x + ((t_distance * t_scale) * Cos(t_heading))
        t_y2 = t_position_y - ((t_distance * t_scale) * Sin(t_heading))
        If t_thick = 0 Then
            Pset (t_x2, t_y2)
        Else
            Circle (t_x2, t_y2), t_thick,,,,,f
        End If
        t_c2 = t_c2 + 1
        If t_c2 > (t_vm -64) Then t_c2 =  1 : t_c1 = t_c1 +1
        If t_c1 >  t_a Then t_c1 =1
    End If
    
    If  t_vm > 96 And t_vm < 123  Then 
        t_x3 = t_position_x + ((t_distance * t_scale) * Cos(t_heading))
        t_y3 = t_position_y - ((t_distance * t_scale) * Sin(t_heading))
        If t_thick = 0 Then
            'pset (t_x3, t_y3)
        Else
            'circle (t_x3, t_y3), t_thick,,,,,f
        End If
        t_c3 = t_c3 + 1
        If t_c3 > (t_vm -96) Then t_c3 =  1 : t_c1 = t_c1 +1
        If t_c1 >  t_a Then t_c1 =1
    End If
    t_position_x =  t_position_x + ((t_distance * t_scale) * Cos(t_heading))
    t_position_y =  t_position_y - ((t_distance * t_scale) * Sin(t_heading))
End Sub 


Sub t_photo ()
	Dim As Integer t_nn, t_long_date_time
	Dim As String t_date_time, t_name_photo, t_photo_y
	t_date_time = Date
	t_long_date_time = Len (t_date_time)
	t_name_photo = ""
	t_photo_y = ""
	For t_nn = 1 To t_long_date_time
		t_photo_y= Mid(t_date_time,t_nn,1)
		If t_photo_y <> "-" Then t_name_photo = t_name_photo + t_photo_y
    Next t_nn
	t_name_photo = t_name_photo + "_"
	t_date_time = Time
	t_long_date_time = Len (t_date_time)
	t_photo_y = ""
	For t_nn = 1 To t_long_date_time
		t_photo_y= Mid(t_date_time,t_nn,1)
		If t_photo_y <> ":" Then t_name_photo = t_name_photo + t_photo_y
    Next t_nn
	Bsave t_name_photo+".bmp",0
End Sub

Sub t_pos (Byval t_pos_x As Double, Byval t_pos_y As Double)
	t_turtle_off
	t_gt (t_pos_x, t_pos_y)
	t_turtle_on
End Sub

Sub t_pos_rot_xy(Byval t_po_ro_x As Double, Byval t_po_ro_y As Double)
	t_pos_rot_x = t_po_ro_x
	t_pos_rot_y = t_po_ro_y
End Sub

Sub t_rot_cir_l (Byval t_distance As Double, Byval t_angle As Double)
	t_pos_rot_x = ((t_distance * t_scale) * Cos(t_radians (t_angle)))+t_pos_rot_x
	t_pos_rot_y = ((t_distance * t_scale) * Sin(t_radians (t_angle)))+t_pos_rot_y
	t_heading = t_radians (t_angle * (- 1))
    t_position_x = t_pos_rot_x
    t_position_y = t_pos_rot_y
    t_rot = 1
End Sub

Sub t_rot_cir_r (Byval t_distance As Double, Byval t_angle As Double)
	t_pos_rot_x = ((t_distance * t_scale) * Cos(t_radians (t_angle*-1)))+t_pos_rot_x
	t_pos_rot_y = ((t_distance * t_scale) * Sin(t_radians (t_angle*-1)))+t_pos_rot_y
	t_heading = t_radians (t_angle)
    t_position_x = t_pos_rot_x
    t_position_y = t_pos_rot_y
    t_rot = 1
End Sub

Sub t_rot_ellip_l (Byval t_r1 As Double, Byval t_r2 As Double, Byval t_angle As Double)
	t_pos_rot_x = ((t_r1 * t_scale) * Cos(t_radians (t_angle)))+t_pos_rot_x
	t_pos_rot_y = ((t_r2 * t_scale) * Sin(t_radians (t_angle)))+t_pos_rot_y
	t_heading = t_radians (t_angle * (- 1))
    t_position_x = t_pos_rot_x
    t_position_y = t_pos_rot_y
    t_rot = 1
End Sub

Sub t_rot_ellip_r (Byval t_r1 As Double, Byval t_r2 As Double, Byval t_angle As Double)
	t_pos_rot_x = ((t_r1 * t_scale) * Cos(t_radians (t_angle*-1)))+t_pos_rot_x
	t_pos_rot_y = ((t_r2 * t_scale) * Sin(t_radians (t_angle*-1)))+t_pos_rot_y
	t_heading = t_radians (t_angle)
    t_position_x = t_pos_rot_x
    t_position_y = t_pos_rot_y
    t_rot = 1
End Sub


Sub t_rt (Byval t_angle As Double)
	t_heading = t_heading + t_radians (t_angle)
End Sub

Sub t_style_line_off ()
	t_style_line = 0
End Sub

Sub t_style_line_on ()
	t_style_line = 1
End Sub

Sub t_turtle_off ()
	t_turtle = 0
End Sub

Sub t_turtle_on ()
	t_turtle = 1
End Sub

Sub t_circle (Byval t_r1 As Double)
    Dim As Double t_grad , t_grad2, t_x0 , t_y0  
    For t_grad = 0 To 360
        t_grad2 = t_radians(t_grad)
        t_x0 = t_r1 * Cos(t_grad2) 
        t_y0 = t_r1 * Sin(t_grad2) 
        t_position_x = t_x0 + t_pos_rot_x
        t_position_y = t_y0 + t_pos_rot_y
        t_fd 1
    Next t_grad
    
End Sub


Sub t_arc_sec_cir (Byval t_r1 As Double , Byval t_ini As Double , Byval t_end As Double , Byval t_ang_rot As Double , Byval t_arc_sec_circle As Integer) 'draw a arc / sector of circle
    Dim z As Integer
    Dim As Double t_px, t_py , t_grad , t_grad2, t_x0 , t_y0 
    'draw a arc or sector cir
    't_r = radius circle
    't_ini = angle init
    't_end = angle end
    't_ang_rot = angle of rotation
    't_arc_sec_cir = 0 = arc / 1 = sector
    t_c = 1
    If t_arc_sec_circle = 1 Then
        'radios
        'if t_rot = 1 then t_ang_rot = t_heading

        t_orient_l 0
        t_pos (t_pos_rot_x,t_pos_rot_y)
        t_orient_l t_ini + t_ang_rot
        t_fd t_r1

        t_orient_l 0
        t_pos (t_pos_rot_x,t_pos_rot_y)
        t_orient_l t_end + t_ang_rot
        t_fd t_r1
        
    End If
    
    t_orient_r 0
    t_pos (t_px, t_py)
    t_ang_rot = t_radians (t_ang_rot)
    'if t_rot = 1 then t_ang_rot = t_heading
    For t_grad = t_ini To t_end
        t_grad2 = t_radians(t_grad)
        t_x0 = (((t_r1) * Cos(t_grad2))* Cos (t_ang_rot)) - (((t_r1) * Sin(t_grad2)) * Sin (t_ang_rot))
        t_y0 = (((t_r1) * Cos(t_grad2))* Sin (t_ang_rot)) + (((t_r1) * Sin(t_grad2)) * Cos (t_ang_rot))
        t_position_x = t_x0 + t_pos_rot_x
        t_position_y = t_y0 + t_pos_rot_y
        t_fd 1
    Next t_grad
End Sub

Sub t_ang_cir (Byval t_r1 As Double , Byval t_ini As Double , Byval t_end As Double , Byval t_ang_rot As Double ) 'draw a angle of circle
    Dim z As Integer
    Dim As Double t_px, t_py , t_grad , t_grad2, t_x0 , t_y0 
    'draw a arc or sector cir
    't_r = radius circle
    't_ini = angle init
    't_end = angle end
    't_ang_rot = angle of rotation
    't_arc_sec_cir = 0 = arc / 1 = sector
    t_c = 1
        'radios
        'if t_rot = 1 then t_ang_rot = t_heading

        t_orient_l 0
        t_pos (t_pos_rot_x,t_pos_rot_y)
        t_orient_l t_ini + t_ang_rot
        t_fd t_r1

        t_orient_l 0
        t_pos (t_pos_rot_x,t_pos_rot_y)
        t_orient_l t_end + t_ang_rot
        t_fd t_r1
End Sub


Sub t_ellipse (Byval t_r1 As Double , Byval t_r2 As Double , Byval t_ang_rot As Double)
    Dim As Double t_grad , t_grad2, t_x0 , t_y0 
    t_c = 0
    t_ang_rot = t_radians (t_ang_rot)
    If t_rot = 1 Then t_ang_rot = t_heading
    For t_grad = t_ang_rot To t_ang_rot + 360
        t_grad2 = t_radians(t_grad)
        t_x0 = ((t_r1 * Cos(t_grad2)) * Cos (t_ang_rot)) - ((t_r2 * Sin(t_grad2)) * Sin (t_ang_rot))
        t_y0 = ((t_r1 * Cos(t_grad2)) * Sin (t_ang_rot)) + ((t_r2 * Sin(t_grad2)) * Cos (t_ang_rot))
        't_position_x = t_x0 + t_pos_rot_x
        't_position_y = t_y0 + t_pos_rot_y
        t_fd 1
    T_C = 1
    Next t_grad
End Sub

Sub t_arc_sec_ellip (Byval t_r1 As Double , Byval t_r2 As Double , Byval t_ini As Double , Byval t_end As Double , Byval t_ang_rot As Double , Byval t_arc_sec_circle As Integer) 'draw a arc / sector of circle
    Dim z As Integer
    Dim As Double t_px, t_py , t_grad , t_grad2, t_x0 , t_y0 
    'draw a arc or sector cir
    't_r = radius circle
    't_ini = angle init
    't_end = angle end
    't_ang_rot = angle of rotation
    't_arc_sec_cir = 0 = arc / 1 = sector
    t_c = 1
    If t_arc_sec_circle = 1 Then
        'radios
        'if t_rot = 1 then t_ang_rot = t_heading
        t_orient_l 0
        t_px = t_pos_rot_x
        t_py = t_pos_rot_y
        t_pos (t_px, t_py)
        t_orient_l t_ang_rot
        t_fd t_r1
        
        t_orient_r 0
        t_pos (t_px, t_py)
        t_orient_l t_end + t_ang_rot
        t_fd t_r2
    End If
    
    t_orient_r 0
    t_pos (t_px, t_py)
    t_ang_rot = t_radians (t_ang_rot)
    'if t_rot = 1 then t_ang_rot = t_heading
    For t_grad = t_ini To t_end
        t_grad2 = t_radians(t_grad)
        t_x0 = (((t_r1) * Cos(t_grad2))* Cos (t_ang_rot)) - (((t_r2) * Sin(t_grad2)) * Sin (t_ang_rot))
        t_y0 = (((t_r1) * Cos(t_grad2))* Sin (t_ang_rot)) + (((t_r2) * Sin(t_grad2)) * Cos (t_ang_rot))
        t_position_x = t_x0 + t_pos_rot_x
        t_position_y = t_y0 + t_pos_rot_y
        t_fd 1
    Next t_grad
End Sub


Sub t_poly (Byval t_long_side As Double, Byval t_num_sides As Integer, Byval t_ang_rot As Double)
    Dim As Double t_pol,t_x0,t_y0,t_x1,t_y1
    t_c = 0
    For t_pol  = t_ang_rot To 361 + (t_ang_rot ) Step 360/t_num_sides
        t_x1 = (t_lradius(t_long_side, t_num_sides)  * Cos(t_radians(t_pol)))
        t_y1 = (t_lradius(t_long_side, t_num_sides)  * Sin(t_radians(t_pol)))
        t_orient_l (t_ang (t_x0,t_y0,t_x1,t_y1)+ t_ang_rot )
        t_fd (t_long  (t_x0,t_y0,t_x1,t_y1))
        t_x0 = t_x1
        t_y0 = t_y1
        t_c = t_c + 1
    Next t_pol
    
End Sub

Sub t_rect_l (Byval t_side_upper As Double, Byval t_side_lower As Double, Byval t_ang_rot As Double)
    t_c = 1
    t_orient_l t_ang_rot
    t_turtle_off
    t_fd t_side_upper / 2
    t_turtle_on
    t_lt 90
    t_fd t_side_lower / 2
    t_lt 90
    t_fd t_side_upper
    t_lt 90
    t_fd t_side_lower
    t_lt 90
    t_fd t_side_upper
    t_lt 90
    t_fd t_side_lower / 2
End Sub

Sub t_rect_r (Byval t_side_upper As Double, Byval t_side_lower As Double, Byval t_ang_rot As Double)
    t_c = 1
    t_orient_r t_ang_rot
    t_turtle_off
    t_fd t_side_upper / 2
    t_turtle_on
    t_lt 90
    t_fd t_side_lower / 2
    t_lt 90
    t_fd t_side_upper
    t_lt 90
    t_fd t_side_lower
    t_lt 90
    t_fd t_side_upper
    t_lt 90
    t_fd t_side_lower / 2
End Sub

Sub t_ovoid (Byval t_r1 As Double, Byval t_r2 As Double, Byval t_ang_rot As Double) 
    t_c = 1
    t_arc_sec_ellip (t_r1,t_r2,0,180,t_ang_rot,0)
    t_arc_sec_cir (t_r1,180,360,t_ang_rot,0)
    't_arc_sec_ellip (t_r1,t_r2,180,360,t_ang_rot,0)
End Sub

Sub t_spring (t_ns As Integer , t_rs As Double , t_lo As Double) 'draw a t_spring
    Dim t_n As Integer
    't_ns = number of spirals
    't_rs = stretch of spiral 0...90
    't_lo = long of spiral
    t_c = 1
    For t_n = 1 To t_ns
        t_rt t_rs
        t_fd t_lo
        t_lt t_rs * 2
        t_fd t_lo
        t_rt t_rs
    Next t_n
End Sub

Sub t_star (Byval t_np As Integer , Byval t_rg As Double , Byval t_rp As Double , Byval t_ang_rot As Double)
    Dim As Double t_x0,t_y0,t_x1,t_y1,t_n, t_x2, t_y2
    t_c =0
    For  t_n = 0  To 360  + ((360/(t_np*2)))  Step  360/(t_np*2)
        If  t_c Mod 2  = 0  Then
            t_x1 = (t_rp  * Cos(t_radians(t_n)))
            t_y1 = (t_rp  * Sin(t_radians(t_n)))
        Else
            t_x1  = (t_rg  * Cos(t_radians(t_n)))
            t_y1 =  (t_rg  * Sin(t_radians(t_n)))
        End If
        t_orient_l (t_ang (t_x0,t_y0,t_x1,t_y1)+ t_ang_rot )
        t_fd (t_long  (t_x0,t_y0,t_x1,t_y1))
        t_x0 = t_x1
        t_y0 = t_y1
        t_c = t_c  +  1
    Next t_n
End Sub

Sub t_arc_star (Byval t_np As Integer , Byval t_ang_ini As Double , Byval t_ang_end As Double ,Byval t_rg As Double , Byval t_rp As Double , Byval t_ang_rot As Double)
'sector de estrella
    Dim As Double t_x0,t_y0,t_x1,t_y1,t_n, t_x2, t_y2
    t_c =0
    For  t_n = t_ang_ini  To t_ang_end  Step  (360/(t_np*2))
        If  t_c Mod 2  = 0  Then
            t_x1 = (t_rp  * Cos(t_radians(t_n)))
            t_y1 = (t_rp  * Sin(t_radians(t_n)))
        Else
            t_x1  = (t_rg  * Cos(t_radians(t_n)))
            t_y1 =  (t_rg  * Sin(t_radians(t_n)))
        End If
        t_orient_l (t_ang (t_x0,t_y0,t_x1,t_y1)+ t_ang_rot )
        t_fd (t_long  (t_x0,t_y0,t_x1,t_y1))
        t_x0 = t_x1
        t_y0 = t_y1
        t_c = t_c  +  1
    Next t_n

End Sub


Sub t_rhombus (Byval t_rg As Double , Byval t_rp As Double , Byval t_ang_rot As Double)
    Dim As Double t_x0,t_y0,t_x1,t_y1,t_n, t_x2, t_y2
    t_c =0
    For  t_n = 0 To 360 Step 90
        If  t_c Mod 2  = 0  Then
            t_x1 = (t_rp  * Cos(t_radians(t_n)))
            t_y1 = (t_rp  * Sin(t_radians(t_n)))
        Else
            t_x1  = (t_rg  * Cos(t_radians(t_n)))
            t_y1 =  (t_rg  * Sin(t_radians(t_n)))
        End If
        t_orient_l (t_ang (t_x0,t_y0,t_x1,t_y1)+ t_ang_rot )
        t_fd (t_long  (t_x0,t_y0,t_x1,t_y1))
        t_x0 = t_x1
        t_y0 = t_y1
        t_c = t_c  +  1
    Next t_n
End Sub
Some technicians, will say, it may be easier to make a gauge bellows, without so many gears, it is true, but I wanted to experiment with arches star.

The library Turtle_8 is a simple prototype, I'm experimenting with new forms / figures.

Enjoy!
Last edited by lrcvs on Dec 01, 2015 19:27, edited 2 times in total.
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Library for drawing turtle type (Logo turtle)

Post by Tourist Trap »

Thanks for this nice piece of mechanics simulation. Next step a full nuclear plant?

One detail Ircvs, just for exiting the program... could you add a test like "if inkey=chr(27) then end" in your main loop. Or we have to kill the process.

Really good and funny job anyway!
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Re: Library for drawing turtle type (Logo turtle)

Post by lrcvs »

Hi, Tourist Trap:

Thank you very much for your interest in the program, ... but it's just a prototype, it is not definitive, there is an idea more.

I like to try some of the new features and do experiments with them.

I note your good observation, that's a big mistake on my part, I forget what the program will use others.

PS: I would like more to design a nuclear "fusion" and that worked well.
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Re: Library for drawing turtle type (Logo turtle)

Post by lrcvs »

Program Habichuela

Code: Select all

#include "turtle_8.bi"
DECLARE SUB circuito
DIM AS INTEGER j,k,n,z
DIM t AS STRING
t_init
COLOR RGB (255,255,255)
t_style_line_on()
t_thick = 1
t_model = t_patt (1)
j = 50
FOR n = 0 TO 180
    t = INKEY : IF t = CHR(27) THEN z = 1 : IF z = 1 THEN EXIT FOR
    SCREENLOCK
    CLS
    circuito
    COLOR RGB (255,0,0)
    t_pos_rot_x = 0
    t_pos_rot_y = 0
    t_rot_cir_l (215,n)
    t_star (17,20,10,(-n)*8)
    SCREENUNLOCK
    SLEEP j
NEXT n
':::::::::::::::::::::::::::::::
FOR n = 180 TO 360
    t = INKEY : IF t = CHR(27) THEN z = 1 : IF z = 1 THEN EXIT FOR
    SCREENLOCK
    CLS
    circuito
    COLOR RGB (255,0,0)
    t_pos_rot_x = -120
    t_pos_rot_y = 0
    t_rot_cir_l (95,n)
    t_star (17,20,10,(-n)*8)
    SCREENUNLOCK
    SLEEP j
NEXT n
':::::::::::::::::::::::::::::::
FOR n = 180 TO 0 STEP -1
    t = INKEY : IF t = CHR(27) THEN z = 1 : IF z = 1 THEN EXIT FOR
    SCREENLOCK
    CLS
    circuito
    COLOR RGB (255,0,0)
    t_pos_rot_x = 80
    t_pos_rot_y = -3
    t_rot_cir_r (105,-n)
    t_star (17,20,10,(n)*8)
    SCREENUNLOCK
    SLEEP j
NEXT n
':::::::::::::::::::::::::::::::
FOR n = 180 TO 360 STEP 5
    t = INKEY : IF t = CHR(27) THEN z = 1 : IF z = 1 THEN EXIT FOR
    SCREENLOCK
    CLS
    circuito
    COLOR RGB (255,0,0)
    t_pos_rot_x = 200
    t_pos_rot_y = 0
    t_rot_cir_l (15,n)
    t_star (17,20,10,(-n))
    SCREENUNLOCK
    SLEEP j
NEXT n
':::::::::::::::::::::::::::::::
':::::::::::::::::::::::::::::::
FOR n = 360 TO 180 STEP -1
    t = INKEY : IF t = CHR(27) THEN z = 1 : IF z = 1 THEN EXIT FOR
    SCREENLOCK
    CLS
    circuito
    COLOR RGB (0,255,0)
    t_pos_rot_x = 200
    t_pos_rot_y = 0
    t_rot_cir_r (55,-n)
    t_star (17,20,10,(n)*4)
    SCREENUNLOCK
    SLEEP j
NEXT n
':::::::::::::::::::::::::::::::
FOR n = 0 TO 180
    t = INKEY : IF t = CHR(27) THEN z = 1 : IF z = 1 THEN EXIT FOR
    SCREENLOCK
    CLS
    circuito
    COLOR RGB (0,255,0)
    t_pos_rot_x = 80
    t_pos_rot_y = -3
    t_rot_cir_r (65,-n)
    t_star (17,20,10,(-n)*4)
    SCREENUNLOCK
    SLEEP j
NEXT n
':::::::::::::::::::::::::::::::
FOR n = 360 TO 180 STEP -1
    t = INKEY : IF t = CHR(27) THEN z = 1 : IF z = 1 THEN EXIT FOR
    SCREENLOCK
    CLS
    circuito
    COLOR RGB (0,255,0)
    t_pos_rot_x = -120
    t_pos_rot_y = 0
    t_rot_cir_r (133,-n)
    t_star (17,20,10,(n)*8)
    SCREENUNLOCK
    SLEEP j
NEXT n
':::::::::::::::::::::::::::::::
FOR n = 180 TO 0  STEP -1
    t = INKEY : IF t = CHR(27) THEN z = 1 : IF z = 1 THEN EXIT FOR
    SCREENLOCK
    CLS
    circuito
    COLOR RGB (0,255,0)
    t_pos_rot_x = 0
    t_pos_rot_y = 0
    t_rot_cir_r (255,-n)
    t_star (17,20,10,(n)*8)
    SCREENUNLOCK
    SLEEP j
NEXT n
SLEEP
END

SUB circuito
    COLOR RGB (128,128,128)
    LINE (-300,285)-(300,-200),,b
    t_position_x = 0
    t_position_y = 0
    t_arc_sec_star (240,0,180,240,230,0,1)
    t_position_x = -120
    t_position_y = 0
    t_arc_sec_star (115,0,180,120,110,180,1)
    t_position_x = 80
    t_position_y = -3
    t_arc_sec_star (85,0,180,90,80,0,1)
    t_position_x = 200
    t_position_y = 0
    t_arc_sec_star (36,0,180,40,30,180,1)
END SUB   
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Library for drawing turtle type (Logo turtle)

Post by Tourist Trap »

lrcvs wrote:Program Habichuela

Code: Select all

..
error 41: Variable not declared, t_patt
Maybe you should add something like #lang "QB" ??
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Re: Library for drawing turtle type (Logo turtle)

Post by lrcvs »

Sorry!

Here:

Code: Select all

'turtle 8 basica >>> prototype #4'
'lrcvs 14.nov.15'

Declare Function t_ang (Byval t_x1 As Double, Byval t_y1 As Double, Byval t_x2 As Double,Byval t_y2 As Double) As Double
Declare Function t_apothem (Byval t_numsides As Integer, Byval t_radius As Double) As Double
Declare Function t_degrees (Byval t_rad As Double) As Double
Declare Function t_long (Byval t_x1 As Double, Byval t_y1 As Double, Byval t_x2 As Double, Byval t_y2 As Double) As Double
Declare Function t_lradius ( Byval t_long_side As Double, Byval t_num_sides As Integer) As Double
Declare Function t_radians (Byval t_angle As Double) As Double
Declare Function t_side (Byval t_position_x As Double, Byval t_position_y As Double, Byval t_radius As Double,  Byval t_numsides As Integer) As Double

Declare Sub t_pattern_off ()
Declare Sub t_pattern_on ()
Declare Sub t_primary_off ()
Declare Sub t_primary_on ()
Declare Sub t_secondary_off ()
Declare Sub t_secondary_on ()
Declare Sub t_arc_sec_cir (Byval t_r1 As Double , Byval t_ini As Double , Byval t_end As Double , Byval t_ang_rot As Double , Byval t_arc_sec_circle As Integer) 'draw a arc / sector of circle
Declare Sub t_arc_sec_star (Byval t_np As Integer , Byval t_ang_ini As Double , Byval t_ang_end As Double ,Byval t_rg As Double , Byval t_rp As Double , Byval t_ang_rot As Double, Byval t_arc_sec as double)
Declare Sub t_arc_sec_ellip (Byval t_r1 As Double , Byval t_r2 As Double , Byval t_ini As Double , Byval t_end As Double , Byval t_ang_rot As Double , Byval t_arc_sec_circle As Integer) 'draw a arc / sector of circle
Declare Sub t_axes ()
Declare Sub t_bk (Byval t_distance As Double)
Declare Sub t_circle (Byval t_r1 As Double)
Declare Sub t_ellipse (Byval t_r1 As Double , Byval t_r2 As Double , Byval t_ang_rot As Double)
Declare Sub t_fd (Byval t_distance As Double)
Declare Sub t_grid_1 (Byval t_step_grid As Double)
Declare Sub t_grid_2 (Byval t_step_grid As Double)
Declare Sub t_grid_3 (Byval t_step_grid As Double)
Declare Sub t_grid_4 (Byval t_step_grid As Double)
Declare Sub t_gt (Byval t_position_x As Double, Byval t_position_y As Double)
Declare Sub t_home
Declare Sub t_init ()
Declare Sub t_init_pattern ()
Declare Sub t_init_style_line ()
Declare Sub t_lt (Byval t_angle As Double)
Declare Sub t_orient_l (Byval t_angle As Double)
Declare Sub t_orient_r (Byval t_angle As Double)
Declare Sub t_ovoid (Byval t_r1 As Double, Byval t_r2 As Double, Byval t_ang_rot As Double) 
Declare Sub t_pattern_color (Byval t_distance As Double)
Declare Sub t_photo ()
Declare Sub t_poly (Byval t_long_side As Double, Byval t_num_sides As Integer, Byval t_ang_rot As Double)
Declare Sub t_pos (Byval t_position_x As Double, Byval t_position_x As Double)
Declare Sub t_pos_rot_xy(Byval t_pos_rot_x As Double, Byval t_pos_rot_y As Double)
Declare Sub t_rect_l (Byval t_side_upper As Double, Byval t_side_lower As Double, Byval t_ang_rot As Double)
Declare Sub t_rect_r (Byval t_side_upper As Double, Byval t_side_lower As Double, Byval t_ang_rot As Double)
Declare Sub t_rhombus (Byval t_rg As Double , Byval t_rp As Double , Byval t_ang_rot As Double)
Declare Sub t_rot_cir_l (Byval t_distance As Double,Byval t_angle As Double)
Declare Sub t_rot_cir_r (Byval t_distance As Double,Byval t_angle As Double)
Declare Sub t_rot_ellip_l (Byval t_r1 As Double, Byval t_r2 As Double, Byval t_angle As Double)
Declare Sub t_rot_ellip_r (Byval t_r1 As Double, Byval t_r2 As Double, Byval t_angle As Double)
Declare Sub t_rt (Byval t_angle As Double)
Declare Sub t_arc_star (Byval t_np As Integer , Byval t_ang_ini As Double , Byval t_ang_end As Double , Byval t_rg As Double , Byval t_rp As Double , Byval t_ang_rot As Double)
Declare Sub t_spring (t_ns As Integer , t_rs As Double , t_lo As Double) 'draw a t_spring
Declare Sub t_star (Byval t_np As Integer , Byval t_rg As Double , Byval t_rp As Double , Byval t_ang_rot As Double)
Declare Sub t_style_line_off ()
Declare Sub t_style_line_on ()
Declare Sub t_turtle_off ()
Declare Sub t_turtle_on ()

Const pi As Double = 3.1415926535897932
Const pi2 As Double = 2 * pi
Const t_number_aurum As Double = 1.6180339887498948
Const t_number_e As Double = 2.7182818284590452
Const t_const_radians = 0.01745329251994329576923690768489
Const t_const_degrees = 57.295779513082320876798154814105

Dim Shared As Integer t_c, t_rot, t_pattern , t_primary , t_secondary , t_c1 , t_c2 , t_c3 , t_center_screen_x , t_center_screen_y , t_h , t_inverse_pattern , t_style_line , t_turtle , t_w

Dim Shared As Double t_angle , t_distance , t_heading , t_new_position_x , t_new_position_y , t_pc , t_pos_rot_x , t_pos_rot_y , t_po_ro_x , t_po_ro_y ,t_pos_x , t_pos_y , t_position_x , t_position_y , t_radio , t_scale , t_thick

Dim Shared As String t_model
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Dim Shared As Double pics(18,4)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'A/a = 1   F/f = 6    K/k = 11    P/p = 16    V/v = 21
'B/b = 2   G/g = 7    L/l = 12    Q/q = 17    W/w = 22
'C/c = 3   H/h = 8    M/m = 13    R/r = 18    X/x = 23
'D/d = 4   I/i = 9    N/n = 14    T/t = 19    Y/y = 24
'E/e = 5   J/j = 10   O/o = 15    U/u = 20    Z/z = 25
'Uppers = On/1, Lowers = Off/0

Dim Shared As String t_patt (19)
t_patt (1) =  "A"        :   t_patt (10) =  "Fc"
t_patt (2) =  "Aa"       :   t_patt (11) =  "FcAc"
t_patt (3) =  "Bb"       :   t_patt (12) =  "FcAcAc"
t_patt (4) =  "Cc"       :   t_patt (13) =  "FcAcAcAc"
t_patt (5) =  "Ee"       :   t_patt (14) =  "FcFcAc"
t_patt (6) =  "Ff"       :   t_patt (15) =  "FcFcAcAc"
t_patt (7) =  "CcAc"     :   t_patt (16) =  "FcFcAcAcAc"
t_patt (8) =  "CcAcAc"   :   t_patt (17) =  "FcFcFcAc"
t_patt (9) =  "CcAcAcAc" :   t_patt (18) =  "FcFcFcAcAc"
t_patt (19) =  "LfLfLfAfAfAf"
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Function t_ang (Byval t_x1 As Double, Byval t_y1 As Double, Byval t_x2 As Double, Byval t_y2 As Double) As Double
	Dim As Double t_fang
	If t_x1 < t_x2 And t_y1 < t_y2 Then t_fang = t_degrees(Acos((t_x2 - t_x1)/Sqr (((t_x2 - t_x1)^2) + ((t_y2 - t_y1)^2))))
	If t_x1 > t_x2 And t_y1 < t_y2 Then t_fang = t_degrees(Acos((t_x2 - t_x1)/Sqr (((t_x2 - t_x1)^2) + ((t_y2 - t_y1)^2))))
	If t_x1 > t_x2 And t_y1 > t_y2 Then t_fang = 360 - (t_degrees(Acos((t_x2 - t_x1)/Sqr (((t_x2 - t_x1)^2) + ((t_y2 - t_y1)^2)))))
	If t_x1 < t_x2 And t_y1 > t_y2 Then t_fang = 360 - (t_degrees(Acos((t_x2 - t_x1)/Sqr (((t_x2 - t_x1)^2) + ((t_y2 - t_y1)^2)))))
	If t_x1 < t_x2 And t_y1 = t_y2 Then t_fang = 0
	If t_x1 = t_x2 And t_y1 < t_y2 Then t_fang = 90
	If t_x1 > t_x2 And t_y1 = t_y2 Then t_fang = 180
	If t_x1 = t_x2 And t_y2 < t_y1 Then t_fang = 270
	t_ang = t_fang
End Function

Function t_lradius ( Byval t_long_side As Double, Byval t_num_sides As Integer) As Double
    'calculate radius of one polygon
    t_lradius = (t_long_side * Sin(t_radians((180-(360/t_num_sides ))/2)))/Sin(t_radians(360/t_num_sides))
End Function

Function t_apothem (Byval t_numsides As Integer, Byval t_radius As Double) As Double
    'calculate apothem
	t_apothem = (Cos(t_radians((360/t_numsides)/2)) * t_radius)
End Function

Function t_degrees (Byval t_rad As Double) As Double
    'transform radians to degrees
	t_degrees = (t_rad * t_const_degrees)
End Function

Function t_long (Byval t_x1 As Double, Byval t_y1 As Double, Byval t_x2 As Double, Byval t_y2 As Double) As Double
    'calculate long point to point
	t_long = Sqr(Abs((t_x1 - t_x2)^2) + Abs((t_y1 - t_y2)^2))
End Function

Function t_radians (Byval t_angle As Double) As Double
    'transfor degrees to radians
	t_radians  =  (t_angle * t_const_radians )
End Function

Function t_side (Byval t_position_x As Double, Byval t_position_y As Double, Byval t_radius As Double,  Byval t_numsides As Integer) As Double
	Dim As Double t_rgrad, t_x0, t_y0, t_x1, t_y1
	t_rgrad = t_radians(0)
	t_x0 = (t_radius * Cos (t_rgrad)) + t_position_x
	t_y0 = (t_radius * Sin (t_rgrad)) + t_position_y
	t_rgrad = t_radians(360 / t_numsides)
	t_x1 = (t_radius * Cos (t_rgrad)) + t_position_x
	t_y1 = (t_radius * Sin (t_rgrad)) + t_position_y
	t_side= t_long (t_x0, t_y0, t_x1, t_y1)
End Function

Sub t_pattern_off
	t_pattern = 0
End Sub

Sub t_pattern_on
	t_pattern = 1
End Sub

Sub t_primary_off
	t_primary = 0
End Sub

Sub t_primary_on
	t_primary = 1
End Sub

Sub t_secondary_off
	t_secondary = 0
End Sub

Sub t_secondary_on
	t_secondary = 1
End Sub

Sub t_axes ()
    Line(-t_w/2  , t_center_screen_y) - ( t_w/2 , t_center_screen_y ) 
    Line( t_center_screen_x ,-t_h/2 ) - ( t_center_screen_x , t_h/2 ) 
End Sub

Sub t_bk (Byval t_distance As Double)
	Dim As Integer t_a, t_vm, t_dist
    Dim As Double t_x2, t_y2, t_x3, t_y3
    
	If t_turtle = 0 Then
		t_new_position_x = t_position_x - ((t_distance * t_scale) * Cos(t_heading))
		t_new_position_y = t_position_y + ((t_distance * t_scale) * Sin(t_heading))
		t_position_x = t_new_position_x
		t_position_y = t_new_position_y
    End If
	If t_turtle = 1 And t_style_line = 0 Then
		t_new_position_x = t_position_x - ((t_distance * t_scale) * Cos(t_heading))
		t_new_position_y = t_position_y + ((t_distance * t_scale) * Sin(t_heading))
		Line (t_position_x, t_position_y)-(t_new_position_x, t_new_position_y)
		t_position_x = t_new_position_x
		t_position_y = t_new_position_y
    End If
	If t_turtle = 1 And t_style_line = 1 Then
        t_a = Len(t_model)
        For  t_dist =   1  To  t_distance
            t_vm = (Asc (Mid(t_model,t_c1, 1)))
            If  t_vm > 64  And t_vm < 91 Then 
                t_x2 = t_position_x - ((t_dist* t_scale) * Cos(t_heading))
                t_y2 = t_position_y + ((t_dist* t_scale) * Sin(t_heading))
                If t_thick = 0 Then
                    Pset (t_x2, t_y2)
                Else
                    If t_c > 0 Then Circle (t_x2, t_y2), t_thick,,,,,f
                End If
                t_c2 = t_c2 + 1
                If t_c2 > (t_vm -64) Then t_c2 =  1 : t_c1 = t_c1 +1
                If t_c1 >  t_a Then t_c1 =1
            End If
            
            If  t_vm > 96 And t_vm < 123  Then 
                t_x3 = t_position_x - ((t_dist* t_scale) * Cos(t_heading))
                t_y3 = t_position_y + ((t_dist* t_scale) * Sin(t_heading))
                If t_thick = 0 Then
                    'pset (t_x3, t_y3)
                Else
                    'circle (t_x3, t_y3), t_thick,,,,,f
                End If
                t_c3 = t_c3 + 1
                If t_c3 > (t_vm -96) Then t_c3 =  1 : t_c1 = t_c1 +1
                If t_c1 >  t_a Then t_c1 =1
            End If
        Next t_dist
        t_position_x =  t_position_x + ((t_distance * t_scale) * Cos(t_heading))
        t_position_y =  t_position_y - ((t_distance * t_scale) * Sin(t_heading))
    End If
    
End Sub

Sub t_fd (Byval t_distance As Double)
    Dim As Integer t_a, t_vm, t_dist
    Dim As Double t_x2, t_y2, t_x3, t_y3
    
    If t_turtle = 0 And t_style_line = 0 Then
        t_new_position_x = t_position_x + ((t_distance * t_scale) * Cos(t_heading))
        t_new_position_y = t_position_y - ((t_distance * t_scale) * Sin(t_heading))
        t_position_x = t_new_position_x
        t_position_y = t_new_position_y
    End If
    If t_turtle = 1 And t_style_line = 0 and t_c > 0 Then
        t_new_position_x = t_position_x + ((t_distance * t_scale) * Cos(t_heading))
        t_new_position_y = t_position_y - ((t_distance * t_scale) * Sin(t_heading))
        Line (t_position_x, t_position_y)-(t_new_position_x, t_new_position_y)
        t_position_x = t_new_position_x
        t_position_y = t_new_position_y
    End If
    
    If t_turtle = 1 And t_style_line = 1 Then
        t_a = Len(t_model)
        For  t_dist =   1  To  t_distance
            t_vm = (Asc (Mid(t_model,t_c1, 1)))
            If  t_vm > 64  And t_vm < 91 Then 
                t_x2 = t_position_x + ((t_dist* t_scale) * Cos(t_heading))
                t_y2 = t_position_y - ((t_dist* t_scale) * Sin(t_heading))
                If t_thick = 0 Then
                    Pset (t_x2, t_y2)
                    
                Else
                    If t_c > 0 Then Circle (t_x2, t_y2), t_thick,,,,,f

                    
                End If
                t_c2 = t_c2 + 1
                If t_c2 > (t_vm -64) Then t_c2 =  1 : t_c1 = t_c1 +1
                If t_c1 >  t_a Then t_c1 =1
            End If
            
            If  t_vm > 96 And t_vm < 123  Then 
                t_x3 = t_position_x + ((t_dist* t_scale) * Cos(t_heading))
                t_y3 = t_position_y - ((t_dist* t_scale) * Sin(t_heading))
                If t_thick = 0 Then
                    'pset (t_x3, t_y3)
                Else
                    'circle (t_x3, t_y3), t_thick,,,,,f
                End If
                t_c3 = t_c3 + 1
                If t_c3 > (t_vm -96) Then t_c3 =  1 : t_c1 = t_c1 +1
                If t_c1 >  t_a Then t_c1 =1
            End If
            
        Next t_dist
        t_position_x =  t_position_x + ((t_distance * t_scale) * Cos(t_heading))
        t_position_y =  t_position_y - ((t_distance * t_scale) * Sin(t_heading))
        
    End If
    
    If t_turtle = 0 And t_style_line = 1 Then
        t_a = Len(t_model)
        For  t_dist =   1  To  t_distance
            t_vm = (Asc (Mid(t_model,t_c1, 1)))
            If  t_vm > 64  And t_vm < 91 Then 
                t_x2 = t_position_x + ((t_dist* t_scale) * Cos(t_heading))
                t_y2 = t_position_y - ((t_dist* t_scale) * Sin(t_heading))
                'if t_thick = 0 then
                
                'pset (t_x2, t_y2)
                
                'else
                'if t_c > 0 then circle (t_x2, t_y2), t_thick,,,,,f
                
                'end if
                t_c2 = t_c2 + 1
                If t_c2 > (t_vm -64) Then t_c2 =  1 : t_c1 = t_c1 +1
                If t_c1 >  t_a Then t_c1 =1
            End If
            
            If  t_vm > 96 And t_vm < 123  Then 
                t_x3 = t_position_x + ((t_dist* t_scale) * Cos(t_heading))
                t_y3 = t_position_y - ((t_dist* t_scale) * Sin(t_heading))
                'if t_thick = 0 then
                'pset (t_x3, t_y3)
                'else
                'circle (t_x3, t_y3), t_thick,,,,,f
                'end if
                t_c3 = t_c3 + 1
                If t_c3 > (t_vm -96) Then t_c3 =  1 : t_c1 = t_c1 +1
                If t_c1 >  t_a Then t_c1 =1
            End If
            
        Next t_dist
        
        t_position_x =  t_position_x + ((t_distance * t_scale) * Cos(t_heading))
        t_position_y =  t_position_y - ((t_distance * t_scale) * Sin(t_heading))
    End If
End Sub

Sub t_grid_1 (Byval t_step_grid As Double)
    Dim t_n As Double
    For t_n = -t_h To t_h Step t_step_grid 
        Line(-t_w , t_n) - (t_w , t_n),Color Rgb (128,128,128)   'lineas horizontales
    Next t_n
End Sub

Sub t_grid_2 (Byval t_step_grid As Double)
    Dim t_n As Double
    For t_n = -t_w To t_w Step t_step_grid 
        Line(t_n , -t_h) - (t_n , t_h),Color Rgb (128,128,128)  'lineas verticales
    Next t_n
End Sub


Sub t_grid_3(Byval t_step_grid As Double) 
    Dim t_n As Double
    For t_n = 0 To t_h Step t_step_grid 
        Circle (0, 0), t_n ,Color Rgb (128,128,128) 'dibuja circulos concentricos
    Next t_n
End Sub

Sub t_grid_4 (Byval t_step_grid As Double)
    Dim t_n As Double
    t_style_line_off
    Color Rgb (128,128,128)
    For t_n = 0 To 360 Step t_step_grid 
        'aqui dibujamos los radios/angulos
        t_orient_l t_n
        t_pos (0 ,0)
        t_fd t_w
    Next t_n
    t_style_line_on
End Sub

Sub t_gt (Byval t_pos_x As Double, Byval t_pos_y As Double)
	t_position_x = t_center_screen_x + (t_pos_x * t_scale)
	t_position_y = t_center_screen_y + (t_pos_y * t_scale)
End Sub

Sub t_home ()
	t_position_x = t_center_screen_x
	t_position_y = t_center_screen_y
End Sub

Sub t_init ()
	Screen 19,32
	Screeninfo t_w , t_h
	Window (-t_w/2,-t_h/2)-(t_w/2,t_h/2)
	t_pattern_on
    t_init_pattern
	t_center_screen_x = 0
	t_center_screen_y = 0
	t_gt (t_position_x , t_position_y)
	t_init_style_line
	t_model = "z"
	t_new_position_x = t_position_x
	t_new_position_y = t_position_y
	t_position_x = t_center_screen_x
	t_position_y = t_center_screen_y
	t_scale = 1
	t_style_line_off
	t_thick = 0
	t_turtle_on
    t_secondary_on
    t_secondary_off
End Sub

Sub t_init_style_line ()
	t_c1 = 1 : t_c2 = 1 : t_c3 = 1
End Sub

Sub t_init_pattern ()
    t_c1 = 1
    t_c2 = 1
    t_c3 = 1
End Sub

Sub t_lt (Byval t_angle As Double)
	t_heading = t_heading - t_radians (t_angle)
End Sub

Sub t_orient_l (Byval t_angle As Double)
	t_heading = t_radians (t_angle * (- 1))
End Sub

Sub t_orient_r (Byval t_angle As Double)
	t_heading = t_radians (t_angle)
End Sub

Sub t_pattern_color (Byval t_distance As Double)
    Dim As Integer t_a, t_vm
    Dim As Double t_x2, t_y2, t_x3, t_y3
    
    t_a = Len(t_model)
    t_vm = (Asc (Mid(t_model,t_c1, 1)))
    If  t_vm > 64  And t_vm < 91 Then 
        t_x2 = t_position_x + ((t_distance * t_scale) * Cos(t_heading))
        t_y2 = t_position_y - ((t_distance * t_scale) * Sin(t_heading))
        If t_thick = 0 Then
            Pset (t_x2, t_y2)
        Else
            Circle (t_x2, t_y2), t_thick,,,,,f
        End If
        t_c2 = t_c2 + 1
        If t_c2 > (t_vm -64) Then t_c2 =  1 : t_c1 = t_c1 +1
        If t_c1 >  t_a Then t_c1 =1
    End If
    
    If  t_vm > 96 And t_vm < 123  Then 
        t_x3 = t_position_x + ((t_distance * t_scale) * Cos(t_heading))
        t_y3 = t_position_y - ((t_distance * t_scale) * Sin(t_heading))
        If t_thick = 0 Then
            'pset (t_x3, t_y3)
        Else
            'circle (t_x3, t_y3), t_thick,,,,,f
        End If
        t_c3 = t_c3 + 1
        If t_c3 > (t_vm -96) Then t_c3 =  1 : t_c1 = t_c1 +1
        If t_c1 >  t_a Then t_c1 =1
    End If
    t_position_x =  t_position_x + ((t_distance * t_scale) * Cos(t_heading))
    t_position_y =  t_position_y - ((t_distance * t_scale) * Sin(t_heading))
End Sub 


Sub t_photo ()
	Dim As Integer t_nn, t_long_date_time
	Dim As String t_date_time, t_name_photo, t_photo_y
	t_date_time = Date
	t_long_date_time = Len (t_date_time)
	t_name_photo = ""
	t_photo_y = ""
	For t_nn = 1 To t_long_date_time
		t_photo_y= Mid(t_date_time,t_nn,1)
		If t_photo_y <> "-" Then t_name_photo = t_name_photo + t_photo_y
    Next t_nn
	t_name_photo = t_name_photo + "_"
	t_date_time = Time
	t_long_date_time = Len (t_date_time)
	t_photo_y = ""
	For t_nn = 1 To t_long_date_time
		t_photo_y= Mid(t_date_time,t_nn,1)
		If t_photo_y <> ":" Then t_name_photo = t_name_photo + t_photo_y
    Next t_nn
	Bsave t_name_photo+".bmp",0
End Sub

Sub t_pos (Byval t_pos_x As Double, Byval t_pos_y As Double)
	t_turtle_off
	t_gt (t_pos_x, t_pos_y)
	t_turtle_on
End Sub

Sub t_pos_rot_xy(Byval t_po_ro_x As Double, Byval t_po_ro_y As Double)
	t_pos_rot_x = t_po_ro_x
	t_pos_rot_y = t_po_ro_y
End Sub

Sub t_rot_cir_l (Byval t_distance As Double, Byval t_angle As Double)
	t_pos_rot_x = ((t_distance * t_scale) * Cos(t_radians (t_angle)))+t_pos_rot_x
	t_pos_rot_y = ((t_distance * t_scale) * Sin(t_radians (t_angle)))+t_pos_rot_y
	t_heading = t_radians (t_angle * (- 1))
    t_position_x = t_pos_rot_x
    t_position_y = t_pos_rot_y
    t_rot = 1
End Sub

Sub t_rot_cir_r (Byval t_distance As Double, Byval t_angle As Double)
	t_pos_rot_x = ((t_distance * t_scale) * Cos(t_radians (t_angle*-1)))+t_pos_rot_x
	t_pos_rot_y = ((t_distance * t_scale) * Sin(t_radians (t_angle*-1)))+t_pos_rot_y
	t_heading = t_radians (t_angle)
    t_position_x = t_pos_rot_x
    t_position_y = t_pos_rot_y
    t_rot = 1
End Sub

Sub t_rot_ellip_l (Byval t_r1 As Double, Byval t_r2 As Double, Byval t_angle As Double)
	t_pos_rot_x = ((t_r1 * t_scale) * Cos(t_radians (t_angle)))+t_pos_rot_x
	t_pos_rot_y = ((t_r2 * t_scale) * Sin(t_radians (t_angle)))+t_pos_rot_y
	t_heading = t_radians (t_angle * (- 1))
    t_position_x = t_pos_rot_x
    t_position_y = t_pos_rot_y
    t_rot = 1
End Sub

Sub t_rot_ellip_r (Byval t_r1 As Double, Byval t_r2 As Double, Byval t_angle As Double)
	t_pos_rot_x = ((t_r1 * t_scale) * Cos(t_radians (t_angle*-1)))+t_pos_rot_x
	t_pos_rot_y = ((t_r2 * t_scale) * Sin(t_radians (t_angle*-1)))+t_pos_rot_y
	t_heading = t_radians (t_angle)
    t_position_x = t_pos_rot_x
    t_position_y = t_pos_rot_y
    t_rot = 1
End Sub


Sub t_rt (Byval t_angle As Double)
	t_heading = t_heading + t_radians (t_angle)
End Sub

Sub t_style_line_off ()
	t_style_line = 0
End Sub

Sub t_style_line_on ()
	t_style_line = 1
End Sub

Sub t_turtle_off ()
	t_turtle = 0
End Sub

Sub t_turtle_on ()
	t_turtle = 1
End Sub

Sub t_circle (Byval t_r1 As Double)
    Dim As Double t_grad , t_grad2, t_x0 , t_y0  
    For t_grad = 0 To 360
        t_grad2 = t_radians(t_grad)
        t_x0 = t_r1 * Cos(t_grad2) 
        t_y0 = t_r1 * Sin(t_grad2) 
        t_position_x = t_x0 + t_pos_rot_x
        t_position_y = t_y0 + t_pos_rot_y
        t_fd 1
    Next t_grad
    
End Sub


Sub t_arc_sec_cir (Byval t_r1 As Double , Byval t_ini As Double , Byval t_end As Double , Byval t_ang_rot As Double , Byval t_arc_sec_circle As Integer) 'draw a arc / sector of circle
    Dim z As Integer
    Dim As Double t_px, t_py , t_grad , t_grad2, t_x0 , t_y0 
    'draw a arc or sector cir
    't_r = radius circle
    't_ini = angle init
    't_end = angle end
    't_ang_rot = angle of rotation
    't_arc_sec_cir = 0 = arc / 1 = sector
    t_c = 1
    If t_arc_sec_circle = 1 Then
        'radios
        'if t_rot = 1 then t_ang_rot = t_heading

        t_orient_l 0
        t_pos (t_pos_rot_x,t_pos_rot_y)
        t_orient_l t_ini + t_ang_rot
        t_fd t_r1

        t_orient_l 0
        t_pos (t_pos_rot_x,t_pos_rot_y)
        t_orient_l t_end + t_ang_rot
        t_fd t_r1
        
    End If
    
    t_orient_r 0
    t_pos (t_px, t_py)
    t_ang_rot = t_radians (t_ang_rot)
    'if t_rot = 1 then t_ang_rot = t_heading
    For t_grad = t_ini To t_end
        t_grad2 = t_radians(t_grad)
        t_x0 = (((t_r1) * Cos(t_grad2))* Cos (t_ang_rot)) - (((t_r1) * Sin(t_grad2)) * Sin (t_ang_rot))
        t_y0 = (((t_r1) * Cos(t_grad2))* Sin (t_ang_rot)) + (((t_r1) * Sin(t_grad2)) * Cos (t_ang_rot))
        t_position_x = t_x0 + t_pos_rot_x
        t_position_y = t_y0 + t_pos_rot_y
        t_fd 1
    Next t_grad
End Sub

Sub t_ang_cir (Byval t_r1 As Double , Byval t_ini As Double , Byval t_end As Double , Byval t_ang_rot As Double ) 'draw a angle of circle
    Dim z As Integer
    Dim As Double t_px, t_py , t_grad , t_grad2, t_x0 , t_y0 
    'draw a arc or sector cir
    't_r = radius circle
    't_ini = angle init
    't_end = angle end
    't_ang_rot = angle of rotation
    't_arc_sec_cir = 0 = arc / 1 = sector
    t_c = 1
        'radios
        'if t_rot = 1 then t_ang_rot = t_heading

        t_orient_l 0
        t_pos (t_pos_rot_x,t_pos_rot_y)
        t_orient_l t_ini + t_ang_rot
        t_fd t_r1

        t_orient_l 0
        t_pos (t_pos_rot_x,t_pos_rot_y)
        t_orient_l t_end + t_ang_rot
        t_fd t_r1
End Sub


Sub t_ellipse (Byval t_r1 As Double , Byval t_r2 As Double , Byval t_ang_rot As Double)
    Dim As Double t_grad , t_grad2, t_x0 , t_y0 
    t_c = 0
    t_ang_rot = t_radians (t_ang_rot)
    If t_rot = 1 Then t_ang_rot = t_heading
    For t_grad = t_ang_rot To t_ang_rot + 360
        t_grad2 = t_radians(t_grad)
        t_x0 = ((t_r1 * Cos(t_grad2)) * Cos (t_ang_rot)) - ((t_r2 * Sin(t_grad2)) * Sin (t_ang_rot))
        t_y0 = ((t_r1 * Cos(t_grad2)) * Sin (t_ang_rot)) + ((t_r2 * Sin(t_grad2)) * Cos (t_ang_rot))
        't_position_x = t_x0 + t_pos_rot_x
        't_position_y = t_y0 + t_pos_rot_y
        t_fd 1
    T_C = 1
    Next t_grad
End Sub

Sub t_arc_sec_ellip (Byval t_r1 As Double , Byval t_r2 As Double , Byval t_ini As Double , Byval t_end As Double , Byval t_ang_rot As Double , Byval t_arc_sec_circle As Integer) 'draw a arc / sector of circle
    Dim z As Integer
    Dim As Double t_px, t_py , t_grad , t_grad2, t_x0 , t_y0 
    'draw a arc or sector cir
    't_r = radius circle
    't_ini = angle init
    't_end = angle end
    't_ang_rot = angle of rotation
    't_arc_sec_cir = 0 = arc / 1 = sector
    t_c = 1
    If t_arc_sec_circle = 1 Then
        'radios
        'if t_rot = 1 then t_ang_rot = t_heading
        t_orient_l 0
        t_px = t_pos_rot_x
        t_py = t_pos_rot_y
        t_pos (t_px, t_py)
        t_orient_l t_ang_rot
        t_fd t_r1
        
        t_orient_r 0
        t_pos (t_px, t_py)
        t_orient_l t_end + t_ang_rot
        t_fd t_r2
    End If
    
    t_orient_r 0
    t_pos (t_px, t_py)
    t_ang_rot = t_radians (t_ang_rot)
    'if t_rot = 1 then t_ang_rot = t_heading
    For t_grad = t_ini To t_end
        t_grad2 = t_radians(t_grad)
        t_x0 = (((t_r1) * Cos(t_grad2))* Cos (t_ang_rot)) - (((t_r2) * Sin(t_grad2)) * Sin (t_ang_rot))
        t_y0 = (((t_r1) * Cos(t_grad2))* Sin (t_ang_rot)) + (((t_r2) * Sin(t_grad2)) * Cos (t_ang_rot))
        t_position_x = t_x0 + t_pos_rot_x
        t_position_y = t_y0 + t_pos_rot_y
        t_fd 1
    Next t_grad
End Sub


Sub t_poly (Byval t_long_side As Double, Byval t_num_sides As Integer, Byval t_ang_rot As Double)
    Dim As Double t_pol,t_x0,t_y0,t_x1,t_y1
    t_c = 0
    For t_pol  = t_ang_rot To 361 + (t_ang_rot ) Step 360/t_num_sides
        t_x1 = (t_lradius(t_long_side, t_num_sides)  * Cos(t_radians(t_pol)))
        t_y1 = (t_lradius(t_long_side, t_num_sides)  * Sin(t_radians(t_pol)))
        t_orient_l (t_ang (t_x0,t_y0,t_x1,t_y1)+ t_ang_rot )
        t_fd (t_long  (t_x0,t_y0,t_x1,t_y1))
        t_x0 = t_x1
        t_y0 = t_y1
        t_c = t_c + 1
    Next t_pol
    
End Sub

Sub t_rect_l (Byval t_side_upper As Double, Byval t_side_lower As Double, Byval t_ang_rot As Double)
    t_c = 1
    t_orient_l t_ang_rot
    t_turtle_off
    t_fd t_side_upper / 2
    t_turtle_on
    t_lt 90
    t_fd t_side_lower / 2
    t_lt 90
    t_fd t_side_upper
    t_lt 90
    t_fd t_side_lower
    t_lt 90
    t_fd t_side_upper
    t_lt 90
    t_fd t_side_lower / 2
End Sub

Sub t_rect_r (Byval t_side_upper As Double, Byval t_side_lower As Double, Byval t_ang_rot As Double)
    t_c = 1
    t_orient_r t_ang_rot
    t_turtle_off
    t_fd t_side_upper / 2
    t_turtle_on
    t_lt 90
    t_fd t_side_lower / 2
    t_lt 90
    t_fd t_side_upper
    t_lt 90
    t_fd t_side_lower
    t_lt 90
    t_fd t_side_upper
    t_lt 90
    t_fd t_side_lower / 2
End Sub

Sub t_ovoid (Byval t_r1 As Double, Byval t_r2 As Double, Byval t_ang_rot As Double) 
    t_c = 1
    t_arc_sec_ellip (t_r1,t_r2,0,180,t_ang_rot,0)
    t_arc_sec_cir (t_r1,180,360,t_ang_rot,0)
    't_arc_sec_ellip (t_r1,t_r2,180,360,t_ang_rot,0)
End Sub

Sub t_spring (t_ns As Integer , t_rs As Double , t_lo As Double) 'draw a t_spring
    Dim t_n As Integer
    't_ns = number of spirals
    't_rs = stretch of spiral 0...90
    't_lo = long of spiral
    t_c = 1
    For t_n = 1 To t_ns
        t_rt t_rs
        t_fd t_lo
        t_lt t_rs * 2
        t_fd t_lo
        t_rt t_rs
    Next t_n
End Sub

Sub t_star (Byval t_np As Integer , Byval t_rg As Double , Byval t_rp As Double , Byval t_ang_rot As Double)
    Dim As Double t_x0,t_y0,t_x1,t_y1,t_n, t_x2, t_y2
    t_c =0
    For  t_n = 0  To 360  + ((360/(t_np*2)))  Step  360/(t_np*2)
        If  t_c Mod 2  = 0  Then
            t_x1 = (t_rp  * Cos(t_radians(t_n)))
            t_y1 = (t_rp  * Sin(t_radians(t_n)))
        Else
            t_x1  = (t_rg  * Cos(t_radians(t_n)))
            t_y1 =  (t_rg  * Sin(t_radians(t_n)))
        End If
        t_orient_l (t_ang (t_x0,t_y0,t_x1,t_y1)+ t_ang_rot )
        t_fd (t_long  (t_x0,t_y0,t_x1,t_y1))
        t_x0 = t_x1
        t_y0 = t_y1
        t_c = t_c  +  1
    Next t_n
End Sub

Sub t_arc_sec_star (Byval t_np As Integer , Byval t_ang_ini As Double , Byval t_ang_end As Double ,Byval t_rg As Double , Byval t_rp As Double , Byval t_ang_rot As Double, Byval t_arc_sec as double)
'sector de estrella
    Dim As Double t_x0,t_y0,t_x1,t_y1,t_n, t_x2, t_y2
    t_c =0
    For  t_n = t_ang_ini  To t_ang_end  Step  (360/(t_np*2))
        If  t_c Mod 2  = 0  Then
            t_x1 = (t_rp  * Cos(t_radians(t_n)))
            t_y1 = (t_rp  * Sin(t_radians(t_n)))
        Else
            t_x1  = (t_rg  * Cos(t_radians(t_n)))
            t_y1 =  (t_rg  * Sin(t_radians(t_n)))
        End If

        t_orient_l (t_ang (t_x0,t_y0,t_x1,t_y1)+ t_ang_rot )
        t_fd (t_long  (t_x0,t_y0,t_x1,t_y1))
        t_x0 = t_x1
        t_y0 = t_y1
        t_c = t_c  +  1
    Next t_n

End Sub


Sub t_rhombus (Byval t_rg As Double , Byval t_rp As Double , Byval t_ang_rot As Double)
    Dim As Double t_x0,t_y0,t_x1,t_y1,t_n, t_x2, t_y2
    t_c =0
    For  t_n = 0 To 360 Step 90
        If  t_c Mod 2  = 0  Then
            t_x1 = (t_rp  * Cos(t_radians(t_n)))
            t_y1 = (t_rp  * Sin(t_radians(t_n)))
        Else
            t_x1  = (t_rg  * Cos(t_radians(t_n)))
            t_y1 =  (t_rg  * Sin(t_radians(t_n)))
        End If
        t_orient_l (t_ang (t_x0,t_y0,t_x1,t_y1)+ t_ang_rot )
        t_fd (t_long  (t_x0,t_y0,t_x1,t_y1))
        t_x0 = t_x1
        t_y0 = t_y1
        t_c = t_c  +  1
    Next t_n
End Sub

regards
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Library for drawing turtle type (Logo turtle)

Post by Tourist Trap »

Nice!

Ok this work now, but no critizism just a remark. Could you use fullscreen screen flag (GFX_FULLSCREEN with SCREENRES)? or set a little screen like 800x600? It's that not everyone runs on more than 1024, as I guess you do.

Thanks anyway. That works well.
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Re: Library for drawing turtle type (Logo turtle)

Post by lrcvs »

Hi, Tourist Trap:

OK, as always thank you for your observations.

The display mode is very simple to modify.:
In Turtle_8.bi.
In SUB T_INIT.
mode is now:
Screen 19,32 = 800 * 600, 32 Bits

You can modify / adapt it as you want.!

::::::::::::::::::::::::::::::::::::::::::::::::::

Well, this work is very simple, possibly ugly, but I wanted to show that it is possible to draw a via / rail / track with a gear with either straight, circular or curved paths with different angles / curvature.

Previously, only to circular gears, now, I can make any angle, radius and length of teeth and shape (triangular, square, elliptical, etc, etc), (for parts / pieces)

Cheers
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Library for drawing turtle type (Logo turtle)

Post by Tourist Trap »

lrcvs wrote:The display mode is very simple to modify.:
In Turtle_8.bi.
In SUB T_INIT.
mode is now:
Screen 19,32 = 800 * 600, 32 Bits

You can modify / adapt it as you want.!
Yes you are true of course. But for the definitive comfort of the user that want to run your demos, maybe you should make things like below:

Code: Select all

'********************
'turtle.bi
''
''
'********************

'no include needed
'demo in the same file
'so --> SELECT ALL CODE
'and do a quick run
'is sufficent

'********************
'particular demo code
'+ an escape possibility 
'from any infinite loop
'+ a screen not too big
''for the comfort of
''maximum people
'********************
You still can update the turtle.bi alone in the first page, or somewhere. But when you send a demo, best if you use only one (1) file with 'turtle.bi+demo' together.Personally it's what I do when I post a demo in general for any object. It's so much easier for the people then: just code copy+quick_run!

By the way that's really interesting work that you do. Thanks again!
lrcvs
Posts: 578
Joined: Mar 06, 2008 19:27
Location: Spain

Re: Library for drawing turtle type (Logo turtle)

Post by lrcvs »

Hi,Tourist Trap:

Ok!

You have every reason to improve the demo programs.

Greetings
Post Reply