borderAndreaVB free resources for Visual Basic developersborder
borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2016 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Next Topic (Taskbar color in windows xp) New Topic New Poll Post Reply
AndreaVB Forum : API : How to rotate a drawing object
Poster Message
Benx
Level: Protégé

Registered: 02-11-2008
Posts: 8

icon How to rotate a drawing object

Hello,

I have wrote code to draw moon in the sky using Api's.
Moon is displayed properly, so i want to know how to rotate it from 0 to 360°.
if anyone want to see the code i will attach it with next post.
Thank you

18-03-2009 at 10:06 AM
View Profile Send Email to User Show All Posts | Quote Reply
admin
Level: Administrator


Registered: 04-04-2002
Posts: 536
icon Re: How to rotate a drawing object

Hi Benx,

please attach the code or write it in the post so we can have a look and test your graphical API calls to see if we can rotate it...

    

____________________________
AndreaVB

20-03-2009 at 09:56 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
Benx
Level: Protégé

Registered: 02-11-2008
Posts: 8
icon Re: How to rotate a drawing object

quote:
admin wrote:
Hi Benx,

please attach the code or write it in the post so we can have a look and test your graphical API calls to see if we can rotate it...

    



Yes I do,
code attached to this msg.
21-03-2009 at 09:55 AM
View Profile Send Email to User Show All Posts | Quote Reply
Benx
Level: Protégé

Registered: 02-11-2008
Posts: 8
icon Re: How to rotate a drawing object

quote:
Benx wrote:
quote:
admin wrote:
Hi Benx,

please attach the code or write it in the post so we can have a look and test your graphical API calls to see if we can rotate it...

    



Yes I do,
code attached to this msg.



Option Explicit
    
    Private Type Lune
        X As Double
        y As Double
        Ad As Double
        Dec As Double
        Lat As Double
        Lon As Double
        Elongation As String
        Fraction As Double
        Nom As String
    End Type

    Private Lune As Lune

    'Déclaration des APIs Windows pour l'utilisation des régions

    Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
    Private Declare Function FillRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long) As Long
    Private Declare Function OffsetRgn Lib "gdi32" (ByVal hRgn As Long, ByVal X As Long, ByVal y As Long) As Long
    Private Declare Function PaintRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long) As Long

    'CombineRgn nCombineMode flag constants
    Private Const RGN_AND = 1
    Private Const RGN_OR = 2
    Private Const RGN_XOR = 3
    Private Const RGN_DIFF = 4
    Private Const RGN_COPY = 5

    Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  
    
    Const Pi As Double = 3.141592653
    Const Rad As Double = Pi / 180
    Const Deg As Double = 180 / Pi
  
    
    
Private Sub Form_Click()
   Dim X As Long, y As Long
   Dim Dec As Double, DR As Double
    AutoRedraw = True
    ScaleMode = vbPixels
        
    'Scale (0, -90)-(360, 90)
    BackColor = &HC00000
    
    'moon aspect
    Lune.Elongation = "Ouest"      'Set "Est" or "Ouest"
    Lune.Fraction = 0.25           'Value from 0 to 1
          

    'Moon Diameter
    Dim diam As Integer
     diam = 50

    'center of moon
    'with x=180 and y=0 the moon must be in the center of form, according scale, but it is not!
    
    'Draw moon in the center of the chart.
    X = 180
    Dec = 0
    DR = Dec * Rad

        
    y = Sin(DR) / (1 + Cos(DR)) * Deg
    
    'calculate X and Y based on a (0,-90)-(360,90) scale
    X = (ScaleWidth / 360) * X
    y = (ScaleHeight / 180) * (90 - y)
    
    Dim ShowDarkMoon As Boolean
    Dim lRgn1 As Long, lRgn2 As Long, lRgn3 As Long

    '_____________
    'lune entiere
    lRgn1 = CreateEllipticRgn(0, 0, diam, diam)

    '__________________________
    'tracé de la partie sombre

    'déplacement à l'endroit voulu
    OffsetRgn lRgn1, X - diam / 2, y - diam / 2

    'brosse pour le tracé
    Dim lBrshDrk As Long
    If ShowDarkMoon Then
        lBrshDrk = CreateSolidBrush(&H404040)
    Else
        lBrshDrk = CreateSolidBrush(&H400000)
    End If

    'tracé
    FillRgn hdc, lRgn1, lBrshDrk
    DeleteObject lBrshDrk

    'retour en (0,0) pour la suite
    OffsetRgn lRgn1, -X + diam / 2, -y + diam / 2

    '___________________________________
    'cache rectangulaire pour la moitié
    lRgn3 = CreateRectRgn(0, 0, diam / 2, diam)
    If Lune.Elongation = "Ouest" Then _
        OffsetRgn lRgn3, diam / 2, 0                'repositionnement du cache
    CombineRgn lRgn1, lRgn1, lRgn3, RGN_DIFF        'on soustrait le cache à la lune

    '________________
    'région centrale
    lRgn2 = CreateEllipticRgn(diam * Lune.Fraction, 0, diam * (1 - Lune.Fraction), diam)
    If Lune.Fraction < 0.5 Then
        CombineRgn lRgn1, lRgn1, lRgn2, RGN_DIFF    'région centrale sombre
    Else
        CombineRgn lRgn1, lRgn1, lRgn2, RGN_OR      'région centrale éclairée
    End If

    '______________________________
    'déplacement à l'endroit voulu
    OffsetRgn lRgn1, X - diam / 2, y - diam / 2

    '______
    'tracé
    Dim lBrsh As Long
    lBrsh = CreateSolidBrush(vbWhite)               'brosse pour le tracé
    FillRgn hdc, lRgn1, lBrsh

    '____________________________
    'Suppression des objets créé
    DeleteObject lBrsh
    DeleteObject lRgn1
    DeleteObject lRgn2
    DeleteObject lRgn3

    Refresh
End Sub

    
24-03-2009 at 09:04 AM
View Profile Send Email to User Show All Posts | Quote Reply
doggieshu
Level: Protégé

Registered: 10-03-2014
Posts: 6
icon Re: How to rotate a drawing object

I just wonder which developing environment are you trying to rotate image, Word or PDF?

http://www.rgraph.net/docs/api-to-rotate-image

10-03-2014 at 02:45 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : API : How to rotate a drawing object
Next Topic (Taskbar color in windows xp) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
borderAndreaVB free resources for Visual Basic developersborder
borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2016 Andrea Tincaniborder