drawing

WPF drawing performance with large numbers of elements

坚强是说给别人听的谎言 提交于 2019-12-10 13:53:50
问题 I'm trying to create a custom control in WPF to display the game tree for a game of go (see here for what it looks like). I've more-or-less got it working laying out the nodes, but one problem I've found is that it begins gets noticeably slow to render/navigate (it's in a scroll viewer) when the number of nodes gets larger than about 30. Since an average game of go consists of around 200 moves (not to mention other branches that the player might fork onto), this is going to be a fairly big

How to Scrunchify Angles?

末鹿安然 提交于 2019-12-10 13:39:36
问题 Crunch crunch. Using the calculations from Getting End Point in ArcSegment with Start X/Y and Start+Sweep Angles, how could I scrunchify or inflate(-ify) angles. See images below. Green box is original. The yellow lines depict what the scrunchy or inflated start/end angle should become, but red line is if the original angle of start=169, end=293 is maintained on the scrunched or inflated elliptical arcs. I need a way to figure out how to create the new angles of start/end based off the

how to create soft stroke edge using HTML5 canvas

无人久伴 提交于 2019-12-10 13:39:10
问题 I'm creating a drawing application using HTML5 canvas. https://github.com/homanchou/sketchyPad I can use rgba to control opacity in my line strokes, but how do I achieve a soft feathered brush edge vs a hard circular edge? 回答1: Three possible solutions: You could write your lines into an off-screen canvas, apply a blur filter, and then draw the result into the visible canvas. If you only use straight line segments, you could use a linear gradient for each line segment. The direction of the

fillArc() in Java not blending color as expected

大城市里の小女人 提交于 2019-12-10 12:23:12
问题 I'm trying to blend all the colors into a circle using arcs. However, the arc comes as one solid color and not a blend of color as I thought. Is it possible to? public static void main(String[] args) { DrawingPanel panel = new DrawingPanel(512,512); Graphics g = panel.getGraphics(); int width = 100; int height = 100; g.drawOval(0,0,width, height); //yellow for( int i = 0; i < 100 ; i++){ Color c = new Color(255/100*i,255,0); g.setColor(c); g.fillArc(0,0,width,height,95,11); } 回答1: g.fillArc(0

VB.Net (WinForms) Drawing a Line to Follow the Cursor

雨燕双飞 提交于 2019-12-10 11:54:19
问题 The Problem I am trying to have the line draw to the cursors current position as it moves. I've tried adding the code below to the MouseMove event in the form; however, nothing changed. I have been able to successfully draw the line, but regardless of what I do I just can't seem to get the line to follow the mouse. Also, it would be nice to be able to achieve this with reliable code without using a timer (for resources sake), but whatever works, works. Code The program is simply a blank form.

drawing a pixbuf onto a drawing area using pygtk and glade

末鹿安然 提交于 2019-12-10 11:31:20
问题 i'm trying to make a GTK application in python where I can just draw a loaded image onto the screen where I click on it. The way I am trying to do this is by loading the image into a pixbuf file, and then drawing that pixbuf onto a drawing area. the main line of code is here: def drawing_refresh(self, widget, event): #clear the screen widget.window.draw_rectangle(widget.get_style().white_gc, True, 0, 0, 400, 400) for n in self.nodes: widget.window.draw_pixbuf(widget.get_style().fg_gc[gtk

Draw on Panel, save as Bitmap

不羁的心 提交于 2019-12-10 11:24:31
问题 I'm trying to make a simple application where the user can draw on the Panel and save it to their computer as a bitmap. When I proceed to the save part, however, all I get is an empty (white) bitmap. I've been browsing many other solutions and I am pretty sure I am saving the bitmap the correct way, so I am starting to wonder if my drawing process is incorrect. What exactly is wrong here? public partial class Form1 : Form { SolidBrush brush; Pen pen; Point[] points = new Point[3]; Graphics

Creating a dynamically drawn line in Kivy

亡梦爱人 提交于 2019-12-10 11:12:01
问题 This is a continuation of my post here: Using and moving Widgets/Buttons in Kivy I want to create a line between two nodes(ellipses) in Kivy, so that the end points can be dynamically updated as I move the nodes. Here is my current messy framework: class GraphEdge(Widget): def __init__(self, **kwargs): super(GraphEdge, self).__init__(**kwargs) with self.canvas: Line(points=[100, 100, 200, 100, 100, 200], width=1) pass I've just put in some placeholder value for the points, as I'm not sure how

Image inside NSScrollView drawing on top of other views

亡梦爱人 提交于 2019-12-10 10:59:35
问题 I have a custom NSView that lives inside of a NSScrollView that is in a NSSplitView . The custom view uses the following drawing code: - (void)drawRect:(NSRect)dirtyRect { NSGraphicsContext *ctx = [NSGraphicsContext currentContext]; [ctx saveGraphicsState]; // Rounded Rect NSRect rect = [self bounds]; NSRect pathRect = NSMakeRect(rect.origin.x + 3, rect.origin.y + 6, rect.size.width - 6, rect.size.height - 6); NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:pathRect cornerRadius

How to read screen pixels for an application that is not in the foreground?

本秂侑毒 提交于 2019-12-10 10:59:22
问题 I currently have code that works great to read the pixel colors for whatever is displayed on the screen, an excerpt of which is shown below: using (Bitmap bmpScreenCapture = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)) { using (Graphics g = Graphics.FromImage(bmpScreenCapture)) { g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, bmpScreenCapture.Size, CopyPixelOperation.SourceCopy); } Color c = bmpScreenCapture.GetPixel