ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
plot.c
Go to the documentation of this file.
1/*****************************************************************************
2 * ugBASIC - an isomorphic BASIC language compiler for retrocomputers *
3 *****************************************************************************
4 * Copyright 2021-2026 Marco Spedaletti (asimov@mclink.it)
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *----------------------------------------------------------------------------
18 * Concesso in licenza secondo i termini della Licenza Apache, versione 2.0
19 * (la "Licenza"); è proibito usare questo file se non in conformità alla
20 * Licenza. Una copia della Licenza è disponibile all'indirizzo:
21 *
22 * http://www.apache.org/licenses/LICENSE-2.0
23 *
24 * Se non richiesto dalla legislazione vigente o concordato per iscritto,
25 * il software distribuito nei termini della Licenza è distribuito
26 * "COSÌ COM'È", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o
27 * implicite. Consultare la Licenza per il testo specifico che regola le
28 * autorizzazioni e le limitazioni previste dalla medesima.
29 ****************************************************************************/
30
31/****************************************************************************
32 * INCLUDE SECTION
33 ****************************************************************************/
34
35#include "../../ugbc.h"
36
37/****************************************************************************
38 * CODE SECTION
39 ****************************************************************************/
40
51/* <usermanual>
52@keyword PLOT
53
54@english
55
56The ''PLOT'' command allows you to draw individual points on the screen, laying
57the foundation for creating more complex shapes such as lines or rectangles.
58The origin (0,0) is usually located in the upper left corner of the screen, but can
59be changed using ''ORIGIN'' command. The coordinates increase to the right (for x)
60and down (for y), at least if the y axis is inverted using always the ''ORIGIN''.
61If the color is not provided, the default color is the one set with the last
62''INK'' / ''PEN'' command. It is possible to omit one or both coordinates,
63and ugBASIC will use the last one used, which is stored in the ''XGR'' and ''YGR'' variables.
64
65The ''PLOT'' command is the starting point for any drawing. By drawing a series
66of points close together, you can create the illusion of a line. By combining lines,
67you can create geometric shapes such as rectangles, triangles, and circles.
68By sequentially changing the coordinates of points, you can create rudimentary animations,
69
70The accuracy of your drawings is limited by your screen resolution, and drawing a large
71number of points can be slow, especially on less powerful computers. The ugBASIC
72language offers commands to draw lines, rectangles, and circles more efficiently,
73but ''PLOT'' is the foundation.
74
75@italian
76
77Il comando ''PLOT'' consente di disegnare singoli punti sullo schermo, gettando
78le basi per la creazione di forme più complesse come linee o rettangoli.
79L'origine (0,0) si trova solitamente nell'angolo in alto a sinistra dello schermo,
80ma può essere modificata utilizzando il comando ''ORIGIN''. Le coordinate aumentano
81verso destra (per x) e verso il basso (per y), almeno se l'asse y è invertito
82utilizzando sempre ''ORIGIN''. Se il colore non è specificato, il colore predefinito
83è quello impostato con l'ultimo comando ''INK'' / ''PEN''. È possibile omettere una
84o entrambe le coordinate e ugBASIC utilizzerà l'ultima utilizzata, che è memorizzata
85nelle variabili ''XGR'' e ''YGR''.
86
87Il comando ''PLOT'' è il punto di partenza per qualsiasi disegno. Disegnando una
88serie di punti ravvicinati, è possibile creare l'illusione di una linea. Combinando
89le linee, puoi creare forme geometriche come rettangoli, triangoli e cerchi.
90Modificando in sequenza le coordinate dei punti, puoi creare animazioni rudimentali.
91La precisione dei tuoi disegni è limitata dalla risoluzione dello schermo e
92disegnare un gran numero di punti può essere lento, specialmente su computer
93meno potenti. Il linguaggio ugBASIC offre comandi per disegnare linee, rettangoli
94e cerchi in modo più efficiente, ma ''PLOT'' è la base.
95
96@syntax PLOT [x], [y][, color]
97
98@example PLOT 42, 42
99@example PLOT 100, 100, RED
100
101@usedInExample contrib_sierpinski3.bas
102
103@target c128
104 </usermanual> */
105
106/* <usermanual>
107@keyword POINT AT
108
109@english
110
111@italian
112
113@syntax POINT AT ( [x], [y] )
114
115@example POINT AT ( 42, 42 )
116
117@usedInExample contrib_sierpinski3.bas
118
119</usermanual> */
120
121void plot( Environment * _environment, char * _x, char * _y, char *_c, int _preserve_color ) {
122
123 vic2_pset_vars( _environment, _x, _y, _c );
124
125 if ( _c && !_preserve_color ) {
126 pen( _environment, _c );
127 }
128
129}
void pen(Environment *_environment, char *_color)
Emit code for PEN ... command.
Definition pen.c:47
void plot(Environment *_environment, char *_x, char *_y, char *_c, int _preserve_color)
Definition plot.c:46
struct _Environment Environment
Structure of compilation environment.
void vic2_pset_vars(Environment *_environment, char *_x, char *_y, char *_c)
Definition vic2.c:1370