drawing

WinForms Draw, Then Move Rectangle

大兔子大兔子 提交于 2019-12-11 16:34:05
问题 I have a rectangle I am trying to draw in a WinForms project using C#. I am drawing the rectangle on the form's Paint event: private void onPaintHandler(object sender, PaintEventArgs e) { using (Pen pen = new Pen(Color.Black, 1)) { Brush brush = new SolidBrush(Color.Gray); e.Graphics.FillRectangle(brush, 0, this.Height - 100, this.Width, 100); e.Graphics.DrawRectangle(pen, -1, this.Height - 100, this.Width, 100); brush.Dispose(); pen.Dispose(); } } I am interested in being able to move the

System.OutOfMemoryException when creating brush from image byte array

穿精又带淫゛_ 提交于 2019-12-11 15:30:11
问题 I sometimes need to load an image from a byte array like this: Bitmap image = null; using (var ms = new MemoryStream(File.ReadAllBytes(sourceImagePath))) { image = (Bitmap)Image.FromStream(ms); } Now I need to create a TextureBrush from that image, so I use the following approach: using (var b = new TextureBrush(image)) { } It throws System.OutOfMemoryException: 'Out of memory.' . After a while of experimenting, I've found that I can create the brush if I use Image.FromFile like this: using

JNI Warning : Too many PopLocalFrame calls android

匆匆过客 提交于 2019-12-11 14:45:59
问题 I am developing an application and drawing SVG files, lines and images on canvas. and my issue is that when i save my diagram and re open it, it gives me the warning. JNI WARNING: too many PopLocalFrame calls. does any body have any idea what is this warning says and how can i resolve it. i have goggled it around but have not got satisfactory thing. Thanks 回答1: Look for calls to PushLocalFrame. They should generally be paired. Most likely you're calling PopLocalFrame without a preceding

In JS, how to have multiple drawings at different speeds?

元气小坏坏 提交于 2019-12-11 14:44:27
问题 I’ve got drawings of planets that revolve around the sun. They rotate fine, but they need to be positioned accurately. They move at the same speed so it doesn’t look realistic. I would like to know how to make some planets swing a lot faster than others but they’re all in the same animation function and trying to make several animation functions just causes errors. Here's my relevant code: function rotate_point(pointX, pointY, originX, originY, ang) { ang = Math.PI / 180.0; return { x: Math

Brush pattern in c# wpf (xaml - vector)

孤人 提交于 2019-12-11 14:28:00
问题 I need to draw on canvas using a few brush patterns like "Paint" in Windows OS. I need "oil brush" and "pastel". As I understand, it's possible via VisualBrush.Visual (Canvas with vector paths). <UserControl x:Class="DrawingToolbar.DTBrushParamsContainer" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression

how to take input from text to draw shapes on screen c#

不打扰是莪最后的温柔 提交于 2019-12-11 14:14:20
问题 Hi all I am trying to create a program that takes commands from the user to draw shapes on the screen. The program should have basic commands to draw shapes and a clear command to clear the screen afterwards, the user should be able to type moveTo in the text box and the pen should move the the coordinates they set it to then the user should be able to type in the shape they want to draw(circle(radius), rectangle(width, height), triangle(side, side, side). I have got it to work for the

Optimize canvas drawing to make a continuous path

旧巷老猫 提交于 2019-12-11 14:03:57
问题 This is a script for filling canvas' grid squares with red color. I'm looking for tips how to optimize my script to fill squares continuously, without chopping like here: I tried to separate and merge some functions, but can't find a solution. Here's the updated jsFiddle and my code: HTML: <canvas id="plan" width="501px" height="301px"></canvas> JavaScript (updated): var canvas = document.getElementById('plan'); var context = canvas.getContext('2d'), wt = canvas.width, ht = canvas.height; var

draw imaginary path between two points and print image along that path?

六眼飞鱼酱① 提交于 2019-12-11 13:34:35
问题 Is there a way with Javascript (or jQuery) to draw lines between coordinates (not necessarily showing those lines) and then repeat an image or a letter along those "paths"? I am talking straight lines here, no bezier curves or anything. I would think it doesn't seem like a big deal and will give it a go, but I'd like to have others' opinion on this... something like (imaginary code): path = point1[x,y], point2[x,y], point3[x,y]; every20pixels-->renderimage('path/to/image') or letter('letter')

GTK+3 multithreading

大城市里の小女人 提交于 2019-12-11 13:10:47
问题 I have a program (written in C, currently running on Mac OS X 10.8.4) that simulates a world and updates the world's state multiple times per second. At startup this program creates a background thread which creates a simple GTK window and calls gtk_main . After each time the world's state is updated (in the main thread), I would like the window to reflect that change. My first approach was to simply update the GTK widgets after the world was updated, but because that was in a different

Custom View extending the View-Class but still based on a XML-Layout

淺唱寂寞╮ 提交于 2019-12-11 12:59:30
问题 I want to build my own custom view which should look like the Crysis-GUI. At first I designed a XML-based Layout and made it visible via the setContentView(int resid)-Method. Worked pretty well. But now I wan't to go a step further and draw in my Layout. So I created a new Class, let it extend View and overrode the onDraw()-Method. So far so good. Works as expected public class RifleView extends View { public RifleView(Context context) { super(context); } @Override protected void onDraw