circ
рисование круга
circ (x, y, radius, color
)
Параметры:x
- координата центра круга по оси xy
- координата центра круга по оси yradius
- радиус круга в пикселяхcolor
- индекс цвета в текущей палитре
Описание:
Рисует заполненный цветной круг с центром x
и y
с указанным радиусом. Используется алгоритм "bresenham".
Пример:
Запустить или скачать картридж примера.
-- title: circ demo
-- author: Al Rado
-- desc: particular qualities 'circ'
-- script: lua
-- input: gamepad
poke(0x3FF8,2)
cls(15)
SCREEN_WIDTH=240
SCREEN_HEIGHT=136
STEP=20
for radius=1, 6 do
--vertical
circ(radius,radius*STEP,radius,0)
circ(SCREEN_WIDTH-radius-1,radius*STEP,radius,0)-- minus one!
--horizontal
circ(radius*STEP,radius,radius,0)
circ(radius*STEP,SCREEN_HEIGHT-radius-1,radius,0)-- minus one!
end
function TIC() end
Пример:
Запустить или скачать картридж примера.
-- title: circ demo
-- author: Filippo
-- desc:
-- script: lua
-- input: gamepad
--init balls
balls={}
d=1
for i=0,50 do
ball={
x =math.random(10,220),
y =math.random(10,126),
dx=math.random(1,2)*d,
dy=math.random(1,2)*d,
r =math.random(6,12),
c =math.random(1,6)
}
balls[i]=ball
d=d*-1
end
function TIC()
cls()
for k,b in pairs(balls) do
--move the ball
b.x=b.x+b.dx
b.y=b.y+b.dy
--check right/left walls
if b.x >= 240-b.r then
b.x=240-b.r-1 --constraints inside the wall
b.dx=-b.dx --reverse direction
elseif b.x < b.r then
b.x=b.r
b.dx=-b.dx
end
--check bottom/top walls
if b.y >= 136-b.r then
b.y=136-b.r-1
b.dy=-b.dy
elseif b.y < b.r then
b.y=b.r
b.dy=-b.dy
end
--draw balls
circ(b.x,b.y,b.r,b.c)
circ(b.x+b.r/4,b.y-b.r/4,b.r/4,b.c+7)
end
end
Запустить или скачать картридж примера.
-- title: circ demo
-- author: Al Rado
-- desc: particular qualities 'circ'
-- script: moon
-- input: gamepad
poke 0x3FF8,2
cls 15
SCREEN_WIDTH=240
SCREEN_HEIGHT=136
STEP=20
for radius=1, 6
--vertical
circ(radius,radius*STEP,radius,0)
circ(SCREEN_WIDTH-radius-1,radius*STEP,radius,0)-- minus one!
--horizontal
circ(radius*STEP,radius,radius,0)
circ(radius*STEP,SCREEN_HEIGHT-radius-1,radius,0)-- minus one!
export TIC=->
Пример:
Запустить или скачать картридж примера.
-- title: circ demo
-- author: Filippo
-- desc:
-- script: moon
-- input: gamepad
--init balls
balls={}
d=1
for i=0,50
ball={
x:math.random(10,220)
y:math.random(10,126)
dx:math.random(1,2)*d
dy:math.random(1,2)*d
r:math.random(6,12)
c:math.random(1,6)
}
balls[i]=ball
d*=-1
export TIC=->
cls()
for b in *balls
--move the ball
b.x=b.x+b.dx
b.y=b.y+b.dy
--check right/left walls
if b.x >= 240-b.r
b.x=240-b.r-1 --constraints inside the wall
b.dx=-b.dx --reverse direction
elseif b.x < b.r
b.x=b.r
b.dx=-b.dx
--check bottom/top walls
if b.y >= 136-b.r
b.y=136-b.r-1
b.dy=-b.dy
elseif b.y < b.r
b.y=b.r
b.dy=-b.dy
--draw balls
circ b.x,b.y,b.r,b.c
circ b.x+b.r/4,b.y-b.r/4,b.r/4,b.c+7
// title: circ demo
// author: Al Rado
// desc: particular qualities 'circ'
// script: js
// input: gamepad
poke(0x3FF8, 2)
cls(15)
SCREEN_WIDTH = 240
SCREEN_HEIGHT = 136
STEP = 20
for (radius = 1; radius < 6; radius++) {
//vertical
circ(radius, radius * STEP, radius, 0)
circ(SCREEN_WIDTH - radius - 1, radius * STEP, radius, 0)// minus one!
//horizontal
circ(radius * STEP, radius, radius, 0)
circ(radius * STEP, SCREEN_HEIGHT - radius - 1, radius, 0)// minus one!
}
function TIC() { }
Пример:
// title: circ demo
// author: Filippo
// desc:
// script: js
// input: gamepad
//init balls
balls = {}
d = 1
for (i = 0; i < 50; i++) {
ball = {
x: random(10, 220),
y: random(10, 126),
dx: random(1, 2) * d,
dy: random(1, 2) * d,
r: random(6, 12),
c: random(1, 6)
}
balls[i] = ball
d = d * -1
}
function random(min, max) {
return Math.min(Math.random() * max + min, max)
}
function TIC() {
cls()
for (var k in balls) {
b = balls[k]
//move the ball
b.x = b.x + b.dx
b.y = b.y + b.dy
//check right/left walls
if (b.x >= 240 - b.r) {
b.x = 240 - b.r - 1 //constraints inside the wall
b.dx = -b.dx //reverse direction
}
else if (b.x < b.r) {
b.x = b.r
b.dx = -b.dx
}
//check bottom/top walls
if (b.y >= 136 - b.r) {
b.y = 136 - b.r - 1
b.dy = -b.dy
}
else if (b.y < b.r) {
b.y = b.r
b.dy = -b.dy
}
//draw balls
circ(b.x, b.y, b.r, b.c)
circ(b.x + b.r / 4, b.y - b.r / 4, b.r / 4, b.c + 7)
}
}