Compare commits

...

2 commits

Author SHA1 Message Date
visionmercer
827afeb19a added canvas 2026-04-30 08:23:26 +02:00
visionmercer
7cfd54d39d canvas 2026-04-29 21:17:20 +02:00

View file

@ -11,7 +11,7 @@ type layertype
kind as long kind as long
end type end type
dim shared layers(0) as layertype redim shared layers(1) as layertype
dim shared state as statetype dim shared state as statetype
@ -21,12 +21,17 @@ dim shared mousedown as integer
dim shared rmouseclicked as integer dim shared rmouseclicked as integer
dim shared rmousedown as integer dim shared rmousedown as integer
$resize:on $resize:on
screen _newimage(640,480,32) screen _newimage(750,480,32)
_delay 0.1 _delay 0.1
temp&=_resize temp&=_resize
redim shared pal(0) as _unsigned long redim shared pal(0) as _unsigned long
dim as integer ch1,ch2,ch3,bt dim as integer ch1,ch2,ch3,bt
loadpalette "endesga16",pal() loadpalette "endesga16",pal()
layers(0).ihandle=_newimage(640,350,32)
layers(1).ihandle=_newimage(640,350,32)
_dest layers(0).ihandle
line (0,0)-(_width-1,_height-1),_rgb32(255),bf
_dest 0
do do
line (0,0)-(_width-1,_height-1),backgroundcolor1,bf line (0,0)-(_width-1,_height-1),backgroundcolor1,bf
@ -35,7 +40,7 @@ do
mouseclicked=0 mouseclicked=0
rmouseclicked=0 rmouseclicked=0
if mousedown=-1 and _mousebutton(1)=0 then mouseclicked=-1 if mousedown=-1 and _mousebutton(1)=0 then mouseclicked=-1
if rmousedown=-1 and _mousebutton(1)=0 then rmouseclicked=-1 if rmousedown=-1 and _mousebutton(2)=0 then rmouseclicked=-1
mousedown=_mousebutton(1) mousedown=_mousebutton(1)
rmousedown=_mousebutton(2) rmousedown=_mousebutton(2)
toolbox toolbox
@ -73,7 +78,30 @@ sub colorpicker
end sub end sub
sub canvas sub canvas
line (70,0)-(_width-1,_height-20),_rgb32(64),bf ' 1. Define the box boundaries
dim boxX1 as integer: boxX1 = 70
dim boxWidth as integer: boxWidth = _width - 1 - boxX1
dim boxHeight as integer: boxHeight = _height - 20
' 2. Draw the background box
line (boxX1, 0)-(_width - 1, boxHeight), _rgb32(64), bf
' 3. Loop through layers and calculate centering for each
for i = 0 to ubound(layers)
dim imgW as integer: imgW = _width(layers(i).ihandle)
' Calculate X to center the image relative to the box
' We take the box start (70) and add half of the remaining whitespace
dim drawX as integer
drawX = boxX1 + (boxWidth - imgW) / 2
' If you also want it centered vertically:
dim imgH as integer: imgH = _height(layers(i).ihandle)
dim drawY as integer
drawY = (boxHeight - imgH) / 2
_putimage (drawX, drawY), layers(i).ihandle
next
end sub end sub
function icon(index as long) function icon(index as long)