Seite 1 von 2

[ ERLEDIGT ] wie Linienbreite festlegen

Verfasst: 14.12.2015 12:23
von Gimbly
Hallo Gemeinde,

bin zwar kein PB-Anfänger, aber in Punkto 2DDrawing schon.

Habe ich das richtig verstanden, dass Linien (Line/LineXY) immer 1 Pixel breit sind und es keinen Weg in PB gibt, breitere (dickere) Linien zu zeichnen?

Irgendwo fand ich diese Proc (Win-API), wo ich die Breite (PenSize) setzen kann:

Code: Alles auswählen

Procedure BigLineXY(X1,Y1,X2,Y2,Color.l,PenSize.l,*hDC)
   Protected  *hPen
   *hPen = CreatePen_(#PS_SOLID, PenSize, Color)
   If *hPen
      If SelectObject_(*hDC, *hPen)
         MoveToEx_(*hDC, X1, Y1, 0)
         LineTo_(*hDC, X2, Y2)
      EndIf
      DeleteObject_(*hPen)
   EndIf      
EndProcedure
Klappt auch soweit. Jetzt habe ich allerdings noch zwei Probleme:
1. Wie kriege ich 50% Transparenz in die Linie?
2. Wie kann ich das für Linux umsetzen, da mein Proggi auch darunter laufen muss.

Re: wie Linienbreite festlegen

Verfasst: 14.12.2015 12:54
von NicTheQuick
Hast du dir schon die neue 'VectorDrawing'-Bibliothek angeschaut? Die kann genau sowas.

Re: wie Linienbreite festlegen

Verfasst: 14.12.2015 13:02
von Gimbly
Hallo NicTheQuick,

meinst du die, die in PB 5.40 neu enthalten ist?

Nutze noch 5.31, aber das währe dann ein Grund upzudaten!

Re: wie Linienbreite festlegen

Verfasst: 14.12.2015 13:36
von udg
hi, ich bin zwar auch kein Profi aber mit Linien helfe ich mir immer so:

für Flat Buttons benutze ich die Lib: PureColor

Download: free and fast from zippyshare

Screenshot:
Bild

und code (benötigt PureColor)

Code: Alles auswählen

;
; needs PURECOLOR
; free and fast from zippyshare : http://www13.zippyshare.com/v/aEWTlfqs/file.html
;-Prepare and Declare Items, Objects
Enumeration
;{
  ;Objects Button 2pix
    #Btn_2pix
    #Btn_2pix_Frame_Left
    #Btn_2pix_Frame_Right
    #Btn_2pix_Frame_Top
    #Btn_2pix_Frame_Bottom
  ;Objects Button 4pix
    #Btn_4pix
    #Btn_4pix_Frame_Left
    #Btn_4pix_Frame_Right
    #Btn_4pix_Frame_Top
    #Btn_4pix_Frame_Bottom
  ;Objects Button Exit_1px
    #Btn_Exit_1px
    #Btn_Exit_1px_Frame_Left
    #Btn_Exit_1px_Frame_Right
    #Btn_Exit_1px_Frame_Top
    #Btn_Exit_1px_Frame_Bottom
  ;FRAME AROUND Window
    #Window_Frame_Left
    #Window_Frame_Right
    #Window_Frame_Top
    #Window_Frame_Bottom
EndEnumeration
;}  
  
;-MAIN WINDOW
OpenWindow(0, 732, 301, 540, 610, "", #PB_Window_ScreenCentered | #PB_Window_BorderLess)
SetWindowColor(0,RGB(4, 0, 9))
        
      ;=================================================================================================================
      ;=================================================================================================================
      ;-CREATE BUTTONS
      ;
        ;-SHOW 2px Frame around BTN 2pix
           ;Left
            TextGadget(#Btn_2pix_Frame_Left, 15, 559, 2, 32, "")                 ;Frame size
            SetGadgetColor(#Btn_2pix_Frame_Left, #PB_Gadget_BackColor, $454543)  ;Frame Color
           ;Right
            TextGadget(#Btn_2pix_Frame_Right, 117, 559, 2, 32, "")               ;Frame size
            SetGadgetColor(#Btn_2pix_Frame_Right, #PB_Gadget_BackColor, $454543) ;Frame Color
           ;Top
            TextGadget(#Btn_2pix_Frame_Top, 16, 558, 102, 2, "")                 ;Frame size
            SetGadgetColor(#Btn_2pix_Frame_Top, #PB_Gadget_BackColor, $454543)   ;Frame Color
           ;Top
            TextGadget(#Btn_2pix_Frame_Bottom, 16, 590, 102, 2, "")              ;Frame size
            SetGadgetColor(#Btn_2pix_Frame_Bottom, #PB_Gadget_BackColor, $454543);Frame Color
            
          ;BTN 2pix
            Btn_2pix = ButtonGadget(#Btn_2pix, 17, 560, 100, 30, "2pix", #BS_FLAT)
            ;Font and Back color: BTN 2pix 
              PureCOLOR_SetButtonColor(#Btn_2pix, RGB(102, 104, 106), RGB(0, 0, 0), RGB(102, 104, 106), RGB(28, 28, 28))
      ;=================================================================================================================        
      ;
        ;-SHOW 4px Frame around BTN 4pix
           ;Left
            TextGadget(#Btn_4pix_Frame_Left, 216, 559, 4, 35, "")                ;Frame size
            SetGadgetColor(#Btn_4pix_Frame_Left, #PB_Gadget_BackColor, $454543)  ;Frame Color
           ;Right
            TextGadget(#Btn_4pix_Frame_Right, 320, 559, 4, 35, "")               ;Frame size
            SetGadgetColor(#Btn_4pix_Frame_Right, #PB_Gadget_BackColor, $454543) ;Frame Color
           ;Top
            TextGadget(#Btn_4pix_Frame_Top, 216, 556, 108, 4, "")                ;Frame size
            SetGadgetColor(#Btn_4pix_Frame_Top, #PB_Gadget_BackColor, $454543)   ;Frame Color
           ;Top
            TextGadget(#Btn_4pix_Frame_Bottom, 219, 590, 102, 4, "")             ;Frame size
            SetGadgetColor(#Btn_4pix_Frame_Bottom, #PB_Gadget_BackColor, $454543);Frame Color
              
          ;BTN 4pix
            Btn_4pix = ButtonGadget(#Btn_4pix, 220, 560, 100, 30, "4pix", #BS_FLAT)
            ;Font and Back color: BTN 4pix 
              PureCOLOR_SetButtonColor(#Btn_4pix, RGB(102, 104, 106), RGB(0, 0, 0), RGB(102, 104, 106), RGB(28, 28, 28))
      ;=================================================================================================================
      ;        
        ;-SHOW 1px Frame around BTN Exit_1px
           ;Left
            TextGadget(#Btn_Exit_1px_Frame_Left, 419, 559, 1, 32, "")                ;Frame size
            SetGadgetColor(#Btn_Exit_1px_Frame_Left, #PB_Gadget_BackColor, $454543)  ;Frame Color  
           ;Right
            TextGadget(#Btn_Exit_1px_Frame_Right, 520, 559, 1, 32, "")               ;Frame size
            SetGadgetColor(#Btn_Exit_1px_Frame_Right, #PB_Gadget_BackColor, $454543) ;Frame Color
           ;Top
            TextGadget(#Btn_Exit_1px_Frame_Top, 419, 559, 102, 1, "")                ;Frame size
            SetGadgetColor(#Btn_Exit_1px_Frame_Top, #PB_Gadget_BackColor, $454543)   ;Frame Color
           ;Top
            TextGadget(#Btn_Exit_1px_Frame_Bottom, 419, 590, 102, 1, "")             ;Frame size
            SetGadgetColor(#Btn_Exit_1px_Frame_Bottom, #PB_Gadget_BackColor, $454543);Frame Color

          ;BTN Exit_1px
            ButtonGadget(#Btn_Exit_1px, 420, 560, 100, 30, "Exit 1px", #BS_FLAT)
            ;Font and Back color: BTN Exit_1px 
              PureCOLOR_SetButtonColor(#Btn_Exit_1px, RGB(102, 104, 106), RGB(0, 0, 0), RGB(102, 104, 106), RGB(28, 28, 28))
      ;=================================================================================================================
      ;=================================================================================================================
      ;
        ; GIVE THE Window A 2PX Frame
           ;Left 2px
            TextGadget(#Window_Frame_Left, 0, 0, 2, 608, "")                              ;Frame size
            SetGadgetColor(#Window_Frame_Left, #PB_Gadget_BackColor, RGB(102, 102, 102))  ;Frame Color
           ;Right 2px
            TextGadget(#Window_Frame_Right, 538, 0, 2, 608, "")                           ;Frame size
            SetGadgetColor(#Window_Frame_Right, #PB_Gadget_BackColor, RGB(102, 102, 102)) ;Frame Color
           ;Top 20 px
            TextGadget(#Window_Frame_Top, 2, 0, 536, 20, "")                            ;Frame size
            SetGadgetColor(#Window_Frame_Top, #PB_Gadget_BackColor, RGB(102, 102, 102)) ;Frame Color
           ;Bottom 2px
            TextGadget(#Window_Frame_Bottom, 0, 608, 540, 2, "")                          ;Frame size
            SetGadgetColor(#Window_Frame_Bottom, #PB_Gadget_BackColor, RGB(102, 102, 102));Frame Color
      ;=================================================================================================================

Repeat
  Event = WaitWindowEvent()
    If Event = #PB_Event_Gadget
      Select EventGadget()  
        Case #Btn_Exit_1px
        End
      EndSelect
    EndIf
    
;-MOVE WINDOW WITH MOUSE 
  SendMessage_(WindowID(0), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
  

  Until Event = #PB_Event_CloseWindow

Re: wie Linienbreite festlegen

Verfasst: 14.12.2015 15:01
von Bisonte

Code: Alles auswählen

...benutze ich die Lib: PureColor
Keine gute Idee....

Nur Windows 32Bit und keine Updates... Kann bei jeder neuen PB Version aus sein, mit der Nutzung !

Da diese Userlibrary massiv die WINAPI benutzt, kann ich zur Suche nach relevanten Funktionen die WINAPI Library von RSBasic
empfehlen !

Re: wie Linienbreite festlegen

Verfasst: 14.12.2015 15:14
von C h r i s :)
Ist purecolor open source? dann könnte man die api befehle in winapi lib übernehmen

Re: wie Linienbreite festlegen

Verfasst: 14.12.2015 15:24
von Bisonte
C h r i s :) hat geschrieben:Ist purecolor open source? dann könnte man die api befehle in winapi lib übernehmen
Gnozal hat zu keiner seiner Userlibraries jemals den Source veröffentlicht. Leider.
Geschrieben wurden sie meines Wissens mit PB 3.9x und max. Windows XP. Um nur mal Eckdaten der Erstellung zu haben ;)

Re: wie Linienbreite festlegen

Verfasst: 14.12.2015 15:37
von udg
ICh benutze purecolor derzeit unter Windows 7 64bit mit Purebasic 5.3 . Noch läuft alles super.
Aber das es eine API von rsbasic gibt,die das selbe tut wusste ich nicht. Wo kann man diese bekommen?

Grüße

Re: wie Linienbreite festlegen

Verfasst: 14.12.2015 15:46
von RSBasic
PureColor ist eine umfangreiche Bibliothek zum Umfärben von Gadgets. Meine WinAPI Library bietet einige, aber nicht alle Codes zum Umfärben von Gadgets.
Wenn du was brauchst, um die Vorder-/Hintergrundfarbe eines bestimmten Gadgets zu ändern und es existiert noch kein Code in der WinAPI Library, dann sag einfach Bescheid.

Re: wie Linienbreite festlegen

Verfasst: 14.12.2015 17:30
von udg
RSBasic hat geschrieben:PureColor ist eine umfangreiche Bibliothek zum Umfärben von Gadgets. Meine WinAPI Library bietet einige, aber nicht alle Codes zum Umfärben von Gadgets.
Wenn du was brauchst, um die Vorder-/Hintergrundfarbe eines bestimmten Gadgets zu ändern und es existiert noch kein Code in der WinAPI Library, dann sag einfach Bescheid.
Herzlichen Dank. :allright:

Ich sehe gerade, dass ich dies als Installer auf meinem PC habe :) Was ich für Buttons nicht finden konnte ist die Option, die Gnozal anietet in seiner Lib für Buttons:

ButtonGadget:
erstellt einen Flat Button mit verschiedenen Farben gleich in einer Zeile.
PureCOLOR_SetButtonColor(#Btn_OpenBrowserGadget, RGB(189, 189, 189) <-- Textfarbe Button normal, $262322<--Button Farbe normal, RGB(244, 244, 244)<-- Textfarbe wenn aktiv (Klickevent), RGB(6, 6, 6)<-- Button Farbe wenn aktiv (Klickevent))

Was noch nice ist und fehlt: eine Hover Farbe bei MouseEnter (stelle ich mir so vor):

SetButtonColor_(0, RGB(189, 189, 189) <-- Textfarbe Button normal, $262322<--Button Farbe normal, RGB(244, 244, 244)<-- Textfarbe bei Hover (MouseEnter), RGB(6, 6, 6)<-- Button Farbe bei Hover (MouseEnter)RGB(244, 244, 244)<-- Textfarbe wenn aktiv (Klickevent), RGB(6, 6, 6)<-- Button Farbe wenn aktiv (Klickevent));

Unterstützung Alphatransparenz für die Farbwerte wäre top.