Announcement

Collapse
No announcement yet.

Banked Sketch Routine

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Banked Sketch Routine

    I'm just experimenting with banked code, which seems to be working, given your example. I'm trying a sketch routine (patterned after a forum example) in a bank. It works . . . sort of (see attached project).

    The things I don't understand are:

    1. I've had to add a pause in the sketch routine to get it to work at all tolerably.
    2. I can sketch if I move a stylus continuously but it exits if I stop moving while still pressing the stylus. The exit is triggered by a NOTOUCH status but I'm still touching.

    Is the pause necessary and, if so, why (or is it a fix for something I'm doing wrong)? I haven't tried to optimize the pause and it's length (in the time region I've used) doesn't seem to impact the problem of exiting when the stylus stops moving. Is banking in any way involved?

    Also: Do you have a suggestion for an optimum stylus material and stylus tip radius for effective operation with minimum long term damage to the display?

    Thanks,
    Hunter
    Attached Files

  • #2

    Hi Hunter,

    Good Day.

    On your attached project, Try to use TOUCH_RELEASED instead of NOTOUCH.
    Code:
     until(state == NOTOUCH);
    change to
    Code:
    until(state ==TOUCH_RELEASED);
    and you can now remove the pause(); It should now work smoothly.


    BR,

    Comment


    • #3

      Works perfectly!

      Stupid question . . . how do you insert the shaded code samples into a post?

      Thanks,
      Hunter
      Last edited by Hunter.uCyg; 7th November 2016, 02:58 PM.

      Comment


      • #4

        Hi Hunter,

        Highlight your code and goto Toggle Advanced Editor and choose # symbol.

        BR,

        Comment


        • #5
          Thanks for the code highlighting tip.

          This little sketch tool is great! I'm already working on integrating it into my application. I need to do some shading and am working on a brush (or maybe airbrush?) tool, but fear I might be reinventing the wheel. Might you know of any code examples of such a tool?

          Thanks,
          Hunter

          Comment


          • #6

            Hi Hunter,

            Good Day.

            You can try the attached file and used as a reference. You can change the radius and colour of the brush tool.


            BR,
            Ferdinand
            Attached Files

            Comment


            • #7
              Ferdinand,

              Yes. This certainly looks to work. My only problem is that it gives solid "brushing".

              I've gotten a little more aggressive about my requirements. My goal is to build up shading with multiple strokes, like an airbrush. My current approach is to get a group of pixels, modify their brightness (adding a variable amount for each pass) and rewriting to GRAM. One thing that's easy for me is that everything I do is red to maintain dark adaptation at night at a telescope.

              I've tried several approaches, even trying for a shading gradient going out from the touch point. Unfortunately, there's a bit too much math for each pixel for a round pattern (I did several multiplies, a divide and a square root for each pixel) and it slowed to leaving blotches as I move rather than a continuous path. I'm working with radii in the range of 10-15 pixels so there are many of these operations per update.

              I've now compromised, using mostly shifts and a square pattern and some other tricks which give me an interesting sort of chicken scratch shading effect which I rather like. The idea is to sketch what I see in the telescope. Adding a "brush erase" instead of adding brightness seems to be working out so I can correct mistakes.

              Here's a snip from the code:


              Code:
                          if(state == TOUCH_MOVING)
              
                              for(i := y-size/2; i <= y+size/2; i+=2)
                                  for(j := x-size/2; j <= x+size/2; j+=2)
                                      t := (ABS(x0-j) + ABS(y0-i));
                                      if(t <= size/2)
                                          p := gfx_GetPixel(j,i);
                                          p := p >> 11;
                                          t := t << 3;
                                          if(*dModeP == DRAW)   p := MIN(31, p+opac << t);  // Increase brightness of selected pixels
                                          if(*dModeP == ERASE)  p := MIN(31, p := 0);  // Erase everything
                                          p := p << 11;
                                          gfx_PutPixel(j, i, p);
                                      endif
                                  next
                              next
                              x0 := x;
                              y0 := y;
                          endif

              Probably doesn't make much sense . . . maybe not to me either . . . but it's getting closer to an effect that might do. I just "scrub" the stylus to increase the shading effect.

              I haven't tried moving a block of pixels to an array for processing. Wonder if that might be faster? I note at least one vestige of a prior try that serves no purpose in the code and probably more.

              Any thoughts about getting such shading effects?


              Here's a "faked" example of the sort of thing I'm after . . . quick and extremely crude . . . I'm certainly no artist and just learning to do this with a stylus. The "up" button switches from pen to brush and the "down" button switches between draw and erase.

              Click image for larger version  Name:	27s.jpg Views:	1 Size:	51.7 KB ID:	54755


              I turned up an acrylic stylus on a small lathe and finished with a hand graver, not wanting to use abrasives lest a speck of grit remain and scratch the screen. It seems to be working well.

              Thanks for your time on this. Any suggestions much appreciated.
              Hunter




              Last edited by Hunter.uCyg; 10th November 2016, 04:19 PM.

              Comment


              • #8
                p.s.


                The pen tool us useful for annotating stored images . . . again faked comments as an experiment.


                Click image for larger version

Name:	26s2.jpg
Views:	34
Size:	77.2 KB
ID:	54757


                Note . . . I tried to edit the previous post, adding this second image but the first image went away. ??? Pilot error?

                Thanks,
                Hunter



                Comment

                Working...
                X