drawing

Drawing incrementally in a UIView (iPhone)

这一生的挚爱 提交于 2019-12-28 03:32:08
问题 As far as I have understood so far, every time I draw something in the drawRect: of a UIView, the whole context is erased and then redrawn. So I have to do something like this to draw a series of dots: Method A: drawing everything on every call - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextDrawImage(context, self.bounds, maskRef); //draw the mask CGContextClipToMask(context, self.bounds, maskRef); //respect alpha mask CGContextSetBlendMode

Scaling/Translating a Shape to a given Rectangle using AffineTransform

夙愿已清 提交于 2019-12-28 03:10:54
问题 I'm trying to scale/translate a java.awt. Shape with AffineTransform in order to draw it in a defined bounding Rectangle. Moreover, I want to paint it in a drawing Area having a ' zoom ' parameter. I tried various concatenations of AffineTransform but I couldn't find the correct sequence. For example, the following solution was wrong: double zoom=(...);/* current zoom */ Rectangle2D viewRect=(...)/** the rectangle where we want to paint the shape */ Shape shape=(...)/* the original shape that

eraser not working in iOS drawing

痞子三分冷 提交于 2019-12-28 03:10:07
问题 I am working on a drawing project, where I have an eraser option. The code given below is for when I start my app and draw some lines and the proceed to use the eraser. It works fine and I get the eraser effect. Now the second scenario is where I draw some 10 lines and then click on the "undo button" and undo the whole thing, then I redo the whole thing, and now when I click on the "eraser button" and try to erase some part, but instead, it will clear the whole drawing. This is what I am

Any alternative to calling getGraphics() which is returning null

非 Y 不嫁゛ 提交于 2019-12-28 02:11:11
问题 Frequently when I call getGraphics() it returns null, even if I set the xxx.getGraphics(); xxx to be visible (as a Google search shows...) But this doesn't work, and this frustrates me as it is easy and simple to do in C-Sharp. Does anyone know of a better way of doing this instead of using getGraphics()?? 回答1: You usually don't want to use getGraphics on a Java Swing component since this will be null if the component has not been rendered yet, and even if the component has been rendered and

Draw arrow on canvas tag

南笙酒味 提交于 2019-12-28 01:48:07
问题 I want to draw an arrow using the canvas tag, javascript. I've made it using the quadratic function, but I'm having problems to calculate the angle of rotation of the arrow... Anyone have a clue on this? Thank you 回答1: As simple as I can get it. You'll have to prepend context.beginPath() and append context.stroke() yourself: ctx = document.getElementById("c").getContext("2d"); ctx.beginPath(); canvas_arrow(ctx, 10, 30, 200, 150); canvas_arrow(ctx, 100, 200, 400, 50); canvas_arrow(ctx, 200, 30

Android: programmatically created image vs resource image

删除回忆录丶 提交于 2019-12-25 20:01:14
问题 1) Is it possible to create drawable, example static Bitmap.Config conf = Bitmap.Config.ARGB_8888; static Bitmap bmp = Bitmap.createBitmap(100, 100, conf); // something draw // eventually convert to DrawableBitmap and then convert it / asiggn as / put in resource, to use in function with resource id param, like: public void setWidgetLayoutResource (int widgetLayoutResId) or 2) is it possible to dynamically draw to change image in R.drawable.something.bmp? All this for change color of widget

How to stop DrawText from underlining alt characters?

南楼画角 提交于 2019-12-25 19:37:00
问题 I'm using DrawText to draw text onto a DBGrid canvas. The text comes from the database. But when the string contains an ampersand (&) it treats it as an alt shortcut and underlines it. For example, what should be Wool & Silk winds up being Wool _Silk How do I stop this behavior? 回答1: Suppress prefix handling with the DT_NOPREFIX flag. This is the way forward if you know you do not want any prefixes drawn. If you want to draw text with both prefixes and ampersand, you can escape the ampersand

How to choose the right buffer to draw and stop it from swapping continuously

假装没事ソ 提交于 2019-12-25 19:05:19
问题 Please tell me if the question's vogue, I need the answe as soon as possible for more information about the problem you can refer to this. I just didn't understand how to manage buffers properly. A red rectangle drawn on 2D texture disappears right after being drawn Being in the last stages of customizing the class COpenGLControl: I have created two instances of the class in my MFC Dialog: whenever the extent of zoom is changed in the bigger window, it is drawn as a red rectangle on the

Drawing overlay view on top of a web view

二次信任 提交于 2019-12-25 18:48:08
问题 I am trying to make an app that can annotate PDFs. What I have done, is add the PDF through a UIWebview, so my main UIViewControllerhas a UIWebView Delegate. What I am trying to do is put my drawing layer, which is a UIView over the top of my PDF view. I have tried setting the background colour to "clearColour" and the opaque property to no, I still get a weird affect. I think the issue might be because of drawing a bitmap onto the UIView, but I would still like some insight, or an example if

Graphics.DrawImage Doesn't Always Paint The Whole Bitmap?

Deadly 提交于 2019-12-25 14:05:14
问题 I have run into a strange problem when using Graphics.DrawImage . When using e.Graphics.DrawImage(Image, Point) in OnPaint to paint a bitmap 'buffer' on the control, it appears that parts of the image are omitted. The buffer is populated in a helper method which draws directly onto the Bitmap using a Graphics constructed from it. When the control paints, the cached bitmap is drawn on the control. Nothing appears to be omitted on the bitmap itself, because when I saved the bitmap to disc and