forked from splashkit/splashkit.io-starlight
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Circle intersect #335
Open
Jinx-means-jinx
wants to merge
21
commits into
thoth-tech:usage-examples
Choose a base branch
from
Jinx-means-jinx:circle-intersect
base: usage-examples
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Circle intersect #335
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
083956f
Made some change base on the PR
6a53854
delete mdx file
cac3e39
change the house drawing to background in C# code
ff3ab6b
change the title to blue background
9956b61
Remove the mouse in gif
7448f80
Update to simplify example
omckeon 5e8f8e8
add usage example draw circle on window
ee3d2c9
Merge branch 'thoth-tech:main' into draw-circle-on-window
Jinx-means-jinx c6a9a31
delete
a663878
Merge branch 'draw-circle-on-window' of https://github.com/Jinx-means…
23bd119
small change on txt
6987ddf
txt change
4ca74bf
add usage example point point angle
9783b8f
add usage example point-at
a6ca527
add usage example point-at
cfeb41e
txt
9859666
new idea
ab217ad
add new usage example
e8aac3a
change base on the PR
f7f31de
change base on the PR
8df8874
.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
public/usage-examples/geometry/circles_intersect/circles_intersect-1-simple-oop.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using SplashKitSDK; | ||
|
||
namespace CircleIntersectExample | ||
{ | ||
public class Program | ||
{ | ||
public static void Main() | ||
{ | ||
// Read the data for Circle A | ||
SplashKit.WriteLine("X coordinate for circle A: "); | ||
int X_A = SplashKit.ConvertToInteger(SplashKit.ReadLine()); | ||
SplashKit.WriteLine("Y coordinate for circle A: "); | ||
int Y_A = SplashKit.ConvertToInteger(SplashKit.ReadLine()); | ||
SplashKit.WriteLine("Radient for circle A: "); | ||
int R_A = SplashKit.ConvertToInteger(SplashKit.ReadLine()); | ||
|
||
// Create circle A based on the user's data | ||
Circle A = SplashKit.CircleAt(X_A, Y_A, R_A); | ||
|
||
//Read the data for Circle B | ||
SplashKit.WriteLine("X coordinate for circle B: "); | ||
int X_B = SplashKit.ConvertToInteger(SplashKit.ReadLine()); | ||
SplashKit.WriteLine("Y coordinate for circle B: "); | ||
int Y_B = SplashKit.ConvertToInteger(SplashKit.ReadLine()); | ||
SplashKit.WriteLine("Radient for circle B: "); | ||
int R_B = SplashKit.ConvertToInteger(SplashKit.ReadLine()); | ||
|
||
// Create circle B based on the user's data | ||
Circle B = SplashKit.CircleAt(X_B, Y_B, R_B); | ||
|
||
// Detect if the circles intersect | ||
if (SplashKit.CirclesIntersect(A, B)) | ||
{ | ||
SplashKit.WriteLine("The circles intersect!"); | ||
} | ||
else | ||
{ | ||
SplashKit.WriteLine("The circles do not intersect!"); | ||
} | ||
|
||
// Create a window | ||
SplashKit.OpenWindow("Circle Intersect", 800, 600); | ||
SplashKit.ClearScreen(); | ||
|
||
// Draw the circles based on the data given by user | ||
SplashKit.DrawCircle(Color.Red, X_A, Y_A, R_A); | ||
SplashKit.DrawCircle(Color.Red, X_B, Y_B, R_B); | ||
|
||
SplashKit.RefreshScreen(); | ||
SplashKit.Delay(4000); | ||
SplashKit.CloseAllWindows(); | ||
} | ||
} | ||
} | ||
|
47 changes: 47 additions & 0 deletions
47
public/usage-examples/geometry/circles_intersect/circles_intersect-1-simple-top-level.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using SplashKitSDK; | ||
using static SplashKitSDK.SplashKit; | ||
|
||
// Read the data for Circle A | ||
WriteLine("X coordinate for circle A: "); | ||
int X_A = ConvertToInteger(ReadLine()); | ||
WriteLine("Y coordinate for circle A: "); | ||
int Y_A = ConvertToInteger(ReadLine()); | ||
WriteLine("Radient for circle A: "); | ||
int R_A = ConvertToInteger(ReadLine()); | ||
|
||
// Create circle A based on the user's data | ||
Circle A = CircleAt(X_A, Y_A, R_A); | ||
|
||
// Read the data for Circle B | ||
WriteLine("X coordinate for circle B: "); | ||
int X_B = ConvertToInteger(ReadLine()); | ||
WriteLine("Y coordinate for circle B: "); | ||
int Y_B = ConvertToInteger(ReadLine()); | ||
WriteLine("Radient for circle B: "); | ||
int R_B = ConvertToInteger(ReadLine()); | ||
|
||
// Create circle B based on the user's data | ||
Circle B = CircleAt(X_B, Y_B, R_B); | ||
|
||
// Detect if the circles intersect | ||
if (CirclesIntersect(A, B)) | ||
{ | ||
WriteLine("The circles intersect!"); | ||
} | ||
else | ||
{ | ||
WriteLine("The circles do not intersect!"); | ||
} | ||
|
||
// Create a window | ||
OpenWindow("Circle Intersect", 800, 600); | ||
ClearScreen(); | ||
|
||
// Draw the circles based on the data given by user | ||
DrawCircle(Color.Red, X_A, Y_A, R_A); | ||
DrawCircle(Color.Red, X_B, Y_B, R_B); | ||
|
||
RefreshScreen(); | ||
Delay(4000); | ||
CloseAllWindows(); | ||
|
47 changes: 47 additions & 0 deletions
47
public/usage-examples/geometry/circles_intersect/circles_intersect-1-simple.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "splashkit.h" | ||
|
||
int main() | ||
{ | ||
// Read the data for Circle A | ||
write_line("X coordinate for circle A: "); | ||
int X_A = convert_to_integer(read_line()); | ||
write_line("Y coordinate for circle A: "); | ||
int Y_A = convert_to_integer(read_line()); | ||
write_line("Radient for circle A: "); | ||
int R_A = convert_to_integer(read_line()); | ||
|
||
// Create circle A based on the user's data | ||
circle A = circle_at(X_A, Y_A, R_A); | ||
|
||
// Read the data for Circle B | ||
write_line("X coordinate for circle B: "); | ||
int X_B = convert_to_integer(read_line()); | ||
write_line("Y coordinate for circle B: "); | ||
int Y_B = convert_to_integer(read_line()); | ||
write_line("Radient for circle B: "); | ||
int R_B = convert_to_integer(read_line()); | ||
|
||
// Create circle B based on the user's data | ||
circle B = circle_at(X_B, Y_B , R_B); | ||
|
||
// Detect if the circles intersect | ||
if(circles_intersect(A, B)) | ||
{ | ||
write_line("The circles intersect!"); | ||
} | ||
else{ | ||
write_line("The circles do not intersect!"); | ||
} | ||
|
||
// Create a window | ||
open_window("Circle Intersect", 800, 600); | ||
clear_screen(); | ||
|
||
// Draw the circles based on the data given by user | ||
draw_circle(COLOR_RED, X_A, Y_A, R_A); | ||
draw_circle(COLOR_RED, X_B, Y_B, R_B); | ||
|
||
refresh_screen(); | ||
delay(4000); | ||
close_all_windows(); | ||
} |
Binary file added
BIN
+18 KB
public/usage-examples/geometry/circles_intersect/circles_intersect-1-simple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions
45
public/usage-examples/geometry/circles_intersect/circles_intersect-1-simple.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from splashkit import * | ||
|
||
# Read the data for Circle A | ||
write_line("X coordinate for circle A: ") | ||
X_A = convert_to_integer(read_line()) | ||
write_line("Y coordinate for circle A: ") | ||
Y_A = convert_to_integer(read_line()) | ||
write_line("Radient for circle A: ") | ||
R_A = convert_to_integer(read_line()) | ||
|
||
# Create circle A based on the user's data | ||
A = circle_at(point_at(X_A, Y_A), R_A) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you could use circle_at_from_points here to match the overloaded functions used in the other files and not have to use point_at here. |
||
|
||
# Read the data for Circle B | ||
write_line("X coordinate for circle B: ") | ||
X_B = convert_to_integer(read_line()) | ||
write_line("Y coordinate for circle B: ") | ||
Y_B = convert_to_integer(read_line()) | ||
write_line("Radient for circle B: ") | ||
R_B = convert_to_integer(read_line()) | ||
|
||
# Create circle B based on the user's data | ||
B = circle_at(point_at(X_B, Y_B), R_B) | ||
|
||
# Detect if the circles intersect | ||
if (circles_intersect(A, B)): | ||
write_line("The circles intersect!") | ||
else: | ||
write_line("The circles do not intersect!") | ||
|
||
# Create a window | ||
open_window("Circle Intersect", 800, 600) | ||
clear_screen(color_white()) | ||
|
||
# Draw the circles based on the data given by user | ||
draw_circle(color_red(), X_A, Y_A, R_A) | ||
draw_circle(color_red(), X_B, Y_B, R_B) | ||
|
||
refresh_screen() | ||
delay(4000) | ||
close_all_windows() | ||
|
||
|
||
|
||
|
3 changes: 3 additions & 0 deletions
3
public/usage-examples/geometry/circles_intersect/circles_intersect-1-simple.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#### Circles Intersection Detect System | ||
|
||
The following code shows examples of using [Circles Intersect](/api/geometry/#circles-intersect-1) to show how to detect if two circle A and B intersect or not. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The window title in your screen shot does not match the code. Currently shows PointAt rather than Circle Intersect