How To Model Shape Using Record

This article will show you how to draw shape using record in SwinGame

howtomodelshapeusingrecord

Level

Advanced

Details

SwinGame allows you to use different record for various shape types such as Circle, Rectangle, Triangle, LineSegment. To use these record you need to:

  1. Make sure your code is opening SwinGame's graphic windows
  2. Clear the screen
  3. Call appropriate shape function to initialize your record. Function such as CircleAt, RectangleFrom etc ....
  4. Call draw "insert shape name" procedure and passing the record as parameter to draw a shape
  5. Refresh the screen
  6. Released all resources
  7. Run the program

Under Read These First is a screenshot showing what the program look like and below is the code for it.

Source Code Widget

  • program HowToModelShapeUsingRecord;
    uses SwinGame;
    
    procedure Main();
    var
        c : Circle;
        r : Rectangle;
        t : Triangle;
        l : LineSegment;
    begin
        OpenGraphicsWindow('Model Shape Using Record' ,600 ,100 );
        LoadDefaultColors();
        ClearScreen(ColorWhite );
        c := CircleAt(50 ,50 ,30 );
        r := RectangleFrom(300 ,20 ,100 ,60 );
        t := TriangleFrom(450 ,80 ,550 ,80 ,500 ,20 );
        l := LineFrom(100 ,40 ,250 ,40 );
        DrawCircle(ColorBlue ,c );
        DrawRectangle(ColorGreen ,r );
        DrawTriangle(ColorPink ,t );
        DrawLine(ColorRed ,l );
        RefreshScreen();
        Delay(5000 );
        ReleaseAllResources();
    end;
    begin
        Main();
    end.
    Download Now"
  • #include 
    #include "SwinGame.h"
    int main() 
    {
        circle  c;
        rectangle  r;
        triangle  t;
        line_segment  l;
        open_graphics_window("Model Shape Using Record" ,600 ,100 );
        load_default_colors();
        clear_screen(color_white );
        c = circle_at(50 ,50 ,30 ) ;
        r = rectangle_from(300 ,20 ,100 ,60 ) ;
        t = triangle_from(450 ,80 ,550 ,80 ,500 ,20 ) ;
        l = line_from(100 ,40 ,250 ,40 ) ;
        draw_circle(color_blue ,c );
        draw_rectangle(color_green ,r );
        draw_triangle(color_pink ,t );
        draw_line(color_red ,l );
        refresh_screen();
        delay(5000 );
        release_all_resources();
        return 0;
    }
    
    Download Now"
  • Source Code Coming Soon

  • Source Code Coming Soon

  • Source Code Coming Soon


Possibilities

Suggested projects will appear here.