Skip to main content

How to Create a Star Rotation Program in VB.net

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
        g.Clear(Color.White)

    
        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))))
        Next

        ' 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
        Next
        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
    email: butanikartik1108@gmail.com
*/


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>
    <s…

Intent demo pass with text demo in Android

First Create Two acitvity layout file name firstscreen.xml second_screen.xml java filename FirstScreen.java SecondScreen.javafirstscreen.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/firstscreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.krbutani.intentpasswithdatademo.Firstscreen">

<Button
android:text="Goto Second"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignPare…