このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。

翻訳前ページへ


製図/抽選 Tools2- Lazarus graphics HOME - - - - - Lazarus Tutorials TOC - - - - - - Other 構成要素 for programmers

Graphics with Lazarus

Part 2- Subroutines to "splice into" your 使用/適用s
Draw lines, in colors; make pixels change color.

とじ込み/提出する: lt2n-drawtools-pt2.htm

This essay will 供給する you with some 天然のまま, and in some ways 欠陥d, subroutines... but I hope the corners I've 削減(する) make them more accessible to Lazarus beginners.

This essay, by the way, was created after my problems with "fencepost errors" in 尊敬(する)・点 of 製図/抽選 with Lazarus and Delphi. (They were explained in PixelProblem.htm.) I may have RE-made those old mistakes, in the (比較して trivial) graphing elements of this... but THINK (and hope!) not.

You can download (解放する/自由な) the 十分な sourcecode for this 使用/適用. It is 十分な of rems and デモs to help you get to 支配するs with using the code.

Very sorry but...When first published, there were two 欠陥s in the code. And in the CODE shown here, and in the FIRST of the two downloads on 申し込む/申し出, they may 固執する. (But there's good news in the next paragraph!) They were subtle. The code "mostly 作品"; the 全体にわたる design was 罰金. Just a few boo-boos in the 罰金 print in at least one subroutine (sigh). Even the calling 条約s were 罰金!... but if the graph 高さ is 400, then if you use the old code of iDGToolYScale to calculate a Y 調整する for DGToolDoDotWWr, you get bad results いつかs. (It might even be that it was just a subroutine (extRemap) used by iDGToolYScale. I forget the 詳細(に述べる)s... I HAVE WORKING CODE NOW. I just need to tidy this page.) (明確な/細部 examples of things that the old code got wrong are given in 類似の text 近づく the 底(に届く) of the page.) If you keep the graph 高さ (as 始める,決める by the constant iDGToolImgHeight) at 150, I think you get good results for any values... please let me know if you discover exceptions... or find the 原因(となる)! (Please say, "In your page lt2n-drawtools-pt2.htm....")

I think I've 設立する the cure. But at the moment don't have to time to 直す/買収する,八百長をする the text below, or the OLD .zip that you can still download. You'll have to keep the に引き続いて in mind, and make edits to the code in the .zip.... OR find your way around the second zip, where everything 作品 (I hope! Again.) but you have to wade through some 捨てるs of MAKING it work!

A link to download the old .zip is in the 類似の text below. The one that has the 直す/買収する,八百長をするd subroutines, but some "other stuff" cluttering it can be downloaded in this zip, a 見解/翻訳/版 of the 道具s デモ ソフトウェア I created while working on the bug. It still has the bug, but at least there's an 平易な, interactive way to try using the subroutines.

"Just" 取って代わる the 団体/死体s (the stuff between the subroutines' "begin" and "end") of the two subroutines 示すd by the rems in the に引き続いて. Everything else... even the "headers" of the 影響する/感情d subroutines... can stay the same. 陳謝s for the nuisance. The un-patched code DID run... for the 実験(する) data I gave it. 明白に I need to work on my app-実験(する)ing 技術s.


// -------- iDGToolYScale -----------------



 begin

  if iRawMin>iRawMax then begin

    iTmp:=iRawMin;

    iRawMin:=iRawMax;

    iRawMax:=iTmp;

    end;



  extRaw:=extRemap(extRaw,iRawMin,iRawMax,

            iUseMin,iUseMax);



  extFactor:=(iDGToolImgHeight-1)/100;



  extRaw:=extRaw*extFactor;



 iTmp:=一連の会議、交渉/完成する(extRaw);



 result:=iDGToolImgHeight-1-iTmp;



 end;//of iDGToolYScale





// ------------------------------------

// -------- extRemap ------------------





 begin

  iShiftWantedsToZero:=iOutMin;//**1

  iShiftHavesToZero:=iSourceMin;//**2



  extScaleFactor:=(iSourceMax-iShiftHavesToZero)/

                  (iOutMax-iShiftWantedsToZero);//**3



  extTmp:=extInput-iSourceMin;

  extTmp:=extTmp/extScaleFactor;



  result:=iOutMin+extTmp;

end;//extRemap

And, to come in new 見解/翻訳/版 when it comes out, a new 機能(する)/行事...


// ------------------------------------

// -------- iDGToolConstrain ----------



機能(する)/行事 TLT2N_DrawTools_bF1.iDGToolConstrain

       (iToConstrain,iMin,iMax:integer):integer;

//Needs work... should the constraining be to 範囲 of

//   iMin-iMax INCLUSIVE? EXCLUSIVE?

begin

  if iToConstrain<iMin then iToConstrain:=iMin;

  if iToConstrain>iMax then iToConstrain:=iMax;

result:=iToConstrain;

end;

The 計画(する) is that you will use that along to way to plotting a point for a datum, in 事例/患者s where you want "too big" or "too small" values to be 変えるd to "biggest I can 陰謀(を企てる)"/ "smallest I can 陰謀(を企てる)". To be explained more fully in 改訂するd tutorial, in 予定 course... but don't look for anything "深い" here. You probably しっかり掴むd the entire 目的 at a ちらりと見ること, and using iDGToolConstrain isn't much harder than seeing its 目的.

And now for the tutorial!...



You can download a zip with a 見解/翻訳/版 of the 道具s デモ ソフトウェア I created while working on the bug. It still has the bug. (If you use copy/paste to patch in the two 改正s given above, it SHOULD be okay!) But it does, at least, give you an 平易な, interactive way to try using...


DGToolDoDotWWr(iX,

  iDGToolYScale(iRawValue,100,150,80,90),

  clbBlue);

... with different values where you see "100,150,80,90" in the line above.

支援する to happier 事柄s...


Many of the subroutines are meant to be of general use. You should be able to "patch" any of the 決まりきった仕事s into other programs. Any such subroutine will have "DGTool" (from "DrawGraphTool") at or 近づく the start of their 指名するs.

So, for example, you can 輸出(する) DGToolScrollLeft to your own code やめる easily.

Two of the subroutines meant for 会社にする/組み込むing in your code are more 一般に useful, and not tied to the "製図/抽選 道具s" 面s of what is 現在のd here. They are the ones called "延期する" and "extRemap". (The "trivial" iDGToolConstrain, when it becomes part of the 道具 始める,決める is also "一般に useful", but it would be as 平易な to 令状 your own as to copy/paste that for use どこかよそで. It was 含むd because it will often be 手配中の,お尋ね者 when using the other 道具s.)

If you are not an "old 手渡す" at using subroutines, you may 利益 from a tutorial on subroutines which I wrote for Delphi, Lazarus's inspiration. (For our wants here, there are hardly any differences.) Good use of subroutines- i.e. 手続きs and 機能(する)/行事s- makes programming a lot easier!

But. There's always a but!...

To 挿入する these subroutines into your own code, you must also 輸出(する) a few 全世界の variables... something we try to 避ける. However, they too have DGTool in their 指名するs, to help you. I will try to do a concise "How to 輸出(する)" guide later.

And finally, subroutines for 製図/抽選 暗示するs a place to draw on, doesn't it? You'll need an Image 反対する on your form. Again, 指導/手引 will be given.

This essay carries on from the first "Draw Graph 道具s", lt2n-drawtools.htm.. but should be useable on its own. If you want to be taken gently by the 手渡す through the 早期に parts of what's assumed knowledge here, try the first essay first.

"Drawtools_b" needs what that needed...


 手続き DGToolDrawLine

 手続き DGToolDoDotWWr

and 追加するs...


  手続き DGToolClearDrawingArea

  手続き DGToolScrollLeft

  機能(する)/行事 iDGToolYScale

  手続き 延期する

  機能(する)/行事 extRemap

  

手続き DGToolDrawLine (from first DrawTools tutorial)

This draws a line. It takes 5 parameters:
An X and a Y for where the line starts
Another X and Y for where the line goes to
And a TColor parameter which 明示するs the color for the line.

The X and Y 調整するs should be held in integer type variables.

I believe if you request...

DGToolDrawLine(0,0,100,100,clBlue)

... (assuming the 製図/抽選 area is large enough, you will get the first dot in the upper 権利 手渡す corner. (THAT is pixel 0,0, and I know this subroutine will put a dot at the pixel 明示するd for the start of the line.

the "部隊s" for those parameters is pixels.

I am いっそう少なく sure about 正確に/まさに where the line will end! It will, I think, 含む a colored pixel at 99,99. But it might also do one at 100,100 if I am wrong.

The color parameter can be a system defined color constant, e.g. clTeal. Or it can be a number. The link given will help you with ways to get the 権利 number for the color you want.

手続き DGToolDoDotWWr (from first DrawTools tutorial)

This 手続き needs three parameters: Two integers to 明示する an X and a Y, and another color code. (See previous, for comments on color codes. They are "just numbers", or simple system constants, like clGreen.)

公式文書,認める: These 調整するs (the X and the Y) are in the system which is normal in programming. "0,0" is at the upper left of the graph. (Unlike what mathematicians usually use: 0,0 at the lower left.

DGToolDoDotWWr has a nice feature. (It would have been called "DGToolDoDot" without the feature.) If you 明示する a Bad Number (too big, or too small (i.e. 消極的な)) for the X or Y 調整する, it will "包む". The "WWr" in the 手続き's 指名する is for "With Wrap".

The "Line of Dots" button in the app associated with this tutorial uses DGToolDoDotWWr to draw a diagonal line of dots.

The program that 供給(する)s you with the subroutines has some デモs in it. The に引き続いて is there to 論証する DGToolDoDotWWr.


手続き TLT2N_DrawTools_bF1.buLineOfDotsClick(Sender: TObject);

var xTmp, yTmp:integer;

begin

  xTmp:=10;

  for yTmp:=10 to 200 do begin

    DGToolDoDotWWr(xTmp,yTmp,clRed);

    xTmp:=xTmp+1;

    延期する(20);

  end;// of for...

end;// of  buLineOfDotsClick

Want to make it snow (in green!) in the 製図/抽選 area?...


手続き TLT2N_DrawTools_bF1.

   Button1Click(Sender: TObject);

var c1:integer;

begin

  for c1:=0 to 500 do

    DGToolDoDotWWr(無作為の(iDGToolImgWidth),

       無作為の(iDGToolImgHeight),clGreen);

  end;

Nota Bene:
By using DGToolYScale (see below) "on" the values passed to DGToolDoDotWWr, you can say "put the dot between 10 and 20 パーセント "up" the graph. And if the value 存在 plotted is, say 280, from a sensor 推定する/予想するd to return values between 200 and 300, put the dot 15% of the way from the 10% level to the 20% level.

Re-read that. DGToolDoDotWWr with DGToolYScale give you very simple plotting of 多重の graphs on one 製図/抽選 surface. See also the source-code, which 含む/封じ込めるs デモs. 十分な sourcecode 供給(する)d.

公式文書,認める that the sourcecode was 取って代わるd with a more polished 見解/翻訳/版 on 23 Dec 2018, about 8:10pm New York time. (The 見解/翻訳/版 identified internally, and in the 肩書を与える 妨げる/法廷,弁護士業 of the window, when you run the .exe, as "23Dec2018, 19:30".) If you downloaded the .zip before that time, fetch the updated 見解/翻訳/版.

DGToolClearDrawingArea;

DGToolClearDrawingArea; ...ummm... (疑いを)晴らすs the 製図/抽選 area! I.e. erases everything on it. Changes everything to whatever color you have 蓄える/店d in the 全世界の variable "clDGToolGraphBackGround" (type TColor). You can use the Lazarus-供給するd color constants, e.g. clRed, or a raw number. See http://wiki.freepascal.org/Colors. That variable also now 決定するs the "background color" when the graphing area is first 陳列する,発揮するd, by the way. (In lt2n_drawtools_a, it always had a white background.)

Why not 追加する a parameter to 明示する the color to make the 製図/抽選 area? Having the background color in a variable has other uses... most 顕著に in erasing lines. If you draw a line in, say, red (on a white background), and later draw another line, in the same place, but this time using the background color, you will "erase" the first line. (XORing with the color you used to create the line is a little bit better... but a story for a Google search, or another day.)

DGToolScrollLeft;

DGToolScrollLeft scrolls everything on the graph to the left one pixel's 価値(がある). The 権利 手渡す column is filled with whatever color clDGToolGraphBackGround 明示するs at the moment. The column of pixels that was at the left 辛勝する/優位 of the graph "落ちるs off", and is lost.

This might seem an arcane 手続き. Who would want it? But once you have this, you can do Good Stuff. It is 根底となる to the Scroll デモ, and to what is 法案d as "the Main Event", によれば the button texts. (In that, a 機能(する)/行事 creates a 偽の "reading" from a "sensor" which might be 記録,記録的な/記録するing the 気温 of something with a changing temperture.) Here's the code for the Scroll デモ:


手続き TLT2N_DrawTools_bF1.DemoBuildFrmRt;

//(a デモ 決まりきった仕事)

var iY, iCount:integer;

begin

  for iCount:=0 to 70 do begin

    DGToolScrollLeft;

    iY:=10+(iCount mod 30);//Goes 10,11,12...38,39,10, 11...

    DGToolDoDotWWr(iDGToolImgWidth-1,iY,clRed);

    延期する(40);

  end;//for

end;//BuildFrmRt; (a デモ of a trick)

延期する

一般に useful. A simple little thing, but to save you going off to the internet land to fetch your own. Gives a 非,不,無-封鎖するing 延期する of at least... but probably not 正確に/まさに... x milliseconds.

extRemap

一般に useful. A 機能(する)/行事 to "remap" a number. For the graph 製図/抽選 this essay is about, you won't need to use it 直接/まっすぐに... but it is an 成分 of iDGToolYScale, which I will 現在の in a moment. And it is 利用できる to you to use 直接/まっすぐに, when you need it.

Needs 5 numbers... If you passed 280,200,300,10,20, it would return 18: Start with the 280. That is the number 存在 re-mapped. the 200,300 tells you the 範囲 that it (機の)カム FROM, i.e. the 最小限 and 最大限 numbers that the 280 could have been. (公式文書,認める that 280 is 80% "along" the number line from 200 to 300.)

The last two parameters 宣言する the 範囲 you want the number mapped TO. 10 to 20, in this 事例/患者. 80% along THAT line is 18.

If that doesn't yet make sense, re-read the above?

This 決まりきった仕事 is really helpful if you are, say, doing a graph of some numbers. Let's say you're doing graphs of some 天候 and home heating 支配(する)/統制する 気温s. Let's say your data is in degrees C. And in your area, the outside tture can swing from -10 degrees C to +205 degrees. But, on your graph, you want those numbers to 陰謀(を企てる) from 10% up the Y axis to, say, 90 %.

You could "pre-過程" the 気温 sensor number with extRemap, and pass those results to DGToolDoDotWWr, as the Y value.

But, in this 控訴 of graph 製図/抽選 決まりきった仕事s, as inimated above, there's an even better 機能(する)/行事: iDGToolYScale. I only について言及するd (just now) what you could do to help you see if my explanation was good enough.

It is simpler to explain what extRemap does, than it was to 令状 the subroutine, I 約束 you! (Try it, if you don't believe me!)

(The 機能(する)/行事 does not break 負かす/撃墜する if you pass, say, 310 to it... but the result will be more than 20).

Just before we start with DGToolYScale, I have to tell you that this TUTORIAL unravelled a bit に向かって the end. but, you can fetch the 十分な sourcecode of DrawTools_B, for 解放する/自由な. THAT has been 完全にするd... carefully... and is 十分な of デモs and rems. If I were an 知らせるd reader of this tutorial, I would ちらりと見ること the stuff about DGToolYScale that comes next, and when you've had enough, go to the sourcecode!

公式文書,認める that the sourcecode was 取って代わるd with a more polished 見解/翻訳/版 on 23 Dec 2018, about 8:10pm New York time. (The 見解/翻訳/版 identified internally, and in the 肩書を与える 妨げる/法廷,弁護士業 of the window, when you run the .exe, as "23Dec2018, 19:30".) If you downloaded the .zip before that time, fetch the updated 見解/翻訳/版.

DGToolYScale

DGToolYScale is a "helper" 機能(する)/行事, for use with DGToolDoDotWWr, which was 利用できる as part of lt2n_drawtools_a.

DGToolDoDotWWr puts a dot on the graph in the color of your choice, and takes three parameters.... iX, iY and iColor. iX and iY say WHERE the dot should go, and iColor 決定するs the color it will be.

iX 決定するs the left-and-権利-ness of the dot. Use 0 to put it in the left-most column, and iDGToolImgWidth-1 to put it in the 権利 手渡す column. (公式文書,認める the "-1")

So far, so simple, so useable.

iY 決定するs the up-負かす/撃墜する-ness of the dot. 0 puts it at the 最高の,を越す of the graph, iDGToolImgHeight-1 (don't 行方不明になる the "-1") puts it at the 底(に届く) of the graph. Not 特に 使用者-friendly.

So I created DGToolYScale

Hang on to you hat.

It has 5 parameters... we'll come to them in a moment.

Suppose you have a sensor that, in the 条件s which 利益/興味 you, returns values from 28 to 232. And suppose that your graphing area is 150 pixels high. We'll assume that the sensor reading is in iSensor.

A VERY 天然のまま answer would be...

手続き TLT2N_DrawTools_bF1.DemoCrudeScaling;

//デモ of a 天然のまま plotting of a 偽のd sensor

//  reading

//The HEART of this is the call to DGToolDoDotWWr. Most of

//  the 残り/休憩(する) is there to make it happen 60 times, and to

//  供給する 偽のd sensor readings

var bCount:byte;//(0-255)

    shiDrift:shortint;//(-128 to 127)

    boDirectionUp:boolean;//Which way should readings drift?

    iSensor:integer;//(肯定的な AND 消極的な numbers in the 範囲 許すd.)



機能(する)/行事 iFakedSensor:integer;

  //uses several 株d variables. Bad practice!

  begin

    iSensor:=iSensor+shiDrift;

    result:=iSensor;

  end;//iFakedSensor



begin

//From here...

iSensor:=100;//初期の value from sensor.

shiDrift:=-2;

boDirectionUp:=true;

//... to here: Just setting up the sensor reading faker.



//Now read sensor, 陰謀(を企てる) at 権利 辛勝する/優位, scroll... 60 times.

for bCount:=0 to 60 do begin

    DGToolDoDotWWr(iDGToolImgWidth-1,iFakedSensor,clGreen);

    //   max sensible second 称する,呼ぶ/期間/用語: iDGToolImgHeight-1

    DGToolScrollLeft;

    延期する(20);

    end;//for...

end;//DemoCrudeScaling

That calls DGToolDoDotWWr 繰り返して, with the X 調整する 始める,決める so that the new dots appear at the 権利 手渡す 味方する of the 150 pixel high graph. (You can't tell it is 150 pixels from the code fragment... but it is, in the 状況 I want!) After each is plotted, the graph scrolls one pixel to the left. What's REALLY 天然のまま is that the sensor readings are 98, 96, 94, 92....

.. and they 結局 become 消極的な. Which would be BAD, if we were just using Lazarus's pixel plotting 決まりきった仕事, but because we are using our DGToolDoDotWWr (even though it has Lazarus's 決まりきった仕事 at it's heart), at least our line of dots "包むs".

But! And for me it is a biggish "but"... the line goes UP when our numbers go DOWN.

We'll を取り引きする that in a moment. First let's create a "good" "偽の" sensor. We 手配中の,お尋ね者 one to give values from 28 to 232, remember.

Don't be 圧倒するd by the に引き続いて... it took a lot of code to create a sensible 偽の sensor... if you skim 負かす/撃墜する to the 底(に届く), where it says "begin //main 封鎖する of DemoCrudeScaling", you'll see that as long as we have a source of sensor readings, doing the graph is still やめる simple... mostly what we had before!


手続き TLT2N_DrawTools_bF1.DemoCrudeScaling;

//デモ of a 天然のまま plotting of a 偽のd sensor

//  reading

//The HEART of this is the call to DGToolDoDotWWr. Most of

//  the 残り/休憩(する) is there to make it happen 60 times, and to

//  供給する 偽のd sensor readings

var bCount, bDrift:byte;//(0-255)

    boDirectionUp:boolean;//Which way should readings drift?

    iSensor:integer;//(肯定的な AND 消極的な numbers in the 範囲 許すd.)



機能(する)/行事 iFakedSensor:integer;

  //Uses several 株d variables. Bad practice!

  begin

    //From time to time, change direction of

    //  drift

    if (無作為の(10)=0) then boDirectionUp:=

       not boDirectionUp;



    //From time to time, change size of drift

    if (無作為の(8)=0) then begin

       bDrift:=無作為の(3);

       end;//change size of drift.



    //適用する drift to previous sensor reading

    if boDirectionUp then

        iSensor:=iSensor+bDrift//no ; here

       else

        iSensor:=iSensor-bDrift;



    //Clip, if value has gone beyond

    //  the (独断的な) 社債s 要求するd of

    //  this 決まりきった仕事's design parameters

    if (iSensor>232) then begin

       iSensor:=232;

       boDirectionUp:=誤った;

       end;



    if (iSensor<28) then begin

       iSensor:=28;

       boDirectionUp:=true;

       end;



    result:=iSensor;

  end;//iFakedSensor



begin //main 封鎖する of DemoCrudeScaling

//From here...

iSensor:=100;//初期の value from sensor.

bDrift:=2;

boDirectionUp:=true;

//... to here: Just setting up the sensor reading faker.



//Now read sensor, 陰謀(を企てる) at 権利 辛勝する/優位, scroll... many times.

for bCount:=0 to 160 do begin

    DGToolDoDotWWr(iDGToolImgWidth-1,iFakedSensor,clGreen);

    //   max sensible second 称する,呼ぶ/期間/用語: iDGToolImgHeight-1

    DGToolScrollLeft;

    延期する(20);

    end;//for...

end;//DemoCrudeScaling

And that "作品"... 公正に/かなり 井戸/弁護士席. But remember that our graph is 150 pixels high, and that our (arbitrarily chosen, for discussion) sensor returns nothing いっそう少なく than 28, but いつかs readings as high as 232. If the sensor returns values above 150, the line will 包む. Untidy. And the part of the graph from y=0 to y=26 isn't used at all (except for 包む-arounds.)

And it is still all upside 負かす/撃墜する.

A simple, 天然のまま "直す/買収する,八百長をする" to the いつかs the numbers are too big" problem would be to use the に引き続いて for the "陰謀(を企てる) pixel". 公式文書,認める the "div 2". That divides the number in iFakedSensor, and sends the result to DGToolDoDotWWr. Now the number passed for plotting... 以前 28 to 232 is 14 to 116. (inclusive).


DGToolDoDotWWr(iDGToolImgWidth-1,iFakedSensor div 2,clGreen);

That would "work". But is terribly "広告 hoc". But we'll use it as a starting point for the goal we are working に向かって: A 機能(する)/行事 to "直す/買収する,八百長をする" ANY 範囲 of numbers to fit where we want them on our graph. It will be called DGToolYScale... as in "this 規模s a Y value to make it "権利" for the graphing area 利用できる."

It will also 直す/買収する,八百長をする the problem of the numbers 存在 "upside 負かす/撃墜する".

公式文書,認める that I said that DGToolYScale will let us put the dots from the readings where we want them. いつかs they will be using the whole 高さ of the graphing area. いつかs we will have two graphs on the graphing area... one on the 最高の,を越す half, the other on the 底(に届く) half.

Doing it...

First we'll take what we had a moment ago, and 配列し直す things somewhat, so that we have started our DGToolYScale. For the moment, it will just do the "div 2" that was our 天然のまま 直す/買収する,八百長をする. (I'll explain the "ext" and the "一連の会議、交渉/完成する" in a moment.

Here's the main part of our "デモ" code, and all of the code, so far....


for bCount:=0 to 160 do begin

    DGToolDoDotWWr(iDGToolImgWidth-1,iDGToolYScale(iFakedSensor),clGreen);

    //   max sensible second 称する,呼ぶ/期間/用語: iDGToolImgHeight-1

    DGToolScrollLeft;

    延期する(5);

    end;//for...

end;//DemoCrudeScaling



機能(する)/行事 TLT2N_DrawTools_bF1.iDGToolYScale(extRaw:延長するd):integer;

    begin

      result:=一連の会議、交渉/完成する(extRaw/2);

    end;//iDGToolYScale(extRaw:延長するd):integer;

The "延長するd" data type 許すs fractions. In our discussion, our sensor only returns integers. But we're building iDGToolYScale to be able to 扱う many 可能性s. (Some will say "but that will be slow.". Yes. It will. The whole APPROACH is 欠陥d, if you want, say, to 陳列する,発揮する 音声部の waveforms in real time. But the 原則s you'll learn here will still be 関連した when you re-work the code to make it do the same thing, but faster.)

When I pass an integer-type value into an 延長するd-type variable, there is no problem. The fact that extRaw can 持つ/拘留する 4.5 doesn't stop it 持つ/拘留するing "plain" 4. (Though it might call it "4.0"!)

So the 機能(する)/行事 can take 4 or 4.5 as the value that is passed TO it.

When you are 取引,協定ing with "real" type numbers, of which "延長するd" is one class, you don't use "div 2". (That's for when you are using integer-type data, and it truncates, by the way. 7 div 2 is 3.) With real-type variable, you use "/" to divide. And the answer can 含む a わずかの part.

So far, so good? We're going through iDGToolYScale, and have now looked at "extRaw/2".

The "一連の会議、交渉/完成する(extRaw/2)" says "一連の会議、交渉/完成する off the result of extRaw divided by two". THAT will be an integer, and thus it can be the result for iDGToolYScale

Moving on...

So, good, we have a structure. Now lets make iDGToolYScale a whole lot fancier.

Besides the number to be 規模d, returned in integer form, we will 追加する 4 numbers to what we send to the 機能(する)/行事.

The first two will 明示する the lowest and highest values we 推定する/予想する the sensor to return. (If values outside that 範囲 arise, they will only lead to dots higher or lower than we 手配中の,お尋ね者, with wrapping happening when necessary.)

The second two should be in the 範囲 0-99, inclusive.

If they are 0 and 9, the dots resulting should appear in the 底(に届く) 10% of the graphing area.

To make the dots all be in the upper half, you would use 50 and 99.

And, oh by the way, the 高めるd 機能(する)/行事 also turns the graph "the 権利 way up". That happens by the 魔法 of it's last line.

Umm. Ah.

Umm. Things got a bit messy. Sorry. "The Story" will not be fully 現在の here. I got too engrossed in Making It Work, and failed to 記録,記録的な/記録する, 文書 all that went into getting from "Hello World" to "The Finished 製品".

For fellow obsessives out there, I saved what I could. I will try to zip and upload that, later. You can dig in it to your heart's content.

But most of us are mostly 利益/興味d in the finished 製品. So... without all the 詳細(に述べる)s of how I got there, we have, ta da!...

The finished 製品

Thank you for trying to read the above, imperfect text. I hope your 成果/努力s will be rewarded when you download (解放する/自由な) the 十分な sourcecode for this 使用/適用. It is 十分な of rems and デモs to help you get to 支配するs with using this code... which is, I 心から believe, MUCH better than this documentation!

公式文書,認める that the sourcecode was 取って代わるd with a more polished 見解/翻訳/版 on 23 Dec 2018, about 8:10pm New York time. (The 見解/翻訳/版 identified internally, and in the 肩書を与える 妨げる/法廷,弁護士業 of the window, when you run the .exe, as "23Dec2018, 19:30".) If you downloaded the .zip before that time, fetch the updated 見解/翻訳/版.


Very sorry but...At the moment there is a 欠陥, somewhere in the code. It "mostly 作品" (sigh)... but if the graph 高さ is 400, then if you use iDGToolYScale to calculate a Y 調整する for DGToolDoDotWWr, you get bad results いつかs.

If you 繰り返して 陰謀(を企てる) 100 to 150 in iRawValue with...


for iX:=0 to 200 do begin

DGToolDoDotWWr(iX,

  iDGToolYScale(iRawValue,100,150,80,90),

  clbBlue);

end;

... you will find nice diagonal lines,almost like the...

((q-alt text for image))

... you would 推定する/予想する...

But! It will be in 底(に届く) of the graph pane, in the 10-20 % (up from 底(に届く)) 禁止(する)d, instead of the 80-90% 禁止(する)d, where it should be. If you ask for 100-150 to be plotted in the 60-70%, you get even worse results... if, as I say, the graph 高さ is 始める,決める (with the constant iDGToolImgHeight) at 400.

If you keep the graph 高さ at 150, I think you get good results for any values... please let me know if you discover exceptions... or find the 原因(となる)! (Please say, "In your page lt2n-drawtools-pt2.htm...."

You can also download a zip with a 見解/翻訳/版 of the 道具s デモ ソフトウェア I created while working on the bug. It still has the bug, but at least there's an 平易な, interactive way to try using...


DGToolDoDotWWr(iX,

  iDGToolYScale(iRawValue,100,150,80,90),

  clbBlue);

... with different values where you see "100,150,80,90" in the line above.



The good news...

In a sense, these 道具s are the 2018 manifestation of something I've been 令状ing new 見解/翻訳/版s of since 1983. It should be "coming on" by now!

Your thoughts, as ever, very welcome.

The 核心 subroutines...

Here is the code for the 核心 subroutines, as they stood in the '23 Dec 2018, 20:50' 見解/翻訳/版 of 'LT2N_DrawTools_B'. Remember that each place where TLT2N_DrawTools_bF1. appears, you will have to change that to match the 状況 in your app. And that they will need 今後 宣言s in the interface section of the code.


//===================================

手続き TLT2N_DrawTools_bF1.DGToolClearDrawingArea;

//始める,決めるs all pixels in 製図/抽選 area to

//whatever color is 明示するd by the value in

//the 全世界の clDGToolGraphBackGround;(TColor)



//公式文書,認める that there is a slight differnce between

//how Delphi and Lazarus initialize things...

//The TImage 反対する? The Bitmap? The picture?

//canvas? Something like that! THIS 作品 with

//Lazarus, and would with Delphi, too, I think.

//Delphi people can get away with not

//initializing something. 公式文書,認める I said "Get away

//with"... always a bad thing to lean on

//in programming.

begin

  //Pen, 小衝突: One is 輪郭(を描く), other is fill...



  //clDGToolGraphBackGround:=clRed;



  imgDGTool.canvas.小衝突.color:=clDGToolGraphBackGround;

  imgDGTool.canvas.pen.color:=clDGToolGraphBackGround;



  imgDGTool.picture.bitmap.

      canvas.rectangle(0,0,iDGToolImgWidth,iDGToolImgHeight);



  //bmDGTool.canvas.pen.color:=clDGToolGraphBackGround;

  //DGToolClearDrawingArea;



  //bmDGTool.canvas.rectangle(0,0,iDGToolImgWidth,iDGToolImgHeight);







  //Last two 条件 実験(する)d for fencepost errors... to re-

  //  実験(する), 始める,決める 小衝突 to 黒人/ボイコット, pen to red

end;//DGToolClearDrawingArea;



//===================================

手続き TLT2N_DrawTools_bF1.

   DGToolDrawLine(iX1,iY1,

             iX2,iY2:integer;clInk:TColor);

  begin

    imgDGTool.canvas.pen.color:=clInk;

    imgDGTool.picture.bitmap.canvas.moveto(iX1,iY1);

    imgDGTool.picture.bitmap.canvas.lineto(iX2,iY2);

  end; //DGToolDrawLine



//===================================

手続き TLT2N_DrawTools_bF1.

   DGToolDoDotWWr(iX1,iY1

     :integer;clInk:TColor);

//vers 23 Dec 2018

//TOOLS_B 見解/翻訳/版... 改善するd.. twice...

//over "初めの 初めの" in

//  Tools_a. This 包むs if values

//  of iY1 become 消極的な. (Tools_a may

//  have been 昇格d to this by the time

//  you are reading these comments... or may

//  still 存在する in the 早期に, 欠陥d,

//  "mostly 作品" form it was 初めは

//  published in)

  begin

    //Next two: New since 1Dec18

    iX1:=iX1 mod iDGToolImgWidth;

    while (iX1<0) do iX1:=iX1+iDGToolImgWidth;



    iY1:=iY1 mod iDGToolImgHeight;//REVISED

    while (iY1<0) do iY1:=iY1+iDGToolImgHeight;



    imgDGTool.picture.bitmap.

      canvas.pixels[iX1,iY1]:=clInk;//REVISED

  end; //DGToolDrawLineWWr



//===================================

手続き TLT2N_DrawTools_bF1.

   DGToolScrollLeft;

var rectSource,rectDest:TRect;

begin

  //First: Copy all but first column one place to the left.

  rectSource:=Rect(1,0,iDGToolImgWidth,iDGToolImgHeight);

  rectDest:=Rect(0,0,iDGToolImgWidth-1,iDGToolImgHeight);

  imgDGTool.picture.bitmap.

      canvas.CopyRect(rectDest,imgDGTool.picture.bitmap.

      canvas,rectSource);



  //Then: Erase 権利 手渡す column to backgorund color

  imgDGTool.canvas.pen.color:=clDGToolGraphBackGround;

  imgDGTool.picture.bitmap.

      canvas.moveto(iDGToolImgWidth-1,0);

  imgDGTool.picture.bitmap.

      canvas.lineto(iDGToolImgWidth-1,iDGToolImgHeight);

  //In prev: Definitely NOT "-1" on iDGToolImgHeight

  //  (Because it is lineTO??)

end;//DGToolScrollLeft;



//===================================

//An important "helper" 機能(する)/行事...

機能(する)/行事 TLT2N_DrawTools_bF1.

   iDGToolYScale(extRaw:延長するd;

     iRawMin,iRawMax:integer;

     iUseMin,iUseMax:byte):integer;

//Makes 言及/関連 to some 全世界の constants:

//  (名簿(に載せる)/表(にあげる))

//This is まず第一に/本来 a service 決まりきった仕事 for

//  DGToolDoDotWWr.

//Takes iRaw, and 変えるs it to a value suitable

//  for use as a Y value for plotting a pixel on

//  graph.

//"Suitable" 含むs inverting things, so big

//  numbers are high on the cartesian 計画(する),

//  low numbers are に向かって 底(に届く).

//iRawMin, iRawMax should 持つ/拘留する the 最小限 and

//  最大限 values 推定する/予想するd for the raw data.

//  (These should be INCLUSIVE of 範囲 推定する/予想するd... ARE THEY?

//(Are 消極的なs 許すd?? Inversion (i.e. iRawMin > iRawMax)

//  If the actual data 越えるs any 期待s,

//    the resulting dots may be above or below

//    the 禁止(する)d of the graph 明示するd by iUseMin,

//    iUseMax. The worst thing that can happens

//    is that data will "包む", vertically. You

//    will be saved by the "out of 範囲"

//    準備/条項s in DGToolDoDotWWr.

//iUseMin, iUseMax 明示する where the data should

//  appear, vertically, on the graph. If 0 and 99

//  それぞれ, iRawMin should 陰謀(を企てる) at 底(に届く)

//  of graph, iRawMax should 陰謀(を企てる) at 最高の,を越す.

//  In other words, they are 表明するd in パーセントs.

//  予定 to 一連の会議、交渉/完成するing errors, etc, these may not

//     be where you will always find them, 正確に/まさに.

//  ... or they may not be 正確に/まさに where planned 予定

//  ... to problems with the 詳細(に述べる)s of the programming

//  ... 実験(する)s of "境界 事例/患者s" are still needed. In

//  ... particular, check that no datum will go unseen,

//  ... i.e. be "off 辛勝する/優位 of page".

var iTmp:integer;

    extFactor:延長するd;

begin

 //供給(する) iUseMin and iUseMax with 60 and 69

 //   if iRawMin should 陰謀(を企てる) 60% up the graphing

 //   area, and  iRawMax should 陰謀(を企てる) 69% UP the graphing

 //   area. The 決まりきった仕事 returns the 調整する,

 //   as needed for the 基準 Lazarus "Pixel", so

 //   before we do anything else, we will 変える the

 //   "パーセントs" to 調整する values.

 //Example... if 50, 60 were passed when iDGToolImgHeight

 //   were 200, then they should be changed to 100 and 120.

 //   (There may be one or more "-1"s needed somewhere

//     here. Sigh.



 //First check if 使用者 has inverted the raw 範囲 spec, and

 //  直す/買収する,八百長をする, if so.

 if iRawMin>iRawMax then begin

    iTmp:=iRawMin;

    iRawMin:=iRawMax;

    iRawMax:=iTmp;

    end;

 extFactor:=(iDGToolImgHeight-1)/100;

 iUseMin:=trunc(iUseMin*extFactor);//trunc, not 一連の会議、交渉/完成する, on 目的!

 iUseMax:=trunc(iUseMax*extFactor);



 extRaw:=extRemap(extRaw,iRawMin,iRawMax,

            iUseMin,iUseMax);



 iTmp:=一連の会議、交渉/完成する(extRaw);

 //"iRaw" is no lnoger the "raw" number we had when

 //we entered this 決まりきった仕事. It has been 変えるd

 //to more useable value.



 //and finally "invert" the value...

 //   Up 'til now we've been working as it the

 //   graph origen (0,0) is at TOP of page, as

 //   indeed it is in the Lazarus (and Delphi)

 //   world. We want low numbers to print LOW

 //   in the graph, not high... and this 達成するs

 //   that.

 result:=iDGToolImgHeight-1-iTmp;

end;//iDGToolYScale



//===================================

//An important "helper" 機能(する)/行事, and useful in

//  many 状況s, not just these 製図/抽選 道具s

機能(する)/行事 TLT2N_DrawTools_bF1.

    extRemap(extInput:延長するd;

        iSourceMin,iSourceMax,

        iOutMin,iOutMax:integer):延長するd;

//This is used inside iDGToolYScale

//

//I have not yet 調査/捜査するd what happens

//   if you have 消極的な numbers anywhere.

//Nor what happens if you spec, say...

//    123, 50, 150, 500, 400

// (123: to be 転換d and 規模d,

//    50 to 150: 範囲 that 123 will be in

//    500 to 400, the 範囲 you want it

//    remapped to. If the 機能(する)/行事 can be

//    made tolerant of such inputs, then as

//    the input (123) rises, the 生産(高) would

//    落ちる. And 副/悪徳行為 versa. Sho8uld be possible.

//    But I 港/避難所't 実験(する)d for that yet.



//While some of the numbers you will want to

//  転換 will have わずかの parts, you must

//  明示する the 範囲 of what you start from

//  with integers. So, if the input could 範囲,

//  say, from 3.5 to 7.8, 宣言する the source

//  範囲 as from 2 to 8. (The numbers spec'd

//  are 扱う/治療するd as part of the 範囲.)

//Likewise, you must 明示する the 範囲 they

//  will 地図/計画する to with integers. You want the

//  results to run from 76.3 to 95.2? 明示する

//  75 to 96.



//In the に引き続いて 指名するs, "have" 言及するs to the

// numbers you "have" before you do the 転換

// and 規模.

//"手配中の,お尋ね者" 言及するs to the numbers you want after

//   tbe 転換ing and 規模ing.



var iShiftWantedsToZero,iShiftHavesToZero:integer;

    extScaleFactor:延長するd;

begin

 iShiftWantedsToZero:=iOutMin;//**1

 iShiftHavesToZero:=iSourceMin;//**2



 extScaleFactor:=(iSourceMax-iShiftHavesToZero)/

                 (iOutMax-iShiftWantedsToZero);//**3



 extInput:=(extInput-iShiftHavesToZero)/extScaleFactor;//**4



 result:=extInput+iShiftWantedsToZero;//**5

end;//extRemap



//===================================

//A useful little 機能(する)/行事, and useful in

//  many 状況s, not just these 製図/抽選 道具s

手続き TLT2N_DrawTools_bF1.延期する(qwMilliSeconds: QWord);

//Copied from third reply in https://会議.lazarus.

//   freepascal.org/索引.php?topic=40760.0

//Creates 非,不,無-封鎖するing 延期する of about AMilliseconds

//

//Cannot be moved to sau because it needs 接近 to

//   反対する "使用/適用".

var

  qwTmp: QWord;

begin

  qwTmp := GetTickCount64 + qwMilliSeconds;//公式文書,認める:

  //if 洪水 occurs, it won't 事柄, I think

  //The problem CAN be solved... Have I done it here?

  //The problem would arise if this were called with

  //qwMilliseconds = to, say, 1000, when GetTickCount

  //was いっそう少なく than 1000 "ticks" from the 最大限

  //number that 機能(する)/行事 can return. The 解答

  //lies in the fact that

  //the value returned by GetTickCount ALSO rolls

  //over. (There may be 問題/発行するs with RangeChecking

  //throwing up a 警告... this 橋(渡しをする) can be

  //crossed if we get to it. Sigh.

  while (GetTickCount64 < qwTmp) and

     (not 使用/適用.終結させるd) do

        使用/適用.ProcessMessages;

end;//延期する





Search across all my 場所/位置s with the Google search...

Custom Search
            力/強力にするd by FreeFind
  場所/位置 search Web search
場所/位置 地図/計画する    What's New    Search This search 単に looks for the words you enter. It won't answer "Where can I download InpOut32?"
広告 from page's editor: Yes.. I do enjoy 収集するing these things for you. I hope they are helpful. However... this doesn't 支払う/賃金 my 法案s!!! Sheepdog ソフトウェア (tm) is supposed to help do that, so if you 設立する this stuff useful, (and you run a Windows or MS-DOS PC) please visit my freeware and shareware page, download something, and 循環させる it for me? Links on your page to this page would also be 高く評価する/(相場などが)上がるd!
Click here to visit editor's freeware, shareware page.

Link to Lazarus Tutorials main page
How to 接触する the editor of this page, Tom Boyd


Valid HTML 4.01 Transitional Page 実験(する)d for 同意/服従 with INDUSTRY (not MS-only) 基準s, using the 解放する/自由な, 公然と accessible validator at validator.w3.org. Mostly passes. There were two "unknown せいにするs" in Google+ button code. Sigh.


If this page 原因(となる)s a script to run, why? Because of things like Google パネル盤s, and the code for the search button. Why do I について言及する scripts? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....