rect

D3.js adjust rect to text size: getBBox()?

匿名 (未验证) 提交于 2019-12-03 01:40:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm creating a force directed graph using D3.js, see JSFiddle: http://jsfiddle.net/pwxecn8q/ . The text and rect are placed in the same group. When appending the rect s I want to select the text element for the same group. Call getBBox() on it and use those values to resize the rect to fit the text "in" it. However, I'm unsure how to select the text element from the same group when appending the rect s... Any suggestion on how to go about this? The relevant code: var color = d3.scale.category20(); var svg = d3.select("body").append("svg")

Calculating PI using Monte Carlo method gives imprecise answer

匿名 (未验证) 提交于 2019-12-03 01:39:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to calculate PI using Monte Carlo method. My code gives the result 3.000 no matter how big MAXLEN is. After debugging it many times, I couldn't get what I'm doing wrong. #include <stdio.h> #include <stdlib.h> #define sqr2 ( x ) (( x )*( x )) #define frand () (( double ) rand () / ( RAND_MAX )) #define MAXLEN 1000 int circumscribed ( int radius ){ float xcoord = frand (); float ycoord = frand (); float coord = sqr2 ( xcoord ) + sqr2 ( ycoord ); if ( coord <= radius ) return 1 ; return - 1 ; } int main () { int i ; int

How to draw a triangle programmatically

匿名 (未验证) 提交于 2019-12-03 01:33:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a triangle solver, I want a way to use the values I get from the answer to draw a triangle to the screen that matches it. 回答1: If you subclass a UIView you can implement something like this in drawRect to draw a triangle: -(void)drawRect:(CGRect)rect { CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextBeginPath(ctx); CGContextMoveToPoint (ctx, CGRectGetMinX(rect), CGRectGetMinY(rect)); // top left CGContextAddLineToPoint(ctx, CGRectGetMaxX(rect), CGRectGetMidY(rect)); // mid right CGContextAddLineToPoint(ctx, CGRectGetMinX

Pygame needs “for event in pygame.event.get()” in order not to crash

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: The program works fine like this but, I don't understand why it needs the useless for event in pygame.event.get(): None in the gameOver while statement inside game_loop . If you could find a way to delete it or explain why it doesn't run without it, that would be great! import pygame , time , random pygame . init () # SOUND/TEXTURES icon = pygame . image . load ( "textures\snakeicon.png" ) pygame . display . set_icon ( icon ) # VARIABLES white = ( 255 , 255 , 255 ) black = ( 0 , 0 , 0 ) red = ( 200 , 0 , 0 ) green = ( 0 , 155 , 0 )

requestDisallowInterceptTouchEvent for Scrollview

匿名 (未验证) 提交于 2019-12-03 01:26:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a StreetViewPanoramaView inside a linearlayout inside a scrollview: <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/scrollview"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/linear"> <com.google.android.gms.maps.StreetViewPanoramaView android:id="@+id/street_view_panorama" android:layout_width="match_parent" android:layout_height="wrap_content"/> <other views - textviews etc> </LinearLayout> <

Crop Rectangle returned by minAreaRect OpenCV [Python]

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: minAreaRect in OpenCV returns a rotated rectangle. How do I crop this part of the image which is inside the rectangle? boxPoints returns the co-ordinates of the corner points of the rotated rectangle so one can access the pixels by looping through the points inside the box, but is there a faster way to crop in Python? EDIT See code in my answer below. 回答1: You have not given sample code, so I am answering without code also. You could proceed as follows: From corners of rectangle, determine angle alpha of rotation against horizontal

Objective-C Address of property expression

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need access address of property but have problem. example code is @interface Rectangle : NSObject { SDL_Rect wall; SDL_Rect ground; } @property SDL_Rect wall; @property SDL_Rect ground; @end @implementation Rectangle @synthesize x; @synthesize y; @end @interface Graphics : NSObject { int w; int h; } -(void) drawSurface @end @implementation Graphics -(void) drawSurface { Rectangle *rect = [[Rectangle alloc] init]; SDL_BlitSurface(camera, NULL, background, &rect.wall); } @end &rect.x is Address of property expression requested 回答1: As the

reprojectImageTo3D() in OpenCV

匿名 (未验证) 提交于 2019-12-03 01:13:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've been trying to compute real world coordinates of points from a disparity map using the reprojectImageTo3D() function provided by OpenCV, but the output seems to be incorrect. I have the calibration parameters, and compute the Q matrix using stereoRectify(left_cam_matrix, left_dist_coeffs, right_cam_matrix, right_dist_coeffs, frame_size, stereo_params.R, stereo_params.T, R1, R2, P1, P2, Q, CALIB_ZERO_DISPARITY, 0, frame_size, 0, 0); I believe this first step is correct, since the stereo frames are being rectified properly, and the

Canvas: trying to use a recycled bitmap android.graphics.Bitmap in android

匿名 (未验证) 提交于 2019-12-03 01:13:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am working on the crop image class, but encounter a recycled bit map problem: 03-02 23:14:10.514: E/AndroidRuntime(16736): FATAL EXCEPTION: Thread-1470 03-02 23:14:10.514: E/AndroidRuntime(16736): java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@428e5450 03-02 23:14:10.514: E/AndroidRuntime(16736): at android.graphics.Canvas.throwIfRecycled(Canvas.java:1026) 03-02 23:14:10.514: E/AndroidRuntime(16736): at android.graphics.Canvas.drawBitmap(Canvas.java:1096) 03-02 23:14:10.514: E/AndroidRuntime

Shift image content with OpenCV

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Starting from an image, I would like to shift its content to the top of 10 pixels, without change the size and filling the sub image width x 10 on bottom with black. For instance, the original: And the shifted: Is there a function to perform directly this operation with OpenCV? 回答1: Is there a function to perform directly this operation with OpenCV? http://code.opencv.org/issues/2299 or you would do this cv::Mat out = cv::Mat::zeros(frame.size(), frame.type()); frame(cv::Rect(0,10, frame.cols,frame.rows-10)).copyTo(out(cv::Rect(0,0,frame