line

HTML5 canvas - opacity problem with a paint app

北战南征 提交于 2019-12-08 04:55:12
问题 I'm trying to program a paint application using Canvas. the way it works is by connection lines when the mouse is pressed. when the line is opaque it works well, but when I change the alpha parameter I get a problem. I tried two options: a. The path begins when the mouse is down for the first time and ends when the mouse is up again: every move of the mouse calls the stroke() function. because the line is transparent the beginning of the whole path will become opaque and the end won't,

Delphi: Center Specific Line in TRichEdit by Scrolling

跟風遠走 提交于 2019-12-08 03:12:26
问题 I have a Delphi 2007 TRichEdit with several lines in it. I want to scroll the richedit vertically such that a specific line number if approximately centered in the visible/display area of the richedit. For example, I want to write the code for CenterLineInRichEdit in this example: procedure CenterLineInRichEdit(Edit: TRichEdit; LineNum: Integer); begin ... Edit.ScrollTo(...); end; procedure TForm1.FormCreate(Sender: TObject); var REdit: TRichEdit; i: Integer; begin REdit := TRichEdit.Create

解决CSS移动端1px边框问题

我怕爱的太早我们不能终老 提交于 2019-12-08 01:57:49
移动项目开发中,安卓或者IOS等高分辨率屏幕会把1px的border渲染成2px来显示,网上搜了一下,解决方法如下: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>解决1px边框问题</title> <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no"/> <style> .line {position:relative;} .line:after {width:200%;height:200%;position:absolute;top:0;left:0;z-index:0;content:"";-webkit-transform:scale(0.5);-webkit-transform-origin:0 0;transform:scale(0.5);transform-origin:0 0;} .list {width:100%;margin:auto;list-style:none;padding:0;} .list:after {border:1px solid #ccc;border-radius:10px;} .item {padding:10px;} .item:after

How to avoid going to new line with stdin in Rust

我的梦境 提交于 2019-12-08 01:04:24
问题 I have this code: fn main() { let mut stdin = io::stdin(); let input = &mut String::new(); loop { input.clear(); print!("Your age: "); stdin.read_line(input); print!("{}", input); } } So when I input something, the programs returns "Your age:" plus my input. But when I run the program I don't want to write the input in a new line. To do something like that in Python, I can write: var = input("Your age: ") How can I avoid going to a new line? I'm sure it's simple but I really can't realize how

js操作svg整体缩放

十年热恋 提交于 2019-12-07 23:56:29
首先我们先创建一个svg整体布局,代码如下: <!DOCTYPE html> < html > < head > < title > js操作svg实现整体缩放 </ title > < meta charset = "utf-8" > </ head > < body > < svg id = "svg" style = "background:#FAFAFA;" > < g id = "svgPanel" > < g id = "grid" > </ g > < circle fill = "red" r = "50" cx = "100" cy = "100" > </ circle > </ g > </ svg > < button onclick = "zoom(1.1)" > 放大 </ button > < button onclick = "zoom(0.9)" > 缩小 </ button > </ body > </ html > js代码来控制svg整体的大小并且利用svg来绘制背景网格: <script type = "text/javascript" > var svg = document.getElementById( "svg" ); var svgPanel = document.getElementById( "svgPanel" ); var

c getline skip blank line

本秂侑毒 提交于 2019-12-07 20:05:36
问题 while(getline (&line, &line_size, f) != -1){} I'm using this function to read line line. But i want to know when i'm reading a blank line. Can someone help? 回答1: so as H2CO3 already mentioned you can use the line length for this: while (getline (&line, &line_size, f) != -1) { if (strlen(line) == 1) { printf("H2CO3 spotted a blank line\n"); } /* or alternatively */ if ('\n' == line[0]) { printf("Ed Heal also spotted the blank line\n"); } .. } 回答2: You need to define blank line. Also, because

Bresenham line algorithm (thickness)

浪子不回头ぞ 提交于 2019-12-07 17:43:29
问题 I was wondering if anyone knew of any algorithm to draw a line with specific thickness, based on Bresenham's line algorithm or any similar. On a second thought, I've been wondering about for each setPixel(x,y) I'd just draw a circle, e.g.: filledCircle(x,y,thickness); for every x,y but that would of course be very slow. I also tried to use dictionary but that would fill the memory in no time. Check the pixels I'm about to draw on if they have the same color, but that's also not efficient

How to create Paint-like app with XNA?

≯℡__Kan透↙ 提交于 2019-12-07 16:31:18
问题 The issue of programmatically drawing lines using XNA has been covered here. However, I want to allow a user to draw on a canvas as one would with a drawing app such as MS Paint. This of course requires each x and/or y coordinate change in the mouse pointer position to result in another "dot" of the line being drawn on the canvas in the crayon color in real time. In the mouse move event, what XNA API considerations come into play in order to draw the line point by point? Literally, of course,

How to Draw in fragment?

老子叫甜甜 提交于 2019-12-07 15:42:44
问题 I have created Actionbar for my app with viewpager and it works properly. Now I want to draw some objects on each fragment. Can anyone suggest a good tutorial or sample code on how to draw on fragment. I can draw objects on my view when myclass extends Activity but I don't know what to do when it extends Fragment. I have tried this code till now but it does not work public class MoviesFragment extends Fragment { ImageView imageView; Bitmap bitmap; Bitmap bit; Canvas canvas; Paint paint;

How to Use an image as ImageBrush on a Line or Path in WPF

拟墨画扇 提交于 2019-12-07 14:25:00
问题 I have a Canvas on which I draw lines (via Lines or Paths) that indicates a road to follow for users. Is there a way to change the line so that it displays a repetitive image instead? What I'm looking for is to have a step icon (png with transparency) instead of a straight line. Thanks! 回答1: This will draw a repeated image as Stroke for a Path . Laborate with the values of Viewport to achieve what you're looking for <Path StrokeThickness="10" Data="M 10,10 100,10" Stretch="Fill"> <Path.Stroke