菜鸟提问------

kangbo818 2009-04-07 01:41:54
这个代码正确吗?怎么画不出线?
帮忙注释一下


x1:<input type=text id=x1 value=100><br>
y1:<input type=text id=y1 value=100><br>
x2:<input type=text id=x2 value=200><br>
y2:<input type=text id=y2 value=200><br>
<input type=button value=Draw onclick=Line(x1.value,y1.value,x2.value,y2.value)>
<div id=Line1 style="position:absolute;left:0;top:0;color:red;font-size:8px">
</div>
<script>
function DrawLine(x,y,LineLength,LineStyle)
{
var s="";
if(LineStyle=='h')s='<hr color=red width=' LineLength '>';
else for(var i=0;i<LineLength-2;i )s ="|<br>";
document.body.innerHTML ='<div id=Line1 style="position:absolute;left:0;top:0;color:red;font-
size:8px"></div>';
with(Line1)
{
innerHTML=s;;
style.pixelLeft=x;
style.pixelTop=y;
}
}
function Line(x1,y1,x2,y2)
{
DrawLine(x1,y1,(y2-y1)/8,'v');
DrawLine(x1,y2,(x2-x1),'h');
}
</script>
...全文
143 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
kangbo818 2009-04-07
  • 打赏
  • 举报
回复
还是画不出来,都什么意思注释一下
2009-04-07
  • 打赏
  • 举报
回复

x1:<input type=text id=x1 value=100><br>
y1:<input type=text id=y1 value=100><br>
x2:<input type=text id=x2 value=200><br>
y2:<input type=text id=y2 value=200><br>
<input type=button value=Draw onclick=Line(x1.value,y1.value,x2.value,y2.value)>
<div id=Line1 style="position:absolute;left:0;top:0;color:red;font-size:8px">
</div>
<script>
function DrawLine(x,y,LineLength,LineStyle)
{
var s="";
if(LineStyle=='h')s = '<hr color=red width='+ LineLength + '>';
else for(var i=0;i<LineLength-2;i++ )s += "|<br>";
//document.body.innerHTML ='<div id=Line1 style="position:absolute;left:0;top:0;color:red;font-size:8px"></div>';
with(Line1)
{
innerHTML +=s;;
style.pixelLeft=x;
style.pixelTop=y;
}
}
function Line(x1,y1,x2,y2)
{
DrawLine(x1,y1,(y2-y1)/8,'v');
DrawLine(x1,y2,(x2-x1),'h');
}
</script>

kangbo818 2009-04-07
  • 打赏
  • 举报
回复
看不懂啊,注释一下,我那个代码不行吗?我那个简单
feiling111222 2009-04-07
  • 打赏
  • 举报
回复
我给一个例子你
HTML:
<html>
<script>
function document.onmousemove(){return false;}
</script>
<head>
<script src="aaa.js" type="text/javascript"></script>
</head>
<body topmargin="0" leftmargin="0">

<div style="background:#66CCCC; position:relative" id="parent" >
<img style="cursor:crosshair" width="416" height="584.625" src="20080606.bmp" onmousedown="drags()" onmousemove="drag()" onmouseup="drage()"/>
</div>
<input id=inp size="20" /> <input id="testL" type="text" size="30" />
</body>

</html>





JS:
var begin;
var end;
var div1;

var flag1 = false;

function AbsolutePosition(ax, ay) {
this.ax = ax;
this.ay = ay;
}
function getAbsolutePosition() {

var ax =event.x;
var ay =event.y;
return new AbsolutePosition(ax, ay);
}


function drags()

{

flag1=true;
begin=getAbsolutePosition();
div1=document.createElement("<div>");
var mainDIV=document.getElementById("parent");
mainDIV.appendChild(div1);
}


function drage()
{
flag1=false;


}
function drag()

{
if(flag1){
end=getAbsolutePosition();
div1.style.width=Math.abs(end.ax-begin.ax);
div1.style.height=Math.abs(end.ay-begin.ay);
div1.style.position='absolute';
div1.style.border='#FF0000 1px solid';
div1.style.left=(begin.ax>=end.ax)?end.ax:begin.ax;
div1.style.top=(begin.ay>=end.ay)?end.ay:begin.ay;
}


}
稍做改动就可以用了
这只是简单的应用
我这还有复杂更多的
kangbo818 2009-04-07
  • 打赏
  • 举报
