-
Notifications
You must be signed in to change notification settings - Fork 570
Canvas Update #628
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
Canvas Update #628
Conversation
Now I see that the code not compiled but do you have tried it on your machine before creating the PR? I suggest you a more simpler approach instead to draw rectangles one inside the other it will be better to use DrawLine you can draw a simple draw horizontal lines until the rectangle has been filled. Thank you for the help! |
I tried to compil cosmos with #628 and and Cosmos does not build. |
There is obviously no hurry :-) |
where is the test runner? |
The graphic TestRunner is here: https://github.com/CosmosOS/Cosmos/blob/master/Tests/GraphicTest/Kernel.cs to enable it comment the other test and leave only it from here: https://github.com/CosmosOS/Cosmos/blob/master/Tests/Cosmos.TestRunner.Core/TestKernelSets.cs you simply execute tests use the TestRunner project (the text mode one, the graphic based does not show Cosmos' console so no GUI seen!). |
Fix spelling mistake and fix errors
@@ -230,6 +230,29 @@ public void DrawRectangle(Pen pen, int x, int y, int width, int height) | |||
DrawLine(pen, xc, yc, xd, yd); | |||
} | |||
|
|||
public void DrawFilledRectangle(Pen pen, int x_start, int y_start, int width, int height) | |||
{ | |||
for (int i; i != width; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be int i = 0
} | ||
} | ||
|
||
public void DrawSquare(Pen pen, int x, int y, int sideslength) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't make sense to have DrawSquare nor DrawFilledSquare, as it can be done using DrawRectangle and DrawFilledRectangle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have decided that DrawSquare / DrawFilledSquare are in the end not needed.
Only a thing can you add to the CGS demo the Drawing of a filled rectangle?
Another thing the methods that could be overriden by a driver that has these "shapes" in hardware should be done virtual so DrawLine(), DrawRectangle() and DrawFilledRectangle() must be all virtual so as all the methods requested in #603. Thank you! |
What do you mean by virtual? |
Add virtual modifier to the method for example: public virtual void DrawLine(Pen pen, int x1, int y1, int x2, int y2) Bochs not having the capacity to draw lines in hardware will use this software implementation but a more powerful GPU (VmWare has already some emulated "hardware" capabilities) will override this method to implement its version of DrawLine() but it cannot do it if DrawLine() is not declared virtual in the Canvas abstract class. |
So can I make a copy of every drawX void and make it virtual? |
No you not have to copy anything the methods: DrawLine(), DrawRectangle() and DrawFilledRectangle() must have the virtual modifier nothing else have to be changed. The other methods in the more "shapes" issue should be virtual too maybe some very advanced GPU gives the possibility to draw triangles in hardware so it can be overridden too. |
I'm writing the .DrawString method, here an exemple for the letter A: |
@valentinbreiz I don't know if we should have a DrawString method, it should be implemented by the graphics library, because fonts can be vectorial or use images for letters. The example you provided is vectorial, but it should be handled by the graphics library. We should provide methods for drawing vector images, like drawing lines, bézier curves... I don't know if we should handle drawing images, I think it should be implemented by a graphics library too. |
DrawString() and DrawImage() was in the list of "CGS New Features" but I've put them there I didn't had analyzed how much difficult they where... probably as you say they deserve intermediate libraries that will use CGS as a building block.
So in the end I'd say for now let's continue with what is in #603 that are really more primitive graphic types we think of "how to DrawImages" and "how to DrawStrings" after. |
can we add a project that writes letters from a library? |
First a premise: Microsoft itself divides the problem in two parts DirectWrite and Direct2D / GDI+ (legacy), Direct2D is in some way the equivalent of our Canvas class. The OpenType format (successor of TrueType): In conclusion how to Draw Text in Cosmos needs more study and sure should affronted in a separated PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Canvas methods to draw elements on the screen should be virtual.
@@ -230,6 +230,22 @@ public void DrawRectangle(Pen pen, int x, int y, int width, int height) | |||
DrawLine(pen, xc, yc, xd, yd); | |||
} | |||
|
|||
public void DrawFilledRectangle(Pen pen, int x_start, int y_start, int width, int height) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should be virtual.
} | ||
} | ||
|
||
public void DrawTriangle(Pen pen, int v1x, int v1y, int v2x, int v2y, int v3x, int v3y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should be virtual.
Hello @fanoI, I want to introduce a pure C# framework that can
Here =>https://github.com/LayoutFarm/Typography I think my lib can help your graphics system. :) |
It is not only an advertisement. I want to help you too. But I don't known much about Cosmos. I need a time to learn your system first. |
@prepare thank you for your help offer! PM me if you have requests on how Cosmos works. |
Add DrawFilledRectangle()