Negative coordinates in C# Graphics?












0















I am following this documentation, specifically the DrawString method. It says that
for



public void DrawString (string s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y);


x and y are the coordinates of the upper-left corner of the drawn text.



I have call this function with x=0 but there is still some space between the border and the upper left corner so I call it with x=-10 and now it is touching the border.



Does this mean that somehow we can call these with negative values?










share|improve this question























  • Yes, you can move the drawing into the negative. In fact you can move the whole graphics canvas there by Graphics.TranslateTransform(-x, -y);

    – TaW
    Nov 20 '18 at 10:52


















0















I am following this documentation, specifically the DrawString method. It says that
for



public void DrawString (string s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y);


x and y are the coordinates of the upper-left corner of the drawn text.



I have call this function with x=0 but there is still some space between the border and the upper left corner so I call it with x=-10 and now it is touching the border.



Does this mean that somehow we can call these with negative values?










share|improve this question























  • Yes, you can move the drawing into the negative. In fact you can move the whole graphics canvas there by Graphics.TranslateTransform(-x, -y);

    – TaW
    Nov 20 '18 at 10:52
















0












0








0








I am following this documentation, specifically the DrawString method. It says that
for



public void DrawString (string s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y);


x and y are the coordinates of the upper-left corner of the drawn text.



I have call this function with x=0 but there is still some space between the border and the upper left corner so I call it with x=-10 and now it is touching the border.



Does this mean that somehow we can call these with negative values?










share|improve this question














I am following this documentation, specifically the DrawString method. It says that
for



public void DrawString (string s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y);


x and y are the coordinates of the upper-left corner of the drawn text.



I have call this function with x=0 but there is still some space between the border and the upper left corner so I call it with x=-10 and now it is touching the border.



Does this mean that somehow we can call these with negative values?







c# graphics






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 6:17









KansaiRobotKansaiRobot

9891129




9891129













  • Yes, you can move the drawing into the negative. In fact you can move the whole graphics canvas there by Graphics.TranslateTransform(-x, -y);

    – TaW
    Nov 20 '18 at 10:52





















  • Yes, you can move the drawing into the negative. In fact you can move the whole graphics canvas there by Graphics.TranslateTransform(-x, -y);

    – TaW
    Nov 20 '18 at 10:52



















Yes, you can move the drawing into the negative. In fact you can move the whole graphics canvas there by Graphics.TranslateTransform(-x, -y);

– TaW
Nov 20 '18 at 10:52







Yes, you can move the drawing into the negative. In fact you can move the whole graphics canvas there by Graphics.TranslateTransform(-x, -y);

– TaW
Nov 20 '18 at 10:52














1 Answer
1






active

oldest

votes


















1














enter image description here



Depending upon how the Font was developed every character has a bounding box. The Top-Left cordinates that you specify are not where the Alphabet starts but are from where the Bounding Box Top-left starts.



In this image it will be the Top-left Corner of the black rectangle. Now depending upon the Font/Typography - Either the Actual alphabet will be very closely aligned with the bounding box boundaries or may have some padding (like my poor example below has quite some space).



Thats why in your case -10 makes it look like as if Character/Alphabet starts from Exact edge. But In realtiy the Bounding Box Top-Left is at -10 (negative cordinate) which is why it looks so.






share|improve this answer


























  • A post that contains the word 'Typography' shouldn't be so short on line feeds ;-)

    – TaW
    Nov 20 '18 at 10:54











  • :) That was a quick reply - though not enough reason for bad formatting :D

    – Prateek Shrivastava
    Nov 21 '18 at 3:11











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53387284%2fnegative-coordinates-in-c-sharp-graphics%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














enter image description here



Depending upon how the Font was developed every character has a bounding box. The Top-Left cordinates that you specify are not where the Alphabet starts but are from where the Bounding Box Top-left starts.



In this image it will be the Top-left Corner of the black rectangle. Now depending upon the Font/Typography - Either the Actual alphabet will be very closely aligned with the bounding box boundaries or may have some padding (like my poor example below has quite some space).



