BlitzBasic
>
Codearchiv
> Mathematik
Aktuallisiert 30.05.2009
Wurzelzeichen
- von SpionAtom
Eine nützliche Funktion, die das Wurzelzeichen inklusive Radikant und Exponent darstellt. Nützlich für mathematische Programme.
; von SpionAtom, 19.07.2006 im Blitzforum Graphics 400, 300, 16, 2 SetBuffer BackBuffer() Global fnt_radikant = LoadFont("Arial", 32) ;Zahl, die unter dem Bruch steht Global fnt_exponent = LoadFont("Arial", 14) ;Der Exponent, der links auf dem Bruch steht Cls wurzelZeichnen 100, 100, "72342465", "343" Flip() WaitKey() End Function WurzelZeichnen(posx%, posy%, radikant$, exponent$ = "") SetFont fnt_radikant radw = StringWidth(Left$(radikant$, 1)) radh = StringHeight(radikant$) Text posx, posy, radikant$ Line posx-2, posy-2, posx + StringWidth(radikant$), posy-2 ;langer Strich über dem Radikanten Line posx-2, posy-2, posx - radw / 2.0, posy + StringHeight(radikant$) ;Häkchen Line posx - radw / 2.0, posy + StringHeight(radikant$), posx - radw, posy + StringHeight(radikant$) / 2.0 SetFont fnt_exponent Text posx - radw - StringWidth(exponent$), posy + radh / 2.0 - 2 - StringHeight(exponent$), exponent$ Line posx - radw, posy + radh / 2.0, posx - radw - StringWidth(exponent)-2, posy + radh / 2.0 End Function