draw

Draw rectangles, circles or arbitrary polygons in a m x n matrix

余生颓废 提交于 2019-12-03 12:18:07
I want to simulate the flow around objects in two dimensions. Therefore I wrote a program in C which uses the Navier-Stokes equations to describe the motion of fluids. Now I came to the point where I actually want more than just placing a rectangle in the simulation domain. To draw such a rectangle I just do something like: for(int i=start_x; i<end_x; i++) for(int j=start_y; j<end_y; j++) M[i][j] = 1; // barrier cell = 1 Doing this I get a nice rectangle. No surprise. But what would be an approach if I want to simulate the flow around a circle, a cross, a triangle, a wing profile or any other

iPhone CGContext: drawing two lines with two different colors

天涯浪子 提交于 2019-12-03 12:16:33
问题 I am having some troubles using the CGContext with an iPhone app. I am trying to draw several lines with different colors, but all the lines always end up having the color which was used last. I tried several approaches, but haven't been lucky. I set up a small sample project to deal with that issue. This is my code, I use in the drawRect method. I am trying to draw a red and a blue line: - (void)drawRect:(CGRect)rect{ NSLog(@"drawrect!"); CGContextRef bluecontext =

Find and draw the largest contour in opencv on a specific color (Python)

六月ゝ 毕业季﹏ 提交于 2019-12-03 11:07:10
问题 Im trying to get the largest contour of a red book. I've got a little problem with the code because its getting the contours of the smallest objects (blobs) instead of the largest one and I can't seem to figure out why this is happening The code I use: camera = cv2.VideoCapture(0) kernel = np.ones((2,2),np.uint8) while True: #Loading Camera ret, frame = camera.read() blurred = cv2.pyrMeanShiftFiltering(frame, 3, 3) hsv = cv2.cvtColor(blurred, cv2.COLOR_BGR2HSV) lower_range = np.array([150, 10

How to show x and y axes in a MATLAB graph?

有些话、适合烂在心里 提交于 2019-12-03 10:38:48
I am drawing a graph using the plot() function, but by default it doesn't show the axes. How do we enable showing the axes at x=0 and y=0 on the graph? Actually my graph is something like: And I want a horizontal line corresponding to y=0 . How do I get that? By default, plot does show axes, unless you've modified some settings. Try the following hold on; % make sure no new plot window is created on every plot command axes(); % produce plot window with axes plot(% whatever your plot command is); plot([0 10], [0 0], 'k-'); % plot the horizontal line dysan This should work in Matlab: set(gca,

Drawing Rectangles in iOS

ぐ巨炮叔叔 提交于 2019-12-03 09:34:55
问题 My goal for my app is for the user to be able to sort through different scheduling options by swiping to the left and right of an iPhone screen. How would I draw and remove rectangles as the user sorts through these different scheduling options? I have a UIViewController.h, UIViewController.m, and UIViewController.xib files to manipulate. Do I need a separate UIView class? If so, how do I connect that UIView class to the view in my .xib file? 回答1: Wow... so many complicated solution, here is

Android draw path

南楼画角 提交于 2019-12-03 08:40:49
It is not good idea to construct path object every time when call Draw method. Is it better to keep path object and clear/set points every time? Update: One more question - what is difference between 'reset' and 'rewind' path object? Yes, it is better to reset the path and set the points rather than instatiating a new one. This prevents excessive allocation of memory, which can lead to frequent garbage collection. When the GC runs the graphics may pause for a moment, especially on older devices so you want to keep this to a minimum. The reset() and rewind() methods both have pretty much the

Is there an SDK to draw lines on iOS with touch?

╄→гoц情女王★ 提交于 2019-12-03 07:40:50
Is there a framework I can use to draw lines with touch. Basically I want to add ability for a customer to sign on iPad/iPhone and capture it as an image. Any help much appreciated. Thanks. you can meet your requirement by using core graphics available in UIKIT framework. i had a similar requirement in my application with a different use ,if needed i can provide you the code. TNQ .h file #import <UIKit/UIKit.h> typedef enum _DrawingMode{ DrawingModePen =0, DrawingModeEraser=1, } DrawingMode; @interface DrawingView : UIView { CGPoint lastPoint; UIImageView *drawImage; BOOL mouseSwiped; int

Display only the corners of a UIView

天大地大妈咪最大 提交于 2019-12-03 07:38:36
How to display only the corners of a UIView? let view = UIView() view.layer.borderColor = UIColor.white.cgColor view.layer.borderWidth = 2 let maskframe = UIView(frame: CGRect(x:0, y:0, width:view.frame.width, height:view.frame.height)) view.layer.mask = maskframe.layer.` This masks only the right edge and i dont understand how it works either. Try with this class , here I use a custom view drawing using CoreGraphics , added some Inspectable variables to help with customization // // CornerView.swift // CornersViewSO // // Created by Reinier Melian on 5/31/17. // Copyright © 2017 Reinier

How can I draw a vertical line in an Activity when a button is pressed?

心不动则不痛 提交于 2019-12-03 07:10:06
问题 I want to draw a straight vertical line in my Android activity when a button is pressed. Please explain how I can draw the line with a position & length I want. Elaboration: I have a linear layout with vertical orientation. A set of buttons constitute this linear layout. When I press one button, I want a line to appear to the right of these buttons, as if dividing the screen halfway - a straight line of width=2dip and height=200dip. 回答1: I have solved it myself. All you need to do is define a

Formatting legend and axis in Google Charts

有些话、适合烂在心里 提交于 2019-12-03 06:10:50
I'm new with Google Charts and I am not able to obtain a fine result with the texts surrounding the graph. This is how my chart looks: As you can see, it does cut both Horizontal-Axis and Legends, so the final result is not as good as It could be. Is there a way to solve this? I've been reading the official documentation and some posts from here, but I haven't found the way to do this. Recap: How do we modify the legend or the axis texts so they are fully visible? After some time experimenting, I daresay it is not posible to choose how much part of the words on legend or axis you can show.