Canvas

Dec 26, 2012 at 5:55pm
Hey guys, I'm creating a program that essentially consist of a Canvas class that displays shapes (Rectangle & Square) inside it. The issue I have is, I can't seem to have a picture of how it suppose to display on the command prompt. Any screenshots and ideas would be highly appreciated. Thanks everybody :)
Dec 26, 2012 at 8:10pm
search "SVG" or "Scalable Vector Graphics" in google.
it is an XML file (text file). An SVG viewer renders this XML to a picture.
Dec 27, 2012 at 12:30pm
Err does this work in C++?

I am supposed to do it in C++ on standard libraries.
Dec 28, 2012 at 10:06am
Standard library does not have any graphical header.
you can create a text file in SVG format and then open it with an image viewer.
This is a simple SVG picture:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<svg id="svgelem" height="400" width="500" xmlns="http://www.w3.org/2000/svg">
<defs>
	<radialGradient id="gradient1" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
		<stop offset="0%" style="stop-color:rgb(200,200,200); stop-opacity:0" />
		<stop offset="100%" style="stop-color:rgb(0,0,255); stop-opacity:1" />
	</radialGradient>
	<radialGradient id="gradient2" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
		<stop offset="0%" style="stop-color:red; stop-opacity:1" />
		<stop offset="100%" style="stop-color:rgb(100,100,100); stop-opacity:1" />
	</radialGradient>
</defs>

	<circle cx="100" cy="100" r="100" fill="red"
		style="stroke:blue;stroke-width:2;fill:url(#gradient2)" />
	<rect id="redrect" x="200" y="0" width="200" height="200" fill="green"
		style="stroke:yellow;stroke-width:2" />
	<ellipse cx="450" cy="100" rx="50" ry="100"
		style="stroke:gray;stroke-width:2;fill:url(#gradient1)" />
	<polygon points="20,290 170,220, 110,350" fill="magenta"
		style="stroke:cyan;stroke-width:2" />
	<line x1="25" y1="225" x2="175" y2="375"
		style="stroke:purple;stroke-width:2" />
	<polyline points="200,210 200,270 300,230 300,350 410,300 450,380" fill="white"
		style="stroke:purple;stroke-width:2" />
</svg>

As you see this is a text file. you can create one of them with c++, then you can open it with image viewer.

EDIT: you can do this in an object oriented manner.
Last edited on Dec 28, 2012 at 10:06am
Dec 28, 2012 at 2:49pm
Oh all right. Thanks for that. But I'm acquired to do it with standard library.

It's for my assignment :)
Is there a way to do it with a standard one?
Dec 30, 2012 at 9:25pm
If you want to create an image, there are no standard or library in c++ for that.
But as I said create a text file like above with standard library (fstream) and view that with an image viewer.
Topic archived. No new replies allowed.