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

Create usage example for draw_line_on_window #235

Open
wants to merge 3 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,30 @@
using SplashKitSDK;

namespace draw_line_on_window
{
public class Program
{
public static void Main()
{
// Create Window
Window start = new Window("draw line on window", 600, 600);
SplashKit.ClearScreen(SplashKit.ColorBlack());


// Draw line on window - param (Window, Color, x1, y1, x2, y2)
SplashKit.DrawLineOnWindow(start, SplashKit.ColorYellow(), 0,0,600,600);
SplashKit.DrawLineOnWindow(start, SplashKit.ColorGreen(), 0,150,600,450);
SplashKit.DrawLineOnWindow(start, SplashKit.ColorTeal(), 0,300,600,300);
SplashKit.DrawLineOnWindow(start, SplashKit.ColorBlue(), 0,450,600,150);
SplashKit.DrawLineOnWindow(start, SplashKit.ColorViolet(), 0,600,600,0);
SplashKit.DrawLineOnWindow(start, SplashKit.ColorPurple(), 150,0,450,600);
SplashKit.DrawLineOnWindow(start, SplashKit.ColorPink(), 300,0,300,600);
SplashKit.DrawLineOnWindow(start, SplashKit.ColorRed(), 450,0,150,600);
SplashKit.DrawLineOnWindow(start, SplashKit.ColorOrange(), 600,0,0,600);

SplashKit.RefreshScreen();
SplashKit.Delay(5000);
SplashKit.CloseAllWindows();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using SplashKitSDK;
using static SplashKitSDK.SplashKit;


// Create Window
Window start = OpenWindow("draw line on window", 600, 600);
ClearScreen(ColorBlack());


// Draw line on window - param (Window, Color, x1, y1, x2, y2)
DrawLineOnWindow(start, ColorYellow(), 0,0,600,600);
DrawLineOnWindow(start, ColorGreen(), 0,150,600,450);
DrawLineOnWindow(start, ColorTeal(), 0,300,600,300);
DrawLineOnWindow(start, ColorBlue(), 0,450,600,150);
DrawLineOnWindow(start, ColorViolet(), 0,600,600,0);
DrawLineOnWindow(start, ColorPurple(), 150,0,450,600);
DrawLineOnWindow(start, ColorPink(), 300,0,300,600);
DrawLineOnWindow(start, ColorRed(), 450,0,150,600);
DrawLineOnWindow(start, ColorOrange(), 600,0,0,600);
RefreshScreen();
Delay(5000);
CloseAllWindows();
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "splashkit.h"

int main()
{
// Create Window
window start = open_window("draw line on window", 600, 600);
clear_screen(COLOR_BLACK);


// Draw line on window - param (Window, Color, x1, y1, x2, y2)
draw_line_on_window(start, COLOR_YELLOW, 0,0,600,600);
draw_line_on_window(start, COLOR_GREEN, 0,150,600,450);
draw_line_on_window(start, COLOR_TEAL, 0,300,600,300);
draw_line_on_window(start, COLOR_BLUE, 0,450,600,150);
draw_line_on_window(start, COLOR_VIOLET, 0,600,600,0);
draw_line_on_window(start, COLOR_PURPLE, 150,0,450,600);
draw_line_on_window(start, COLOR_PINK, 300,0,300,600);
draw_line_on_window(start, COLOR_RED, 450,0,150,600);
draw_line_on_window(start, COLOR_ORANGE, 600,0,0,600);

refresh_screen();
delay(5000);
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,21 @@
from splashkit import *

#Create Window
start = open_window("draw line on window", 600, 600)
clear_screen(color_black())


#Draw line on window - param (Window, Color, x1, y1, x2, y2)
draw_line_on_window(start, color_yellow(), 0,0,600,600)
draw_line_on_window(start, color_green(), 0,150,600,450)
draw_line_on_window(start, color_teal(), 0,300,600,300)
draw_line_on_window(start, color_blue(), 0,450,600,150)
draw_line_on_window(start, color_violet(), 0,600,600,0)
draw_line_on_window(start, color_purple(), 150,0,450,600)
draw_line_on_window(start, color_pink(), 300,0,300,600)
draw_line_on_window(start, color_red(), 450,0,150,600)
draw_line_on_window(start, color_orange(), 600,0,0,600)

refresh_screen()
delay(5000)
close_all_windows()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Basic Line Drawing

The following code shows examples of using [Draw Line On Window](/api/graphics#draw-line-on-window-1) to draw lines on a window.