Changeset 78 for Include/abgl.ab
 Timestamp:
 Jan 29, 2007, 1:21:03 AM (17 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Include/abgl.ab
r72 r78 41 41 42 42 Public /* operator */ 43 Sub Operator = ( vec As Vector2f)43 Sub Operator = (ByRef vec As Vector2f) 44 44 This.X=vec.X 45 45 This.Y=vec.Y 46 46 End Sub 47 Function Operator + ( vec1 As Vector2f,vec2 As Vector2f) As Vector2f47 Function Operator + (ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f 48 48 Return Add(vec1,vec2) 49 49 End Function 50 Function Operator  ( vec1 As Vector2f,vec2 As Vector2f) As Vector2f50 Function Operator  (ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f 51 51 Return Substract(vec1,vec2) 52 52 End Function … … 55 55 End Function 56 56 */ 57 Function Operator * ( vec As Vector2f, sca As GLfloat) As Vector2f57 Function Operator * (ByRef vec As Vector2f, sca As GLfloat) As Vector2f 58 58 Dim ret As Vector2f(vec.X*sca,vec.Y*sca) 59 59 Return ret 60 60 End Function 61 Function Operator / ( vec As Vector2f, sca As GLfloat) As Vector2f61 Function Operator / (ByRef vec As Vector2f, sca As GLfloat) As Vector2f 62 62 Dim ret As Vector2f(vec.X/sca,vec.Y/sca) 63 63 Return ret … … 66 66 67 67 Public /* method */ 68 Function Add( vec1 As Vector2f,vec2 As Vector2f) As Vector2f68 Function Add(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f 69 69 Dim ret As Vector2f(vec1.X+vec2.X,vec1.Y+vec2.Y) 70 70 Return ret 71 71 End Function 72 Function Distance( vec1 As Vector2f,vec2 As Vector2f) As GLfloat72 Function Distance(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As GLfloat 73 73 Dim ret As Vector2f 74 74 ret=vec1vec2 75 75 Return ret.Magnitude 76 76 End Function 77 Function Dot( vec1 As Vector2f,vec2 As Vector2f) As GLfloat77 Function Dot(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As GLfloat 78 78 Return vec1.X*vec2.X+vec1.Y*vec2.Y 79 79 End Function … … 89 89 Return ret 90 90 End Function 91 Function Substract( vec1 As Vector2f,vec2 As Vector2f) As Vector2f91 Function Substract(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f 92 92 Dim ret As Vector2f(vec1.Xvec2.X,vec1.Yvec2.Y) 93 93 Return ret … … 132 132 133 133 Public /* operator */ 134 Sub Operator = ( vec As Vector2d)134 Sub Operator = (ByRef vec As Vector2d) 135 135 This.X=vec.X 136 136 This.Y=vec.Y 137 137 End Sub 138 Function Operator + ( vec1 As Vector2d,vec2 As Vector2d) As Vector2d138 Function Operator + (ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d 139 139 Return Add(vec1,vec2) 140 140 End Function 141 Function Operator  ( vec1 As Vector2d,vec2 As Vector2d) As Vector2d141 Function Operator  (ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d 142 142 Return Substract(vec1,vec2) 143 143 End Function 144 /* Function Operator * ( vec1 As Vector2d,vec2 As Vector2d) As Vector2d144 /* Function Operator * (ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d 145 145 Return Dot(vec1,vec2) 146 146 End Function*/ … … 157 157 158 158 Public /* method */ 159 Function Add( vec1 As Vector2d,vec2 As Vector2d) As Vector2d159 Function Add(ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d 160 160 Dim ret As Vector2d(vec1.X+vec2.X,vec1.Y+vec2.Y) 161 161 Return ret 162 162 End Function 163 Function Distance( vec1 As Vector2d,vec2 As Vector2d) As GLdouble163 Function Distance(ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As GLdouble 164 164 Dim ret As Vector2d 165 165 ret=vec1vec2 166 166 Return ret.Magnitude 167 167 End Function 168 Function Dot( vec1 As Vector2d,vec2 As Vector2d) As GLdouble168 Function Dot(ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As GLdouble 169 169 Return vec1.X*vec2.X+vec1.Y*vec2.Y 170 170 End Function … … 180 180 Return ret 181 181 End Function 182 Function Substract( vec1 As Vector2d,vec2 As Vector2d) As Vector2d182 Function Substract(ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d 183 183 Dim ret As Vector2d(vec1.Xvec2.X,vec1.Yvec2.Y) 184 184 Return ret … … 469 469 470 470 Public /* operator */ 471 471 Function operator () As Color3f 472 Return This 473 End Function 474 Sub operator = (c As Color3f) 475 This.R=c.R 476 This.G=c.G 477 This.B=c.B 478 End Sub 479 480 Public /* method */ 472 481 ' HSBを求める式はhttp://ofo.jp/osakana/cgtips/hsb.phtmlを参考にした 473 482 ' Drawwing\Color.abをさらに参考にしました。 … … 478 487 d = max  min 479 488 If rgb.g = max Then 480 Return ((rgb.b  rgb.r) As Double / d * 1.0*_System_PI/3.0 + 2.0*_System_PI/3.0) As GLfloat489 Return ((rgb.b  rgb.r) As Double / d * 60.0 + 120.0) As GLfloat 481 490 ElseIf rgb.b = max Then 482 Return ((rgb.r  rgb.g) As Double / d * 1.0*_System_PI/3.0 + 4.0*_System_PI/3.0) As GLfloat491 Return ((rgb.r  rgb.g) As Double / d * 60.0 + 240.0) As GLfloat 483 492 ElseIf rgb.g < rgb.b Then 484 Return ((rgb.g  rgb.b) As Double / d * 1.0*_System_PI/3.0 + 6.0*_System_PI/3.0) As GLfloat485 Else 486 Return ((rgb.g  rgb.b) As Double / d * 1.0*_System_PI/3.0) As GLfloat493 Return ((rgb.g  rgb.b) As Double / d * 60.0 + 360.0) As GLfloat 494 Else 495 Return ((rgb.g  rgb.b) As Double / d * 60.0) As GLfloat 487 496 EndIf 488 497 End Function … … 495 504 End Function 496 505 497 Function Get Brightness() As GLfloat506 Function GetVolue() As GLfloat 498 507 Dim max As GLfloat 499 508 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b) 500 509 Return max 501 510 End Function 511 512 Public /* static method */ 513 Static Function FromRGB(r As GLbyte, g As GLbyte, b As GLbyte) As Color3f 514 Dim ret As Color3f(r/255,g/255,b/255) 515 Return ret 516 End Function 517 Static Function FromCOLORREF(c As COLORREF) As Color3f 518 Dim ret As Color3f((c and &hff)/255,(c>>8 and &hff)/255,(c>>16 and &hff)/255) 519 Return ret 520 End Function 521 Static Function FromHSB(h As GLfloat, s As GLfloat, v As GLfloat) As Color3f 522 Dim r As GLfloat 523 Dim g As GLfloat 524 Dim b As GLfloat 525 If h<0 Then h+=360.0 526 Select Case (h\60) 527 Case 0 528 r=v 529 g=v*(1s*(1(h/60h\60))) 530 b=v*(1s) 531 Case 1 532 r=v*(1s*(h/60h\60)) 533 g=v 534 b=v*(1s) 535 Case 2 536 r=v*(1s) 537 g=v 538 b=v*(1s*(1(h/60h\60))) 539 Case 3 540 r=v*(1s) 541 g=v*(1s*(h/60h\60)) 542 b=v 543 Case 4 544 r=v*(1s*(1(h/60h\60))) 545 g=v*(1s) 546 b=v 547 Case 5 548 r=v 549 g=v*(1s) 550 b=v*(1s*(h/60h\60)) 551 End Select 552 553 Dim ret As Color3f(r,g,b) 554 Return ret 555 End Function 556 502 557 Protected 503 558 rgb As RGB_FLOAT … … 1454 1509 glColor3f(red,green,blue) 1455 1510 End Sub 1511 Sub Color(c As Color3f) 1512 glColor3fv(c) 1513 End Sub 1456 1514 Sub Color(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat) 1457 1515 glColor4f(red,green,blue,alpha)
Note:
See TracChangeset
for help on using the changeset viewer.