C++ :: How To Draw Lines With Different Colors

Nov 8, 2014

I want to write a function called DrawLineSegments.This function must change the color of lines at every corner where the corner angle is greater than 60 deg (Assume that there is a function called checkangle). The color sequence must be black, red, green, blue, and repeat this sequence after the fourth color.

View 1 Replies


ADVERTISEMENT

Visual C++ :: Draw Multiple Lines And Move Them On Screen

Jul 28, 2013

I am writing a pure C based win32 applications. I have drawn line. Now i want to translate that line, move the line whereved user wants to move on screen. Then again I drawn another line, I am drawing multiple lines.

I have created rectangle region for each line and trying to move the line.

When I move the 2nd line over the 1st line on screen the 1st line is getting wiped out. Because I am InvalidateRect() of the rect for the line being moved, so when that rectangle is crossing the other line then the other line is getting removed from the screen.

How can I rectify it. How can I have all the lined being on the screen and moved according to the user's wish. The code should be pure C and win32 no MFC.

View 4 Replies View Related

C :: Strings To Be Printed In Different Colors

Aug 21, 2013

I am currently using Dev-C++ 4.9.9.2 compiler for creating a C project. I need few strings to be printed in a different color.

Code:
#include<stdio.h>
#include<conio.h>
int main(void)
{ textcolor(RED);
cprintf("Hello world
");
system("pause");
}

While I use " textcolor(RED) " it says: 'RED' undeclared, first use in this function.

If i make it: " textcolor(3) ", it says: [Linker error] undefined reference to textcolor & undefined reference to cprintf.

have been searching for a solution on google since morning. At last I could make out that it is not the correct compiler with suitable library or outdated <conio.h> header file.

I had switched from turbo(or borland, I don't remember) to Dev-C++ compiler due to some kind of library issue. Now I guess I'll have to switch to some other IDE. Which one is that, I don't know yet. There was another thread also about this topic, but didn't provide any solution.

Is there any method to upgrade certain header file (I don't think so)? What would be the best IDE with updated libraries?

View 7 Replies View Related

C# :: Colors - Integer Value For Alpha

Jul 14, 2014

I want to use a new color for BaseColor in iTextSharp.

I can easily set a new color using RGB values from 0 to 255.

However, if I want to adjust the alpha value (and I know alpha ranges from 0 to 1), I can't make the alpha 0.5 because it's not an integer in the definition of BaseColor.

public BaseColor(int red, int green, int blue, int alpha);

So I can set my BaseColor like below:

static BaseColor newColor = new BaseColor(192, 192, 192);

but I can't use a non-int value for alpha. How can I easily convert double alpha values to integer values? What would be the range for alpha in int values and how do I, e.g., set the alpha value to 0.5 in int values?

EDIT: btw, I found online something like this: int alpha = (pixel >> 24). I don't understand why 24 and how can I break that into chunks I understand?

View 5 Replies View Related

C :: Check How Many Colors Terminal Supports

Feb 17, 2013

I'm generating all ncurses color pairs like this

Code:

void generate_all_color_pairs(){ int foreground;
int background;
int i = 0;
for(foreground=0; foreground<8; foreground++){
for(background=0; background<8; background++){
i++;

[code]....

but according on several sources, some terminals suport more colors.Is there any way to determine how many colors the current terminal supports?

View 3 Replies View Related

C++ :: Detect Colors In The Black Rectangle?

Oct 5, 2013

I want to detect colors that in the black rectangle. [URL] How can I do? What library should I use?

View 7 Replies View Related

C# :: Manipulating Images Colors With ColorMatrix?

Feb 6, 2015

I found this elegant looking code on the net that claims to be able to manipulate an images colors using ColorMatrix.

When I run it, it does nothing! I used the code exactly as is with no editing, except to feed it my own image to do its work.

private void ApplySaturation(float saturation) {
float rWeight = 0.3086f;
float gWeight = 0.6094f;
float bWeight = 0.0820f;
float a = (1.0f - saturation) * rWeight + saturation;

[code].....

View 8 Replies View Related

C++ :: Make Colors Transparent Using 3rd Party Library

Jan 19, 2014

I'm trying to make colors transparent in c++ using a 3rd party library. I've successful made my background transparent but I feel I'm cheating by not understanding how I entered the value.

"0xff, 0xff, 0xff" is the color white but i'm not sure how it's the color white like with RGB values.

View 5 Replies View Related

C++ :: Assigning Colors To Individual Characters In Array?

Aug 31, 2014

Basically I am making a console RPG (isn't every beginner nowadays?) and I am having an incredible amount of trouble assigning specific characters their own color. e.g. monsters being red, cash being green, etc.

I took out Left, Right, and Down controls because of character constraint.

#include <iostream>
#include <windows.h>
//%%%%%%%%%%%%%% COLOR CALL %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void setcolor(unsigned short color) {
HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hcon,color);

[code]....

View 8 Replies View Related

Visual C++ :: Moving Mouse Cursor To Certain Colors On Monitor

Apr 22, 2013

I am currently starting to attempt to make a program that can move my cursor to certain colors on my monitor. The problem is this seems like it will be 10x harder than I first thought.

View 4 Replies View Related

C++ :: Print To Console Contents Of A File Using Foreground Colors And Other Attributes

Jun 29, 2013

Suppose I have a txt file that I want the contents printed to the console in such a way that every five words are colored blue and the following five are red. How do I accomplish such a task? I am currently only able to print the contents of the file in regular color using ifstream.

View 1 Replies View Related

C# :: Customize Font Styles / Colors / Size In Custom Message Box

Jul 15, 2014

I made my own custom message/dialog box.

I have a template mock up view using xaml. I have a viewmodel that raises the message property. I binded the message property to a textblock inside my xaml.

Since my messages are different for every viewmodel I have.

E.g.in every viewmodel, I have something like

messagewindow.Message = "This is a new message";
dialogService.ShowDialog(Success, messageWindow);

In one of my messages, I want to make the font bold and different color for a specific message segment.

How can I do that without messing up with the other messages that inherit from the xaml or code behind?

Currently, I'm not using any code behind and a lot of the examples online I've seen use code behind and/or don't have dynamic message textboxes.

View 5 Replies View Related

C++ :: How To Draw A Polygon

Nov 16, 2013

I am fairly new to c++, and I want to be able to draw a polygon. When I have searched for how to draw one, the only thing i can find is scripts doing things like this:

*
**
***
****
*****

I doubt that c++ is that primitive, and I'm looking for something like the c++ equivalent of this python script:

Syntax: draw.polygon((20,20)(30,30)(50,30)(20,40)(20,20), fill(green))

I am using a mac os 10.9

View 2 Replies View Related

C :: Draw A Grid Using The Characters?

Aug 20, 2013

I'm trying to create a grid using the following characters: !, @, #, $, &.

It's an 8 x 8 grid, and should contain the characters in no particular order (trying to create a Bejeweled-like game).

I already defined the width and length to be 8, so:

#define WIDTH 8
#define LENGTH 8

Code:

void makegrid(char grid[])
{
int j;
int k;
for ( j = -1; j < LENGTH; j++ )
{
for ( k = -1; k < WIDTH; k++ )
{
/* I don't know what to type here anymore :( */
}
} }

View 14 Replies View Related

C++ :: OpenGL - Draw On Top Of Image

Jun 22, 2014

This is my first time using opengl and I am experimenting with adding/drawing polygons/points/etc. on top of a PPM image. The image is already loaded when the application runs. My attempt to draw a square is from lines 30 - 35. The program runs but the square is not present. Just the image.

#include<windows.h>
#include <stdio.h>
#include <stdlib.h>
#include<Gl/gl.h>
#include<GL/glut.h>

int n;
int m;
int *image;

[Code] ....

View 5 Replies View Related

C++ :: How To Draw A 3D Snake In OpenGL

Jan 3, 2014

i want to draw a 3D snake in opengl.. i can't get nothing out of my search to make a start.. how it is made

View 4 Replies View Related

C++ :: Draw 2D Bar Chart According To 10 Or 15 Numbers?

Nov 26, 2013

I want to draw a 2D bar chart according to 10 or 15 numbers in c++. How can i do it? Which i need components?

View 1 Replies View Related

C++ :: How To Draw A Magnifying Glass

Jul 11, 2013

I want to draw a magnifying glass using graphics.h which is used mostly as "Search" icon. But, I am having problems in making the rectangle attached to the two circles (one inscribed on another) . I have also included the screenshot (made in powerpoint) on how the output will look like, enen I've made most of the part, except the search icon (magnifying glass).

The Link for the screenshot is : [URL] ....

View 3 Replies View Related

C/C++ :: How To Draw Shapes Using Loop

Apr 11, 2014

How can I draw thus shape using loop for
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5

Also this shape
1*****
12****
123***
1234**
12345*
123456

View 6 Replies View Related

C# :: How To Draw More Than One Line In WPF Using Array

Jul 8, 2014

I used the following code. I called a method named lets_draw

private void lets_draw() {
int i,z;
z = 40;
Line[] line = new Line[20];
for(i=1;i<=10;i++) {

[Code] ....

But it showed the following message

"An unhandled exception of type 'System.NullReferenceException' occurred in SkeletalTracking.exe
Additional information: Object reference not set to an instance of an object."

View 1 Replies View Related

C++ :: How To Draw Unoccupied Value From Array

Jan 5, 2015

Let's say there are three slots in my array (3 pieces of hardware to be used). If one worker comes in, it takes an instrument, and I tag it as used on random basis. Next, the next worker comes in, it takes another unused instrument randomly and so on. When the first worker finishes using that instrument, he returns it back to the inventory. How should I write such code in C++?

View 8 Replies View Related

C :: Draw Magen David Star

Apr 18, 2014

problem to draw magen david star ,i find code that draw pyramid of starts. how can i modify this code to receive magen david star ?

Code:
#include <stdio.h>
int main() {
int rows, star, spaces;
char bukva='A';
int number_of_stars = 6;
int number_of_rows = number_of_stars;

[Code]....

View 4 Replies View Related

C# :: Draw Single Pixel On Window

Mar 27, 2014

Im new to c#. In c++ I have made a window and painted it with dots and concentric circles, like a radar PPI screen. Trying to do this in c#, I can't find how to draw a single pixel on the window.

Also, what should I be drawing on: the form, panel, picturebox...?

View 2 Replies View Related

C++ :: Program That Can Draw Total Of Passed Value

Feb 4, 2014

Draw the total of a passed value, or value in general, without checking how many values there are individually.

Here's a pseudo-example:

int aliens = 10; // This should be changed as desired.
void drawaliens(int value) {
aliens.draw(value); // Instead of having a test of how many to draw, draw the amount there is from one check
}

I want to draw the amount of aliens passed or called to the alien draw function.

However, I don't want the function to check every possible value of aliens which could be passed before drawing, and just check the value once and draw that value.

IF x ALIENS, DRAW x ALIENS instead of...

IF 1 ALIEN, DRAW ALIEN(1);
IF 2 ALIEN, DRAW ALIEN(2);
IF 3 ALIEN, DRAW ALIEN(3);
.... and so on.

If there can be hundreds of aliens, it seems impractical to check every single possible value before drawing, and just check the value and draw that value.

View 2 Replies View Related

C++ :: 3D Graphics Programming Using SDL - Draw A Cube?

Apr 24, 2014

Ive been experimenting with 3d graphics by using SDL only and lines to draw 3d shapes (no OpenGL or extension libraries, just pure math),

Ive used this page mainly to guide me on perspective projection but i have no luck [URL] ....

Ive been trying to draw a cube, but instead it gives me a mirrored dual triangular pyramids

This code here rotates the object as seen from the equations in this link: [URL] ....

double aX, aY, aZ;
for ( i = 0; i < model->qLength; i++ ) {
for ( j = 0; j < 4; j++ ) {
aX = model->quadArr[i].pointArr[j].x;
aY = model->quadArr[i].pointArr[j].y;
aZ = model->quadArr[i].pointArr[j].z;

[Code] .....

generally, i project it onto a 2d plane using: [URL] .....

double dx, dy, dz, dX, dY, dZ;
int bx, by, bX, bY;
for ( i = 0; i < model->qLength; i++ ) {
for ( j = 0; j < 4; j++ ) {

[Code] .....

I understand that my code is very messy and unoptimized, but im just concentrating on getting the core concepts to work with my code

View 1 Replies View Related

C++ :: Draw The Same Sprite Multiple Times (SDL)?

Sep 7, 2014

I have a question about SDL and drawing sprites (SDL surfaces). My idea is that the user can create a wall of separate sprites by create one sprite each time in the current mouseX and mouseY position, when the user push down the e-key. The problem is that I have no idea how I could draw the same sprite multiple times without to delete the previous one.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved