Problem with partial upd .. function, please help.

Hello.

I'm sorry to start another thread for OnPartialUpdate.

I know there is a lot on the forum, but I have not found a solution and an example that would solve my problem.

I will try to describe here what I need to call regularly via this function.

I have five slashes that I created in the font maker.

These slashes appear to me instead of seconds, ie 1 slash = first second.

It is like
"Knight Rider Car" reads slashes from left to right in seconds. Wink

The problem is that when I do dc.setClip at the bottom of the screen for slash size, width, height, I get to total time fast.


I would ask someone who could help me with this feature.

The best example of how to proceed.


Here's what I'm trying to do in OnPartialUpdate.

I do dcClearClip in OnUpdate...

Thank you

function onPartialUpdate(dc){
		sleepMode = true;

		
		
		dc.setClip(20, 175, 25, 20);
        dc.setColor(Graphics.COLOR_BLUE, Graphics.COLOR_TRANSPARENT);
        dc.drawText(20, 175, $.fontIcon_seconds, $.ICON_SECONDS, Gfx.TEXT_JUSTIFY_CENTER);
    	 
 
    	
        }
         }

  • So if you know how to write app adoption my code should be very easy and you should  know what to do

    - fill arrays mColors and mDrawX

    - put corect arguments in
    -- dc.setClip(...)
    -- dc.drawText()

    - delete code dc.drawText(130, 30, 12, sec.format("%02d"),5);

  • I'm sorry, I noticed I gave you "VoteDown" by mistake.

    I did this over the phone when I wanted to click the Reply button.

    Of course, you deserve credit for your help.

    but I still don't know how to do that function ...Joy

  • What I actually have a problem with is this.

    I have a constant:

    mColors = [ Gfx.COLOR_BLUE, Gfx.COLOR_RED, Gfx.COLOR_BLUE, Gfx.COLOR_RED, Gfx.COLOR_BLUE, Gfx.COLOR_RED,],
    mClip_X = [23, 35, 47, 59, 71, null, 71, 59, 47, 35, 23];

    I kept trying

    make:

    dc.setClip (mClip_X [0], mClip_X [1], mClip_X [2], mClip_X [3] -mClip_X [4]);

    but it doesn't work and i don't know how to delegate properly:

    dc.drawText (23, 175, $ .fontSeconds, $ .ICON_SECONDS, Graphics.TEXT_JUSTIFY_CENTER);

    I know that the code should include:

    dc.setClip (20, 175, 26, 20);

    but I can't write it and put it together with a font and a constant for drawing multiple clips...


    I can't give myself advice here...

    Please someone help.Rolling eyes

    Thank you

  • I assume,your

    - slash has 25x30

    - left X position the most left slash is 25 (justification to left)

    class  X_view

    {

      const mColors =
                    [    
                        GRA.COLOR_BLUE,    
                        GRA.COLOR_RED,
                        GRA.COLOR_BLUE,    
                        GRA.COLOR_RED,
                        GRA.COLOR_BLUE,    
                        GRA.COLOR_RED,
                    ],
                 mDrawX =
                    [
                        25,
                        50,
                        75,
                        100,
                        125,
                        null,
                        125,
                        100,
                        75,
                        50,
                        25
                    ];

    ......

    function onPartialUpdate(dc)
    {

        var   sec  = SYS.getClockTime().sec;
                   
                     if(sec % 6)    
                     {
                         dc.setColor(mColors[(sec / 6) % 2], -1);
                        sec = (sec  % 12)  - 1;
                        dc.setClip(mDrawX[sec ], 160, 25, 30);
                        dc.drawText(mDrawX[sec ], 175, $.fontSeconds, $.ICON_SECONDS,6);
                     }
    }

  • good day.

    My slash is 26x33, but I've already adjusted that.

    I don't even know how I can thank you.

    You helped me a lot and I really appreciate you as a programmer.

    Thank you

  • I still wanted to make the code as one for normal mode.

    This is the part of the code that keeps my slash in color:

    var sec = Sys.getClockTime (). sec;
    if (sec == 59) {
    sec = 60;
    }
    for (var a1 = 0; a1 <1; ++ a1) {
    if ((a1 + 1) * 1 <= sec) {
    SegOneBlack (dc);
    }
    }

    for (var b1 = 0; b1 <1; ++ b1) {
    if ((b1 + 1) * 10 <= sec) {
    SegOneLT_GR (dc);

    }
    }
    for (var c1 = 0; c1 <1; ++ c1) {
    if ((c1 + 1) * 11 <= sec) {
    SegOneBlack (dc);

    Is it possible to add it to this code somehow so that I can use a simpler method for Update and OnPartialUpdate?

  • btw I've fogto to add clearClip() in my code

                       if(sec % 6)    
                     {
                         dc.setColor(mColors[(sec / 6) % 2], -1);
                        sec = (sec  % 12)  - 1;
                        dc.setClip(mDrawX[sec ], 160, 25, 30);
                        dc.drawText(mDrawX[sec ], 175, $.fontSeconds, $.ICON_SECONDS,6);
                        dc.clearClip(); //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                     }

    function DrawSlash(dc, sec)
    {              
                     if(sec % 6)    
                     {
                         dc.setColor(mColors[(sec / 6) % 2], -1);
                        sec = (sec  % 12)  - 1;
                        dc.setClip(mDrawX[sec ], 160, 25, 30);
                        dc.drawText(mDrawX[sec ], 175, $.fontSeconds, $.ICON_SECONDS,6);
                        dc.clearClip();
                     }
    }

    function onPartialUpdate(dc)
    {

       DrawSlash(dc, SYS.getClockTime().sec);

    }

    function onUpdate(dc)
    {

       var sec_now = SYS.getClockTime().sec;

       WRITE ALGORITHM TO  call DrawSlash(dc, ...).; for all slashes (sec_now, sec_now -1, ....) and remember  there is no 2-5=-3 second :)

    }

  • Great, so it retains the color of the slash, as seen in my video?

    Last questions:

    1) how can I move the slashes slightly to the LEFT SIDE?

    Resolved, parameter adjustment:

    mDrawX ;)

    2) Why do I see a white square below the font when resetting?

    Thank you

    IMG:

  • 2. where exactly is the square?