Here's an alien.
Code: Select all
Type Point
As Long x,y
Declare Function rotate(As Point,As Single,As Single) As Point
End Type
Function point.rotate(pivot As Point,angle As Single,scale As Single) As Point
Var a=angle,d=scale
Return Type<Point>(d*(Cos(a*.0174533)*(this.x-pivot.x)-Sin(a*.0174533)*(this.y-pivot.y)) +pivot.x,_
d*(Sin(a*.0174533)*(this.x-pivot.x)+Cos(a*.0174533)*(this.y-pivot.y)) +pivot.y)
End Function
Type Line
As Point s,e
Declare Sub Draw(As Ulong)
End Type
Type shape
As Line w(Any)
As Ulong colour
as point centroid
Declare Sub getdata(As Ulong)
Declare Sub translate(As Point)
Declare Sub rotate(As Point,As Single,as single=1)
Declare Sub Draw(as boolean=false)
declare sub DynamicDraw(As Point,As Single,as single=1,as boolean=false)
End Type
Sub line.draw(colour As Ulong)
Line(s.x,s.y)-(e.x,e.y),colour
End Sub
Sub shape.draw(f as boolean)
For n As Long=1 To Ubound(w)
w(n).draw(colour)
Next n
if f=true then paint (centroid.x,centroid.y),colour,colour
End Sub
Sub shape.getdata(col As Ulong)
dim as long num
read num
colour=col
dim as point acc
dim as long n
Dim As Point p(1 To num)
For n As Long=Lbound(p) To Ubound(p)
Read p(n).x
Next n
For n =Lbound(p) To Ubound(p)
Read p(n).y
Next n
Dim As Long counter
For n =1 To Ubound(p) -1 Step 1
counter+=1
acc.x+=p(n).x
acc.y+=p(n).y
Redim Preserve w(1 To counter)
w(counter)=Type<Line>(p(n),p(n+1))
Next
acc.x+=p(n).x
acc.y+=p(n).y
centroid=type(acc.x/num,acc.y/num)
End Sub
Sub shape.translate(p As Point)
For n As Long=1 To Ubound(w)
w(n).s.x+=p.x
w(n).s.y+=p.y
w(n).e.x+=p.x
w(n).e.y+=p.y
Next n
centroid.x+=p.x
centroid.y+=p.y
End Sub
Sub shape.DynamicDraw(fulcrum As Point,angle As Single,scaler as single,f as boolean)
dim as shape temp = this
For n As Long=1 To Ubound(w)
temp.w(n).s=w(n).s.rotate(fulcrum,angle,scaler)
temp.w(n).e=w(n).e.rotate(fulcrum,angle,scaler)
Next n
temp.draw(f)
End Sub
Sub shape.Rotate(fulcrum As Point,angle As Single,scaler as single)
For n As Long=1 To Ubound(w)
w(n).s=w(n).s.rotate(fulcrum,angle,scaler)
w(n).e=w(n).e.rotate(fulcrum,angle,scaler)
Next n
centroid=centroid.rotate(fulcrum,angle,scaler)
End Sub
Screen 19,32
Dim As shape s
s.getdata(Rgb(0,100,255))
s.translate(Type(-150,-150))
s.rotate(s.centroid,0,.7)
s.draw()
dim as point fulcrum=s.centroid
print "press a key"
sleep
dim as single angle,scale=1,k=1
do
angle+=.2
scale+=.001*k
if scale>1.2 then k=-k
if scale<.4 then k=-k
screenlock
cls
s.DynamicDraw(fulcrum,angle,scale,true)
screenunlock
sleep 1,1
loop until inkey=chr(27)
Sleep
'=============== DATA HERE ================
'Number of points
DATA _
1120
'X_values:
DATA _
459,458,457,456,455,454,453,451,450,448,446,444,443,441,439,437, _
435,433,432,430,428,426,425,423,422,420,419,418,417,416,415,415, _
414,414,414,414,414,415,415,416,417,418,419,420,421,423,424,426, _
428,429,431,433,435,437,439,441,443,445,447,450,452,454,456,458, _
460,462,464,466,468,470,471,473,475,477,479,481,483,485,487,489, _
491,493,496,498,500,502,504,507,509,511,513,515,517,519,521,523, _
525,527,529,531,532,534,535,537,538,539,540,542,543,544,545,546, _
547,549,550,551,552,553,553,554,555,556,557,557,558,559,559,560, _
560,560,561,561,561,561,561,561,561,561,561,560,560,559,559,558, _
557,556,554,553,551,550,548,546,544,542,540,538,536,534,532,530, _
528,526,524,523,521,519,518,516,515,514,513,512,512,511,511,511, _
511,511,512,512,513,514,514,515,516,518,519,520,522,523,525,526, _
528,530,532,533,535,537,539,541,543,545,547,549,551,553,555,556, _
558,560,561,563,565,567,569,571,573,576,578,580,583,585,588,591, _
593,596,598,601,603,606,608,610,613,615,617,619,621,623,625,626, _
628,629,631,632,633,633,634,634,635,635,636,636,636,636,636,636, _
636,635,635,635,634,634,633,632,632,631,630,629,628,627,626,625, _
624,623,621,620,619,617,616,615,614,613,611,609,607,605,603,601, _
599,596,594,591,589,586,584,581,578,576,573,570,568,565,562,560, _
557,555,553,550,548,546,544,542,540,538,537,536,535,533,532,531, _
530,529,528,527,526,525,524,523,522,522,521,520,520,519,519,519, _
518,518,517,517,517,517,517,516,516,516,516,516,516,516,516,516, _
516,516,517,517,517,518,518,519,519,520,521,521,522,523,523,524, _
525,526,527,527,528,529,530,531,531,532,533,534,534,535,536,536, _
537,537,537,538,538,539,539,540,540,541,541,541,542,542,543,543, _
543,544,544,544,545,545,545,546,546,546,547,547,547,548,548,548, _
549,549,549,550,550,550,551,551,551,551,551,552,552,552,552,552, _
552,552,552,552,553,553,553,553,553,553,554,554,554,555,555,556, _
556,557,558,559,559,560,561,562,563,565,566,568,569,571,573,575, _
577,580,582,584,586,589,591,594,596,598,601,603,605,608,610,612, _
614,616,618,620,621,623,624,626,627,628,628,629,629,630,630,631, _
631,631,631,631,631,631,631,631,631,630,630,629,629,628,628,627, _
626,625,625,624,623,622,621,620,619,618,617,616,615,614,613,612, _
610,609,607,606,604,602,601,599,597,595,593,591,589,587,585,583, _
581,579,577,574,572,570,568,566,564,561,559,557,555,553,551,549, _
548,546,544,542,540,538,536,534,532,530,528,526,523,521,519,517, _
515,513,511,509,507,505,503,500,498,496,494,492,490,488,486,485, _
483,481,479,478,476,474,473,471,469,467,465,464,462,460,458,457, _
455,453,452,450,448,447,445,443,442,440,439,437,435,434,432,431, _
430,428,427,425,424,423,422,421,419,418,417,416,415,414,412,411, _
410,409,408,407,406,405,404,403,402,402,401,400,399,398,397,396, _
395,395,394,393,392,391,390,389,388,388,387,386,385,384,383,382, _
381,379,378,377,376,374,373,372,371,370,369,367,366,365,365,364, _
363,362,362,361,361,360,360,360,360,360,360,361,361,362,362,364, _
365,366,367,369,371,373,375,377,379,381,383,385,388,390,393,395, _
397,400,402,405,407,409,411,414,416,418,420,422,423,425,426,427, _
428,430,431,432,433,434,435,436,437,438,439,440,441,442,443,443, _
444,445,445,446,447,447,448,448,449,449,450,450,450,451,451,451, _
452,452,452,452,452,452,453,453,453,452,452,452,452,452,452,451, _
451,451,450,450,450,449,449,448,448,448,447,447,446,446,445,445, _
445,444,444,444,443,443,443,442,442,442,441,441,441,440,440,440, _
439,439,439,438,438,437,437,437,436,436,436,435,435,434,434,434, _
433,433,432,432,432,431,431,430,430,430,429,429,428,428,427,427, _
426,426,425,425,425,424,424,423,423,422,422,421,421,420,420,419, _
419,418,418,417,417,416,415,415,414,414,413,413,412,412,411,411, _
410,410,409,409,408,408,407,407,406,406,405,404,404,403,403,402, _
402,401,400,400,399,398,398,397,396,396,395,394,393,392,392,391, _
390,389,388,387,386,385,384,382,381,380,379,377,376,375,374,372, _
371,370,369,367,366,365,364,363,362,361,360,359,358,357,356,356, _
355,355,355,354,354,353,353,353,353,353,353,353,353,353,353,353, _
353,353,353,353,354,354,354,354,355,355,355,355,356,356,356,357, _
357,357,358,358,358,358,359,359,359,360,360,360,361,361,362,362, _
363,363,364,364,364,365,366,366,367,367,368,368,369,369,370,370, _
371,371,372,372,373,373,374,374,374,375,375,376,376,377,377,378, _
378,379,379,380,380,381,381,382,382,383,383,384,384,384,385,385, _
386,387,387,388,388,389,389,390,390,391,391,392,392,393,393,394, _
394,395,395,396,396,397,397,398,398,399,399,400,400,401,401,402, _
402,403,404,404,405,406,406,407,408,409,410,411,412,412,413,414, _
415,416,418,419,420,422,423,425,426,428,429,431,432,434,435,437, _
439,440,442,443,444,446,447,448,450,451,452,453,454,455,456,457
'Y_values:
DATA _
247,246,246,245,244,243,242,241,240,239,238,237,236,235,233,232, _
231,229,228,227,225,224,222,221,219,218,217,215,214,212,211,209, _
208,206,205,204,203,201,199,198,196,194,192,191,189,187,185,183, _
181,179,177,175,173,172,170,168,166,164,163,161,159,158,156,155, _
154,152,151,150,149,148,148,147,147,146,146,145,145,145,144,144, _
144,144,144,144,144,144,144,144,145,145,145,146,146,147,147,148, _
148,149,149,150,151,151,152,153,154,154,155,156,157,158,159,160, _
161,163,164,165,167,168,170,171,173,174,176,178,179,181,183,184, _
186,187,189,191,192,194,195,197,198,200,201,202,203,204,206,207, _
208,209,211,212,213,215,216,217,218,220,221,222,223,225,226,227, _
228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,242, _
243,243,243,243,243,243,243,242,242,241,240,240,239,238,238,237, _
237,236,236,235,235,235,235,236,236,237,238,239,240,242,244,247, _
249,252,254,258,262,267,272,277,283,289,296,303,310,317,325,332, _
340,348,356,364,372,380,388,396,404,411,419,426,433,440,446,452, _
458,463,468,472,476,478,481,484,487,490,493,495,497,499,501,503, _
505,506,507,508,509,509,510,510,510,510,510,509,509,508,507,506, _
504,503,501,499,497,495,492,489,488,485,481,477,472,467,462,456, _
450,443,436,429,422,415,407,400,392,384,376,369,361,354,346,339, _
332,326,319,313,307,302,297,293,289,285,282,281,279,277,276,275, _
274,273,273,273,273,274,275,276,277,278,280,282,284,286,288,290, _
292,295,297,300,303,305,308,311,314,316,319,322,324,327,328,330, _
333,336,339,342,345,348,352,355,359,363,366,370,374,378,382,385, _
389,393,397,401,405,409,413,416,420,424,427,431,434,437,441,444, _
447,448,451,453,456,459,461,463,466,468,470,473,475,477,479,481, _
483,485,487,489,491,493,495,497,498,500,502,504,506,508,510,511, _
513,515,517,519,520,522,524,525,527,529,530,532,533,535,536,538, _
539,540,542,543,545,546,548,549,551,552,554,556,557,559,561,563, _
565,568,570,572,575,578,580,582,585,588,592,596,600,604,608,612, _
617,622,626,631,636,641,646,651,656,661,666,671,675,680,685,689, _
694,698,702,706,710,713,716,719,722,725,726,728,730,732,734,736, _
738,739,741,742,744,745,746,747,748,748,749,749,750,750,750,750, _
750,750,750,749,748,748,747,746,745,743,742,741,739,738,736,734, _
731,729,726,723,719,716,712,709,705,701,696,692,688,683,679,674, _
669,665,660,655,651,646,641,637,632,628,624,619,615,611,608,604, _
602,598,595,591,587,583,579,575,571,567,563,559,555,551,547,543, _
539,535,532,528,525,521,518,515,512,509,507,505,502,501,499,498, _
497,496,495,495,495,495,496,496,497,499,500,502,504,506,508,511, _
514,517,519,523,526,529,532,536,539,543,546,550,554,557,561,564, _
568,571,575,578,581,584,586,589,592,596,599,602,606,609,613,617, _
621,624,628,632,636,640,644,647,651,655,659,662,666,669,673,676, _
679,683,686,689,691,694,696,699,701,702,704,706,708,710,712,715, _
717,719,721,723,725,727,728,730,732,733,734,736,737,738,738,739, _
739,739,739,738,738,737,735,734,732,730,727,725,723,720,716,711, _
706,701,696,690,683,677,670,663,655,648,640,632,624,616,607,599, _
591,582,574,566,558,549,541,534,526,518,511,504,498,491,485,482, _
476,471,465,460,454,449,443,438,433,428,423,418,413,408,403,398, _
394,389,385,380,376,372,368,364,360,356,352,348,345,341,338,335, _
332,329,327,324,321,319,316,314,311,309,307,305,303,301,299,297, _
295,294,292,291,290,288,287,286,285,284,283,283,282,281,281,280, _
280,280,279,279,279,279,279,279,279,280,280,281,282,283,284,285, _
286,287,288,290,291,293,294,296,297,299,301,302,304,306,308,309, _
311,313,314,316,318,319,321,322,323,324,326,327,329,330,332,333, _
335,336,338,339,341,342,344,345,347,348,350,351,353,354,356,358, _
359,361,363,364,366,368,369,371,373,374,376,377,379,381,382,384, _
386,388,390,392,394,396,397,399,401,403,405,407,409,411,413,415, _
417,419,421,423,425,427,429,431,433,435,437,439,441,443,444,446, _
448,450,452,455,457,459,462,464,466,469,471,474,476,479,481,483, _
486,488,490,492,494,496,498,499,501,502,504,505,506,507,507,508, _
508,508,508,508,507,507,506,505,504,503,502,500,499,497,495,493, _
491,489,487,485,483,481,478,476,474,471,469,467,464,462,460,457, _
455,453,451,449,448,446,444,442,440,438,436,434,432,430,427,425, _
423,421,419,416,414,412,410,408,405,403,401,399,396,394,392,390, _
388,386,383,381,379,377,375,374,372,370,368,366,364,362,360,357, _
355,353,351,349,347,345,343,341,339,337,335,333,331,329,327,325, _
323,321,320,318,316,314,313,311,309,308,307,305,304,303,301,300, _
298,297,296,294,293,292,291,290,288,287,286,285,284,283,282,281, _
280,279,278,277,276,275,274,273,272,271,270,269,268,268,267,266, _
265,265,264,263,262,261,260,260,259,258,257,257,256,255,255,254, _
253,253,252,252,251,251,250,249,249,249,248,248,247,247,247,246
And a data editor.
Click points with mouse.
go into drag mode (top left) anytime to alter the points.
Use the wheel to magnify (e.g. closing a shape perhaps)
Press down on the mouse wheel to reset it.
Right click anywhere to delete the last point.
Press esc to end, save or not.
saves to a file, OR you can copy and paste from the console.
Paste fresh data to the other program.
You may have to skip painting if the centroid is outside the shape.