Thats why in your case -10 makes it look like as if Character/Alphabet starts from Exact edge. But In realtiy the Bounding Box Top-Left is at -10 (negative cordinate) which is why it looks so.






share|improve this answer


























  • A post that contains the word 'Typography' shouldn't be so short on line feeds ;-)

    – TaW
    Nov 20 '18 at 10:54











  • :) That was a quick reply - though not enough reason for bad formatting :D

    – Prateek Shrivastava
    Nov 21 '18 at 3:11
















1














enter image description here



Depending upon how the Font was developed every character has a bounding box. The Top-Left cordinates that you specify are not where the Alphabet starts but are from where the Bounding Box Top-left starts.



In this image it will be the Top-left Corner of the black rectangle. Now depending upon the Font/Typography - Either the Actual alphabet will be very closely aligned with the bounding box boundaries or may have some padding (like my poor example below has quite some space).



Thats why in your case -10 makes it look like as if Character/Alphabet starts from Exact edge. But In realtiy the Bounding Box Top-Left is at -10 (negative cordinate) which is why it looks so.






share|improve this answer


























  • A post that contains the word 'Typography' shouldn't be so short on line feeds ;-)

    – TaW
    Nov 20 '18 at 10:54











  • :) That was a quick reply - though not enough reason for bad formatting :D

    – Prateek Shrivastava
    Nov 21 '18 at 3:11














1












1








1







enter image description here



Depending upon how the Font was developed every character has a bounding box. The Top-Left cordinates that you specify are not where the Alphabet starts but are from where the Bounding Box Top-left starts.



In this image it will be the Top-left Corner of the black rectangle. Now depending upon the Font/Typography - Either the Actual alphabet will be very closely aligned with the bounding box boundaries or may have some padding (like my poor example below has quite some space).



Thats why in your case -10 makes it look like as if Character/Alphabet starts from Exact edge. But In realtiy the Bounding Box Top-Left is at -10 (negative cordinate) which is why it looks so.






share|improve this answer















enter image description here



Depending upon how the Font was developed every character has a bounding box. The Top-Left cordinates that you specify are not where the Alphabet starts but are from where the Bounding Box Top-left starts.



In this image it will be the Top-left Corner of the black rectangle. Now depending upon the Font/Typography - Either the Actual alphabet will be very closely aligned with the bounding box boundaries or may have some padding (like my poor example below has quite some space).



Thats why in your case -10 makes it look like as if Character/Alphabet starts from Exact edge. But In realtiy the Bounding Box Top-Left is at -10 (negative cordinate) which is why it looks so.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 21 '18 at 3:11

























answered Nov 20 '18 at 6:58









Prateek ShrivastavaPrateek Shrivastava

988511




988511













  • A post that contains the word 'Typography' shouldn't be so short on line feeds ;-)

    – TaW
    Nov 20 '18 at 10:54











  • :) That was a quick reply - though not enough reason for bad formatting :D

    – Prateek Shrivastava
    Nov 21 '18 at 3:11



















  • A post that contains the word 'Typography' shouldn't be so short on line feeds ;-)

    – TaW
    Nov 20 '18 at 10:54











  • :) That was a quick reply - though not enough reason for bad formatting :D

    – Prateek Shrivastava
    Nov 21 '18 at 3:11

















A post that contains the word 'Typography' shouldn't be so short on line feeds ;-)

– TaW
Nov 20 '18 at 10:54





A post that contains the word 'Typography' shouldn't be so short on line feeds ;-)

– TaW
Nov 20 '18 at 10:54













:) That was a quick reply - though not enough reason for bad formatting :D

– Prateek Shrivastava
Nov 21 '18 at 3:11





:) That was a quick reply - though not enough reason for bad formatting :D

– Prateek Shrivastava
Nov 21 '18 at 3:11




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53387284%2fnegative-coordinates-in-c-sharp-graphics%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini