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

5 Usage example for Graphics P2 #341

Open
wants to merge 1 commit into
base: usage-examples
Choose a base branch
from

Conversation

huyhuynh2319
Copy link

Description

This is a usage example of the function set, pop, push, reset and current clip to display

Splashkit Function:
set-clip
push-clip
pop-clip
reset-clip
current-clip

Testing Checklist

  • C++ code
  • C# code (top-level statements)
  • C# code (Object-Oriented Programming)
  • Python code
  • Screenshot
  • Title and explanation (.txt)

Usage Example Checks

  • Simple, clear demonstration of the function
  • Code uses Splashkit functions
  • Tested in Chrome and Firefox

@huyhuynh2319 huyhuynh2319 changed the base branch from main to usage-examples December 11, 2024 03:44
Copy link

netlify bot commented Dec 11, 2024

Deploy Preview for splashkit-io ready!

Name Link
🔨 Latest commit 4de225d
🔍 Latest deploy log https://app.netlify.com/sites/splashkit-io/deploys/67590a9bc5ab0200085bbf0a
😎 Deploy Preview https://deploy-preview-341--splashkit-io.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

@Jinx-means-jinx Jinx-means-jinx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be great if u can separate the pull request to 5 different request, current_clip, pop_clip, push_clip, reset_clip and set_clip.

Copy link

@Jinx-means-jinx Jinx-means-jinx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the review for current _clip, fix it and I am happy to pass the PR

public static void Main()
{
// Open a window with the title "Current Clip" and dimensions
Window window= SplashKit.OpenWindow("Current Clip", 800, 600);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space after window, should look like this: Window window = SplashKit.OpenWindow("Current Clip", 800, 600);

using static SplashKitSDK.SplashKit;
using SplashKitSDK;
// Open a window with the title "Current Clip" and dimensions
Window window= OpenWindow("Current Clip", 800, 600);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space after window, same as above.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the space in front of the code.
image
like this

Window window= SplashKit.OpenWindow("Current Clip", 800, 600);

// Push a clipping area
Rectangle rectangle = SplashKit.CurrentClip();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add window in CurrentClip() -> CurrentClip(window), otherwise it is no need to create Window window.

Window window= OpenWindow("Current Clip", 800, 600);

// Push a clipping area
Rectangle rectangle = CurrentClip();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add window in CurrentClip() -> CurrentClip(window), otherwise it is no need to create Window window.

// Wait for 5 seconds
delay(5000);

// Close all windows

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure the commits are the same as well, so it makes less confusion to the users.

@@ -0,0 +1,21 @@
from splashkit import *

# Open a window with the title "Current Clip" and dimensions of 800x600 pixels

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check all commits and make sure it keeps the same please.

font = load_font("Arial", "arial.ttf")

# Retrieve the current clipping area
r = current_clip()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use 'rectangle' here. rectangle = current_clip(window)

rectangle rect = current_clip(win);

// Draw the clipping information
draw_text("Current Clip: " + std::to_string(rect.width) + " X " + std::to_string(rect.height), COLOR_BLACK, "Arial", 24, 100, 100);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to use the same work as the above code. Width and Height.

r = current_clip()

# Draw the clipping area dimensions as text on the screen
draw_text("Current Clip: " + str(r.width) + " X " + str(r.height), color_black(), font, 24, 100, 100)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to use the same work as above code. Width and Height.

@Jinx-means-jinx
Copy link

Jinx-means-jinx commented Jan 11, 2025

For pop clip:
I've reviewed the pop clip part

Checks

  • All required files are present.
    • Title and explanation (.txt)
    • C++ code
    • C# code (top-level statements)
    • C# code (Object-Oriented Programming)
    • Python code
  • Code correctly uses Splashkit functions.
  • Code clearly demonstrates the function.
  • All versions maintain the same structure and comments.

Tests done

  • C++ code ran correctly.
  • C# top level code ran correctly.
  • C# OOP code ran correctly.
  • Python code ran correctly.

@Jinx-means-jinx
Copy link

Jinx-means-jinx commented Jan 11, 2025

For push clip:
I've reviewed the push clip

Checks

  • All required files are present.
    • Title and explanation (.txt)
    • C++ code
    • C# code (top-level statements)
    • C# code (Object-Oriented Programming)
    • Python code
  • Code correctly uses Splashkit functions.
  • Code clearly demonstrates the function.
  • All versions maintain the same structure and comments.

Tests done

  • C++ code ran correctly.
  • C# top level code ran correctly.
  • C# OOP code ran correctly.
  • Python code ran correctly.

@Jinx-means-jinx
Copy link

Jinx-means-jinx commented Jan 11, 2025

For reset-clip:
I've reviewed the reset-clip

Checks

  • All required files are present.
    • Title and explanation (.txt)
    • C++ code
    • C# code (top-level statements)
    • C# code (Object-Oriented Programming)
    • Python code
  • Code correctly uses Splashkit functions.
  • Code clearly demonstrates the function.
  • All versions maintain the same structure and comments.

Tests done

  • C++ code ran correctly.
  • C# top level code ran correctly.
  • C# OOP code ran correctly.
  • Python code ran correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants