zak
20-08-2011, 17:36
here is some canvas graphics which form collectively the figure of the helicopter. the coordinates i have copied from a perl source code with module TK, in TK the arc have more features which i have'nt studied yet.
attached the source code of thinbasic and of perl/tk
thinbasic helicopter:
7419
perl/tk helicopter:
7420
Uses "ui" ,"math"
Function TBMain()
Dim hWin, i As Long
Dim x(8), y(8) As Long
Type PolyPoint
x As Single
y As Single
End Type
Type PolyArray
COUNT As Long
'xy(1024) As PolyPoint 'note, this 1024 represents the maximum points that can be handled
xy(8) As PolyPoint
End Type
hWin = Canvas_Window("Helicopter", 1, 1, 640, 480 )
Canvas_Attach(hWin, 0, %TRUE) ' <- double buffer
'---Init canvas
Canvas_Clear(%BLACK)
Dim pa As PolyArray
Dim pp(8) As PolyPoint
pa.count = 8 '---Indicate you need 8 vertex
'=====================================================
x(1) = 107,322,322,352
y(1) = 114,148,114,114
pa.count = 4 '---Indicate you need 3 vertex
For i=1 To 4
pa.xy(i).x = x(i)
pa.xy(i).y = y(i)
Next i
Canvas_Polygon pa, Rgb(255, 0, 255), Rgb(5,128,0), %CANVAS_FILLSTYLE_DIAGONALCROSSEDLINES
'=====================================================
x(1) = 255,388,490,158
y(1) = 35,71,51,55
pa.count = 4 '---Indicate you need 4 vertex
For i=1 To 4
pa.xy(i).x = x(i)
pa.xy(i).y = y(i)
Next i
Canvas_Polygon pa, Rgb(255, 0, 255), Rgb(5,128,0), %CANVAS_FILLSTYLE_SOLID
'=====================================================
x(1) = 109,108,121.5,97
y(1) = 78, 151,125,103
pa.count = 4 '---Indicate you need 4 vertex
For i=1 To 4
pa.xy(i).x = x(i)
pa.xy(i).y = y(i)
Next i
'tail propeller
Canvas_Polygon pa, Rgb(255, 0, 0), Rgb(255,0,0), %CANVAS_FILLSTYLE_SOLID
'=====================================================
Canvas_Width(3)
'helicopter Cockpit
Canvas_Arc(247, 58, 396, 170, Pi/2 ,Pi,Rgb(255, 0, 0) )
Canvas_Arc(274, 57, 355, 165,0,Pi/2 ,Rgb(255, 0, 0) )
Canvas_Arc(288,79,355,148,-Pi/2, 0 ,Rgb(255, 0, 0) )
'helicopter wheel
Canvas_Ellipse(311,142,333,164, Rgb(255, 0, 0),Rgb(100, 22, 0))
Canvas_Redraw
Canvas_WaitKey
End Function
the perl/tk code:
#!/usr/local/bin/perl
use strict;
use Tk;
use Tk::Canvas;
my $mw=MainWindow->new();
my $c=$mw->Canvas(-width=>490,-height=>170)->pack;
# Helicopter (c) Felix Liberman
$c->configure(-background=>'lightblue');
#front glass
my $cnv_Chord_11 = $c->create('arc',274.00,57.00,355.00,165.00,-start,356.00,-fill,'Blue',-extent,82.00,-style,'chord',-tags=>['cnv_Chord_11','cnv_obj']);
#cocktail backglass
my $cnv_Pie_12 = $c->create('arc',247.00,58.00,396.00,170.00,-start,90.00,-fill,'Cyan',-extent,90.00,-tags=>['cnv_Pie_12','cnv_obj']);
#tail
my $cnv_Polygon_13 = $c->create('polygon',107.00,114.00,322.00,114.00,322.00,148.00,-fill,'Cyan',-outline,'Black',-tags=>['cnv_Polygon_13','cnv_obj']);
my $cnv_Splash_14 = $c->create('polygon',255.00,35.00,388.50,71.00,490.00,51.00,158.00,55.00,-smooth,1.00,-tags=>['cnv_Splash_14','cnv_obj']);
#front bottom of the cockpit
my $cnv_Pie_15 = $c->create('arc',288.00,79.00,355.00,148.00,-start,270.00,-fill,'Cyan',-extent,90.00,-tags=>['cnv_Pie_15','cnv_obj']);
#wheel
my $cnv_Circle_16 = $c->create('oval',311.00,142.00,333.00,164.00,-width,10.00,-tags=>['cnv_Circle_16','cnv_obj']);
#tail propeller
my $cnv_Splash_17 = $c->create('polygon',109.00,78.00,108.00,151.00,121.50,125.00,97.00,103.00,-smooth,1.00,-tags=>['cnv_Splash_17','cnv_obj']);
MainLoop;
attached the source code of thinbasic and of perl/tk
thinbasic helicopter:
7419
perl/tk helicopter:
7420
Uses "ui" ,"math"
Function TBMain()
Dim hWin, i As Long
Dim x(8), y(8) As Long
Type PolyPoint
x As Single
y As Single
End Type
Type PolyArray
COUNT As Long
'xy(1024) As PolyPoint 'note, this 1024 represents the maximum points that can be handled
xy(8) As PolyPoint
End Type
hWin = Canvas_Window("Helicopter", 1, 1, 640, 480 )
Canvas_Attach(hWin, 0, %TRUE) ' <- double buffer
'---Init canvas
Canvas_Clear(%BLACK)
Dim pa As PolyArray
Dim pp(8) As PolyPoint
pa.count = 8 '---Indicate you need 8 vertex
'=====================================================
x(1) = 107,322,322,352
y(1) = 114,148,114,114
pa.count = 4 '---Indicate you need 3 vertex
For i=1 To 4
pa.xy(i).x = x(i)
pa.xy(i).y = y(i)
Next i
Canvas_Polygon pa, Rgb(255, 0, 255), Rgb(5,128,0), %CANVAS_FILLSTYLE_DIAGONALCROSSEDLINES
'=====================================================
x(1) = 255,388,490,158
y(1) = 35,71,51,55
pa.count = 4 '---Indicate you need 4 vertex
For i=1 To 4
pa.xy(i).x = x(i)
pa.xy(i).y = y(i)
Next i
Canvas_Polygon pa, Rgb(255, 0, 255), Rgb(5,128,0), %CANVAS_FILLSTYLE_SOLID
'=====================================================
x(1) = 109,108,121.5,97
y(1) = 78, 151,125,103
pa.count = 4 '---Indicate you need 4 vertex
For i=1 To 4
pa.xy(i).x = x(i)
pa.xy(i).y = y(i)
Next i
'tail propeller
Canvas_Polygon pa, Rgb(255, 0, 0), Rgb(255,0,0), %CANVAS_FILLSTYLE_SOLID
'=====================================================
Canvas_Width(3)
'helicopter Cockpit
Canvas_Arc(247, 58, 396, 170, Pi/2 ,Pi,Rgb(255, 0, 0) )
Canvas_Arc(274, 57, 355, 165,0,Pi/2 ,Rgb(255, 0, 0) )
Canvas_Arc(288,79,355,148,-Pi/2, 0 ,Rgb(255, 0, 0) )
'helicopter wheel
Canvas_Ellipse(311,142,333,164, Rgb(255, 0, 0),Rgb(100, 22, 0))
Canvas_Redraw
Canvas_WaitKey
End Function
the perl/tk code:
#!/usr/local/bin/perl
use strict;
use Tk;
use Tk::Canvas;
my $mw=MainWindow->new();
my $c=$mw->Canvas(-width=>490,-height=>170)->pack;
# Helicopter (c) Felix Liberman
$c->configure(-background=>'lightblue');
#front glass
my $cnv_Chord_11 = $c->create('arc',274.00,57.00,355.00,165.00,-start,356.00,-fill,'Blue',-extent,82.00,-style,'chord',-tags=>['cnv_Chord_11','cnv_obj']);
#cocktail backglass
my $cnv_Pie_12 = $c->create('arc',247.00,58.00,396.00,170.00,-start,90.00,-fill,'Cyan',-extent,90.00,-tags=>['cnv_Pie_12','cnv_obj']);
#tail
my $cnv_Polygon_13 = $c->create('polygon',107.00,114.00,322.00,114.00,322.00,148.00,-fill,'Cyan',-outline,'Black',-tags=>['cnv_Polygon_13','cnv_obj']);
my $cnv_Splash_14 = $c->create('polygon',255.00,35.00,388.50,71.00,490.00,51.00,158.00,55.00,-smooth,1.00,-tags=>['cnv_Splash_14','cnv_obj']);
#front bottom of the cockpit
my $cnv_Pie_15 = $c->create('arc',288.00,79.00,355.00,148.00,-start,270.00,-fill,'Cyan',-extent,90.00,-tags=>['cnv_Pie_15','cnv_obj']);
#wheel
my $cnv_Circle_16 = $c->create('oval',311.00,142.00,333.00,164.00,-width,10.00,-tags=>['cnv_Circle_16','cnv_obj']);
#tail propeller
my $cnv_Splash_17 = $c->create('polygon',109.00,78.00,108.00,151.00,121.50,125.00,97.00,103.00,-smooth,1.00,-tags=>['cnv_Splash_17','cnv_obj']);
MainLoop;