Skip to main content

How to Create a Star Rotation Program in

Design View :
                    Take two control button and timer control and not change any property.
Code View :

Public Class Form1
    Dim g As Graphics

    ' variable declaration
    Dim theta As Double = 3.1415 / 180
    Dim t(5) As Double
    Dim i As Integer = 1
    Dim xc, yc, r, cx, cy As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Start() ' timer is star to draw the star
    End Sub

    Public Sub drawstar()
        g = Me.CreateGraphics

        r = 80 ' size of object

        ' find a center point of the screen and assign a value of variable
        cx = (Me.Width / 2) - 30
        cy = (Me.Height / 2) - 30

        ' find out the xc and yc center point of the circle
        xc = CInt(cx + Math.Cos(t(0)))
        yc = CInt(cy + Math.Sin(t(0)))

        ' find the acutal point of the draw the star
        Dim pts1(5) As Point
        For k As Integer = 0 To t.Length - 1
            pts1(k) = New Point(xc + CInt(r * Math.Cos(t(k))), yc + CInt(r * Math.Sin(t(k))))

        ' draw the star
        g.DrawPolygon(Pens.Black, pts1)

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ' this logic is apply for rotation of the star

        Dim angle As Integer = 360 / 5

        Dim j As Integer = 0 ' it is use to find the star 5 point
        For k As Integer = 0 To t.Length - 1
            t(k) = theta * (angle + j + i) ' find out the theata value of the polygon
            j += 144
        i += 5 ' every time angle is change if i value is change to increment that is draw diffrent angle

        ' i += 10 then the rotation speed is increase
        ' i += 1 then the rotation speed is small

        ' so if you increase the value of i is high then speed is also high
        ' else speed is slow
        drawstar() ' call main star drawing funtion or may procedure
    End Sub
End Class
Post a Comment

Popular posts from this blog

My new Jquery Plugin name is krDailog

This is my new jquery plugin i hope this is use full to you if you require this plugin than contact me

    krDailog Version 1.0
    Author: krButani

Require to use this function
    - bootstrap.css new version
    - bootstrap.js new version
    - jquery.js new version
    - jquery-ui.js new version
    - glyphicons font by bootstrap

# you can use new version of all and also use min file also

# include file first this way

    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/krDailog.css">
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>

Intent demo pass with text demo in Android

First Create Two acitvity layout file name firstscreen.xml second_screen.xml java filename SecondScreen.javafirstscreen.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=""

android:text="Goto Second"