Rotationszentrum von Texten

Übersicht BlitzMax, BlitzMax NG Beginners-Corner

Neue Antwort erstellen

Ana

Betreff: Rotationszentrum von Texten

BeitragDo, März 03, 2011 22:27
Antworten mit Zitat
Benutzer-Profile anzeigen
Hallihallo,

kann mir wer sagen wie ich das Rotationszentrum von nicht images festlege?

Im Grunde möchte ich, dass ein Text sich rotierend auf eine Stelle zu bewegt. Geht auch gut, nur sieht es halt doof aus, wenn die Buchstaben so eiern.

Hier der Code, aber ich glaube er ist eigentlich nicht nötig, weil es wirklich nur dieses Problem mit dem Zentrum der Rotation ist. Nur damit kein "Ohne Code können wir dir auch nicht helfen" kommt Wink.
BlitzMax: [AUSKLAPPEN]
SuperStrict
Graphics 1024,720
Type TMessage
Field x:Int,y:Int
Field T$
Field image:TImage
Field alpha:Float
Field LetterList:TList = New TList

Method draw()
Local l:TLetter
If image <> Null
SetBlend Alphablend
SetAlpha alpha
DrawImage image,x,y
SetAlpha 1
EndIf
For L:Tletter = EachIn letterlist
l.draw()
Next
End Method

Method Create_letter()
Local i:Int
Local tex:String
Local L:TLetter
For i = 1 To Len(t)
tex = Mid(t,i,1)
L = Create_Tletter(tex)
l.zx = x + 16 * (i-1)
l.zy = y
Local vx# = (l.x - l.zx)
Local vy# = (l.y - l.zy)
Local dis# = Sqr(vx^2 + vy^2)
l.speed = dis/120
ListAddLast(letterlist,l)
Next
End Method
End Type

Function Create_TMessage:Tmessage(T:String,x:Int,y:Int)
Local M:TMessage = New tmessage
m.t = t
m.x = x
m.y = y
m.alpha = 1
m.Create_letter()
Return m
End Function

Type TLetter
Field x:Float,y:Float
Field c:String
Field Rotation:Float
Field rot:Float
Field zx:Int,zy:Int
Field speed:Float

Method Draw()

SetColor 100,0,0
DrawRect zx,zy,16,16
SetColor 255,255,255
Local vx# = (x - zx)
Local vy# = (y - zy)
Local dis# = Sqr(vx^2 + vy^2)
vx:/dis
vy:/dis
If dis > speed
x:- vx * speed
y:- vy * speed
SetRotation(rotation)
rotation:-rot
Else
x = zx
y = zy
EndIf
DrawText c,x,y
SetRotation(0)
End Method

End Type


Function Create_Tletter:Tletter(T:String)
Local L:Tletter = New tletter
Local s:Int = Rand(0,3)
l.c = t
If s < 2
If s = 0
l.x = 0
ElseIf s = 1
l.x = GraphicsWidth()
EndIf
l.y = Rand(0,GraphicsHeight())
Else
If s = 2
l.y = 0
ElseIf s = 3
l.y = GraphicsHeight()
EndIf
l.x = Rand(0,GraphicsWidth())
EndIf
l.rotation = Rand (0,359)
l.rot = (l.rotation + 360 * Rand(0,5))/120
Return l
End Function


Local M:Tmessage = Create_TMessage("Test Nachricht",200,200)
SetColor 255,255,255
Repeat
Cls
m.draw()
Flip
Until AppTerminate()

Don't only practice your art,
but force your way into its secrets,
for it and knowledge
can raise human to divine

Xeres

Moderator

BeitragDo, März 03, 2011 22:42
Antworten mit Zitat
Benutzer-Profile anzeigen
TextWidth & TextHeight sollten helfen. Wenn ich richtig aus dem Gedächtnis tippe:
Code: [AUSKLAPPEN]
DrawText( c, x - TextWidth(c) / 2.0, y - TextHeight(c) / 2.0)


Nachtrag:
uh... Rotation? SetHandle hilft da ^^

Noch ein Nachtrag:
Code: [AUSKLAPPEN]
SetHandle(TextWidth(c) / 2.0, TextHeight(c) / 2.0)
DrawText(c, x, y)
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus
T
HERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld)

Ana

BeitragFr, März 04, 2011 1:16
Antworten mit Zitat
Benutzer-Profile anzeigen
ah super danke =)
Don't only practice your art,
but force your way into its secrets,
for it and knowledge
can raise human to divine

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group