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

update1 #67

Open
wants to merge 2 commits into
base: master
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,87 @@
# Basic Graphic Programming in C++

<aside>
💡 Introduction to C++ graphics: Graphics in C++ is defined to create a graphic model like creating different shapes and adding colors to it. It can be done in the C++ using your terminal or command prompt or you can download DevC++ compiler to create graphic programs. For terminal you need to add the graphics. h library to you GCC compiler. We can draw the circle, line, eclipse, and other geometric shapes too

</aside>

### What is graphics.h exactly?

**graphics.h** library is used to include and facilitate graphical operations in program. graphics.h functions can be used to draw different shapes, display text in different fonts, change colors and many more. Using functions of graphics.h you can make graphics programs, animations, projects and games. You can draw circles, lines, rectangles, bars and many other geometrical figures. You can change their colors using the available functions and fill them.

### **As mentioned earlier the header file “graphics.h” contains functions which some of them are described below:**

- `int initwindow (int width, int height, const char* title, int left, int top)`

In order to generate a Viewport or a window for drawing graphics shapes, we should use a function called initwindow()

- **int width:** width of the created window in pixels (integer type)
- **int height:** height of the created window in pixels (integer type)
- **const char* title: t**he title of the generated window which is a string type with dynamic and fixed memory allocation
- **int left:** the horizontal (X) position of the window on the screen (integer type)
- **int top:** the longitudinal (Y) position of the window on the screen (integer type)

`initwindow (400 ,400, "Viewport" ,300 ,200);`

- `putpixel(int x, int y)`

This function is used to draw a dot in (x, y) position.

- `line(int x1, int y1, int x2, int y2);`

Line function is used to draw a line from a point (x1, y1) to point (x2, y2). (x1, y1) and (x2, y2) are end points of the line.

- `circle(int x, int y, int radius);`

Circle function is used to draw a circle with center (x, y) and radius specified in the third parameter.

- `rectangle (int left, int top, int right, int bottom);`

To create a rectangle, you have to pass the four parameters in this function. The two parameters represent the left and top upper left corner. Similarly, the right bottom parameter represents the lower right corner of the rectangle.

- `outtextxy(int x, int y, char *string);`

This function displays the text or string at a specified point (x, y) on the screen.
.

- `setcolor(int color);`

setcolor sets the current drawing color to a new color. In graphics, each color is assigned a number. Total number of colors available are 16. Number of available colors depends on current graphics mode and driver. For example, setcolor(RED) or setcolor(4) changes the current drawing color to RED. (default drawing color is WHITE) The Colors table is given below:

| Color | Int values |
| --- | --- |
| BLACK | 0 |
| BLUE | 1 |
| GREEN | 2 |
| CYAN | 3 |
| RED | 4 |
| MAGENTA | 5 |
| BROWN | 6 |
| LIGHTGRAY | 7 |
| DARKGRAY | 8 |
| LIGHTBLUE | 9 |
| LIGHTGREEN | 10 |
| LIGHTCYAN | 11 |
| LIGHRED | 12 |
| LIGHTMAGENTA | 13 |
| YELLOW | 14 |
| WHITE | 15 |
- `setfillstyle(int pattern, int color);`

This ****function sets the current fill pattern and fill color. The table of colors has already mentioned; below is the table showing INT VALUES corresponding to Patterns:

| Pattern | Int values |
| --- | --- |
| EMPTY_FILL | 0 |
| SOLID_FILL | 1 |
| LINE_FILL | 2 |
| LTSLASH_FILL | 3 |
| SLASH_FILL | 4 |
| BKSLASH_FILL | 5 |
| LTBKSLASH_FILL | 6 |
| HATCH_FILL | 7 |
| XHATCH_FILL | 8 |
| INTERLEAVE_FILL | 9 |
| WIDE_DOT_FILL | 10 |
| CLOSE_DOT_FILL | 11 |
| USER_FILL | 12 |
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13 changes: 13 additions & 0 deletions django_practiceEnglish_app/PracticeEnglish/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django.contrib import admin
from .models import *
admin.site.register(example)
admin.site.register(verb_court)
admin.site.register(verb_restaurant)
admin.site.register(verb_airport)
admin.site.register(verb_hotel)
admin.site.register(phrase_say)
admin.site.register(phrase_off)
admin.site.register(phrase_afraid)
admin.site.register(new_thing_me_too)
admin.site.register(new_thing_ithink)
admin.site.register(new_thing_very)
6 changes: 6 additions & 0 deletions django_practiceEnglish_app/PracticeEnglish/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class PracticeenglishConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'PracticeEnglish'
10 changes: 10 additions & 0 deletions django_practiceEnglish_app/PracticeEnglish/form.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# from django.forms import ModelForm
# from django import forms
# from .models import *

