drawing

Drawing in JavaScript / HTML5 using XOR to remove old sprite

a 夏天 提交于 2020-01-29 05:39:08
问题 I'm building the engine for a tiny game, and right now I have just got a red circle with two little eyes as a main character. I have keyPress functions to detect movement, and that works, but I wanted to use something I used a long time ago in QBASIC to remove the character and redraw at a new location: XOR Basically, on keypress this happens: if (code == 39) { mainChar.drawChar(); mainChar.x += 1; mainChar.leftEye.x += 1; mainChar.rightEye.x += 1; mainChar.drawChar(); } I thought drawing the

How to effectively draw on desktop in C#?

前提是你 提交于 2020-01-26 11:35:31
问题 I want to draw directly on the desktop in C#. From searching a bit, I ended up using a Graphics object from the Desktop HDC (null). Then, I painted normally using this Graphics object. The problem is that my shapes get lost when any part of the screen is redrawn. I tried a While loop, but it actually ends up drawing as fast as the application can, which is not the update rate of the desktop. Normally, I would need to put my drawing code in a "OnPaint" event, but such thing does not exist for

Lines drawn with core graphics that are set to the same width sometimes vary in size when drawn

旧城冷巷雨未停 提交于 2020-01-25 10:23:19
问题 Here is a picture of two lines drawn in a UITableViewCell with the same function, and same width, and color As you can see the bottom line is a lot thicker than the other line. The code I am using for drawing: [CSDrawing drawLineWithColor:[UIColor blackColor] width:1.0 yPosition:1.0 rect:rect]; [CSDrawing drawLineWithColor:[UIColor blackColor] width:1.0 yPosition:CGRectGetMaxY(rect) - 3.0 rect:rect]; // draw a line on top and bottom +(void)drawLineWithColor:(UIColor *)color width:(CGFloat

Exactly what should happen in a CALayer's display/drawRect methods?

纵然是瞬间 提交于 2020-01-24 16:03:43
问题 Which, if either, of these methods would be an appropriate place to: Change the text of a CATextLayer Load a different image into a CAImageLayer Tell sublayers to update themselves 回答1: Dude I may be way drunk ... but there is NO drawRect method in CAlayers I think you can use drawInContext: to actually (gulp) draw in to CALayers, but nobody is man enough to do that since WW2. Regarding display, you don't need to call it, it basically updates what you set using .contents . I just use

Rotate Point around pivot Point repeatedly

折月煮酒 提交于 2020-01-24 10:51:25
问题 For a while now I've been using the following function to rotate a series of Points around a pivot point in various programs of mine. private Point RotatePoint(Point point, Point pivot, double radians) { var cosTheta = Math.Cos(radians); var sinTheta = Math.Sin(radians); var x = (cosTheta * (point.X - pivot.X) - sinTheta * (point.Y - pivot.Y) + pivot.X); var y = (sinTheta * (point.X - pivot.X) + cosTheta * (point.Y - pivot.Y) + pivot.Y); return new Point((int)x, (int)y); } This has always

Drawing performance over time for a UIBezierPath with Swift for iOS

Deadly 提交于 2020-01-23 17:11:01
问题 I'm trying to understand different drawing methods in Swift and why they perform as they do. The below code draws smooth lines using a UIBezierPath , project available from https://github.com/limhowe/LimSignatureView Initially the performance of the code below is highly responsive when the user begins touching the screen. However, over time, the longer the duration of touching and moving on the screen, the performance begins to lag and the drawing displayed doesn't keep up and isn't accurate

Drawing performance over time for a UIBezierPath with Swift for iOS

淺唱寂寞╮ 提交于 2020-01-23 17:10:11
问题 I'm trying to understand different drawing methods in Swift and why they perform as they do. The below code draws smooth lines using a UIBezierPath , project available from https://github.com/limhowe/LimSignatureView Initially the performance of the code below is highly responsive when the user begins touching the screen. However, over time, the longer the duration of touching and moving on the screen, the performance begins to lag and the drawing displayed doesn't keep up and isn't accurate

Draw on top of the screen using xlib

纵然是瞬间 提交于 2020-01-23 07:41:50
问题 I want to draw some primitives on top of all windows on the screen. I've found some code in C and tried to port it to use python's xlib: from Xlib.display import Display from Xlib import X from Xlib import protocol display = Display(':0') root = display.screen().root gc = root.create_gc() root.fill_rectangle(gc, 100, 100, 500, 500) But nothing appears on the screen (however, the root window is assigned: grabbing keyboard after it works). How to do this correctly? 回答1: You can draw on root

How to draw an arc in universal windows app

和自甴很熟 提交于 2020-01-23 02:57:04
问题 I need an arc (circle segment) in my universal windows application, but i just cant figure it out how to make it. There are only circle and rectangle shapes available. My goal is to create an arc that is showing the given percent, line 50% 66% etc. 回答1: If you want something like this: Check my solution (tested on Windows 8.1 and Windows 10 UWP): https://github.com/arek-kubiak/ArcControl/tree/master I hope it will be helpful for you :) Be careful, control automatically adjusts the height and

Get images from DrawingGroup

别来无恙 提交于 2020-01-23 01:40:06
问题 Maybe it's a stupid question, but I have some problems with finding the proper answer:S How to get frames as Bitmap 's or Image 's (or something similar) from DrawingGroup ? I don't actually know how to bite it. I tried to look for it in the Internet, but had problems with finding something useful. 回答1: If you need an image to be used as the Source of an Image control, you could simply put the drawing into a DrawingImage: var drawing = ... var drawingImage = new DrawingImage(drawing); image