scaling

Scaling canvas element with static resolution

那年仲夏 提交于 2019-12-05 00:29:43
I have canvas element and I want to scale it down, but without changing it's js logic. Drawing space in js should always be 600x300px, even if it is displayed in HTML as 300x150px. I know, I can resize image with static resolution, but can I do the same with canvas? Changing the size using CSS scales it Live Demo So basically you set its size for drawing objects, etc, via the width and height properties like so var canvas = document.getElementById("canvas"), ctx = canvas.getContext("2d"); canvas.width = 600; canvas.height = 300; and then change its displayed size using css #canvas{ width:

UIWebView scaling page so that there is no need for horizontal scrolling

拈花ヽ惹草 提交于 2019-12-04 22:38:59
Is there a way to scale a web page in a UIWebView that maintains the aspect ratio but alleviates the need to scroll horizontally to read an article, for example. Vertical scrolling is fine, I just don't want the user to have to constantly be scrolling back and forth horizontally to read each line of the article. Thanks! Edit: the code I'm using to create the view _webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, [[self view] frame].size.width, [[self view] frame].size.height)]; [_webView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth]; [

Java (Android): How to scale a drawable without Bitmap?

…衆ロ難τιáo~ 提交于 2019-12-04 22:32:25
问题 I need to scale the background image of a button but can't turn it into a Bitmap. Here is the code right now: int height = 50; int width = 80; Button b = new Button (this); b. setBackgroundResource(R.drawable.btn); Now I need to scale "R.drawable.btn" according to the "height" and "width". The setBackgroundResource won't accept a Bitmap. How do I do that? Thank you. 回答1: You can allow the layout parameters to control the scale or you can scale the image yourself. Allow the layout to scale the

How to fix pinch zoom focal point in a custom view?

断了今生、忘了曾经 提交于 2019-12-04 21:59:39
问题 For my question I have prepared a very simple test app at Github. For simplicity I have removed flinging, scroll constraints and edge effects (which actually work well in my real app): So the custom view in my test app only supports scrolling: mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float dX, float dY) { mBoardScrollX -= dX; mBoardScrollY -= dY; ViewCompat

How to auto resize the image for responsive design with pure css?

ぐ巨炮叔叔 提交于 2019-12-04 19:37:30
问题 I have tried to auto resize the image using the CSS property max-width , but it does't work in IE7 and IE8. Is there any way to auto resize the image with pure CSS in IE7 and IE8? 回答1: Use width: inherit; to make it work with pure CSS in IE8. (See responsive-base.css.) Like this: img { width: inherit; /* This makes the next two lines work in IE8. */ max-width: 100%; /* Add !important if needed. */ height: auto; /* Add !important if needed. */ } I'm not sure if that works in IE7—please test it

Scaling an SVG in Java

元气小坏坏 提交于 2019-12-04 17:36:06
问题 I'm attempting to scale an image, modify it, and then output to another image format. So far, I've been using the apache batik library. For simple conversion, this is easy. For clipping the svg, this is easy. However, I can't seem to figure out how to scale to the full image created by the svg. That is, I can specify the area of interest as a bounding rectangle, and then scaling works over the bounding rectangle, but I do NOT know how to scale over the image of the svg. This is what I have so

How do you Schedule Index Updates in CouchDB

走远了吗. 提交于 2019-12-04 16:58:07
问题 As far as I understand, CouchDB indexes are updated when a view is queried. Assuming there are more reads than writes, isn't this bad for scaling? How would I configure CouchDB to update indexes on writes, or better yet, on a schedule? 回答1: CouchDB does regenerate views on update, but only on what has changed since the last read access to the view. Assuming your read volume greatly outweighs your write volume, this shouldn't be a problem. When you're changing large numbers of documents at

R: outlier cleaning for each column in a dataframe by using quantiles 0.05 and 0.95

限于喜欢 提交于 2019-12-04 14:07:35
I am a R-novice. I want to do some outlier cleaning and over-all-scaling from 0 to 1 before putting the sample into a random forest. g<-c(1000,60,50,60,50,40,50,60,70,60,40,70,50,60,50,70,10) If i do a simple scaling from 0 - 1 the result would be: > round((g - min(g))/abs(max(g) - min(g)),1) [1] 1.0 0.1 0.0 0.1 0.0 0.0 0.0 0.1 0.1 0.1 0.0 0.1 0.0 0.1 0.0 0.1 0.0 So my idea is to replace the values of each column that are greater than the 0.95-quantile with the next value smaller than the 0.95-quantile - and the same for the 0.05-quantile. So the pre-scaled result would be: g<-c(**70**,60,50

Algorithm for self-scaling ruler in plotter GUI component

隐身守侯 提交于 2019-12-04 13:59:44
I am designing (not programming) a data-series viewer program for medical data, using C#/WPF. There is one main panel which shows the data, with the common mouse pan/zoom functionality (pan with left drag, horizontal zoom with scroll, vertical auto-fit with double click, selection with right drag). The problem is: I need vertical and horizontal grid with rulers on the top/left, similar to those seen in audio-editing (goldwave, audacity), cartography (gpsTrackmaker) and ilustration (photoshop, inkscape) programs. Besides, these rulers are even configurable in most plotting APIs (Matlab, GNUPlot

QGraphicsScene scaled weirdly in QGraphicsView

六月ゝ 毕业季﹏ 提交于 2019-12-04 11:13:33
I'm messing around with QGraphicsView and QGraphicsScene to create a Tic Tac Toe clone. I add some QGraphicsLineItem s to my scene and override the resizeEvent method of the Widget that contains the view, so that when the window is resized, the view and its contents are scaled appropriately. This works fine, except for the first time that I run the program: Once I resize the window by any amount, the scene is scaled correctly: Here's the code: main.cpp: #include <QtGui> #include "TestApp.h" int main(int argv, char **args) { QApplication app(argv, args); TestApp window; window.show(); return