# class uoload_verb_court(ModelForm):
# verb=forms.TextInput()
# meaning=forms.TextInput()
# class Meta:
# model=verb_court
# fields=["verb", "meaning"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Generated by Django 4.1.3 on 2022-11-23 07:47

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='example',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=30)),
('meaning', models.CharField(max_length=30)),
('example', models.CharField(max_length=500)),
],
),
migrations.CreateModel(
name='new_thing_ithink',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('new', models.CharField(max_length=30)),
('example', models.CharField(max_length=60)),
],
),
migrations.CreateModel(
name='new_thing_me_too',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('new', models.CharField(max_length=30)),
('example', models.CharField(max_length=60)),
],
),
migrations.CreateModel(
name='phrase_afraid',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('phrase', models.CharField(max_length=30)),
('meaning', models.CharField(max_length=30)),
],
),
migrations.CreateModel(
name='phrase_off',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('phrase', models.CharField(max_length=30)),
('meaning', models.CharField(max_length=30)),
],
),
migrations.CreateModel(
name='phrase_say',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('phrase', models.CharField(max_length=30)),
('meaning', models.CharField(max_length=30)),
],
),
migrations.CreateModel(
name='verb_airport',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('verb', models.CharField(max_length=30)),
('meaning', models.CharField(max_length=30)),
],
),
migrations.CreateModel(
name='verb_court',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('verb', models.CharField(max_length=30)),
('meaning', models.CharField(max_length=30)),
],
),
migrations.CreateModel(
name='verb_hotel',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('verb', models.CharField(max_length=30)),
('meaning', models.CharField(max_length=60)),
],
),
migrations.CreateModel(
name='verb_restaurant',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('verb', models.CharField(max_length=30)),
('meaning', models.CharField(max_length=30)),
],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.1.3 on 2022-11-23 10:07

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('PracticeEnglish', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='new_thing_ithink',
name='example',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.1.3 on 2022-11-23 10:18

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('PracticeEnglish', '0002_remove_new_thing_ithink_example'),
]

operations = [
migrations.CreateModel(
name='new_thing_very',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('new', models.CharField(max_length=30)),
('example', models.CharField(max_length=60)),
],
),
]
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
83 changes: 83 additions & 0 deletions django_practiceEnglish_app/PracticeEnglish/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
from django.db import models

class example(models.Model):
name = models.CharField(max_length=30)
meaning = models.CharField(max_length=30)
example = models.CharField(max_length=500)

def __str__ (self):
return self.name

class phrase_say(models.Model):
phrase = models.CharField(max_length=30)
meaning = models.CharField(max_length=30)
#example = models.CharField(max_length=500)

def __str__ (self):
return self.phrase
class phrase_off(models.Model):
phrase = models.CharField(max_length=30)
meaning = models.CharField(max_length=30)
#example = models.CharField(max_length=500)

def __str__ (self):
return self.phrase
class phrase_afraid(models.Model):
phrase = models.CharField(max_length=30)
meaning = models.CharField(max_length=30)
#example = models.CharField(max_length=500)

def __str__ (self):
return self.phrase

class verb_court(models.Model):
verb = models.CharField(max_length=30)
meaning = models.CharField(max_length=30)
#example = models.CharField(max_length=500)

def __str__ (self):
return self.verb
class verb_restaurant(models.Model):
verb = models.CharField(max_length=30)
meaning = models.CharField(max_length=30)
#example = models.CharField(max_length=500)

def __str__ (self):
return self.verb
class verb_airport(models.Model):
verb = models.CharField(max_length=30)
meaning = models.CharField(max_length=30)
#example = models.CharField(max_length=500)

def __str__ (self):
return self.verb
class verb_hotel(models.Model):
verb = models.CharField(max_length=30)
meaning = models.CharField(max_length=60)
#example = models.CharField(max_length=500)

def __str__ (self):
return self.verb


class new_thing_me_too(models.Model):
new = models.CharField(max_length=30)
example = models.CharField(max_length=60)
# instead = models.CharField(max_length=1000)

def __str__ (self):
return self.new
class new_thing_ithink(models.Model):
new = models.CharField(max_length=30)
# example = models.CharField(max_length=60)
# instead = models.CharField(max_length=1000)

def __str__ (self):
return self.new
class new_thing_very(models.Model):
new = models.CharField(max_length=30)
example = models.CharField(max_length=60)
# instead = models.CharField(max_length=1000)

def __str__ (self):
return self.new
Loading