Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7774313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:20:47+00:00 2026-06-01T17:20:47+00:00

I found this small application that i’ve been playing around with for the past

  • 0

I found this small application that i’ve been playing around with for the past little while. I was wondering, if i wanted to simply rotate the image in a circle? or make the entire image just bounce up and down, how would i modify this program to do so? Everything i’ve tried will just stretch the image – even if i do get it to move to the left or to the right. Any ideas on what i can do? Code is below

   public partial class Form1 : Form
   {
          private int width = 15;
          private int height = 15;

          Image pic = Image.FromFile("402.png");
          private Button abort = new Button();
          Thread t;

          public Form1()
          {
            abort.Text = "Abort";
            abort.Location = new Point(190, 230);
            abort.Click += new EventHandler(Abort_Click);
            Controls.Add(abort);

            SetStyle(ControlStyles.DoubleBuffer| ControlStyles.AllPaintingInWmPaint| ControlStyles.UserPaint, true);

            t = new Thread(new ThreadStart(Run));
            t.Start();
          }
          protected void Abort_Click(object sender, EventArgs e) 
          {
            t.Abort();
          }

          protected override void OnPaint( PaintEventArgs e )   
          {
             Graphics g = e.Graphics;
             g.DrawImage(pic, 10, 10, width, height);
             base.OnPaint(e);
          }

          public void Run() 
          {

              while (true) 
              {
                for(int i = 0; i < 200; i++) 
                {
                    width += 5;

                  Invalidate();
                  Thread.Sleep(30);
                }

              }
          }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:20:48+00:00Added an answer on June 1, 2026 at 5:20 pm

    So I don’t know what you’re trying to achieve, but to get the fundies out of the way, WinForms is a GDI+ library and its meant more for GUI stuff, so something like animation will probably be handled better by a graphics library like SFML.

    Anyways, there’s a million ways to achieve what you want. In terms of moving something around in a circle, you’re gonna need a little simple trig. For a bouncing motion, I would say following a sine curve would be the easiest way.

    Here’s some pseudo-code (not sure if this is syntax-perfect) for bouncing:

    Field Definitions:

    private double frame = 0;
    

    OnPaint:

    Graphics g = e.Graphics;
    g.DrawImage(pic, 10, 10 + Math.sin(frame)*10, width, height);
    frame+=.01;
    base.OnPaint(e);
    

    This way, every time the paint event is triggered, t will increase by .01 radians. The sin has a domain that will oscillate between -1 and 1, and you can multiply that by a factor of 10 to get that bouncing effect.

    Frame represents your “keyframe”. If you want to speed it up, increase the frame+=__ to a higher value. If you want to increase the range, change the offset Math.sin(frame)*__

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've found this small code that sends email to gmail users. I'd like the
This is from a small library that I found online: const char* GetHandStateBrief(const PostFlopState*
I found this open-source library that I want to use in my Java application.
I have a small application that I was running right now and I wanted
I've written a small application that simply has a timer that polls a database
I found this css body { font: 13px/1.231 arial,helvetica,clean,sans-serif; *font-size: small; *font: x-small; }
Found this question that explained a way to communicate between layers. However there is
I am implementing a small application (observer) that needs to attach itself to the
I am writing a small WebSocket server application that should support both draft 17
I have a small application that uses the same API as the powerscript examples

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.