Text Vertikal
Verfasst: 10.08.2005 10:10
Wie kann ich einen Text nicht horizontal sondern vertikal schreiben (2D Drawing)?
Code: Alles auswählen
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitSprite3D() = 0
MessageRequester("Error", "Can't open DirectX 7 or later", 0)
End
EndIf
If OpenWindow(0,0,0,640,480,#PB_Window_ScreenCentered,"Hallo Welt!!!") = 0
End
EndIf
If OpenWindowedScreen(WindowID(0),0,0,640,480,0,0,0)
CreateSprite(0,128,128,#PB_Sprite_Texture)
If StartDrawing(SpriteOutput(0))
FrontColor(255, 0, 0)
DrawText("Hallo Welt!!!")
StopDrawing()
EndIf
;Sprite3DQuality(1)
CreateSprite3D(0,0)
RotateSprite3D(0,90,0)
Repeat
FlipBuffers()
ClearScreen(0,0,0)
Start3D()
DisplaySprite3D(0, 10, 10)
Stop3D()
;DisplaySprite(0,50,50)
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
Else
MessageRequester("Error", "Can't open a 640*480 - 16 bit screen !", 0)
EndIf
End
Code: Alles auswählen
#Breite = 40
#Hoehe = 100
CreateImage(0,#Breite,#Hoehe)
StartDrawing(ImageOutput())
y = 270
For k=0 To 255
Box(0,y,#Breite,#Hoehe,RGB(0,0,255-k*6)) ;Hintergrundfärbung
y - 3
Next k
Locate((#Breite-15)/2,#Hoehe-20)
DrawingMode(1)
FrontColor($FF,$FF,$00)
DrawText("Vertikal")
StopDrawing()
OpenWindow(0, 0, 0, 300, 200, #PB_Window_SystemMenu|#PB_Window_ScreenCentered, "Menu")
StartDrawing(WindowOutput())
DrawImage(UseImage(0),10,10)
StopDrawing()
Repeat
Event=WaitWindowEvent()
If Event=#WM_RBUTTONDOWN
DisplayPopupMenu(0, hWnd)
EndIf
Until Event=#PB_Event_CloseWindow
End
Code: Alles auswählen
; Here' a bit of code that experiments with the
; api createfont, which I find a bit more flexible
; then PB's font command.
; It must be the longest api, there are 14 parameters,
; most of which can safely be set to 0 - whatever Smile
;
; Steve.
;apifont.pb
;tested with pb3.0 and win95
Declare PaintIt()
Quit.l = 0
#TRUE = 1
If OpenWindow(0, 0, 0, 640, 400, #PB_Window_SystemMenu, "Api fonts")
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_EventCloseWindow
Quit = 1
ElseIf EventID = #PB_EventRepaint
PaintIt()
EndIf
Until Quit = 1
EndIf
End
Procedure PaintIt()
angle.l = 0
color.l = $00aa3333
*DC = GetDC_(WindowID()) ; Get the windows client dc
SetBkMode_(*DC, #TRANSPARENT)
;draw some text at different angles, the angle parm is in 1/10th degrees
For a = 1 To 72
font1H = CreateFont_(24,16,angle,0.0,0,0,0,0,0,0,0,0,0,"ARIAL")
SelectObject_(*DC, font1H)
SetTextColor_(*DC, color)
TextOut_(*DC, 200, 185,"Pure Basic", 10)
DeleteObject_(font1H)
angle = angle + 50
color = color + $00000040
Next a
;underline
font1H = CreateFont_(30,14, 0,0.0,0,0,#TRUE,0,0,0,0,0,0,"COURIER")
SelectObject_(*DC, font1H)
SetTextColor_(*DC, $00ffffff)
TextOut_(*DC, 410, 90,"Pure Basic", 10)
DeleteObject_(font1H)
;italic
font1H = CreateFont_(30,14, 0,0,0,#TRUE,0,0,0,0,0,0,0,"COURIER")
SelectObject_(*DC, font1H)
SetTextColor_(*DC, $0000ffff)
TextOut_(*DC, 410, 130,"Pure Basic", 10)
DeleteObject_(font1H)
; straight down
font1H = CreateFont_(30,16, 2700,0,0,0,0,0,0,0,0,0,0,"ARIAL")
SelectObject_(*DC, font1H)
SetTextColor_(*DC, $0012ee56)
TextOut_(*DC, 500, 170,"Pure Basic", 10)
DeleteObject_(font1H)
ReleaseDC_(WindowID(), *DC) ;don't forget this Smile
EndProcedure