回复
快来人啊!!!!!!!
菜鸟提问基于MATLAB的防盗报警系统的有关问题-voice.m 话不多说,之前有人做出视频防盗系统,详见此贴。 原来的一个版本:视频监控,有东西经过监控区域就报警: 贴子如下: https://www.ilovematlab.cn/thread-133835-1-1.html 后来又有人加上了声音报警系统。声音过大就会报警。 详见此贴 声音监控,有东西发出声音就进行报警 https://www.ilovematlab.cn/thread-133881-1-1.html 。。 然后就是我们有个大作业,我想到的是将两者结合在一起,在视频监控的同时,如果声音过大就进行报警,然后拍照(要是能把照片发到邮箱就好了)。 以下是我的修改,但是一直报错。希望有人能帮忙修改下实现上面的功能。 代码贴出: function intruderdetecting2 % 运动参数阈值 motionThreshold = 200;         %  0 ~ 255 secondsToRecord = 10; % 声音参数阈值 soundThreshold = 0.1;         % 0.0 ~ 1.0 %声音麦克风 ai = analoginput; addchannel; set; set; set; samplesToRecord = ceil; set; set; set; set; %启动摄像头 a = imaqhwinfo; [camera_name, camera_id, format] = getCameraInfo; vid = videoinput; set; set; triggerconfig; start; trigger; try     wait; catch     stop; end %启动函数,时间函数 set; set; set; %创建figure fig = figure('DoubleBuffer','on', ...     'Name', 'Intruder Detection', ...     'NumberTitle', 'off', ...     'WindowStyle', 'docked', ...     'Toolbar', 'none', ...     'MenuBar', 'none', ...     'Color',[.1 .1 .1], ...     'CloseRequestFcn', @figureCloseFcn, ...     'DeleteFcn', @figureDeleteFcn); %对界面初始化 timePrevious = []; start; imagePrevious = []; start; %视频的启动函数     function videoStartFcn             imagePrevious = getsnapshot;     end %声音启动函数     function soundStartFcn             timePrevious = now;     end %视频时间函数         function videoTimerFcn         try             imageCurrent = getsnapshot;             timeCurrent = now;         catch             % getsnapshot can fail if object is deleted while we are waiting.             return;         end samplesRequested = ceil * *... ai.SampleRate); warning; try sound = peekdata; catch sound = zeros); end warning; sound = sound - mean); % Center about the mean. soundMax = max)); % Calculate max deviation from mean. timePrevious = timeCurrent; % Make our figure current. figOld = get; %if fig ~= figOld %set; %end %plot;         imageDifference = abs;         imageMax = max);         imagePrevious = imageCurrent;         figOld = get;         if fig ~= figOld             set;         end         image;         label = datestr;         xlabel;         set;         if imageMax > motionThreshold             motion = true;         else             motion = false;         end         if ~islogging             % 如果有东西闯入,进行响应             if motion                 % 将figure变红                 set;                 % 将闯入者的视频发送到你的邮箱                 str=['SB.jpg'];                 imwrite; %保存拍下来的图像                 customIntruderAction();             else                 set;             end;         end     if ~islogging    % if noise       customIntruderAction();%有人闯入时发进行报警         if fig ~= figOld             set;         end    % end     end    %function customIntruderAction()      % [y,fs]=wavread;      % sound; end     function figureCloseFcn         %关闭视频和声音         try             stop;             stop;         catch         end         closereq;     end     function figureDeleteFcn         delete;         delete;     end end 纯M文件编程。
菜鸟提问基于MATLAB的防盗报警系统的有关问题-sounddetection.m 话不多说,之前有人做出视频防盗系统,详见此贴。 原来的一个版本:视频监控,有东西经过监控区域就报警: 贴子如下: https://www.ilovematlab.cn/thread-133835-1-1.html 后来又有人加上了声音报警系统。声音过大就会报警。 详见此贴 声音监控,有东西发出声音就进行报警 https://www.ilovematlab.cn/thread-133881-1-1.html 。。 然后就是我们有个大作业,我想到的是将两者结合在一起,在视频监控的同时,如果声音过大就进行报警,然后拍照(要是能把照片发到邮箱就好了)。 以下是我的修改,但是一直报错。希望有人能帮忙修改下实现上面的功能。 代码贴出: function intruderdetecting2 % 运动参数阈值 motionThreshold = 200;         %  0 ~ 255 secondsToRecord = 10; % 声音参数阈值 soundThreshold = 0.1;         % 0.0 ~ 1.0 %声音麦克风 ai = analoginput; addchannel; set; set; set; samplesToRecord = ceil; set; set; set; set; %启动摄像头 a = imaqhwinfo; [camera_name, camera_id, format] = getCameraInfo; vid = videoinput; set; set; triggerconfig; start; trigger; try     wait; catch     stop; end %启动函数,时间函数 set; set; set; %创建figure fig = figure('DoubleBuffer','on', ...     'Name', 'Intruder Detection', ...     'NumberTitle', 'off', ...     'WindowStyle', 'docked', ...     'Toolbar', 'none', ...     'MenuBar', 'none', ...     'Color',[.1 .1 .1], ...     'CloseRequestFcn', @figureCloseFcn, ...     'DeleteFcn', @figureDeleteFcn); %对界面初始化 timePrevious = []; start; imagePrevious = []; start; %视频的启动函数     function videoStartFcn             imagePrevious = getsnapshot;     end %声音启动函数     function soundStartFcn             timePrevious = now;     end %视频时间函数         function videoTimerFcn         try             imageCurrent = getsnapshot;             timeCurrent = now;         catch             % getsnapshot can fail if object is deleted while we are waiting.             return;         end samplesRequested = ceil * *... ai.SampleRate); warning; try sound = peekdata; catch sound = zeros); end warning; sound = sound - mean); % Center about the mean. soundMax = max)); % Calculate max deviation from mean. timePrevious = timeCurrent; % Make our figure current. figOld = get; %if fig ~= figOld %set; %end %plot;         imageDifference = abs;         imageMax = max);         imagePrevious = imageCurrent;         figOld = get;         if fig ~= figOld             set;         end         image;         label = datestr;         xlabel;         set;         if imageMax > motionThreshold             motion = true;         else             motion = false;         end         if ~islogging             % 如果有东西闯入,进行响应             if motion                 % 将figure变红                 set;                 % 将闯入者的视频发送到你的邮箱                 str=['SB.jpg'];                 imwrite; %保存拍下来的图像                 customIntruderAction();             else                 set;             end;         end     if ~islogging    % if noise       customIntruderAction();%有人闯入时发进行报警         if fig ~= figOld             set;         end    % end     end    %function customIntruderAction()      % [y,fs]=wavread;      % sound; end     function figureCloseFcn         %关闭视频和声音         try             stop;             stop;         catch         end         closereq;     end     function figureDeleteFcn         delete;         delete;     end end 纯M文件编程。

87,992

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