Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Point in circle #354

Open
wants to merge 27 commits into
base: usage-examples
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using SplashKitSDK;

namespace PointInCircleExample
{
public class Program
{
public static void Main()
{
Window window = new Window("Point In Circle", 800, 600);
window.Clear(Color.White);

// Create a circle A
Circle A = SplashKit.CircleAt(400, 300, 100);

// Create a point 2d name mounse point
Point2D MousePoint;

while (!SplashKit.QuitRequested())
{
SplashKit.ProcessEvents();

// Set mouse point to the position of mouse
MousePoint = SplashKit.MousePosition();

// When mouse inside the circle show text "point in the circle!" and the color of the circle change to red
if (SplashKit.PointInCircle(MousePoint, A))
{
SplashKit.ClearScreen();
SplashKit.DrawCircle(SplashKit.ColorRed(), A);
string text = "Point in the Circle!";
SplashKit.DrawText(text, SplashKit.ColorRed(), 100, 100);
SplashKit.RefreshScreen();
}
// When mouse do not inside the circle show text "point not in the circle!" and the color of the circle change to green
else
{
SplashKit.ClearScreen();
SplashKit.DrawCircle(SplashKit.ColorGreen(), A);
string text = "Point not in the Circle!";
SplashKit.DrawText(text, SplashKit.ColorRed(), 100, 100);
SplashKit.RefreshScreen();
}
}

window.Refresh();
SplashKit.Delay(4000);
window.Close();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using SplashKitSDK;
using static SplashKitSDK.SplashKit;

OpenWindow("Point In Circle", 800, 600);
ClearScreen();

// Create a circle A
Circle A = CircleAt(400, 300, 100);

// Create a point 2d name mounse point
Point2D MousePoint;

while (!QuitRequested())
{
ProcessEvents();

// Set mouse point to the position of mouse
MousePoint = MousePosition();

// When mouse inside the circle show text "point in the circle!" and the color of the circle change to red
if (PointInCircle(MousePoint, A))
{
ClearScreen();
DrawCircle(ColorRed(), A);
string text = "Point in the Circle!";
DrawText(text, ColorRed(), 100, 100);
RefreshScreen();
}
// When mouse do not inside the circle show text "point not in the circle!" and the color of the circle change to green
else
{
ClearScreen();
DrawCircle(ColorGreen(), A);
string text = "Point not in the Circle!";
DrawText(text, ColorRed(), 100, 100);
RefreshScreen();
}
}

RefreshScreen();
Delay(4000);
CloseAllWindows();
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "splashkit.h"

int main()
{
open_window("Point In Circle", 800, 600);
clear_screen();

// Create a circle A
circle A = circle_at(400, 300, 100);

// Create a point 2d name mounse point
point_2d MousePoint;

while (!quit_requested())
{
process_events();

// Set mouse point to the position of mouse
MousePoint = mouse_position();

// When mouse inside the circle show text "point in the circle!" and the color of the circle change to red
if (point_in_circle(MousePoint, A))
{
clear_screen();
draw_circle(COLOR_RED, A);
string text = "Point in the Circle!";
draw_text(text, COLOR_RED, 100, 100);
refresh_screen();
}
// When mouse do not inside the circle show text "point not in the circle!" and the color of the circle change to green
else
{
clear_screen();
draw_circle(COLOR_GREEN, A);
string text = "Point not in the Circle!";
draw_text(text, COLOR_RED, 100, 100);
refresh_screen();
}
}
refresh_screen();
delay(4000);
close_all_windows();

return 0;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from splashkit import *

open_window("Point In Circle", 800, 600)
clear_screen(color_white())

# Create a circle A
A = circle_at(point_at(400, 300), 100)

while not quit_requested():

process_events()

# Set mouse point to the position of mouse
MousePoint = mouse_position()

# When mouse inside the circle show text "point in the circle!" and the color of the circle change to red
if point_in_circle(MousePoint, A):
clear_screen(color_white())
draw_circle(color_red(), 400, 300, 100)
text = "Point in the Circle!"
draw_text(text, color_red(),0, 10, 100, 100)
refresh_screen()

# When mouse do not inside the circle show text "point not in the circle!" and the color of the circle change to green
else:
clear_screen(color_white())
draw_circle(color_green(), 400, 300, 100)
text = "Point not in the Circle!"
draw_text(text, color_red(), 0, 10, 100, 100)
refresh_screen()

refresh_screen()
delay(4000)
close_all_windows()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#### Point in tcircle

The following code shows an example of using [Point In Circle](/api/geometry/#point-in-circle) to show how to check if the mouse point in circle or not.