Jump to content

Czar

Members
  • Content Count

    445
  • Joined

  • Last visited

  • Days Won

    13

Posts posted by Czar

  1. This maths parser http://mathjs.org/ looks like a library I could really use.

     

    However, I am having difficulties incorporating into SMS

    I have the js file in the lib subfolder

    But I am stuck how to 

    1. pass through a string to parse

    2. retrieve the result

       console.log(math.sqrt(-4))

    I can't find any posts or information on how to even start.

     

     

    math.js

  2. Yes I am using RequestAnimationFrame

    The tw3sprite is perfect for animation for our maths exercises - the software is not a game it mainlky uses editboxes and labels etc so the visual components are better than using canvas. The preloading solves the flash issue so I am happy again.

     

    I use canvas when converting directx games

     

  3. I think I may have solved it by preloading the images into a tw3image

    The following solved my flash issue - posting for completeness. And yes the procedure can be simpler

    procedure TForm1.PreloadImages(MyImage : tw3image; MyImageName : string);
    begin
      MyImage.visible := false;
      MyImage.LoadFromUrl(MyImageName);
    end;
    
    procedure TForm1.InitializeForm;
    begin
      inherited;
    
      PreloadImages(tw3image.create(self), 'res/girlidle.png');
      PreloadImages(tw3image.create(self), 'res/girlwalk.png');
      PreloadImages(tw3image.create(self), 'res/girlattack.png');
      PreloadImages(tw3image.create(self), 'res/girldefend.png');
      PreloadImages(tw3image.create(self), 'res/girldie.png');
    
      PreloadImages(tw3image.create(self), 'res/trexidle.png');
      PreloadImages(tw3image.create(self), 'res/trexwalk.png');
      PreloadImages(tw3image.create(self), 'res/trexbite.png');
      PreloadImages(tw3image.create(self), 'res/trexroar.png');

     

  4. When you set the background of a tw3sprite there is a noticeable flash when you switch from one image to another. I am using different PNGs for simple animation but I cannot seem to prevent the momentary blip where nothing is drawn.

    e.g., if I am displaying walking animation and I switch to the following

    sprite.Handle.style['background'] := 'res/girlidle.png';

    there is a flicker on the screen. Not too noticeable in chrome but it is in my embedded chromium app and in the internal server.

    How can I prevent the screen updating until new background has loaded?

     

    Is that even possible?

    Alternatively is it possible to double buffer the form?

     

    I have attached an example. It flashes horribly in internal browser, hardly never in chrome but I would ideally love no flash even in internal browser as it is similar to the situation i want to use it in

     

     

     

     

     

    tw3spritex_flash.rar

    2018-08-15_13-52-31.gif

  5. I feel that method might not be the best way to go about it. You could render to offscreen image and then copy to main image. Also I wonder if you might have difficulty because you are going from height x width to a width x height

    q@Christian

  6. @lynkfs- I liked the ability to upload an image. But I was hoping to store that image server-side. So, yes, I am referring to your edited section. I might use a php script to upload the images - or simply ftp them up when required. I am making a little inhouse app to allow our franchisees to make personalised ads - i.e., image add in their phone number etc and then download the result to their computer. I was simply looking for a way to allow a colleague to upload the images without my help ;)

  7. Ok this driving me to distraction. The sample above work great so I thought I would add text to my image

     

    var
      LBitmap:  TBitmap;
      LRect:    TRect;
    begin
    
      LBitmap := TBitmap.Create;
      try
        LBitmap.Allocate(640, 480);
        LRect := TRect.Create(0, 0, LBitmap.width-1, LBitmap.Height-1);
        LBitmap.Canvas.Brush.Color := clRed;
        LBitmap.Canvas.FillRect(LRect);
    
        LBitmap.Canvas.Font.size := 28;
        LBitmap.Canvas.TextOut(10,10, 'It displays text but in small font', clblack);
    
        var LEncodedData:= LBitmap.Canvas.ToDataURL('image/png');
        w3image1.LoadFromUrl(LEncodedData);
    
        TW3URLObject.Download( LEncodedData, 'picture.png');
    
      finally
        LBitmap.free;
      end;

    it seems font.size or font.color have no influence on the textout. Which is confusing. Is it a bug or am I missing something? In which case how can I set the font name, size and color?

  8. Didn't even realise that was a possibility. I create a symlink to a network folder containing our common files. That way more than one developer has access to the same common files.

     

    Just make sure you create it inside the RTL folder. When IDE starts up it will be able to access the other files in the symlink

  9. I am trying to find a demo that uses different fonts loaded from the internet. I cannot find a suitable sample, anyone got an idea?

    ideally something basic like how to load (for example) a cursive font and then set a label to use the new font.

  10. Colleagues have asked me if it possible to set a system where-by franchisees can edit text for social media ads. i.e., I display an image in their browser, they can edit the text and when they are done a PNG or JPG can be downloaded.

     

    I am just not sure about the last step - downloading. I know javascript is not supposed to access local machine but there must be a way to do it - my question is how easy is it to implement and can someone point me in the right direction?

    cheers

     

  11. procedure TForm1.W3EditBox1KeyDown(Sender: TObject; const KeyCode: Integer);
    begin
        if (keyCode < 48) or (keyCode > 57) then   //numbers
          if (keyCode <> 8 ) and (keycode<>46) and (keyCode <> 37) and (keyCode <>39) and (keyCode <>46)  then
          BrowserAPI.EventObject.preventDefault;
    end;

     

    Would it be possible to extend the keydown event so that "AllowKey : boolean = true" is added which would do the  "BrowserAPI.EventObject.preventDefault;"?

    That would make it more obvious and usable.

    QUESTION:  why does the "delete key" not work very well within SMS? Back space not a problem but delete (keycode 46) basically does not function most of the time.

     

     

     

  12. That is basically the solution we too came up with.

    Ideally the characters should never appear, looks a bit nicer. If not possible then either this solution or the inputtype solution, inserted below, will have to do

    In javascript it is possible to "not allow" a key press - that would be a great function to add to tw3editbox ;) @jarto

     

    <INPUT id="txtChar" onkeypress="return false;" type="text" name="txtChar">

×
×
  • Create New...