I'm painting a Paragraph onto a Canvas using a CustomPainter. How can I find out on which pixels the text actually got painted?
If its just visually, you can try visual debugging from here:
https://flutter.dev/docs/testing/debugging#visual-debugging
Related
I am looking to find a way to draw a horizontal line of full page width on a PNG file with a single click. Thing is I am trying to draw a lot of lines and if I've to click and drag it becomes extremely inefficient.
I am working on a Windows platform.
How can I achieve this using Adobe Photoshop? Any ideas?
Thanks
Here is a sample of page. Green lines are the ones drawn.
Draw a line as you want it on a big new canva. Trim the image when done. Then Create a brush from the open file (edit > define brush preset), save it, done. Now you can use yout line as a brush.
CTLineGetBoundsWithOptions() uses CTLineBoundsOptions. One of the option is kCTLineBoundsUseOpticalBounds whose doc says:
Pass this option to use optical bounds.
But I don't understand the meaning of optical bounds.
The font designer can specify the optical bounds of a glyph separately from its typographic bounds. In a TrueType font, the opbd table, if present, contains optical bounds.
From WWDC 2012 Session 226: Core Text and Fonts:
Now, as I advance to the next few slides, I want to call your attention in particular to the left and right sides of this rectangle on screen because I’m going to start passing some different options to this API and it’s going to have an effect on either side.
Let’s go ahead and advance now as I invoke use optical bounds. This is a very slight difference here, but you may have noticed that the edges of the box have been pulled in a little bit here. What’s going on here is that optical bounds are very closely related to the typographic bounds, the regular measurement of the line.
But, in this case, the font designer has specified that the way that the font is likely to be perceived by our eyes means that they don’t line up exactly with just the glyph measurements. The optical bounds in this case have been designed to pull in on either of these curly quotes here because the way our eyes see rounded shapes. It’s a bit different than the way we see straight lines, so the font designer has compensated for that by providing us information in the font.
(Find the full session transcript here.)
Microsoft describes it this way:
Aligns glyphs by their apparent left or right extents in horizontal setting, or apparent top or bottom extents in vertical setting, replacing the default behavior of aligning glyphs by their origins. Another name for this behavior would be visual justification. The optical edge of a given glyph is only indirectly related to its advance width or bounding box; this feature provides a means for getting true visual alignment.
I have got an UIImageView in which the image can be rotated using UIRotationGestureRecognizer.
Based on the UIImageView a frame in the middle of the screen is extracted from the image.
For the better understanding here's a little screenshot:
http://d.pr/i/hzhA
As you can see there's an empty area at the right edge within the target frame.
The Question is: How can I check if there is an empty area within the target image, for example in the right top area of the target frame (as you can see in the screenshot).
Any help will be highly appreciated.
Regards,
Christian
On iOS, I'm using core-plot to draw a line graph. I want the line to be bordered top and bottom with a solid color and a different color in the middle, a striping effect. This cannot be done using CPTLineStyle, so I created a custom line style that uses CGContextSetStrokePattern to draw the line.
I thought I achieve the desired effect by creating a striped image and using it as the stroke pattern. This works, but the image orientation does not follow the direction of the path. The stripes are always horizontal even if the direction of the path is 45 degrees.
How can I tell Quartz auto rotate the pattern fill such that it follows the vector direction of the graph segment? Or alternatively, how can I get core-plot to do this for me?
We recently added the lineGradient property to CPTLineStyle that gives you a very flexible way to do this. See the "Gradient Scatter Plot" demo in the Plot Gallery example app.
Note that this change was added after the 1.3 release and is not part of a downloadable release yet. You will need to pull the latest code with Mercurial to get the change or wait for the next release.
The best solution I've found is to use two plots. The first with the wider line style the second with the narrower one. That achieves the desired effect.
I am using XNA 3.1 for the a game development, I am having little issue with the mouse position, I am also providing the screen shots of the issue, for now in the code below I am trying to display text "Start" exactly at mouse Position but the location of the the text is around 200 - 250 pixels away from the cursor instead to be at the same point where the cursor is on game window.
void MenuMainMenuDraw()
{
// Main Menu After Draw
// Menu Option After Draw
MouseState ms = Mouse.GetState();
spriteBatch.DrawString(fontMenu, "Start"
, new Vector2(ms.X, ms.Y)
, Color.Red);
spriteBatch.DrawString(fontMenu, "Options"
, new Vector2((float)MENU_GLOBAL.MENU_POSITION_X, (float)MENU_GLOBAL.OPTION_POSITION_Y)
, Color.Red);
spriteBatch.DrawString(fontMenu, "Leader's Board"
, new Vector2((float)MENU_GLOBAL.MENU_POSITION_X, (float)MENU_GLOBAL.HIGHSCORE_POSITION_Y)
, Color.Red);
}
Regards
MGD
There are a few possible causes that I can think of. I can't see anything directly wrong with the code snippet that you posted, so if none of these things resolve it, post more of your code.
Does the same problem occur when you create a new SpriteFont using the default font face? It may be a problem with the spacing in the font you're currently using.
In your spriteBatch.Begin(...) code are you supplying a transformMatrix? If so, try just using spriteBatch.Begin() with no arguments. Are you doing anything unusual like applying an Effects to your SpriteBatch drawing?
Are you drawing to a render target that is then redrawn to the screen?
I've had mouse position issues that seemed strange if my game window was actually larger than the resolution of the computer screen that I was running the game on. Its a quick check but it just might help. (Also remember that XNA draws images from the center point, but I believe by default draws test from the text's upper left corner). Hope that helps