graphics

Fit 3d model inside a window

末鹿安然 提交于 2019-12-30 03:32:06
问题 I want to display models of different sizes fitted into a view, so that the whole model is visible inside the screen. What is the best way to do it? I tried scaling (using glScale) the model using this formula scaleFactor = ( screenSize / (maxModelSize * constant) ) Where size is height or width, depending on what is bigger. Constant is 1 / (length of one screen pixel in OpenGL units) There are two problems with this: 1. After doing some transformations, I want to be able to return to this

Find all the points of a cubic bezier curve in javascript

做~自己de王妃 提交于 2019-12-30 03:27:07
问题 I have a cubic bezier with 2 control points. Starting point and control points are known. Need to get all the points of the curve, given the control, starting and ending points. What I wanna to achieve is ..given a value i from 1 to length of curve.. get the X and Y and alpha (angle) of each point in that position. I cannot find a good reference or working code for that. I'm using javascript. 回答1: If I understand correctly, you are trying to determine the position and slope (tangent to the

Draw a sphere using 3D pixels (voxels)

♀尐吖头ヾ 提交于 2019-12-30 02:18:27
问题 Can you suggest an algorithm that can draw a sphere in 3D space using only the basic plot(x,y,z) primitive (which would draw a single voxel)? I was hoping for something similar to Bresenham's circle algorithm, but for 3D instead of 2D. FYI, I'm working on a hardware project that is a low-res 3D display using a 3-dimensional matrix of LEDs, so I need to actually draw a sphere, not just a 2D projection (i.e. circle). The project is very similar to this: ... or see it in action here. One

View.onDraw() — when does it get called?

放肆的年华 提交于 2019-12-30 00:52:30
问题 I put a Log.d() call into the onDraw() of my extended View, so I could see how often and when it's getting called. It gets called upon instantiation of the view, which is not surprising. But then I notice, it gets called on every tap that is handled by onTouchEvent(), even though my code there isn't doing anything remotely related to graphics. However, in the documentation for Views, I can't seem to find anything about when onDraw() is actually called. I'm not really concerned about my

Drawing a line with arrow in Java

半世苍凉 提交于 2019-12-30 00:37:31
问题 Can anyone guide me how to code the arrow line in different direction. wa and wl is positive the rectangle will be on top of the x-axis. Below example shown if wl is negative and wa is positive. The code below shown how i code the rectangle shape. x1 is the varaible to state where to start at x axis. e1 is the length of the shape, wa1 and wl1 is the height. wsign to determine the height wa1 or wl1 should display at negative side or positive side. if (Math.abs(wl1) > Math.abs(wa1)) { y_scale =

Drawing a moving sine wave anti-aliased

夙愿已清 提交于 2019-12-29 15:02:12
问题 I want to draw a moving sine wave with variable frequency and variable amplitude in a crisp and anti-aliased way. How is this possible? 回答1: Well, I implemented sine wave into the UIView drawrect method as follows : float x=75; float yc=50; float w=0; while (w<=rect.frame.size.width) { CGPathMoveToPoint(path, nil, w,y/2); CGPathAddQuadCurveToPoint(path, nil, w+x/4, -yc,w+ x/2, y/2); CGPathMoveToPoint(path, nil, w+x/2,y/2); CGPathAddQuadCurveToPoint(path, nil, w+3*x/4, y+yc, w+x, y/2);

How to concatenate icons into a single image with ImageMagick?

安稳与你 提交于 2019-12-29 11:46:09
问题 I want to use CSS sprites on a web site instead of separate image files, for a large collection of small icons that are all the same size. How can I concatenate (tile) them into one big image using ImageMagick? 回答1: From the page you linked, 'montage' is the tool you want. It'll take a bunch of images and concatenate/tile them into a single output. Here's an example image I've made before using the tool: (source: davr.org) 回答2: convert works much better than montage. It arranges images

Which Event should I use to display drawing?

こ雲淡風輕ζ 提交于 2019-12-29 09:07:30
问题 I need to put some graphics in one section of a TableLayoutPanel. I'm doing this by creating a PictureBox in one cell of the TLP. Can't get two things to work: 1) The initial display is blank! Drawing appears only when you resize the form 2) The resize event doesn't fire equally when expanding the size as compared contracting. Any suggestions to improve the above two problems would be great! Here is my code. The form has a 2x2 TableLayoutPanel in it, and one cell of the TLP has a PictureBox

Drawing JTable rows and columns on a Panel

佐手、 提交于 2019-12-29 09:00:07
问题 I am writing one application in which I have to draw JTable component on a canvas. But after my several attempts still unable to draw a completely perfect picture of a JTable. I tried to draw using sizes of specific cells of a JTable using getCellRect api, but when data is big not able to draw specific cells on the canvas. Here is the sample code:- import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.*; import java

save high resolution figures with parfor in matlab

可紊 提交于 2019-12-29 08:59:32
问题 I am using parfor loop to produce and save quite big number of figures. Due to the amount of data which will be presented in the figures, the resolution of the figures need to be high, something around 920 dpi. Using the normal for , the function works fine. But when we switch to parfor the resolution of the produced and saved pictures becomes totally low. This is the figure handle creation part: mainFig=figure('visible','off'); set(mainFig, 'Renderer', 'OpenGL'); and here is the saving part