![]() |
Forum Index : Microcontroller and PC projects : Just a M or already a W?
Author | Message | ||||
Nathan Regular Member ![]() Joined: 10/01/2016 Location: GermanyPosts: 49 |
Hi, please find attached a small demo for polygon drawing. This version does not contain TTF memory read functions, so it should run on the most tft displays. rem ************************************************************************** rem * rem * File: polygonDemo.bas rem * Author: Nathan rem * rem * Created on 08. October 2016, 16:19 rem * rem ************************************************************************** rem some buffer for the polygon definition and modification Dim point%(polygonPointSize(14)) Dim pointX%(polygonPointSize(14)) Dim pointY%(polygonPointSize(14)) rem re2016-10-08_150925_polygon.zip set the point list point%(0) = 0 rem polygonPointSet(<polygonArray>, P1x,P1y,P2x,P2y,P3x,P3y,P4x,P4y) rem maximum of four points can be defines by single call of polygonPointSet rem make a polygon last entry will be closed automatically x%=polygonPointSet(point%(), 2,0,4,0,5,4,6,0) x%=polygonPointSet(point%(), 8,0,10,7,8,7,7,3) x%=polygonPointSet(point%(), 6,5,4,5,3,3,2,7) x%=polygonPointSet(point%(), 0,7) Rem for debug Rem For cnt% = 0 To 12 Step 1 Rem polygonPointGet(point%(),cnt%,x%,y%) Rem Print Str$(x%) + " " + Str$(y%) Rem Next cnt% cls scaleX% = 1000 scaleY% = 1000 dx% = MM.HRES\2 dy% = MM.VRES\2 For outloop% = 0 To 4 Step 1 For angle% = -3600 To 3600 Step 10 REM polyRot(<inPointArray%>,<outPointArray%>,originRotX%,originRotY%,scaleX%,scaleY%,angle%,drawX%,drawy%) REM processing order originRotX%,originRotY% -> scaleX%,scaleY% -> angle% -> drawX%,drawy% REM Range: scale 1000 -> 1.0 angle -3600 to 3600 -> -360.0 to 360.0 polyRot( point%(),pointY%(),5,3,scaleX%,scaleY%,angle%,5,3) polyRot( pointY%(),pointX%(),30,0,1000,1000,-3600+angle%*2,dx%,dy%) scaleX% = scaleX% + 10 scaleY% = scaleX% REM draw the polygon REM polygon(<inPointArray%>,color%) polygon(pointX%(),RGB(255,0 ,0)) Pause 100 REM remove te polygon (simple version for the moment) polygon(pointX%(),0) Next angle% Next outloop% print ".done" Please find the recuired CSUB/CFUNCTION inside of th attached file. 2016-10-08_151110_polygon.zip Nathan |
||||
Nathan Regular Member ![]() Joined: 10/01/2016 Location: GermanyPosts: 49 |
Hi, I have a small update on the documentation REM polyRot(<inPointArray%>,<outPointArray%>,originRotX%,originRotY%,scaleX%,scaleY%,angle%,drawX%,drawy%) REM processing order originRotX%,originRotY% -> scaleX%,scaleY% -> angle% -> drawX%,drawy% REM Range: scale[X,Y] 1000 -> 1.0 angle -3600 to 3600 -> -360.0 to 360.0 + REM a negative scale is allowed and is equal to an mirror on X, Y. Nathan |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |