Blend2D.pas 577 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764
  1. unit Blend2D;
  2. { OPP wrappers for Blend2D C API.
  3. Follows the C++ API where possible. The following C++ classes are not
  4. converted because Delphi provides built-in alternatives for these:
  5. * BLArray<T>: uses TArray<T> instead
  6. * BLFile: uses TFileStream instead
  7. * BLString: uses String instead
  8. * BLVariant: not needed
  9. * BLStyle: style properties are used in another way. We may introduce a
  10. TBLStyle type once Delphi has support for managed records (or use Scope
  11. solution like TBLStrokeOptions). }
  12. {$SCOPEDENUMS ON}
  13. {$EXCESSPRECISION OFF}
  14. interface
  15. uses
  16. System.Math,
  17. System.SysUtils,
  18. Blend2D.Api;
  19. {$REGION 'Error Handling'}
  20. { ============================================================================
  21. [Error Handling - Enums]
  22. ============================================================================ }
  23. type
  24. { Blend2D result code. }
  25. TBLResultCode = (
  26. { Successful result code. }
  27. Success = BL_SUCCESS,
  28. { Out of memory [ENOMEM]. }
  29. OutOfMemory = BL_ERROR_OUT_OF_MEMORY,
  30. { Invalid value/argument [EINVAL]. }
  31. InvalidValue = BL_ERROR_INVALID_VALUE,
  32. { Invalid state [EFAULT]. }
  33. InvalidState = BL_ERROR_INVALID_STATE,
  34. { Invalid handle or file. [EBADF]. }
  35. InvalidHandle = BL_ERROR_INVALID_HANDLE,
  36. { Value too large [EOVERFLOW]. }
  37. ValueTooLarge = BL_ERROR_VALUE_TOO_LARGE,
  38. { Not initialized (some instance is built-in none when it shouldn't be). }
  39. NotInitialized = BL_ERROR_NOT_INITIALIZED,
  40. { Not implemented [ENOSYS]. }
  41. NotImplemented = BL_ERROR_NOT_IMPLEMENTED,
  42. { Operation not permitted [EPERM]. }
  43. NotPermitted = BL_ERROR_NOT_PERMITTED,
  44. { IO error [EIO]. }
  45. IOError = BL_ERROR_IO,
  46. { Device or resource busy [EBUSY]. }
  47. Busy = BL_ERROR_BUSY,
  48. { Operation interrupted [EINTR]. }
  49. Interrupted = BL_ERROR_INTERRUPTED,
  50. { Try again [EAGAIN]. }
  51. TryAgain = BL_ERROR_TRY_AGAIN,
  52. { Timed out [ETIMEDOUT]. }
  53. TimedOut = BL_ERROR_TIMED_OUT,
  54. { Broken pipe [EPIPE]. }
  55. BrokenPipe = BL_ERROR_BROKEN_PIPE,
  56. { File is not seekable [ESPIPE]. }
  57. InvalidSeek = BL_ERROR_INVALID_SEEK,
  58. { Too many levels of symlinks [ELOOP]. }
  59. SymlinkLoop = BL_ERROR_SYMLINK_LOOP,
  60. { File is too large [EFBIG]. }
  61. FileTooLarge = BL_ERROR_FILE_TOO_LARGE,
  62. { File/directory already exists [EEXIST]. }
  63. AlreadyExists = BL_ERROR_ALREADY_EXISTS,
  64. { Access denied [EACCES]. }
  65. AccessDenied = BL_ERROR_ACCESS_DENIED,
  66. { Media changed [Windows::ERROR_MEDIA_CHANGED]. }
  67. MediaChanged = BL_ERROR_MEDIA_CHANGED,
  68. { The file/FS is read-only [EROFS]. }
  69. ReadOnlyFS = BL_ERROR_READ_ONLY_FS,
  70. { Device doesn't exist [ENXIO]. }
  71. NoDevice = BL_ERROR_NO_DEVICE,
  72. { Not found, no entry (fs) [ENOENT]. }
  73. NoEntry = BL_ERROR_NO_ENTRY,
  74. { No media in drive/device [ENOMEDIUM]. }
  75. NoMedia = BL_ERROR_NO_MEDIA,
  76. { No more data / end of file [ENODATA]. }
  77. NoMoreData = BL_ERROR_NO_MORE_DATA,
  78. { No more files [ENMFILE]. }
  79. NoMoreFiles = BL_ERROR_NO_MORE_FILES,
  80. { No space left on device [ENOSPC]. }
  81. NoSpaceLeft = BL_ERROR_NO_SPACE_LEFT,
  82. { Directory is not empty [ENOTEMPTY]. }
  83. NotEmpty = BL_ERROR_NOT_EMPTY,
  84. { Not a file [EISDIR]. }
  85. NotFile = BL_ERROR_NOT_FILE,
  86. { Not a directory [ENOTDIR]. }
  87. NotDirectory = BL_ERROR_NOT_DIRECTORY,
  88. { Not same device [EXDEV]. }
  89. NotSameDevice = BL_ERROR_NOT_SAME_DEVICE,
  90. { Not a block device [ENOTBLK]. }
  91. NotBlockDevice = BL_ERROR_NOT_BLOCK_DEVICE,
  92. { File/path name is invalid [n/a]. }
  93. InvalidFilename = BL_ERROR_INVALID_FILE_NAME,
  94. { File/path name is too long [ENAMETOOLONG]. }
  95. FilenameTooLong = BL_ERROR_FILE_NAME_TOO_LONG,
  96. { Too many open files [EMFILE]. }
  97. TooManyOpenFiles = BL_ERROR_TOO_MANY_OPEN_FILES,
  98. { Too many open files by OS [ENFILE]. }
  99. TooManyOpenFilesByOS = BL_ERROR_TOO_MANY_OPEN_FILES_BY_OS,
  100. { Too many symbolic links on FS [EMLINK]. }
  101. TooManyLinks = BL_ERROR_TOO_MANY_LINKS,
  102. { Too many threads [EAGAIN]. }
  103. TooManyThreads = BL_ERROR_TOO_MANY_THREADS,
  104. { Thread pool is exhausted and couldn't acquire the requested thread count. }
  105. ThreadPoolExhausted = BL_ERROR_THREAD_POOL_EXHAUSTED,
  106. { File is empty (not specific to any OS error). }
  107. FileEmpty = BL_ERROR_FILE_EMPTY,
  108. { File open failed [Windows::ERROR_OPEN_FAILED]. }
  109. OpenFailed = BL_ERROR_OPEN_FAILED,
  110. { Not a root device/directory [Windows::ERROR_DIR_NOT_ROOT]. }
  111. NotRootDevice = BL_ERROR_NOT_ROOT_DEVICE,
  112. { Unknown system error that failed to translate to Blend2D result code. }
  113. UnknownSystemError = BL_ERROR_UNKNOWN_SYSTEM_ERROR,
  114. { Invalid data alignment. }
  115. InvalidArgument = BL_ERROR_INVALID_ALIGNMENT,
  116. { Invalid data signature or header. }
  117. InvalidSignature = BL_ERROR_INVALID_SIGNATURE,
  118. { Invalid or corrupted data. }
  119. InvalidData = BL_ERROR_INVALID_DATA,
  120. { Invalid string (invalid data of either UTF8, UTF16, or UTF32). }
  121. InvalidString = BL_ERROR_INVALID_STRING,
  122. { Truncated data (more data required than memory/stream provides). }
  123. DataTruncated = BL_ERROR_DATA_TRUNCATED,
  124. { Input data too large to be processed. }
  125. DataTooLarge = BL_ERROR_DATA_TOO_LARGE,
  126. { Decompression failed due to invalid data (RLE, Huffman, etc). }
  127. DecompressionFailed = BL_ERROR_DECOMPRESSION_FAILED,
  128. { Invalid geometry (invalid path data or shape). }
  129. InvalidGeometry = BL_ERROR_INVALID_GEOMETRY,
  130. { Returned when there is no matching vertex in path data. }
  131. NoMatchingVertex = BL_ERROR_NO_MATCHING_VERTEX,
  132. { No matching cookie (BLContext). }
  133. NoMatchingCookie = BL_ERROR_NO_MATCHING_COOKIE,
  134. { No states to restore (BLContext). }
  135. NoStatesToRestore = BL_ERROR_NO_STATES_TO_RESTORE,
  136. { The size of the image is too large. }
  137. ImageTooBig = BL_ERROR_IMAGE_TOO_LARGE,
  138. { Image codec for a required format doesn't exist. }
  139. ImageNoMatchingCodec = BL_ERROR_IMAGE_NO_MATCHING_CODEC,
  140. { Unknown or invalid file format that cannot be read. }
  141. ImageUnknownFileFormat = BL_ERROR_IMAGE_UNKNOWN_FILE_FORMAT,
  142. { Image codec doesn't support reading the file format. }
  143. ImageDecoderNotProvided = BL_ERROR_IMAGE_DECODER_NOT_PROVIDED,
  144. { Image codec doesn't support writing the file format. }
  145. ImageEncoderNotProvided = BL_ERROR_IMAGE_ENCODER_NOT_PROVIDED,
  146. { Multiple IHDR chunks are not allowed (PNG). }
  147. PngMultipleIHDR = BL_ERROR_PNG_MULTIPLE_IHDR,
  148. { Invalid IDAT chunk (PNG). }
  149. PngInvalidIDAT = BL_ERROR_PNG_INVALID_IDAT,
  150. { Invalid IEND chunk (PNG). }
  151. PngInvalidIEND = BL_ERROR_PNG_INVALID_IEND,
  152. { Invalid PLTE chunk (PNG). }
  153. PngInvalidPLTE = BL_ERROR_PNG_INVALID_PLTE,
  154. { Invalid tRNS chunk (PNG). }
  155. PngInvalidTRNS = BL_ERROR_PNG_INVALID_TRNS,
  156. { Invalid filter type (PNG). }
  157. PngInvalidFilter = BL_ERROR_PNG_INVALID_FILTER,
  158. { Unsupported feature (JPEG). }
  159. JpegUnsupportedFeature = BL_ERROR_JPEG_UNSUPPORTED_FEATURE,
  160. { Invalid SOS marker or header (JPEG). }
  161. JpegInvalidSOS = BL_ERROR_JPEG_INVALID_SOS,
  162. { Invalid SOF marker (JPEG). }
  163. JpegInvalidSOF = BL_ERROR_JPEG_INVALID_SOF,
  164. { Multiple SOF markers (JPEG). }
  165. JpegMultipleSOF = BL_ERROR_JPEG_MULTIPLE_SOF,
  166. { Unsupported SOF marker (JPEG). }
  167. JpegUnsupportedSOF = BL_ERROR_JPEG_UNSUPPORTED_SOF,
  168. { Font doesn't have any data as it's not initialized. }
  169. FontNotInitialized = BL_ERROR_FONT_NOT_INITIALIZED,
  170. { Font or font-face was not matched (BLFontManager). }
  171. FontNoMatch = BL_ERROR_FONT_NO_MATCH,
  172. { Font has no character to glyph mapping data. }
  173. FontNoCharacterMapping = BL_ERROR_FONT_NO_CHARACTER_MAPPING,
  174. { Font has missing an important table. }
  175. FontMissingImportantTable = BL_ERROR_FONT_MISSING_IMPORTANT_TABLE,
  176. { Font feature is not available. }
  177. FontFeatureNotAvailable = BL_ERROR_FONT_FEATURE_NOT_AVAILABLE,
  178. { Font has an invalid CFF data. }
  179. FontCFFInvalidData = BL_ERROR_FONT_CFF_INVALID_DATA,
  180. { Font program terminated because the execution reached the limit. }
  181. FontProgramTerminated = BL_ERROR_FONT_PROGRAM_TERMINATED,
  182. { Invalid glyph identifier. }
  183. InvalidGlyph = BL_ERROR_INVALID_GLYPH);
  184. type
  185. _TBLResultCodeHelper = record helper for TBLResultCode
  186. public
  187. function ToString: String;
  188. end;
  189. { ============================================================================
  190. [Error Handling - Handlers]
  191. ============================================================================ }
  192. type
  193. { Type of exception that is raised for Blend2D errors.
  194. Exceptions are enabled by default, but can be disabled using
  195. BLSetErrorHandler. }
  196. EBlend2DError = class(Exception)
  197. {$REGION 'Internal Declarations'}
  198. private
  199. FResultCode: TBLResultCode;
  200. {$ENDREGION 'Internal Declarations'}
  201. public
  202. constructor Create(const AResultCode: TBLResultCode);
  203. { The Blend2D result code }
  204. property ResultCode: TBLResultCode read FResultCode;
  205. end;
  206. type
  207. { Type of procedure that is called when a Blend2D error occurs.
  208. Parameters:
  209. AResultCode: the Blend2D result code
  210. AUserData: any user data passed to BLSetErrorHandler. }
  211. TBLErrorHandler = procedure(const AResultCode: TBLResultCode;
  212. const AUserData: Pointer);
  213. { Sets a Blend2D error handler.
  214. Parameters:
  215. AHandler: the error handler that is called when a Blend2D error occurs.
  216. AUserData: any data you want to pass to the handler.
  217. The default error handler raises an exception of type EBlend2DError.
  218. You can disable error handling completely by setting AHandler to nil. In that
  219. case, there is no way to know if and when an error occured.
  220. The following procedures can be used to set some default error handlers:
  221. * BLSetExceptionErrorHandler: sets the error handler to a procedure that
  222. raises an exception when a Blend2D error occurs. This is the default
  223. behavior.
  224. * BLSetGetLastErrorHandler: sets the error handler to a procedure that sets
  225. a global error variable when a Blend2D error occurs. You can then use
  226. BLGetLastError to retrieve this error code. }
  227. procedure BLSetErrorHandler(const AHandler: TBLErrorHandler;
  228. const AUserData: Pointer);
  229. { Sets the error handler to a procedure that raises an exception when a Blend2D
  230. error occurs. This is the default behavior. }
  231. procedure BLSetExceptionErrorHandler;
  232. { Sets the error handler to a procedure that sets a global error variable when a
  233. Blend2D error occurs. You can then use BLGetLastError to retrieve this error
  234. code. }
  235. procedure BLSetGetLastErrorHandler;
  236. { Retrieves the last Blend2D error, or TBLResultCode.Success if there was
  237. none.
  238. After this call, the last error is reset to TBLResultCode.Success.
  239. This function should only be used when BLSetGetLastErrorHandler has been
  240. called. Otherwise, it always returns TBLResultCode.Success.
  241. This function is not thread-safe. If Blend2D is used from multiple threads,
  242. the returned value can be from any thread. }
  243. function BLGetLastError: TBLResultCode;
  244. {$ENDREGION 'Error Handling'}
  245. {$REGION 'General'}
  246. { ============================================================================
  247. [General - Types]
  248. ============================================================================ }
  249. type
  250. { Tag is a 32-bit integer consisting of 4 characters in the following format:
  251. Tag := (A shl 24) or (B shl 16) or (C shl 8) or D
  252. Tags are used extensively by OpenType fonts and other binary formats like
  253. PNG. In most cases TAGs should only contain ASCII letters, digits, and
  254. spaces.
  255. Blend2D uses TBLTag in public and internal APIs to distinguish between a
  256. regular UInt32 and tag. }
  257. TBLTag = BLTag;
  258. type
  259. { Unique identifier that can be used for caching purposes.
  260. Some objects such as IBLImage and IBLFontFace have assigned an unique
  261. identifier that can be used to identify such objects for caching purposes.
  262. This identifier is never zero, so zero can be safely used as "uncached".
  263. Note: Unique identifier is per-process. It's implemented as an increasing
  264. global or thread-local counter in a way that identifiers would not
  265. collide. }
  266. TBLUniqueId = BLUniqueId;
  267. type
  268. { A type used to store a pack of bits.
  269. BitWord should be equal in size to a machine word. }
  270. TBLBitWord = BLBitWord;
  271. { ============================================================================
  272. [General - Enums]
  273. ============================================================================ }
  274. type
  275. { Boolean operator. }
  276. TBLBooleanOp = (
  277. { Result = B. }
  278. Copy = BL_BOOLEAN_OP_COPY,
  279. { Result = A and B. }
  280. &And = BL_BOOLEAN_OP_AND,
  281. { Result = A or B. }
  282. &Or = BL_BOOLEAN_OP_OR,
  283. { Result = A xor B. }
  284. &Xor = BL_BOOLEAN_OP_XOR,
  285. { Result = A and not B. }
  286. Sub = BL_BOOLEAN_OP_SUB);
  287. type
  288. { Extend mode. }
  289. TBLExtendMode = (
  290. { Pad extend [default]. }
  291. Pad = BL_EXTEND_MODE_PAD,
  292. { Repeat extend. }
  293. &Repeat = BL_EXTEND_MODE_REPEAT,
  294. { Reflect extend. }
  295. Reflect = BL_EXTEND_MODE_REFLECT,
  296. { Alias to Pad. }
  297. PadXPadY = BL_EXTEND_MODE_PAD_X_PAD_Y,
  298. { Alias to Repeat. }
  299. RepeatXRepeatY = BL_EXTEND_MODE_REPEAT_X_REPEAT_Y,
  300. { Alias to Reflect. }
  301. ReflectXReflectY = BL_EXTEND_MODE_REFLECT_X_REFLECT_Y,
  302. { Pad X and repeat Y. }
  303. PadXRepeatY = BL_EXTEND_MODE_PAD_X_REPEAT_Y,
  304. { Pad X and reflect Y. }
  305. PadXReflectY = BL_EXTEND_MODE_PAD_X_REFLECT_Y,
  306. { Repeat X and pad Y. }
  307. RepeatXPadY = BL_EXTEND_MODE_REPEAT_X_PAD_Y,
  308. { Repeat X and reflect Y. }
  309. RepeatXReflectY = BL_EXTEND_MODE_REPEAT_X_REFLECT_Y,
  310. { Reflect X and pad Y. }
  311. ReflectXPadY = BL_EXTEND_MODE_REFLECT_X_PAD_Y,
  312. { Reflect X and repeat Y. }
  313. ReflectXRepeatY = BL_EXTEND_MODE_REFLECT_X_REPEAT_Y);
  314. type
  315. { Text encoding. }
  316. TBLTextEncoding = (
  317. { UTF-8 encoding. }
  318. UTF8 = BL_TEXT_ENCODING_UTF8,
  319. { UTF-16 encoding (native endian). }
  320. UTF16 = BL_TEXT_ENCODING_UTF16,
  321. { UTF-32 encoding (native endian). }
  322. UTF32 = BL_TEXT_ENCODING_UTF32,
  323. { LATIN1 encoding (one byte per character). }
  324. Latin1 = BL_TEXT_ENCODING_LATIN1);
  325. { ============================================================================
  326. [BLRange]
  327. ============================================================================ }
  328. type
  329. { Provides start and end indexes. It's used to specify a range of an operation
  330. related to indexed containers like IBLPath, IBLGradient, etc... }
  331. TBLRange = record
  332. {$REGION 'Internal Declarations'}
  333. private
  334. FHandle: BLRange;
  335. function GetFinish: Integer; inline;
  336. function GetStart: Integer; inline;
  337. procedure SetFinish(const AValue: Integer); inline;
  338. procedure SetStart(const AValue: Integer); inline;
  339. {$ENDREGION 'Internal Declarations'}
  340. public
  341. class operator Equal(const ALeft, ARight: TBLRange): Boolean; inline; static;
  342. class operator NotEqual(const ALeft, ARight: TBLRange): Boolean; inline; static;
  343. public
  344. procedure Reset; overload; inline;
  345. procedure Reset(const AStart, AFinish: Integer); overload; inline;
  346. function Equals(const AOther: TBLRange): Boolean; inline;
  347. property Start: Integer read GetStart write SetStart;
  348. property Finish: Integer read GetFinish write SetFinish;
  349. end;
  350. PBLRange = ^TBLRange;
  351. function BLRange(const AStart, AFinish: Integer): TBLRange; inline;
  352. {$ENDREGION 'General'}
  353. {$REGION 'Array'}
  354. { ============================================================================
  355. [BLArrayView]
  356. ============================================================================ }
  357. type
  358. { Array view }
  359. TBLArrayView<T> = record
  360. public type
  361. P = ^T;
  362. {$REGION 'Internal Declarations'}
  363. private
  364. FHandle: BLArrayView;
  365. function GetLast: Pointer; inline;
  366. function GetLength: Integer; inline;
  367. {$ENDREGION 'Internal Declarations'}
  368. public
  369. procedure Reset; overload; inline;
  370. procedure Reset(const AData: Pointer; const ALength: Integer); overload; inline;
  371. property Data: Pointer read FHandle.data;
  372. property First: Pointer read FHandle.data;
  373. property Last: Pointer read GetLast;
  374. property Length: Integer read GetLength;
  375. end;
  376. {$ENDREGION 'Array'}
  377. {$REGION 'Color'}
  378. { ============================================================================
  379. [BLRgba32]
  380. ============================================================================ }
  381. type
  382. { 32-bit RGBA color (8-bit per component) stored as $AARRGGBB. }
  383. TBLRgba32 = record
  384. {$REGION 'Internal Declarations'}
  385. private
  386. FHandle: BLRgba32;
  387. function GetIsOpaque: Boolean; inline;
  388. function GetIsTransparent: Boolean; inline;
  389. {$ENDREGION 'Internal Declarations'}
  390. public
  391. class operator Implicit(const AValue: Cardinal): TBLRgba32; inline; static;
  392. class operator Implicit(const AValue: TBLRgba32): Cardinal; inline; static;
  393. class operator Equal(const ALeft, ARight: TBLRgba32): Boolean; inline; static;
  394. class operator NotEqual(const ALeft, ARight: TBLRgba32): Boolean; inline; static;
  395. public
  396. procedure Reset; overload; inline;
  397. procedure Reset(const AValue: Cardinal); overload; inline;
  398. procedure Reset(const AR, AG, AB: Byte; const AA: Byte = 255); overload; inline;
  399. property R: Byte read FHandle.r write FHandle.r;
  400. property G: Byte read FHandle.g write FHandle.g;
  401. property B: Byte read FHandle.b write FHandle.b;
  402. property A: Byte read FHandle.a write FHandle.a;
  403. property Value: Cardinal read FHandle.value write FHandle.value;
  404. property IsOpaque: Boolean read GetIsOpaque;
  405. property IsTransparent: Boolean read GetIsTransparent;
  406. end;
  407. PBLRgba32 = ^TBLRgba32;
  408. function BLRgba32: TBLRgba32; overload; inline;
  409. function BLRgba32(const AValue: Cardinal): TBLRgba32; overload; inline;
  410. function BLRgba32(const AR, AG, AB: Byte; const AA: Byte = 255): TBLRgba32; overload; inline;
  411. { ============================================================================
  412. [BLRgba64]
  413. ============================================================================ }
  414. type
  415. { 64-bit RGBA color (16-bit per component) stored as $AAAARRRRGGGGBBBB. }
  416. TBLRgba64 = record
  417. {$REGION 'Internal Declarations'}
  418. private
  419. FHandle: BLRgba64;
  420. function GetIsOpaque: Boolean; inline;
  421. function GetIsTransparent: Boolean; inline;
  422. {$ENDREGION 'Internal Declarations'}
  423. public
  424. class operator Implicit(const AValue: UInt64): TBLRgba64; inline; static;
  425. class operator Implicit(const AValue: TBLRgba64): UInt64; inline; static;
  426. class operator Equal(const ALeft, ARight: TBLRgba64): Boolean; inline; static;
  427. class operator NotEqual(const ALeft, ARight: TBLRgba64): Boolean; inline; static;
  428. public
  429. procedure Reset; overload; inline;
  430. procedure Reset(const AValue: UInt64); overload; inline;
  431. procedure Reset(const AR, AG, AB: Word; const AA: Word = $FFFF); overload; inline;
  432. procedure Reset(const AValue: TBLRgba32); overload; inline;
  433. property R: Word read FHandle.r write FHandle.r;
  434. property G: Word read FHandle.g write FHandle.g;
  435. property B: Word read FHandle.b write FHandle.b;
  436. property A: Word read FHandle.a write FHandle.a;
  437. property Value: UInt64 read FHandle.value write FHandle.value;
  438. property IsOpaque: Boolean read GetIsOpaque;
  439. property IsTransparent: Boolean read GetIsTransparent;
  440. end;
  441. PBLRgba64 = ^TBLRgba64;
  442. function BLRgba64: TBLRgba64; overload; inline;
  443. function BLRgba64(const AValue: UInt64): TBLRgba64; overload; inline;
  444. function BLRgba64(const AR, AG, AB: Word; const AA: Word = $FFFF): TBLRgba64; overload; inline;
  445. function BLRgba64(const AValue: TBLRgba32): TBLRgba64; overload; inline;
  446. { ============================================================================
  447. [BLRgba]
  448. ============================================================================ }
  449. type
  450. { 128-bit RGBA color stored as 4 32-bit floating point values in [RGBA] order. }
  451. TBLRgba = record
  452. {$REGION 'Internal Declarations'}
  453. private
  454. FHandle: BLRgba;
  455. function GetIsOpaque: Boolean; inline;
  456. function GetIsTransparent: Boolean; inline;
  457. {$ENDREGION 'Internal Declarations'}
  458. public
  459. class operator Equal(const ALeft, ARight: TBLRgba): Boolean; inline; static;
  460. class operator Equal(const ALeft: TBLRgba; const ARight: TBLRgba32): Boolean; inline; static;
  461. class operator Equal(const ALeft: TBLRgba; const ARight: TBLRgba64): Boolean; inline; static;
  462. class operator NotEqual(const ALeft, ARight: TBLRgba): Boolean; inline; static;
  463. class operator NotEqual(const ALeft: TBLRgba; const ARight: TBLRgba32): Boolean; inline; static;
  464. class operator NotEqual(const ALeft: TBLRgba; const ARight: TBLRgba64): Boolean; inline; static;
  465. public
  466. procedure Reset; overload; inline;
  467. procedure Reset(const AR, AG, AB: Single; const AA: Single = 1); overload; inline;
  468. procedure Reset(const ARgba: TBLRgba32); overload; inline;
  469. procedure Reset(const ARgba: TBLRgba64); overload; inline;
  470. property R: Single read FHandle.r write FHandle.r;
  471. property G: Single read FHandle.g write FHandle.g;
  472. property B: Single read FHandle.b write FHandle.b;
  473. property A: Single read FHandle.a write FHandle.a;
  474. property IsOpaque: Boolean read GetIsOpaque;
  475. property IsTransparent: Boolean read GetIsTransparent;
  476. end;
  477. PBLRgba = ^TBLRgba;
  478. function BLRgba: TBLRgba; overload; inline;
  479. function BLRgba(const AR, AG, AB: Single; const AA: Single = 1): TBLRgba; overload; inline;
  480. function BLRgba(const ARgba: TBLRgba32): TBLRgba; overload; inline;
  481. function BLRgba(const ARgba: TBLRgba64): TBLRgba; overload; inline;
  482. type
  483. { Adds TBLRgba32 <-> TBLRgba64 <-> TBLRgba conversion }
  484. _TBLRgba32Helper = record helper for TBLRgba32
  485. public
  486. procedure Reset(const AValue: TBLRgba64); overload; inline;
  487. procedure Reset(const AValue: TBLRgba); overload; inline;
  488. end;
  489. function BLRgba32(const AValue: TBLRgba64): TBLRgba32; overload; inline;
  490. function BLRgba32(const AValue: TBLRgba): TBLRgba32; overload; inline;
  491. type
  492. { Adds TBLRgba64 <-> TBLRgba conversion }
  493. _TBLRgba64Helper = record helper for TBLRgba64
  494. public
  495. procedure Reset(const AValue: TBLRgba); overload; inline;
  496. end;
  497. function BLRgba64(const AValue: TBLRgba): TBLRgba32; overload; inline;
  498. {$ENDREGION 'Color'}
  499. {$REGION 'File System'}
  500. { ============================================================================
  501. [Enums]
  502. ============================================================================ }
  503. type
  504. { File read flags used by IBLFileSystem.ReadFile. }
  505. TBLFileReadFlag = (
  506. { Use memory mapping to read the content of the file.
  507. The destination buffer would be configured to use the memory mapped buffer
  508. instead of allocating its own. }
  509. MmapEnabled = 0,
  510. { Avoid memory mapping of small files.
  511. The size of small file is determined by Blend2D, however, you should
  512. expect it to be 16kB or 64kB depending on host operating system. }
  513. MmapAvoidSmall = 1,
  514. { Do not fallback to regular read if memory mapping fails. It's worth noting
  515. that memory mapping would fail for files stored on filesystem that is not
  516. local (like a mounted network filesystem, etc...). }
  517. MmapNoFallback = 3);
  518. TBLFileReadFlags = set of TBLFileReadFlag;
  519. {$ENDREGION 'File System'}
  520. {$REGION 'Geometry'}
  521. { ============================================================================
  522. [Enums]
  523. ============================================================================ }
  524. type
  525. { Direction of a geometry used by geometric primitives and paths. }
  526. TBLGeometryDirection = (
  527. { No direction specified. }
  528. None = BL_GEOMETRY_DIRECTION_NONE,
  529. { Clockwise direction. }
  530. CW = BL_GEOMETRY_DIRECTION_CW,
  531. { Counter-clockwise direction. }
  532. CCW = BL_GEOMETRY_DIRECTION_CCW);
  533. type
  534. { Geometry type.
  535. Geometry describes a shape or path that can be either rendered or added to
  536. a BLPath container. Both IBLPath and IBLContext provide functionality to
  537. work with all geometry types. Please note that each type provided here
  538. requires to pass a matching record to the function that consumes
  539. AGeometryType and AGeometryData arguments. }
  540. TBLGeometryType = (
  541. { No geometry provided. }
  542. None = BL_GEOMETRY_TYPE_NONE,
  543. { TBLBoxI record. }
  544. BoxI = BL_GEOMETRY_TYPE_BOXI,
  545. { TBLBox record. }
  546. BoxD = BL_GEOMETRY_TYPE_BOXD,
  547. { TBLRectI record. }
  548. RectI = BL_GEOMETRY_TYPE_RECTI,
  549. { TBLRect record. }
  550. RectD = BL_GEOMETRY_TYPE_RECTD,
  551. { TBLCircle record. }
  552. Circle = BL_GEOMETRY_TYPE_CIRCLE,
  553. { TBLEllipse record. }
  554. Ellipse = BL_GEOMETRY_TYPE_ELLIPSE,
  555. { TBLRoundRect record. }
  556. RoundRect = BL_GEOMETRY_TYPE_ROUND_RECT,
  557. { TBLArc record. }
  558. Arc = BL_GEOMETRY_TYPE_ARC,
  559. { TBLArc record representing chord. }
  560. Chord = BL_GEOMETRY_TYPE_CHORD,
  561. { TBLArc record representing pie. }
  562. Pie = BL_GEOMETRY_TYPE_PIE,
  563. { TBLLine record. }
  564. Line = BL_GEOMETRY_TYPE_LINE,
  565. { TBLTriangle record. }
  566. Triangle = BL_GEOMETRY_TYPE_TRIANGLE,
  567. { TBLArrayView<TBLPointI> representing a polyline. }
  568. PolylineI = BL_GEOMETRY_TYPE_POLYLINEI,
  569. { TBLArrayView<TBLPoint> representing a polyline. }
  570. PolylineD = BL_GEOMETRY_TYPE_POLYLINED,
  571. { TBLArrayView<TBLPointI> representing a polygon. }
  572. PolygonI = BL_GEOMETRY_TYPE_POLYGONI,
  573. { TBLArrayView<TBLPoint> representing a polygon. }
  574. PolygonD = BL_GEOMETRY_TYPE_POLYGOND,
  575. { TBLArrayView<TBLBoxI> record. }
  576. ArrayViewBoxI = BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXI,
  577. { TBLArrayView<TBLBox> struct. }
  578. ArrayViewBoxD = BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXD,
  579. { TBLArrayView<TBLRectI> record. }
  580. ArrayviewRectI = BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTI,
  581. { TBLArrayView<TBLRect> record. }
  582. ArrayViewRectD = BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTD,
  583. { IBLPath. }
  584. Path = BL_GEOMETRY_TYPE_PATH,
  585. { IBLRegion. }
  586. Region = BL_GEOMETRY_TYPE_REGION,
  587. { The last simple type. }
  588. SimpleLast = TBLGeometryType.Triangle);
  589. type
  590. { Fill rule. }
  591. TBLFillRule = (
  592. { Non-zero fill-rule. }
  593. NonZero = BL_FILL_RULE_NON_ZERO,
  594. { Even-odd fill-rule. }
  595. EvenOdd = BL_FILL_RULE_EVEN_ODD);
  596. type
  597. { Hit-test result. }
  598. TBLHitTest = (
  599. { Fully in. }
  600. FullyIn = BL_HIT_TEST_IN,
  601. { Partially in/out. }
  602. PartiallyIn = BL_HIT_TEST_PART,
  603. { Fully out. }
  604. FullyOut = BL_HIT_TEST_OUT,
  605. { Hit test failed (invalid argument, NaNs, etc). }
  606. Invalid = BL_HIT_TEST_INVALID);
  607. { ============================================================================
  608. [BLPointI]
  609. ============================================================================ }
  610. type
  611. { Point specified as [x, y] using Integer as a storage type. }
  612. TBLPointI = record
  613. {$REGION 'Internal Declarations'}
  614. private
  615. FHandle: BLPointI;
  616. {$ENDREGION 'Internal Declarations'}
  617. public
  618. class operator Equal(const ALeft, ARight: TBLPointI): Boolean; inline; static;
  619. class operator NotEqual(const ALeft, ARight: TBLPointI): Boolean; inline; static;
  620. class operator Negative(const AValue: TBLPointI): TBLPointI; inline; static;
  621. class operator Add(const ALeft: TBLPointI; const ARight: Integer): TBLPointI; inline; static;
  622. class operator Add(const ALeft: Integer; const ARight: TBLPointI): TBLPointI; inline; static;
  623. class operator Add(const ALeft, ARight: TBLPointI): TBLPointI; inline; static;
  624. class operator Subtract(const ALeft: TBLPointI; const ARight: Integer): TBLPointI; inline; static;
  625. class operator Subtract(const ALeft: Integer; const ARight: TBLPointI): TBLPointI; inline; static;
  626. class operator Subtract(const ALeft, ARight: TBLPointI): TBLPointI; inline; static;
  627. class operator Multiply(const ALeft: TBLPointI; const ARight: Integer): TBLPointI; inline; static;
  628. class operator Multiply(const ALeft: Integer; const ARight: TBLPointI): TBLPointI; inline; static;
  629. class operator Multiply(const ALeft, ARight: TBLPointI): TBLPointI; inline; static;
  630. class operator IntDivide(const ALeft: TBLPointI; const ARight: Integer): TBLPointI; inline; static;
  631. class operator IntDivide(const ALeft: Integer; const ARight: TBLPointI): TBLPointI; inline; static;
  632. class operator IntDivide(const ALeft, ARight: TBLPointI): TBLPointI; inline; static;
  633. public
  634. procedure Reset; overload; inline;
  635. procedure Reset(const AX, AY: Integer); overload; inline;
  636. function Equals(const AOther: TBLPointI): Boolean; inline;
  637. property X: Integer read FHandle.x write FHandle.x;
  638. property Y: Integer read FHandle.y write FHandle.y;
  639. end;
  640. PBLPointI = ^TBLPointI;
  641. function BLPointI: TBLPointI; overload; inline;
  642. function BLPointI(const AX, AY: Integer): TBLPointI; overload; inline;
  643. { ============================================================================
  644. [SizeI]
  645. ============================================================================ }
  646. type
  647. { Size specified as [w, h] using Integer as a storage type. }
  648. TBLSizeI = record
  649. {$REGION 'Internal Declarations'}
  650. private
  651. FHandle: BLSizeI;
  652. {$ENDREGION 'Internal Declarations'}
  653. public
  654. class operator Equal(const ALeft, ARight: TBLSizeI): Boolean; inline; static;
  655. class operator NotEqual(const ALeft, ARight: TBLSizeI): Boolean; inline; static;
  656. public
  657. procedure Reset; overload; inline;
  658. procedure Reset(const AW, AH: Integer); overload; inline;
  659. function Equals(const AOther: TBLSizeI): Boolean; inline;
  660. property W: Integer read FHandle.w write FHandle.w;
  661. property H: Integer read FHandle.h write FHandle.h;
  662. end;
  663. PBLSizeI = ^TBLSizeI;
  664. function BLSizeI: TBLSizeI; overload; inline;
  665. function BLSizeI(const AW, AH: Integer): TBLSizeI; overload; inline;
  666. { ============================================================================
  667. [BLBoxI]
  668. ============================================================================ }
  669. type
  670. { Box specified as [x0, y0, x1, y1] using Integer as a storage type. }
  671. TBLBoxI = record
  672. {$REGION 'Internal Declarations'}
  673. private
  674. FHandle: BLBoxI;
  675. function GetHeight: Integer; inline;
  676. function GetWidth: Integer; inline;
  677. procedure SetHeight(const AValue: Integer); inline;
  678. procedure SetWidth(const AValue: Integer); inline;
  679. {$ENDREGION 'Internal Declarations'}
  680. public
  681. class operator Equal(const ALeft, ARight: TBLBoxI): Boolean; inline; static;
  682. class operator NotEqual(const ALeft, ARight: TBLBoxI): Boolean; inline; static;
  683. public
  684. procedure Reset; overload; inline;
  685. procedure Reset(const AX0, AY0, AX1, AY1: Integer); overload; inline;
  686. function Equals(const AOther: TBLBoxI): Boolean; inline;
  687. function Contains(const AX, AY: Integer): Boolean; overload; inline;
  688. function Contains(const AP: TBLPointI): Boolean; overload; inline;
  689. property X0: Integer read FHandle.x0 write FHandle.x0;
  690. property Y0: Integer read FHandle.y0 write FHandle.y0;
  691. property X1: Integer read FHandle.x1 write FHandle.x1;
  692. property Y1: Integer read FHandle.y1 write FHandle.y1;
  693. property Width: Integer read GetWidth write SetWidth;
  694. property Height: Integer read GetHeight write SetHeight;
  695. end;
  696. PBLBoxI = ^TBLBoxI;
  697. function BLBoxI: TBLBoxI; overload; inline;
  698. function BLBoxI(const AX0, AY0, AX1, AY1: Integer): TBLBoxI; overload; inline;
  699. { ============================================================================
  700. [BLRectI]
  701. ============================================================================ }
  702. type
  703. { Rectangle specified as [x, y, w, h] using Integer as a storage type. }
  704. TBLRectI = record
  705. {$REGION 'Internal Declarations'}
  706. private
  707. FHandle: BLRectI;
  708. {$ENDREGION 'Internal Declarations'}
  709. public
  710. class operator Equal(const ALeft, ARight: TBLRectI): Boolean; inline; static;
  711. class operator NotEqual(const ALeft, ARight: TBLRectI): Boolean; inline; static;
  712. public
  713. procedure Reset; overload; inline;
  714. procedure Reset(const AX, AY, AW, AH: Integer); overload; inline;
  715. function Equals(const AOther: TBLRectI): Boolean; inline;
  716. property X: Integer read FHandle.x write FHandle.x;
  717. property Y: Integer read FHandle.y write FHandle.y;
  718. property W: Integer read FHandle.w write FHandle.w;
  719. property H: Integer read FHandle.h write FHandle.h;
  720. end;
  721. PBLRectI = ^TBLRectI;
  722. function BLRectI: TBLRectI; overload; inline;
  723. function BLRectI(const AX, AY, AW, AH: Integer): TBLRectI; overload; inline;
  724. { ============================================================================
  725. [BLPoint]
  726. ============================================================================ }
  727. type
  728. { Point specified as [x, y] using Double as a storage type. }
  729. TBLPoint = record
  730. {$REGION 'Internal Declarations'}
  731. private
  732. FHandle: BLPoint;
  733. {$ENDREGION 'Internal Declarations'}
  734. public
  735. class operator Equal(const ALeft, ARight: TBLPoint): Boolean; inline; static;
  736. class operator NotEqual(const ALeft, ARight: TBLPoint): Boolean; inline; static;
  737. class operator Negative(const AValue: TBLPoint): TBLPoint; inline; static;
  738. class operator Add(const ALeft: TBLPoint; const ARight: Double): TBLPoint; inline; static;
  739. class operator Add(const ALeft: Double; const ARight: TBLPoint): TBLPoint; inline; static;
  740. class operator Add(const ALeft, ARight: TBLPoint): TBLPoint; inline; static;
  741. class operator Subtract(const ALeft: TBLPoint; const ARight: Double): TBLPoint; inline; static;
  742. class operator Subtract(const ALeft: Double; const ARight: TBLPoint): TBLPoint; inline; static;
  743. class operator Subtract(const ALeft, ARight: TBLPoint): TBLPoint; inline; static;
  744. class operator Multiply(const ALeft: TBLPoint; const ARight: Double): TBLPoint; inline; static;
  745. class operator Multiply(const ALeft: Double; const ARight: TBLPoint): TBLPoint; inline; static;
  746. class operator Multiply(const ALeft, ARight: TBLPoint): TBLPoint; inline; static;
  747. class operator Divide(const ALeft: TBLPoint; const ARight: Double): TBLPoint; inline; static;
  748. class operator Divide(const ALeft: Double; const ARight: TBLPoint): TBLPoint; inline; static;
  749. class operator Divide(const ALeft, ARight: TBLPoint): TBLPoint; inline; static;
  750. public
  751. procedure Reset; overload; inline;
  752. procedure Reset(const AX, AY: Double); overload; inline;
  753. function Equals(const AOther: TBLPoint): Boolean; inline;
  754. property X: Double read FHandle.x write FHandle.x;
  755. property Y: Double read FHandle.y write FHandle.y;
  756. end;
  757. PBLPoint = ^TBLPoint;
  758. function BLPoint: TBLPoint; overload; inline;
  759. function BLPoint(const AX, AY: Double): TBLPoint; overload; inline;
  760. { ============================================================================
  761. [Size]
  762. ============================================================================ }
  763. type
  764. { Size specified as [w, h] using Double as a storage type. }
  765. TBLSize = record
  766. {$REGION 'Internal Declarations'}
  767. private
  768. FHandle: BLSize;
  769. {$ENDREGION 'Internal Declarations'}
  770. public
  771. class operator Equal(const ALeft, ARight: TBLSize): Boolean; inline; static;
  772. class operator NotEqual(const ALeft, ARight: TBLSize): Boolean; inline; static;
  773. public
  774. procedure Reset; overload; inline;
  775. procedure Reset(const AW, AH: Double); overload; inline;
  776. function Equals(const AOther: TBLSize): Boolean; inline;
  777. property W: Double read FHandle.w write FHandle.w;
  778. property H: Double read FHandle.h write FHandle.h;
  779. end;
  780. PBLSize = ^TBLSize;
  781. function BLSize: TBLSize; overload; inline;
  782. function BLSize(const AW, AH: Double): TBLSize; overload; inline;
  783. { ============================================================================
  784. [BLBox]
  785. ============================================================================ }
  786. type
  787. { Box specified as [x0, y0, x1, y1] using Double as a storage type. }
  788. TBLBox = record
  789. {$REGION 'Internal Declarations'}
  790. private
  791. FHandle: BLBox;
  792. function GetWidth: Double; inline;
  793. procedure SetWidth(const AValue: Double); inline;
  794. function GetHeight: Double; inline;
  795. procedure SetHeight(const AValue: Double); inline;
  796. {$ENDREGION 'Internal Declarations'}
  797. public
  798. class operator Equal(const ALeft, ARight: TBLBox): Boolean; inline; static;
  799. class operator NotEqual(const ALeft, ARight: TBLBox): Boolean; inline; static;
  800. class operator Add(const ALeft: TBLBox; const ARight: Double): TBLBox; inline; static;
  801. class operator Add(const ALeft: Double; const ARight: TBLBox): TBLBox; inline; static;
  802. class operator Add(const ALeft: TBLBox; const ARight: TBLPoint): TBLBox; inline; static;
  803. class operator Add(const ALeft: TBLPoint; const ARight: TBLBox): TBLBox; inline; static;
  804. class operator Subtract(const ALeft: TBLBox; const ARight: Double): TBLBox; inline; static;
  805. class operator Subtract(const ALeft: Double; const ARight: TBLBox): TBLBox; inline; static;
  806. class operator Subtract(const ALeft: TBLBox; const ARight: TBLPoint): TBLBox; inline; static;
  807. class operator Subtract(const ALeft: TBLPoint; const ARight: TBLBox): TBLBox; inline; static;
  808. class operator Multiply(const ALeft: TBLBox; const ARight: Double): TBLBox; inline; static;
  809. class operator Multiply(const ALeft: Double; const ARight: TBLBox): TBLBox; inline; static;
  810. class operator Multiply(const ALeft: TBLBox; const ARight: TBLPoint): TBLBox; inline; static;
  811. class operator Multiply(const ALeft: TBLPoint; const ARight: TBLBox): TBLBox; inline; static;
  812. class operator Divide(const ALeft: TBLBox; const ARight: Double): TBLBox; inline; static;
  813. class operator Divide(const ALeft: Double; const ARight: TBLBox): TBLBox; inline; static;
  814. class operator Divide(const ALeft: TBLBox; const ARight: TBLPoint): TBLBox; inline; static;
  815. class operator Divide(const ALeft: TBLPoint; const ARight: TBLBox): TBLBox; inline; static;
  816. public
  817. procedure Reset; overload; inline;
  818. procedure Reset(const AX0, AY0, AX1, AY1: Double); overload; inline;
  819. function Equals(const AOther: TBLBox): Boolean; inline;
  820. function Contains(const AX, AY: Double): Boolean; overload; inline;
  821. function Contains(const AP: TBLPoint): Boolean; overload; inline;
  822. property X0: Double read FHandle.x0 write FHandle.x0;
  823. property Y0: Double read FHandle.y0 write FHandle.y0;
  824. property X1: Double read FHandle.x1 write FHandle.x1;
  825. property Y1: Double read FHandle.y1 write FHandle.y1;
  826. property Width: Double read GetWidth write SetWidth;
  827. property Height: Double read GetHeight write SetHeight;
  828. end;
  829. PBLBox = ^TBLBox;
  830. function BLBox: TBLBox; overload; inline;
  831. function BLBox(const AX0, AY0, AX1, AY1: Double): TBLBox; overload; inline;
  832. { ============================================================================
  833. [BLRect]
  834. ============================================================================ }
  835. type
  836. { Rectangle specified as [x, y, w, h] using Double as a storage type. }
  837. TBLRect = record
  838. {$REGION 'Internal Declarations'}
  839. private
  840. FHandle: BLRect;
  841. {$ENDREGION 'Internal Declarations'}
  842. public
  843. class operator Equal(const ALeft, ARight: TBLRect): Boolean; inline; static;
  844. class operator NotEqual(const ALeft, ARight: TBLRect): Boolean; inline; static;
  845. public
  846. procedure Reset; overload; inline;
  847. procedure Reset(const AX, AY, AW, AH: Double); overload; inline;
  848. function Equals(const AOther: TBLRect): Boolean; inline;
  849. property X: Double read FHandle.x write FHandle.x;
  850. property Y: Double read FHandle.y write FHandle.y;
  851. property W: Double read FHandle.w write FHandle.w;
  852. property H: Double read FHandle.h write FHandle.h;
  853. end;
  854. PBLRect = ^TBLRect;
  855. function BLRect: TBLRect; overload; inline;
  856. function BLRect(const AX, AY, AW, AH: Double): TBLRect; overload; inline;
  857. { ============================================================================
  858. [BLLine]
  859. ============================================================================ }
  860. type
  861. { Line specified as [x0, y0, x1, y1] using Double as a storage type. }
  862. TBLLine = record
  863. {$REGION 'Internal Declarations'}
  864. private
  865. FHandle: BLLine;
  866. {$ENDREGION 'Internal Declarations'}
  867. public
  868. class operator Equal(const ALeft, ARight: TBLLine): Boolean; inline; static;
  869. class operator NotEqual(const ALeft, ARight: TBLLine): Boolean; inline; static;
  870. public
  871. procedure Reset; overload; inline;
  872. procedure Reset(const AX0, AY0, AX1, AY1: Double); overload; inline;
  873. procedure Reset(const AP0, AP1: TBLPoint); overload; inline;
  874. function Equals(const AOther: TBLLine): Boolean; inline;
  875. property X0: Double read FHandle.x0 write FHandle.x0;
  876. property Y0: Double read FHandle.y0 write FHandle.y0;
  877. property X1: Double read FHandle.x1 write FHandle.x1;
  878. property Y1: Double read FHandle.y1 write FHandle.y1;
  879. end;
  880. PBLLine = ^TBLLine;
  881. function BLLine: TBLLine; overload; inline;
  882. function BLLine(const AX0, AY0, AX1, AY1: Double): TBLLine; overload; inline;
  883. function BLLine(const AP0, AP1: TBLPoint): TBLLine; overload; inline;
  884. { ============================================================================
  885. [BLTriangle]
  886. ============================================================================ }
  887. type
  888. { Triangle data specified as [x0, y0, x1, y1, x2, y2] using Double as a
  889. storage type.}
  890. TBLTriangle = record
  891. {$REGION 'Internal Declarations'}
  892. private
  893. FHandle: BLTriangle;
  894. {$ENDREGION 'Internal Declarations'}
  895. public
  896. class operator Equal(const ALeft, ARight: TBLTriangle): Boolean; inline; static;
  897. class operator NotEqual(const ALeft, ARight: TBLTriangle): Boolean; inline; static;
  898. public
  899. procedure Reset; overload; inline;
  900. procedure Reset(const AX0, AY0, AX1, AY1, AX2, AY2: Double); overload; inline;
  901. function Equals(const AOther: TBLTriangle): Boolean; inline;
  902. property X0: Double read FHandle.x0 write FHandle.x0;
  903. property Y0: Double read FHandle.y0 write FHandle.y0;
  904. property X1: Double read FHandle.x1 write FHandle.x1;
  905. property Y1: Double read FHandle.y1 write FHandle.y1;
  906. property X2: Double read FHandle.x2 write FHandle.x2;
  907. property Y2: Double read FHandle.y2 write FHandle.y2;
  908. end;
  909. PBLTriangle = ^TBLTriangle;
  910. function BLTriangle: TBLTriangle; overload; inline;
  911. function BLTriangle(const AX0, AY0, AX1, AY1, AX2, AY2: Double): TBLTriangle; overload; inline;
  912. { ============================================================================
  913. [BLRoundRect]
  914. ============================================================================ }
  915. type
  916. { Rounded rectangle specified as [x, y, w, h, rx, ry] using Double as a
  917. storage type. }
  918. TBLRoundRect = record
  919. {$REGION 'Internal Declarations'}
  920. private
  921. FHandle: BLRoundRect;
  922. {$ENDREGION 'Internal Declarations'}
  923. public
  924. class operator Equal(const ALeft, ARight: TBLRoundRect): Boolean; inline; static;
  925. class operator NotEqual(const ALeft, ARight: TBLRoundRect): Boolean; inline; static;
  926. public
  927. procedure Reset; overload; inline;
  928. procedure Reset(const ARect: TBLRect; const AR: Double); overload; inline;
  929. procedure Reset(const ARect: TBLRect; const ARX, ARY: Double); overload; inline;
  930. procedure Reset(const AX, AY, AW, AH, AR: Double); overload; inline;
  931. procedure Reset(const AX, AY, AW, AH, ARX, ARY: Double); overload; inline;
  932. function Equals(const AOther: TBLRoundRect): Boolean; inline;
  933. property X: Double read FHandle.x write FHandle.x;
  934. property Y: Double read FHandle.y write FHandle.y;
  935. property W: Double read FHandle.w write FHandle.w;
  936. property H: Double read FHandle.h write FHandle.h;
  937. end;
  938. PBLRoundRect = ^TBLRoundRect;
  939. function BLRoundRect: TBLRoundRect; overload; inline;
  940. function BLRoundRect(const ARect: TBLRect; const AR: Double): TBLRoundRect; overload; inline;
  941. function BLRoundRect(const ARect: TBLRect; const ARX, ARY: Double): TBLRoundRect; overload; inline;
  942. function BLRoundRect(const AX, AY, AW, AH, AR: Double): TBLRoundRect; overload; inline;
  943. function BLRoundRect(const AX, AY, AW, AH, ARX, ARY: Double): TBLRoundRect; overload; inline;
  944. { ============================================================================
  945. [BLCircle]
  946. ============================================================================ }
  947. type
  948. { Circle specified as [cx, cy, r] using Double as a storage type. }
  949. TBLCircle = record
  950. {$REGION 'Internal Declarations'}
  951. private
  952. FHandle: BLCircle;
  953. {$ENDREGION 'Internal Declarations'}
  954. public
  955. class operator Equal(const ALeft, ARight: TBLCircle): Boolean; inline; static;
  956. class operator NotEqual(const ALeft, ARight: TBLCircle): Boolean; inline; static;
  957. public
  958. procedure Reset; overload; inline;
  959. procedure Reset(const ACX, ACY, AR: Double); overload; inline;
  960. function Equals(const AOther: TBLCircle): Boolean; inline;
  961. property CX: Double read FHandle.cx write FHandle.cx;
  962. property CY: Double read FHandle.cy write FHandle.cy;
  963. property R: Double read FHandle.r write FHandle.r;
  964. end;
  965. PBLCircle = ^TBLCircle;
  966. function BLCircle: TBLCircle; overload; inline;
  967. function BLCircle(const ACX, ACY, AR: Double): TBLCircle; overload; inline;
  968. { ============================================================================
  969. [BLEllipse]
  970. ============================================================================ }
  971. type
  972. { Ellipse specified as [cx, cy, rx, dy] using Double as a storage type. }
  973. TBLEllipse = record
  974. {$REGION 'Internal Declarations'}
  975. private
  976. FHandle: BLEllipse;
  977. {$ENDREGION 'Internal Declarations'}
  978. public
  979. class operator Equal(const ALeft, ARight: TBLEllipse): Boolean; inline; static;
  980. class operator NotEqual(const ALeft, ARight: TBLEllipse): Boolean; inline; static;
  981. public
  982. procedure Reset; overload; inline;
  983. procedure Reset(const ACX, ACY, ARX, ARY: Double); overload; inline;
  984. function Equals(const AOther: TBLEllipse): Boolean; inline;
  985. property CX: Double read FHandle.cx write FHandle.cx;
  986. property CY: Double read FHandle.cy write FHandle.cy;
  987. property RX: Double read FHandle.rx write FHandle.rx;
  988. property RY: Double read FHandle.ry write FHandle.ry;
  989. end;
  990. PBLEllipse = ^TBLEllipse;
  991. function BLEllipse: TBLEllipse; overload; inline;
  992. function BLEllipse(const ACX, ACY, ARX, ARY: Double): TBLEllipse; overload; inline;
  993. { ============================================================================
  994. [BLArc]
  995. ============================================================================ }
  996. type
  997. { Arc specified as [cx, cy, rx, ry, start, sweep] using Double as a storage
  998. type. }
  999. TBLArc = record
  1000. {$REGION 'Internal Declarations'}
  1001. private
  1002. FHandle: BLArc;
  1003. {$ENDREGION 'Internal Declarations'}
  1004. public
  1005. class operator Equal(const ALeft, ARight: TBLArc): Boolean; inline; static;
  1006. class operator NotEqual(const ALeft, ARight: TBLArc): Boolean; inline; static;
  1007. public
  1008. procedure Reset; overload; inline;
  1009. procedure Reset(const ACX, ACY, AR, AStart, ASweep: Double); overload; inline;
  1010. procedure Reset(const ACX, ACY, ARX, ARY, AStart, ASweep: Double); overload; inline;
  1011. function Equals(const AOther: TBLArc): Boolean; inline;
  1012. property CX: Double read FHandle.cx write FHandle.cx;
  1013. property CY: Double read FHandle.cy write FHandle.cy;
  1014. property RX: Double read FHandle.rx write FHandle.rx;
  1015. property RY: Double read FHandle.ry write FHandle.ry;
  1016. property Start: Double read FHandle.start write FHandle.start;
  1017. property Sweep: Double read FHandle.sweep write FHandle.sweep;
  1018. end;
  1019. PBLArc = ^TBLArc;
  1020. function BLArc: TBLArc; overload; inline;
  1021. function BLArc(const ACX, ACY, AR, AStart, ASweep: Double): TBLArc; overload; inline;
  1022. function BLArc(const ACX, ACY, ARX, ARY, AStart, ASweep: Double): TBLArc; overload; inline;
  1023. { ============================================================================
  1024. [Globals Functions]
  1025. ============================================================================ }
  1026. function BLAbs(const AA: TBLPoint): TBLPoint; overload; inline;
  1027. function BLAbs(const AA: TBLSize): TBLSize; overload; inline;
  1028. function BLMin(const AA, AB: TBLPoint): TBLPoint; overload; inline;
  1029. function BLMin(const AA: TBLPoint; const AB: Double): TBLPoint; overload; inline;
  1030. function BLMin(const AA: Double; const AB: TBLPoint): TBLPoint; overload; inline;
  1031. function BLMin(const AA, AB: TBLSize): TBLSize; overload; inline;
  1032. function BLMax(const AA, AB: TBLPoint): TBLPoint; overload; inline;
  1033. function BLMax(const AA: TBLPoint; const AB: Double): TBLPoint; overload; inline;
  1034. function BLMax(const AA: Double; const AB: TBLPoint): TBLPoint; overload; inline;
  1035. function BLMax(const AA, AB: TBLSize): TBLSize; overload; inline;
  1036. function BLClamp(const AA: TBLPoint; const AB, AC: Double): TBLPoint; inline;
  1037. {$ENDREGION 'Geometry'}
  1038. {$REGION 'Matrix'}
  1039. { ============================================================================
  1040. [BLMatrix2D - Enums]
  1041. ============================================================================ }
  1042. type
  1043. { 2D matrix type that can be obtained by querying TBLMatrix2D.MatrixType.
  1044. Identity Transl. Scale Swap Affine
  1045. [1 0] [1 0] [. 0] [0 .] [. .]
  1046. [0 1] [0 1] [0 .] [. 0] [. .]
  1047. [0 0] [. .] [. .] [. .] [. .] }
  1048. TBLMatrix2DType = (
  1049. { Identity matrix. }
  1050. Identity = BL_MATRIX2D_TYPE_IDENTITY,
  1051. { Has translation part (the rest is like identity). }
  1052. Translate = BL_MATRIX2D_TYPE_TRANSLATE,
  1053. { Has translation and scaling parts. }
  1054. Scale = BL_MATRIX2D_TYPE_SCALE,
  1055. { Has translation and scaling parts, however scaling swaps X/Y. }
  1056. Swap = BL_MATRIX2D_TYPE_SWAP,
  1057. { Generic affine matrix. }
  1058. Affine = BL_MATRIX2D_TYPE_AFFINE,
  1059. { Invalid/degenerate matrix not useful for transformations. }
  1060. Invalid = BL_MATRIX2D_TYPE_INVALID);
  1061. type
  1062. { 2D matrix data index. }
  1063. TBLMatrix2DValue = (
  1064. { Value at index 0 - M00. }
  1065. M00 = BL_MATRIX2D_VALUE_00,
  1066. { Value at index 1 - M01. }
  1067. M01 = BL_MATRIX2D_VALUE_01,
  1068. { Value at index 2 - M10. }
  1069. M10 = BL_MATRIX2D_VALUE_10,
  1070. { Value at index 3 - M11. }
  1071. M11 = BL_MATRIX2D_VALUE_11,
  1072. { Value at index 4 - M20. }
  1073. M20 = BL_MATRIX2D_VALUE_20,
  1074. { Value at index 5 - M21. }
  1075. M21 = BL_MATRIX2D_VALUE_21);
  1076. { ============================================================================
  1077. [BLMatrix2D]
  1078. ============================================================================ }
  1079. type
  1080. { 2D matrix represents an affine transformation matrix that can be used to
  1081. transform geometry and images. }
  1082. TBLMatrix2D = record
  1083. {$REGION 'Internal Declarations'}
  1084. private
  1085. FHandle: BLMatrix2D;
  1086. function GetElement(const AIndex: TBLMatrix2DValue): Double; inline;
  1087. procedure SetElement(const AIndex: TBLMatrix2DValue; const AValue: Double); inline;
  1088. function GetMatrixType: TBLMatrix2DType; inline;
  1089. function GetDeterminant: Double; inline;
  1090. {$ENDREGION 'Internal Declarations'}
  1091. public
  1092. class operator Equal(const ALeft, ARight: TBLMatrix2D): Boolean; inline; static;
  1093. class operator NotEqual(const ALeft, ARight: TBLMatrix2D): Boolean; inline; static;
  1094. { Creates a new matrix initialized to identity. }
  1095. class function MakeIdentity: TBLMatrix2D; inline; static;
  1096. { Creates a new matrix initialized to translation. }
  1097. class function MakeTranslation(const AX, AY: Double): TBLMatrix2D; overload; inline; static;
  1098. class function MakeTranslation(const AP: TBLPoint): TBLMatrix2D; overload; inline; static;
  1099. class function MakeTranslation(const AP: TBLPointI): TBLMatrix2D; overload; inline; static;
  1100. { Creates a new matrix initialized to scaling. }
  1101. class function MakeScaling(const AXY: Double): TBLMatrix2D; overload; inline; static;
  1102. class function MakeScaling(const AX, AY: Double): TBLMatrix2D; overload; inline; static;
  1103. class function MakeScaling(const AP: TBLPoint): TBLMatrix2D; overload; inline; static;
  1104. class function MakeScaling(const AP: TBLPointI): TBLMatrix2D; overload; inline; static;
  1105. { Creates a new matrix initialized to rotation, optional around point. }
  1106. class function MakeRotation(const AAngle: Double): TBLMatrix2D; overload; inline; static;
  1107. class function MakeRotation(const AAngle, AX, AY: Double): TBLMatrix2D; overload; inline; static;
  1108. class function MakeRotation(const AAngle: Double; const AP: TBLPoint): TBLMatrix2D; overload; inline; static;
  1109. { Create a new skewing matrix. }
  1110. class function MakeSkewing(const AX, AY: Double): TBLMatrix2D; overload; inline; static;
  1111. class function MakeSkewing(const AP: TBLPoint): TBLMatrix2D; overload; inline; static;
  1112. { Create a new rotation matrix specified by ASin and ACos and optional
  1113. translation. }
  1114. class function MakeSinCos(const ASin, ACos: Double; const ATranslateX: Double = 0;
  1115. const ATranslateY: Double = 0): TBLMatrix2D; overload; inline; static;
  1116. class function MakeSinCos(const ASin, ACos: Double; const ATranslate: TBLPoint): TBLMatrix2D; overload; inline; static;
  1117. { Inverts ASrc matrix and stores the result in ADst.
  1118. Returns True if the matrix has been inverted successfully. }
  1119. class function Invert(const ASrc: TBLMatrix2D; out ADst: TBLMatrix2D): Boolean; overload; inline; static;
  1120. public
  1121. { Resets matrix to identity. }
  1122. procedure Reset; overload; inline;
  1123. { Creates a new matrix initialized to:
  1124. [m00 m01]
  1125. [m10 m11]
  1126. [m20 m21] }
  1127. procedure Reset(const AM00, AM01, AM10, AM11, AM20, AM21: Double); overload; inline;
  1128. { Resets matrix to translation. }
  1129. procedure ResetToTranslation(const AX, AY: Double); overload; inline;
  1130. procedure ResetToTranslation(const AP: TBLPoint); overload; inline;
  1131. procedure ResetToTranslation(const AP: TBLPointI); overload; inline;
  1132. { Resets matrix to scaling. }
  1133. procedure ResetToScaling(const AXY: Double); overload; inline;
  1134. procedure ResetToScaling(const AX, AY: Double); overload; inline;
  1135. procedure ResetToScaling(const AP: TBLPoint); overload; inline;
  1136. procedure ResetToScaling(const AP: TBLPointI); overload; inline;
  1137. { Resets matrix to rotation, optional around point. }
  1138. procedure ResetToRotation(const AAngle: Double); overload;
  1139. procedure ResetToRotation(const AAngle, AX, AY: Double); overload;
  1140. procedure ResetToRotation(const AAngle: Double; const AP: TBLPoint); overload;
  1141. { Resets matrix to skewing. }
  1142. procedure ResetToSkewing(const AX, AY: Double); overload;
  1143. procedure ResetToSkewing(const AP: TBLPoint); overload;
  1144. { Resets matrix to rotation specified by ASin and ACos and optional
  1145. translation. }
  1146. procedure ResetToSinCos(const ASin, ACos: Double; const ATranslateX: Double = 0;
  1147. const ATranslateY: Double = 0); overload; inline;
  1148. procedure ResetToSinCos(const ASin, ACos: Double; const ATranslate: TBLPoint); overload; inline;
  1149. function Equals(const AOther: TBLMatrix2D): Boolean; inline;
  1150. procedure Translate(const AX, AY: Double); overload; inline;
  1151. procedure Translate(const AP: TBLPoint); overload; inline;
  1152. procedure Translate(const AP: TBLPointI); overload; inline;
  1153. procedure Scale(const AXY: Double); overload; inline;
  1154. procedure Scale(const AX, AY: Double); overload; inline;
  1155. procedure Scale(const AP: TBLPoint); overload; inline;
  1156. procedure Scale(const AP: TBLPointI); overload; inline;
  1157. procedure Rotate(const AAngle: Double); overload;
  1158. procedure Rotate(const AAngle, AX, AY: Double); overload;
  1159. procedure Rotate(const AAngle: Double; const AP: TBLPoint); overload;
  1160. procedure Skew(const AX, AY: Double); overload;
  1161. procedure Skew(const AP: TBLPoint); overload;
  1162. procedure Transform(const AMatrix: TBLMatrix2D);
  1163. procedure PostTranslate(const AX, AY: Double); overload; inline;
  1164. procedure PostTranslate(const AP: TBLPoint); overload; inline;
  1165. procedure PostTranslate(const AP: TBLPointI); overload; inline;
  1166. procedure PostScale(const AXY: Double); overload; inline;
  1167. procedure PostScale(const AX, AY: Double); overload; inline;
  1168. procedure PostScale(const AP: TBLPoint); overload; inline;
  1169. procedure PostScale(const AP: TBLPointI); overload; inline;
  1170. procedure PostRotate(const AAngle: Double); overload;
  1171. procedure PostRotate(const AAngle, AX, AY: Double); overload;
  1172. procedure PostRotate(const AAngle: Double; const AP: TBLPoint); overload;
  1173. procedure PostSkew(const AX, AY: Double); overload;
  1174. procedure PostSkew(const AP: TBLPoint); overload;
  1175. procedure PostTransform(const AMatrix: TBLMatrix2D);
  1176. { Inverts the matrix, returns True if the matrix has been inverted
  1177. successfully. }
  1178. function Invert: Boolean; overload;
  1179. function MapPoint(const AX, AY: Double): TBLPoint; overload; inline;
  1180. function MapPoint(const AP: TBLPoint): TBLPoint; overload; inline;
  1181. function MapVector(const AX, AY: Double): TBLPoint; overload; inline;
  1182. function MapVector(const AV: TBLPoint): TBLPoint; overload; inline;
  1183. property Elements[const AIndex: TBLMatrix2DValue]: Double read GetElement write SetElement; default;
  1184. property M00: Double read FHandle.m00 write FHandle.m00;
  1185. property M01: Double read FHandle.m01 write FHandle.m01;
  1186. property M10: Double read FHandle.m10 write FHandle.m10;
  1187. property M11: Double read FHandle.m11 write FHandle.m11;
  1188. property M20: Double read FHandle.m20 write FHandle.m20;
  1189. property M21: Double read FHandle.m21 write FHandle.m21;
  1190. { The matrix type }
  1191. property MatrixType: TBLMatrix2DType read GetMatrixType;
  1192. { Calculates the matrix determinant. }
  1193. property Determinant: Double read GetDeterminant;
  1194. end;
  1195. PBLMatrix2D = ^TBLMatrix2D;
  1196. function BLMatrix2D: TBLMatrix2D; overload; inline;
  1197. function BLMatrix2D(const AM00, AM01, AM10, AM11, AM20, AM21: Double): TBLMatrix2D; overload; inline;
  1198. {$ENDREGION 'Matrix'}
  1199. {$REGION 'Random'}
  1200. { ============================================================================
  1201. [BLRandom]
  1202. ============================================================================ }
  1203. type
  1204. { Simple pseudo random number generator.
  1205. The current implementation uses a PRNG called `XORSHIFT+`, which has 64-bit
  1206. seed, 128 bits of state, and full period `2^128 - 1`.
  1207. Based on a paper by Sebastiano Vigna:
  1208. http://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf }
  1209. TBLRandom = record
  1210. {$REGION 'Internal Declarations'}
  1211. private
  1212. FHandle: BLRandom;
  1213. {$ENDREGION 'Internal Declarations'}
  1214. public
  1215. class operator Equal(const ALeft, ARight: TBLRandom): Boolean; inline; static;
  1216. class operator NotEqual(const ALeft, ARight: TBLRandom): Boolean; inline; static;
  1217. public
  1218. { Resets the random number generator to the given ASeed. }
  1219. procedure Reset(const ASeed: UInt64 = 0);
  1220. { Tests whether the random number generator is equivalent to AOther.
  1221. Random number generator would only be equivalent to AOther if it was
  1222. initialized from the same seed and has the same internal state. }
  1223. function Equals(const AOther: TBLRandom): Boolean; inline;
  1224. { Returns the next pseudo-random UInt64 value and advances its state. }
  1225. function NextUInt64: UInt64;
  1226. { Returns the next pseudo-random UInt32 value and advances its state. }
  1227. function NextUInt32: UInt32;
  1228. { Returns the next pseudo-random Double precision floating point in [0..1)
  1229. range and advances its state. }
  1230. function NextDouble: Double;
  1231. end;
  1232. PBLRandom = ^TBLRandom;
  1233. {$ENDREGION 'Random'}
  1234. {$REGION 'Gradient'}
  1235. { ============================================================================
  1236. [BLGradient - Enums]
  1237. ============================================================================ }
  1238. type
  1239. { Gradient type. }
  1240. TBLGradientType = (
  1241. { Linear gradient type. }
  1242. Linear = BL_GRADIENT_TYPE_LINEAR,
  1243. { Radial gradient type. }
  1244. Radial = BL_GRADIENT_TYPE_RADIAL,
  1245. { Conical gradient type. }
  1246. Conical = BL_GRADIENT_TYPE_CONICAL);
  1247. type
  1248. { Gradient data index. }
  1249. TBLGradientValue = (
  1250. { x0 - start 'x' for Linear/Radial and center 'x' for Conical. }
  1251. CommonX0 = BL_GRADIENT_VALUE_COMMON_X0,
  1252. { y0 - start 'y' for Linear/Radial and center 'y' for Conical. }
  1253. CommonY0 = BL_GRADIENT_VALUE_COMMON_Y0,
  1254. { x1 - end 'x' for Linear/Radial. }
  1255. CommonX1 = BL_GRADIENT_VALUE_COMMON_X1,
  1256. { y1 - end 'y' for Linear/Radial. }
  1257. CommonY1 = BL_GRADIENT_VALUE_COMMON_Y1,
  1258. { Radial gradient r0 radius. }
  1259. RadialR0 = BL_GRADIENT_VALUE_RADIAL_R0,
  1260. {Conical gradient angle. }
  1261. ConicalAngle = BL_GRADIENT_VALUE_CONICAL_ANGLE);
  1262. { ============================================================================
  1263. [BLGradientStop]
  1264. ============================================================================ }
  1265. type
  1266. { Defines an Offset and Rgba color that us used by IBLGradient to define
  1267. a linear transition between colors. }
  1268. TBLGradientStop = record
  1269. {$REGION 'Internal Declarations'}
  1270. private
  1271. FHandle: BLGradientStop;
  1272. function GetRgba: TBLRgba64; inline;
  1273. procedure SetRgba(const AValue: TBLRgba64); inline;
  1274. {$ENDREGION 'Internal Declarations'}
  1275. public
  1276. class operator Equal(const ALeft, ARight: TBLGradientStop): Boolean; inline; static;
  1277. class operator NotEqual(const ALeft, ARight: TBLGradientStop): Boolean; inline; static;
  1278. public
  1279. procedure Reset; overload; inline;
  1280. procedure Reset(const AOffset: Double; const ARgba: TBLRgba32); overload; inline;
  1281. procedure Reset(const AOffset: Double; const ARgba: TBLRgba64); overload; inline;
  1282. function Equals(const AOther: TBLGradientStop): Boolean; inline;
  1283. property Offset: Double read FHandle.offset write FHandle.offset;
  1284. property Rgba: TBLRgba64 read GetRgba write SetRgba;
  1285. end;
  1286. PBLGradientStop = ^TBLGradientStop;
  1287. function BLGradientStop(const AOffset: Double; const ARgba: TBLRgba32): TBLGradientStop; overload; inline;
  1288. function BLGradientStop(const AOffset: Double; const ARgba: TBLRgba64): TBLGradientStop; overload; inline;
  1289. { ============================================================================
  1290. [BLLinearGradientValues]
  1291. ============================================================================ }
  1292. type
  1293. { Linear gradient values packed into a record. }
  1294. TBLLinearGradientValues = record
  1295. {$REGION 'Internal Declarations'}
  1296. private
  1297. FHandle: BLLinearGradientValues;
  1298. {$ENDREGION 'Internal Declarations'}
  1299. public
  1300. procedure Reset; overload; inline;
  1301. procedure Reset(const AX0, AY0, AX1, AY1: Double); overload; inline;
  1302. property X0: Double read FHandle.x0 write FHandle.x0;
  1303. property Y0: Double read FHandle.y0 write FHandle.y0;
  1304. property X1: Double read FHandle.x1 write FHandle.x1;
  1305. property Y1: Double read FHandle.y1 write FHandle.y1;
  1306. end;
  1307. PBLLinearGradientValues = ^TBLLinearGradientValues;
  1308. function BLLinearGradientValues(const AX0, AY0, AX1, AY1: Double): TBLLinearGradientValues; inline;
  1309. { ============================================================================
  1310. [BLRadialGradientValues]
  1311. ============================================================================ }
  1312. type
  1313. { Radial gradient values packed into a record. }
  1314. TBLRadialGradientValues = record
  1315. {$REGION 'Internal Declarations'}
  1316. private
  1317. FHandle: BLRadialGradientValues;
  1318. {$ENDREGION 'Internal Declarations'}
  1319. public
  1320. procedure Reset; overload; inline;
  1321. procedure Reset(const AX0, AY0, AX1, AY1, AR0: Double); overload; inline;
  1322. property X0: Double read FHandle.x0 write FHandle.x0;
  1323. property Y0: Double read FHandle.y0 write FHandle.y0;
  1324. property X1: Double read FHandle.x1 write FHandle.x1;
  1325. property Y1: Double read FHandle.y1 write FHandle.y1;
  1326. property R0: Double read FHandle.r0 write FHandle.r0;
  1327. end;
  1328. PBLRadialGradientValues = ^TBLRadialGradientValues;
  1329. function BLRadialGradientValues(const AX0, AY0, AX1, AY1, AR0: Double): TBLRadialGradientValues; inline;
  1330. { ============================================================================
  1331. [BLConicalGradientValues]
  1332. ============================================================================ }
  1333. type
  1334. { Conical gradient values packed into a record. }
  1335. TBLConicalGradientValues = record
  1336. {$REGION 'Internal Declarations'}
  1337. private
  1338. FHandle: BLConicalGradientValues;
  1339. {$ENDREGION 'Internal Declarations'}
  1340. public
  1341. procedure Reset; overload; inline;
  1342. procedure Reset(const AX0, AY0, AAngle: Double); overload; inline;
  1343. property X0: Double read FHandle.x0 write FHandle.x0;
  1344. property Y0: Double read FHandle.y0 write FHandle.y0;
  1345. property Angle: Double read FHandle.angle write FHandle.angle;
  1346. end;
  1347. PBLConicalGradientValues = ^TBLConicalGradientValues;
  1348. function BLConicalGradientValues(const AX0, AY0, AAngle: Double): TBLConicalGradientValues; inline;
  1349. { ============================================================================
  1350. [BLGradient]
  1351. ============================================================================ }
  1352. type
  1353. { Gradient }
  1354. IBLGradient = interface
  1355. ['{804D20E0-8F67-415C-BD26-E56DC3BA4DDC}']
  1356. {$REGION 'Internal Declarations'}
  1357. function GetIsNone: Boolean;
  1358. function GetIsEmpty: Boolean;
  1359. function GetGradientType: TBLGradientType;
  1360. procedure SetGradientType(const AValue: TBLGradientType);
  1361. function GetExtendMode: TBLExtendMode;
  1362. procedure SetExtendMode(const AValue: TBLExtendMode);
  1363. function GetValue(const AIndex: TBLGradientValue): Double;
  1364. procedure SetValue(const AIndex: TBLGradientValue; const AValue: Double);
  1365. function GetLinear: TBLLinearGradientValues;
  1366. procedure SetLinear(const AValue: TBLLinearGradientValues);
  1367. function GetRadial: TBLRadialGradientValues;
  1368. procedure SetRadial(const AValue: TBLRadialGradientValues);
  1369. function GetConical: TBLConicalGradientValues;
  1370. procedure SetConical(const AValue: TBLConicalGradientValues);
  1371. function GetX0: Double;
  1372. procedure SetX0(const AValue: Double);
  1373. function GetY0: Double;
  1374. procedure SetY0(const AValue: Double);
  1375. function GetX1: Double;
  1376. procedure SetX1(const AValue: Double);
  1377. function GetY1: Double;
  1378. procedure SetY1(const AValue: Double);
  1379. function GetR0: Double;
  1380. procedure SetR0(const AValue: Double);
  1381. function GetAngle: Double;
  1382. procedure SetAngle(const AValue: Double);
  1383. function GetSize: Integer;
  1384. function GetCapacity: Integer;
  1385. function GetAllStops: PBLGradientStop;
  1386. function GetStop(const AIndex: Integer): TBLGradientStop;
  1387. procedure SetStop(const AIndex: Integer; const AValue: TBLGradientStop);
  1388. function GetHasMatrix: Boolean;
  1389. function GetMatrixType: TBLMatrix2DType;
  1390. function GetMatrix: TBLMatrix2D;
  1391. procedure SetMatrix(const AValue: TBLMatrix2D);
  1392. function GetHandle: PBLGradientCore;
  1393. {$ENDREGION 'Internal Declarations'}
  1394. procedure Initialize(const AValues: TBLLinearGradientValues;
  1395. const AExtendMode: TBLExtendMode = TBLExtendMode.Pad;
  1396. const AStops: TArray<TBLGradientStop> = nil); overload;
  1397. procedure Initialize(const AValues: TBLRadialGradientValues;
  1398. const AExtendMode: TBLExtendMode = TBLExtendMode.Pad;
  1399. const AStops: TArray<TBLGradientStop> = nil); overload;
  1400. procedure Initialize(const AValues: TBLConicalGradientValues;
  1401. const AExtendMode: TBLExtendMode = TBLExtendMode.Pad;
  1402. const AStops: TArray<TBLGradientStop> = nil); overload;
  1403. procedure Initialize(const AValues: TBLLinearGradientValues;
  1404. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>;
  1405. const AMatrix: TBLMatrix2D); overload;
  1406. procedure Initialize(const AValues: TBLRadialGradientValues;
  1407. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>;
  1408. const AMatrix: TBLMatrix2D); overload;
  1409. procedure Initialize(const AValues: TBLConicalGradientValues;
  1410. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>;
  1411. const AMatrix: TBLMatrix2D); overload;
  1412. procedure Reset;
  1413. function Equals(const AOther: IBLGradient): Boolean;
  1414. { Resets the gradient extend mode to TBLExtendMode.Pad. }
  1415. procedure ResetExtendMode;
  1416. procedure SetValues(const AIndex: TBLGradientValue; const AValues: TArray<Double>); overload;
  1417. procedure SetValues(const AValues: TBLLinearGradientValues); overload;
  1418. procedure SetValues(const AValues: TBLRadialGradientValues); overload;
  1419. procedure SetValues(const AValues: TBLConicalGradientValues); overload;
  1420. { Reserves the capacity of gradient for at least ACount stops. }
  1421. procedure Reserve(const ACount: Integer);
  1422. { Shrinks the capacity of gradient stops to fit the current usage. }
  1423. procedure Shrink;
  1424. procedure ResetStops;
  1425. procedure SetStops(const AStops: TArray<TBLGradientStop>);
  1426. procedure AddStop(const AOffset: Double; const ARgba: TBLRgba32); overload;
  1427. procedure AddStop(const AOffset: Double; const ARgba: TBLRgba64); overload;
  1428. procedure RemoveStop(const AIndex: Integer);
  1429. procedure RemoveStopByOffset(const AOffset: Double; const AAll: Boolean = True);
  1430. procedure RemoveStops(const ARange: TBLRange);
  1431. procedure RemoveStopsByOffset(const AOffsetMin, AOffsetMax: Double);
  1432. procedure ReplaceStop(const AIndex: Integer; const AOffset: Double;
  1433. const ARgba: TBLRgba32); overload;
  1434. procedure ReplaceStop(const AIndex: Integer; const AOffset: Double;
  1435. const ARgba: TBLRgba64); overload;
  1436. function IndexOfStop(const AOffset: Double): Integer;
  1437. procedure ResetMatrix;
  1438. procedure Translate(const AX, AY: Double); overload;
  1439. procedure Translate(const AP: TBLPoint); overload;
  1440. procedure Translate(const AP: TBLPointI); overload;
  1441. procedure Scale(const AXY: Double); overload;
  1442. procedure Scale(const AX, AY: Double); overload;
  1443. procedure Scale(const AP: TBLPoint); overload;
  1444. procedure Scale(const AP: TBLPointI); overload;
  1445. procedure Skew(const AX, AY: Double); overload;
  1446. procedure Skew(const AP: TBLPoint); overload;
  1447. procedure Rotate(const AAngle: Double); overload;
  1448. procedure Rotate(const AAngle, AX, AY: Double); overload;
  1449. procedure Rotate(const AAngle: Double; const AP: TBLPoint); overload;
  1450. procedure Rotate(const AAngle: Double; const AP: TBLPointI); overload;
  1451. procedure Transform(const AMatrix: TBLMatrix2D);
  1452. procedure PostTranslate(const AX, AY: Double); overload;
  1453. procedure PostTranslate(const AP: TBLPoint); overload;
  1454. procedure PostTranslate(const AP: TBLPointI); overload;
  1455. procedure PostScale(const AXY: Double); overload;
  1456. procedure PostScale(const AX, AY: Double); overload;
  1457. procedure PostScale(const AP: TBLPoint); overload;
  1458. procedure PostScale(const AP: TBLPointI); overload;
  1459. procedure PostSkew(const AX, AY: Double); overload;
  1460. procedure PostSkew(const AP: TBLPoint); overload;
  1461. procedure PostRotate(const AAngle: Double); overload;
  1462. procedure PostRotate(const AAngle, AX, AY: Double); overload;
  1463. procedure PostRotate(const AAngle: Double; const AP: TBLPoint); overload;
  1464. procedure PostRotate(const AAngle: Double; const AP: TBLPointI); overload;
  1465. procedure PostTransform(const AMatrix: TBLMatrix2D);
  1466. { Tests whether the gradient path is a built-in nil instance. }
  1467. property IsNone: Boolean read GetIsNone;
  1468. { Tests whether the gradient is empty.
  1469. Empty gradient is considered any gradient that has no stops. }
  1470. property IsEmpty: Boolean read GetIsEmpty;
  1471. { The type of the gradient }
  1472. property GradientType: TBLGradientType read GetGradientType write SetGradientType;
  1473. { The gradient extend mode }
  1474. property ExtendMode: TBLExtendMode read GetExtendMode write SetExtendMode;
  1475. property Values[const AIndex: TBLGradientValue]: Double read GetValue write SetValue;
  1476. property Linear: TBLLinearGradientValues read GetLinear write SetLinear;
  1477. property Radial: TBLRadialGradientValues read GetRadial write SetRadial;
  1478. property Conical: TBLConicalGradientValues read GetConical write SetConical;
  1479. property X0: Double read GetX0 write SetX0;
  1480. property Y0: Double read GetY0 write SetY0;
  1481. property X1: Double read GetX1 write SetX1;
  1482. property Y1: Double read GetY1 write SetY1;
  1483. property R0: Double read GetR0 write SetR0;
  1484. property Angle: Double read GetAngle write SetAngle;
  1485. { The number of stops the gradient has. }
  1486. property Size: Integer read GetSize;
  1487. { The gradient capacity [in stops]. }
  1488. property Capacity: Integer read GetCapacity;
  1489. { The gradient stop data. }
  1490. property AllStops: PBLGradientStop read GetAllStops;
  1491. { A gradient stop at AIndex. }
  1492. property Stops[const AIndex: Integer]: TBLGradientStop read GetStop write SetStop;
  1493. property HasMatrix: Boolean read GetHasMatrix;
  1494. property MatrixType: TBLMatrix2DType read GetMatrixType;
  1495. property Matrix: TBLMatrix2D read GetMatrix write SetMatrix;
  1496. { Internal handle for use with the C API }
  1497. property Handle: PBLGradientCore read GetHandle;
  1498. end;
  1499. type
  1500. { Implements IBLGradient }
  1501. TBLGradient = class(TInterfacedObject, IBLGradient)
  1502. {$REGION 'Internal Declarations'}
  1503. private
  1504. FHandle: BLGradientCore;
  1505. FIsReference: Boolean;
  1506. protected
  1507. { IBLGradient }
  1508. function GetIsNone: Boolean;
  1509. function GetIsEmpty: Boolean;
  1510. function GetGradientType: TBLGradientType;
  1511. procedure SetGradientType(const AValue: TBLGradientType);
  1512. function GetExtendMode: TBLExtendMode;
  1513. procedure SetExtendMode(const AValue: TBLExtendMode);
  1514. function GetValue(const AIndex: TBLGradientValue): Double;
  1515. procedure SetValue(const AIndex: TBLGradientValue; const AValue: Double);
  1516. function GetLinear: TBLLinearGradientValues;
  1517. procedure SetLinear(const AValue: TBLLinearGradientValues);
  1518. function GetRadial: TBLRadialGradientValues;
  1519. procedure SetRadial(const AValue: TBLRadialGradientValues);
  1520. function GetConical: TBLConicalGradientValues;
  1521. procedure SetConical(const AValue: TBLConicalGradientValues);
  1522. function GetX0: Double;
  1523. procedure SetX0(const AValue: Double);
  1524. function GetY0: Double;
  1525. procedure SetY0(const AValue: Double);
  1526. function GetX1: Double;
  1527. procedure SetX1(const AValue: Double);
  1528. function GetY1: Double;
  1529. procedure SetY1(const AValue: Double);
  1530. function GetR0: Double;
  1531. procedure SetR0(const AValue: Double);
  1532. function GetAngle: Double;
  1533. procedure SetAngle(const AValue: Double);
  1534. function GetSize: Integer;
  1535. function GetCapacity: Integer;
  1536. function GetAllStops: PBLGradientStop;
  1537. function GetStop(const AIndex: Integer): TBLGradientStop;
  1538. procedure SetStop(const AIndex: Integer; const AValue: TBLGradientStop);
  1539. function GetHasMatrix: Boolean;
  1540. function GetMatrixType: TBLMatrix2DType;
  1541. function GetMatrix: TBLMatrix2D;
  1542. procedure SetMatrix(const AValue: TBLMatrix2D);
  1543. function GetHandle: PBLGradientCore;
  1544. procedure Initialize(const AValues: TBLLinearGradientValues;
  1545. const AExtendMode: TBLExtendMode = TBLExtendMode.Pad;
  1546. const AStops: TArray<TBLGradientStop> = nil); overload;
  1547. procedure Initialize(const AValues: TBLRadialGradientValues;
  1548. const AExtendMode: TBLExtendMode = TBLExtendMode.Pad;
  1549. const AStops: TArray<TBLGradientStop> = nil); overload;
  1550. procedure Initialize(const AValues: TBLConicalGradientValues;
  1551. const AExtendMode: TBLExtendMode = TBLExtendMode.Pad;
  1552. const AStops: TArray<TBLGradientStop> = nil); overload;
  1553. procedure Initialize(const AValues: TBLLinearGradientValues;
  1554. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>;
  1555. const AMatrix: TBLMatrix2D); overload;
  1556. procedure Initialize(const AValues: TBLRadialGradientValues;
  1557. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>;
  1558. const AMatrix: TBLMatrix2D); overload;
  1559. procedure Initialize(const AValues: TBLConicalGradientValues;
  1560. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>;
  1561. const AMatrix: TBLMatrix2D); overload;
  1562. procedure Reset;
  1563. function Equals(const AOther: IBLGradient): Boolean; reintroduce; overload;
  1564. procedure ResetExtendMode;
  1565. procedure SetValues(const AIndex: TBLGradientValue; const AValues: TArray<Double>); overload;
  1566. procedure SetValues(const AValues: TBLLinearGradientValues); overload;
  1567. procedure SetValues(const AValues: TBLRadialGradientValues); overload;
  1568. procedure SetValues(const AValues: TBLConicalGradientValues); overload;
  1569. procedure Reserve(const ACount: Integer);
  1570. procedure Shrink;
  1571. procedure ResetStops;
  1572. procedure SetStops(const AStops: TArray<TBLGradientStop>);
  1573. procedure AddStop(const AOffset: Double; const ARgba: TBLRgba32); overload;
  1574. procedure AddStop(const AOffset: Double; const ARgba: TBLRgba64); overload;
  1575. procedure RemoveStop(const AIndex: Integer);
  1576. procedure RemoveStopByOffset(const AOffset: Double; const AAll: Boolean = True);
  1577. procedure RemoveStops(const ARange: TBLRange);
  1578. procedure RemoveStopsByOffset(const AOffsetMin, AOffsetMax: Double);
  1579. procedure ReplaceStop(const AIndex: Integer; const AOffset: Double;
  1580. const ARgba: TBLRgba32); overload;
  1581. procedure ReplaceStop(const AIndex: Integer; const AOffset: Double;
  1582. const ARgba: TBLRgba64); overload;
  1583. function IndexOfStop(const AOffset: Double): Integer;
  1584. procedure ResetMatrix;
  1585. procedure Translate(const AX, AY: Double); overload;
  1586. procedure Translate(const AP: TBLPoint); overload;
  1587. procedure Translate(const AP: TBLPointI); overload;
  1588. procedure Scale(const AXY: Double); overload;
  1589. procedure Scale(const AX, AY: Double); overload;
  1590. procedure Scale(const AP: TBLPoint); overload;
  1591. procedure Scale(const AP: TBLPointI); overload;
  1592. procedure Skew(const AX, AY: Double); overload;
  1593. procedure Skew(const AP: TBLPoint); overload;
  1594. procedure Rotate(const AAngle: Double); overload;
  1595. procedure Rotate(const AAngle, AX, AY: Double); overload;
  1596. procedure Rotate(const AAngle: Double; const AP: TBLPoint); overload;
  1597. procedure Rotate(const AAngle: Double; const AP: TBLPointI); overload;
  1598. procedure Transform(const AMatrix: TBLMatrix2D);
  1599. procedure PostTranslate(const AX, AY: Double); overload;
  1600. procedure PostTranslate(const AP: TBLPoint); overload;
  1601. procedure PostTranslate(const AP: TBLPointI); overload;
  1602. procedure PostScale(const AXY: Double); overload;
  1603. procedure PostScale(const AX, AY: Double); overload;
  1604. procedure PostScale(const AP: TBLPoint); overload;
  1605. procedure PostScale(const AP: TBLPointI); overload;
  1606. procedure PostSkew(const AX, AY: Double); overload;
  1607. procedure PostSkew(const AP: TBLPoint); overload;
  1608. procedure PostRotate(const AAngle: Double); overload;
  1609. procedure PostRotate(const AAngle, AX, AY: Double); overload;
  1610. procedure PostRotate(const AAngle: Double; const AP: TBLPoint); overload;
  1611. procedure PostRotate(const AAngle: Double; const AP: TBLPointI); overload;
  1612. procedure PostTransform(const AMatrix: TBLMatrix2D);
  1613. private
  1614. constructor Create(const AHandle: BLGradientCore;
  1615. const AIsReference: Boolean); overload;
  1616. {$ENDREGION 'Internal Declarations'}
  1617. public
  1618. constructor Create; overload;
  1619. constructor Create(const AType: TBLGradientType;
  1620. const AValues: PDouble = nil); overload;
  1621. constructor Create(const AValues: TBLLinearGradientValues;
  1622. const AExtendMode: TBLExtendMode = TBLExtendMode.Pad;
  1623. const AStops: TArray<TBLGradientStop> = nil); overload;
  1624. constructor Create(const AValues: TBLRadialGradientValues;
  1625. const AExtendMode: TBLExtendMode = TBLExtendMode.Pad;
  1626. const AStops: TArray<TBLGradientStop> = nil); overload;
  1627. constructor Create(const AValues: TBLConicalGradientValues;
  1628. const AExtendMode: TBLExtendMode = TBLExtendMode.Pad;
  1629. const AStops: TArray<TBLGradientStop> = nil); overload;
  1630. constructor Create(const AValues: TBLLinearGradientValues;
  1631. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>;
  1632. const AMatrix: TBLMatrix2D); overload;
  1633. constructor Create(const AValues: TBLRadialGradientValues;
  1634. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>;
  1635. const AMatrix: TBLMatrix2D); overload;
  1636. constructor Create(const AValues: TBLConicalGradientValues;
  1637. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>;
  1638. const AMatrix: TBLMatrix2D); overload;
  1639. destructor Destroy; override;
  1640. function Equals(Obj: TObject): Boolean; overload; override;
  1641. end;
  1642. {$ENDREGION 'Gradient'}
  1643. {$REGION 'Region'}
  1644. { ============================================================================
  1645. [Enums]
  1646. ============================================================================ }
  1647. type
  1648. { Region type. }
  1649. TBLRegionType = (
  1650. { Region is empty (has no rectangles). }
  1651. Empty = BL_REGION_TYPE_EMPTY,
  1652. { Region has one rectangle (rectangular). }
  1653. Rect = BL_REGION_TYPE_RECT,
  1654. { Region has more YX sorted rectangles. }
  1655. Complex = BL_REGION_TYPE_COMPLEX);
  1656. { ============================================================================
  1657. [BLRegion]
  1658. ============================================================================ }
  1659. type
  1660. TBLRegionView = TBLArrayView<TBLBoxI>;
  1661. type
  1662. { 2D region.
  1663. Region is a set of rectangles sorted and coalesced by their Y/X
  1664. coordinates. }
  1665. IBLRegion = interface
  1666. ['{7AFAFA57-1358-490D-A984-4017EE9E3234}']
  1667. {$REGION 'Internal Declarations'}
  1668. function GetIsNone: Boolean;
  1669. function GetIsEmpty: Boolean;
  1670. function GetRegionType: TBLRegionType;
  1671. function GetIsRect: Boolean;
  1672. function GetIsComplex: Boolean;
  1673. function GetSize: Integer;
  1674. function GetCapacity: Integer;
  1675. function GetData: PBLBoxI;
  1676. function GetDataEnd: PBLBoxI;
  1677. function GetBoundingBox: TBLBoxI;
  1678. function GetView: TBLRegionView;
  1679. function GetHandle: PBLRegionCore;
  1680. {$ENDREGION 'Internal Declarations'}
  1681. procedure Reset;
  1682. function Clone: IBLRegion;
  1683. { Tests whether this region and the AOther region are equal. }
  1684. function Equals(const AOther: IBLRegion): Boolean;
  1685. procedure Assign(const ABox: TBLBoxI); overload;
  1686. procedure Assign(const ABoxes: TArray<TBLBoxI>); overload;
  1687. procedure Assign(const ABoxes: PBLBoxI; const ACount: Integer); overload;
  1688. procedure Assign(const ARect: TBLRectI); overload;
  1689. procedure Assign(const ARects: TArray<TBLRectI>); overload;
  1690. procedure Assign(const ARects: PBLRectI; const ACount: Integer); overload;
  1691. procedure Clear;
  1692. { Reserves at least ACount boxes in this region. }
  1693. procedure Reserve(const ACount: Integer);
  1694. { Shrinks the region data so it consumes only memory it requires. }
  1695. procedure Shrink;
  1696. procedure Combine(const ARegion: IBLRegion; const ABooleanOp: TBLBooleanOp); overload;
  1697. procedure Combine(const ABox: TBLBoxI; const ABooleanOp: TBLBooleanOp); overload;
  1698. { Translates the region by the given point APt.
  1699. Possible overflow will be handled by clipping to a maximum region
  1700. boundary, so the final region could be smaller than the region before
  1701. translation. }
  1702. procedure Translate(const APt: TBLPointI);
  1703. { Translates the region by the given point APt and clip it to the given
  1704. AClipBox. }
  1705. procedure TranslateAndClip(const APt: TBLPointI; const AClipBox: TBLBoxI); overload;
  1706. { Intersects the region with AR and clip it to the given AClipBox. }
  1707. procedure IntersectAndClip(const AR: IBLRegion; const AClipBox: TBLBoxI); overload;
  1708. { Tests if a given point APt or ABox is in region }
  1709. function HitTest(const APt: TBLPointI): TBLHitTest; overload;
  1710. function HitTest(const ABox: TBLBoxI): TBLHitTest; overload;
  1711. { Tests whether the region is a built-in nil instance. }
  1712. property IsNone: Boolean read GetIsNone;
  1713. { Tests whether the region is empty. }
  1714. property IsEmpty: Boolean read GetIsEmpty;
  1715. { The type of the region }
  1716. property RegionType: TBLRegionType read GetRegionType;
  1717. { Tests whether the region is one rectangle. }
  1718. property IsRect: Boolean read GetIsRect;
  1719. { Tests whether the region is complex. }
  1720. property IsComplex: Boolean read GetIsComplex;
  1721. { The region size. }
  1722. property Size: Integer read GetSize;
  1723. { The region capacity. }
  1724. property Capacity: Integer read GetCapacity;
  1725. { Pointer to the region data. }
  1726. property Data: PBLBoxI read GetData;
  1727. { Pointer to the end of the region data. }
  1728. property DataEnd: PBLBoxI read GetDataEnd;
  1729. { The region's bounding box. }
  1730. property BoundingBox: TBLBoxI read GetBoundingBox;
  1731. { The region data as TBLRegionView. }
  1732. property View: TBLRegionView read GetView;
  1733. { Internal handle for use with the C API }
  1734. property Handle: PBLRegionCore read GetHandle;
  1735. end;
  1736. type
  1737. { Implements IBLRegion }
  1738. TBLRegion = class(TInterfacedObject, IBLRegion)
  1739. {$REGION 'Internal Declarations'}
  1740. private
  1741. FHandle: BLRegionCore;
  1742. protected
  1743. { IBLRegion }
  1744. function GetIsNone: Boolean;
  1745. function GetIsEmpty: Boolean;
  1746. function GetRegionType: TBLRegionType;
  1747. function GetIsRect: Boolean;
  1748. function GetIsComplex: Boolean;
  1749. function GetSize: Integer;
  1750. function GetCapacity: Integer;
  1751. function GetData: PBLBoxI;
  1752. function GetDataEnd: PBLBoxI;
  1753. function GetBoundingBox: TBLBoxI;
  1754. function GetView: TBLRegionView;
  1755. function GetHandle: PBLRegionCore;
  1756. procedure Reset;
  1757. function Clone: IBLRegion;
  1758. function Equals(const AOther: IBLRegion): Boolean; reintroduce; overload;
  1759. procedure Assign(const ABox: TBLBoxI); overload;
  1760. procedure Assign(const ABoxes: TArray<TBLBoxI>); overload;
  1761. procedure Assign(const ABoxes: PBLBoxI; const ACount: Integer); overload;
  1762. procedure Assign(const ARect: TBLRectI); overload;
  1763. procedure Assign(const ARects: TArray<TBLRectI>); overload;
  1764. procedure Assign(const ARects: PBLRectI; const ACount: Integer); overload;
  1765. procedure Clear;
  1766. procedure Reserve(const ACount: Integer);
  1767. procedure Shrink;
  1768. procedure Combine(const ARegion: IBLRegion; const ABooleanOp: TBLBooleanOp); overload;
  1769. procedure Combine(const ABox: TBLBoxI; const ABooleanOp: TBLBooleanOp); overload;
  1770. procedure Translate(const APt: TBLPointI); overload;
  1771. procedure TranslateAndClip(const APt: TBLPointI; const AClipBox: TBLBoxI); overload;
  1772. procedure IntersectAndClip(const AR: IBLRegion; const AClipBox: TBLBoxI); overload;
  1773. function HitTest(const APt: TBLPointI): TBLHitTest; overload;
  1774. function HitTest(const ABox: TBLBoxI): TBLHitTest; overload;
  1775. {$ENDREGION 'Internal Declarations'}
  1776. public
  1777. constructor Create;
  1778. destructor Destroy; override;
  1779. function Equals(Obj: TObject): Boolean; overload; override;
  1780. public
  1781. class function Combine(const AA, AB: IBLRegion; const ABooleanOp: TBLBooleanOp): IBLRegion; overload; static;
  1782. class function Combine(const AA: IBLRegion; const AB: TBLBoxI; const ABooleanOp: TBLBooleanOp): IBLRegion; overload; static;
  1783. class function Combine(const AA: TBLBoxI; const AB: IBLRegion; const ABooleanOp: TBLBooleanOp): IBLRegion; overload; static;
  1784. class function Combine(const AA, AB: TBLBoxI; const ABooleanOp: TBLBooleanOp): IBLRegion; overload; static;
  1785. class function Translate(const AR: IBLRegion; const APt: TBLPointI): IBLRegion; overload; static;
  1786. class function TranslateAndClip(const AR: IBLRegion; const APt: TBLPointI;
  1787. const AClipBox: TBLBoxI): IBLRegion; overload; static;
  1788. class function IntersectAndClip(const AA, AB: IBLRegion;
  1789. const AClipBox: TBLBoxI): IBLRegion; overload; static;
  1790. end;
  1791. {$ENDREGION 'Region'}
  1792. {$REGION 'Path'}
  1793. { ============================================================================
  1794. [Enums]
  1795. ============================================================================ }
  1796. type
  1797. { Path command. }
  1798. TBLPathCmd = (
  1799. { Move-to command (starts a new figure). }
  1800. Move = BL_PATH_CMD_MOVE,
  1801. { On-path command (interpreted as line-to or the end of a curve). }
  1802. &On = BL_PATH_CMD_ON,
  1803. { Quad-to control point. }
  1804. Quad = BL_PATH_CMD_QUAD,
  1805. { Cubic-to control point (always used as a pair of commands). }
  1806. Cubic = BL_PATH_CMD_CUBIC,
  1807. { Close path. }
  1808. Close = BL_PATH_CMD_CLOSE);
  1809. PBLPathCmd = ^TBLPathCmd;
  1810. type
  1811. { Path flags. }
  1812. TBLPathFlag = (
  1813. { Path is empty (no commands or close commands only). }
  1814. Empty = 0,
  1815. { Path contains multiple figures. }
  1816. Multiple = 1,
  1817. { Path contains quad curves (at least one). }
  1818. Quads = 2,
  1819. { Path contains cubic curves (at least one). }
  1820. Cubics = 3,
  1821. { Path is invalid. }
  1822. Invalid = 30,
  1823. { Flags are dirty (not reflecting the current status). }
  1824. Dirty = 31);
  1825. TBLPathFlags = set of TBLPathFlag;
  1826. type
  1827. { Path reversal mode. }
  1828. TBLPathReverseMode = (
  1829. { Reverse each figure and their order as well (default). }
  1830. Complete = BL_PATH_REVERSE_MODE_COMPLETE,
  1831. { Reverse each figure separately (keeps their order). }
  1832. Separate = BL_PATH_REVERSE_MODE_SEPARATE);
  1833. type
  1834. { Stroke join type. }
  1835. TBLStrokeJoin = (
  1836. { Miter-join possibly clipped at MiterLimit [default]. }
  1837. MiterClip = BL_STROKE_JOIN_MITER_CLIP,
  1838. { Miter-join or bevel-join depending on MiterLimit condition. }
  1839. MiterBevel = BL_STROKE_JOIN_MITER_BEVEL,
  1840. { Miter-join or round-join depending on MiterLimit condition. }
  1841. MiterRound = BL_STROKE_JOIN_MITER_ROUND,
  1842. { Bevel-join. }
  1843. Bevel = BL_STROKE_JOIN_BEVEL,
  1844. { Round-join. }
  1845. Round = BL_STROKE_JOIN_ROUND);
  1846. type
  1847. { Position of a stroke-cap. }
  1848. TBLStrokeCapPosition = (
  1849. { Start of the path. }
  1850. Start = BL_STROKE_CAP_POSITION_START,
  1851. { End of the path. }
  1852. Finish = BL_STROKE_CAP_POSITION_END);
  1853. type
  1854. { A presentation attribute defining the shape to be used at the end of open
  1855. subpaths. }
  1856. TBLStrokeCap = (
  1857. { Butt cap [default]. }
  1858. Butt = BL_STROKE_CAP_BUTT,
  1859. { Square cap. }
  1860. Square = BL_STROKE_CAP_SQUARE,
  1861. { Round cap. }
  1862. Round = BL_STROKE_CAP_ROUND,
  1863. { Round cap reversed. }
  1864. RoundRev = BL_STROKE_CAP_ROUND_REV,
  1865. { Triangle cap. }
  1866. Triangle = BL_STROKE_CAP_TRIANGLE,
  1867. { Triangle cap reversed. }
  1868. TriangleRev = BL_STROKE_CAP_TRIANGLE_REV);
  1869. type
  1870. { Stroke transform order. }
  1871. TBLStrokeTransformOrder = (
  1872. { Transform after stroke => Transform(Stroke(Input)) [default]. }
  1873. After = BL_STROKE_TRANSFORM_ORDER_AFTER,
  1874. { Transform before stroke => Stroke(Transform(Input)). }
  1875. Before = BL_STROKE_TRANSFORM_ORDER_BEFORE);
  1876. type
  1877. { Mode that specifies how curves are approximated to line segments. }
  1878. TBLFlattenMode = (
  1879. { Use default mode (decided by Blend2D). }
  1880. Default = BL_FLATTEN_MODE_DEFAULT,
  1881. { Recursive subdivision flattening. }
  1882. Recursive = BL_FLATTEN_MODE_RECURSIVE);
  1883. type
  1884. { Mode that specifies how to construct offset curves. }
  1885. TBLOffsetMode = (
  1886. { Use default mode (decided by Blend2D). }
  1887. Default = BL_OFFSET_MODE_DEFAULT,
  1888. { Iterative offset construction. }
  1889. Iterative = BL_OFFSET_MODE_ITERATIVE);
  1890. type
  1891. { TODO : Implement once added to Blend2D }
  1892. TBLFitFlag = (_);
  1893. TBLFitFlags = set of TBLFitFlag;
  1894. { ============================================================================
  1895. [BLApproximationOptions]
  1896. ============================================================================ }
  1897. type
  1898. { Options used to describe how geometry is approximated.
  1899. This struct cannot be simply zeroed and then passed to functions that accept
  1900. approximation options. Use BLApproximationOptions.Default to setup defaults
  1901. and then alter values you want to change. }
  1902. TBLApproximationOptions = record
  1903. {$REGION 'Internal Declarations'}
  1904. private class var
  1905. FDefault: BLApproximationOptions;
  1906. private
  1907. FHandle: BLApproximationOptions;
  1908. function GetFlattenMode: TBLFlattenMode; inline;
  1909. function GetOffsetMode: TBLOffsetMode; inline;
  1910. procedure SetFlattenMode(const AValue: TBLFlattenMode); inline;
  1911. procedure SetOffsetMode(const AValue: TBLOffsetMode); inline;
  1912. private
  1913. class function GetDefault: TBLApproximationOptions; static;
  1914. public
  1915. class constructor Create;
  1916. {$ENDREGION 'Internal Declarations'}
  1917. public
  1918. { Specifies how curves are flattened }
  1919. property FlattenMode: TBLFlattenMode read GetFlattenMode write SetFlattenMode;
  1920. { Specifies how curves are offsetted (used by stroking) }
  1921. property OffsetMode: TBLOffsetMode read GetOffsetMode write SetOffsetMode;
  1922. { Tolerance used to flatten curves. }
  1923. property FlattenTolerance: Double read FHandle.flattenTolerance write FHandle.flattenTolerance;
  1924. { Tolerance used to approximatecubic curves qith quadratic curves. }
  1925. property SimplifyTolerance: Double read FHandle.simplifyTolerance write FHandle.simplifyTolerance;
  1926. { Curve offsetting parameter, exact meaning depends on OffsetMode. }
  1927. property OffsetParameter: Double read FHandle.offsetParameter write FHandle.offsetParameter;
  1928. { Default approximation options }
  1929. class property Default: TBLApproximationOptions read GetDefault;
  1930. end;
  1931. PBLApproximationOptions = ^TBLApproximationOptions;
  1932. { ============================================================================
  1933. [BLStrokeOptions]
  1934. ============================================================================ }
  1935. type
  1936. { Stroke options. }
  1937. TBLStrokeOptions = record
  1938. {$REGION 'Internal Declarations'}
  1939. private type
  1940. TScope = class(TInterfacedObject)
  1941. private
  1942. FHandle: PBLStrokeOptionsCore;
  1943. public
  1944. constructor Create(const AHandle: PBLStrokeOptionsCore);
  1945. destructor Destroy; override;
  1946. end;
  1947. private
  1948. FHandle: BLStrokeOptionsCore;
  1949. FScope: IInterface;
  1950. function GetStartCap: TBLStrokeCap; inline;
  1951. procedure SetStartCap(const AValue: TBLStrokeCap); inline;
  1952. function GetEndCap: TBLStrokeCap; inline;
  1953. procedure SetEndCap(const AValue: TBLStrokeCap); inline;
  1954. function GetJoin: TBLStrokeJoin; inline;
  1955. procedure SetJoin(const AValue: TBLStrokeJoin); inline;
  1956. function GetTransformOrder: TBLStrokeTransformOrder; inline;
  1957. procedure SetTransformOrder(const AValue: TBLStrokeTransformOrder); inline;
  1958. function GetDashArray: TArray<Double>; inline;
  1959. procedure SetDashArray(const AValue: TArray<Double>);
  1960. {$ENDREGION 'Internal Declarations'}
  1961. public
  1962. procedure Reset;
  1963. procedure SetCaps(const ACap: TBLStrokeCap); overload; inline;
  1964. procedure SetCaps(const AStartCap, AEndCap: TBLStrokeCap); overload; inline;
  1965. property StartCap: TBLStrokeCap read GetStartCap write SetStartCap;
  1966. property EndCap: TBLStrokeCap read GetEndCap write SetEndCap;
  1967. property Join: TBLStrokeJoin read GetJoin write SetJoin;
  1968. property TransformOrder: TBLStrokeTransformOrder read GetTransformOrder write SetTransformOrder;
  1969. property Width: Double read FHandle.width write FHandle.width;
  1970. property MiterLimit: Double read FHandle.miterLimit write FHandle.miterLimit;
  1971. property DashOffset: Double read FHandle.dashOffset write FHandle.dashOffset;
  1972. property DashArray: TArray<Double> read GetDashArray write SetDashArray;
  1973. end;
  1974. PBLStrokeOptions = ^TBLStrokeOptions;
  1975. { ============================================================================
  1976. [BLPath - View]
  1977. ============================================================================ }
  1978. type
  1979. { 2D path view provides pointers to vertex and command data along with their
  1980. size. }
  1981. TBLPathView = record
  1982. {$REGION 'Internal Declarations'}
  1983. private
  1984. FHandle: BLPathView;
  1985. function GetCommands: PBLPathCmd; inline;
  1986. function GetVertices: PBLPoint; inline;
  1987. function GetCount: Integer; inline;
  1988. {$ENDREGION 'Internal Declarations'}
  1989. public
  1990. procedure Reset; overload; inline;
  1991. procedure Reset(const ACommands: PBLPathCmd; const AVertices: PBLPoint;
  1992. const ACount: Integer); overload; inline;
  1993. property Commands: PBLPathCmd read GetCommands;
  1994. property Vertices: PBLPoint read GetVertices;
  1995. property Count: Integer read GetCount;
  1996. end;
  1997. PBLPathView = ^TBLPathView;
  1998. function BLPathView(const ACommands: PBLPathCmd; const AVertices: PBLPoint;
  1999. const ACount: Integer): TBLPathView; inline;
  2000. { ============================================================================
  2001. [BLPath]
  2002. ============================================================================ }
  2003. type
  2004. { 2D vector path }
  2005. IBLPath = interface
  2006. ['{18B368F9-0E76-4C83-9B21-06CDB127430E}']
  2007. {$REGION 'Internal Declarations'}
  2008. function GetIsNone: Boolean;
  2009. function GetIsEmpty: Boolean;
  2010. function GetCount: Integer;
  2011. function GetCapacity: Integer;
  2012. function GetVertexData: PBLPoint;
  2013. function GetVertexDataEnd: PBLPoint;
  2014. function GetLastVertex: TBLPoint;
  2015. function GetCommandData: PBLPathCmd;
  2016. function GetCommandDataEnd: PBLPathCmd;
  2017. function GetView: TBLPathView;
  2018. function GetInfoFlags: TBLPathFlags;
  2019. function GetControlBox: TBLBox;
  2020. function GetBoundingBox: TBLBox;
  2021. function GetFigureRange(const AIndex: Integer): TBLRange;
  2022. function GetHandle: PBLPathCore;
  2023. {$ENDREGION 'Internal Declarations'}
  2024. procedure Reset;
  2025. function Clone: IBLPath;
  2026. { Tests whether this path and the AOther path are equal.
  2027. The equality check is deep. The data of both paths is examined and binary
  2028. compared (thus a slight difference like -0 and +0 would make the equality
  2029. check to fail). }
  2030. function Equals(const AOther: IBLPath): Boolean;
  2031. { Clears the content of the path. }
  2032. procedure Clear;
  2033. { Shrinks the capacity of the path to fit the current usage. }
  2034. procedure Shrink;
  2035. { Reserves the capacity of the path for at least ACoount vertices and
  2036. commands. }
  2037. procedure Reserve(const ACount: Integer);
  2038. { Sets vertex at AIndex to ACmd and APt.
  2039. Set APreserve to True to preserve the current command.}
  2040. procedure SetVertexAt(const AIndex: Integer; const ACmd: TBLPathCmd;
  2041. const APt: TBLPoint; const APreserve: Boolean = False); overload;
  2042. { Sets vertex at AIndex to ACmd and [AX, AY].
  2043. Set APreserve to True to preserve the current command.}
  2044. procedure SetVertexAt(const AIndex: Integer; const ACmd: TBLPathCmd;
  2045. const AX, AY: Double; const APreserve: Boolean = False); overload;
  2046. { Moves to AP0.
  2047. Appends TBLPathCmd.Move[AP0] command to the path. }
  2048. procedure MoveTo(const AP0: TBLPoint); overload;
  2049. { Moves to [AX0, AY0].
  2050. Appends TBLPathCmd.Move[AX0, AY0] command to the path. }
  2051. procedure MoveTo(const AX0, AY0: Double); overload;
  2052. { Adds line to AP1.
  2053. Appends TBLPathCmd.On[AP1] command to the path. }
  2054. procedure LineTo(const AP1: TBLPoint); overload;
  2055. { Adds line to [AX1, AY1].
  2056. Appends TBLPathCmd.On[AX1, AY1] command to the path. }
  2057. procedure LineTo(const AX1, AY1: Double); overload;
  2058. { Adds a polyline (LineTo) of the given APoly array.
  2059. Appends multiple TBLPathCmd.On[X, Y] commands to the path depending. }
  2060. procedure PolyTo(const APoly: TArray<TBLPoint>); overload;
  2061. procedure PolyTo(const APoly: PBLPoint; const ACount: Integer); overload;
  2062. { Adds a quadratic curve to AP1 and AP2.
  2063. Appends the following commands to the path:
  2064. * TBLPathCmd.Quad[AP1]
  2065. * TBLPathCmd.On[AP2]
  2066. Matches SVG 'Q' path command:
  2067. https://www.w3.org/TR/SVG/paths.html#PathDataQuadraticBezierCommands }
  2068. procedure QuadTo(const AP1, AP2: TBLPoint); overload;
  2069. { Adds a quadratic curve to [AX1, AY1] and [AX2, AY2].
  2070. Appends the following commands to the path:
  2071. * TBLPathCmd.Quad[AX1, AY1]
  2072. * TBLPathCmd.On[AX2, AY2]
  2073. Matches SVG 'Q' path command:
  2074. https://www.w3.org/TR/SVG/paths.html#PathDataQuadraticBezierCommands }
  2075. procedure QuadTo(const AX1, AY1, AX2, AY2: Double); overload;
  2076. { Adds a cubic curve to AP1, AP2 and AP3.
  2077. Appends the following commands to the path:
  2078. * TBLPathCmd.Cubic[AP1]
  2079. * TBLPathCmd.Cubic[AP2]
  2080. * TBLPathCmd.On[AP3]
  2081. Matches SVG 'C' path command:
  2082. https://www.w3.org/TR/SVG/paths.html#PathDataCubicBezierCommands }
  2083. procedure CubicTo(const AP1, AP2, AP3: TBLPoint); overload;
  2084. { Adds a cubic curve to [AX1, AY1], [AX2, AY2] and [AX3, AY3].
  2085. Appends the following commands to the path:
  2086. * TBLPathCmd.Cubic[AX1, AY1]
  2087. * TBLPathCmd.Cubic[AX2, AY2]
  2088. * TBLPathCmd.On[AX3, AY3]
  2089. Matches SVG 'C' path command:
  2090. https://www.w3.org/TR/SVG/paths.html#PathDataCubicBezierCommands }
  2091. procedure CubicTo(const AX1, AY1, AX2, AY2, AX3, AY3: Double); overload;
  2092. { Adds a smooth quadratic curve to AP2, calculating AP1 from last points.
  2093. Appends the following commands to the path:
  2094. * TBLPathCmd.Quad[calculated]
  2095. * TBLPathCmd.On[AP2]
  2096. Matches SVG 'T' path command:
  2097. https://www.w3.org/TR/SVG/paths.html#PathDataQuadraticBezierCommands }
  2098. procedure SmoothQuadTo(const AP2: TBLPoint); overload;
  2099. { Adds a smooth quadratic curve to [AX2, AY2], calculating [AX1, AY1] from
  2100. last points.
  2101. Appends the following commands to the path:
  2102. * TBLPathCmd.Quad[calculated]
  2103. * TBLPathCmd.On[AX2, AY2]
  2104. Matches SVG 'T' path command:
  2105. https://www.w3.org/TR/SVG/paths.html#PathDataQuadraticBezierCommands }
  2106. procedure SmoothQuadTo(const AX2, AY2: Double); overload;
  2107. { Adds a smooth cubic curve to AP2 and AP3, calculating AP1 from last
  2108. points.
  2109. Appends the following commands to the path:
  2110. * TBLPathCmd.Cubic[calculated]
  2111. * TBLPathCmd.Cubic[AP2]
  2112. * TBLPathCmd.On[AP3]
  2113. Matches SVG 'S' path command:
  2114. https://www.w3.org/TR/SVG/paths.html#PathDataCubicBezierCommands }
  2115. procedure SmoothCubicTo(const AP2, AP3: TBLPoint); overload;
  2116. { Adds a smooth cubic curve to [AX2, AY2] and [AX3, AY3], calculating
  2117. [AX1, AY1] from last points.
  2118. Appends the following commands to the path:
  2119. * TBLPathCmd.Cubic[calculated]
  2120. * TBLPathCmd.Cubic[[AX2, AY2]]
  2121. * TBLPathCmd.On[[AX3, AY3]]
  2122. Matches SVG 'S' path command:
  2123. https://www.w3.org/TR/SVG/paths.html#PathDataCubicBezierCommands }
  2124. procedure SmoothCubicTo(const AX2, AY2, AX3, AY3: Double); overload;
  2125. { Adds an arc to the path.
  2126. The center of the arc is specified by AC and radius by AR. Both AStart
  2127. and ASweep angles are in radians. If the last vertex doesn't match the
  2128. start of the arc then a LineTo would be emitted before adding the arc.
  2129. Pass True in AForceMoveTo to always emit MoveTo at the beginning of the
  2130. arc, which starts a new figure. }
  2131. procedure ArcTo(const AC, AR: TBLPoint; const AStart, ASweep: Double;
  2132. const AForceMoveTo: Boolean = False); overload;
  2133. procedure ArcTo(const ACX, ACY, ARX, ARY, AStart, ASweep: Double;
  2134. const AForceMoveTo: Boolean = False); overload;
  2135. { Adds an arc quadrant (90deg) to the path. The first point AP1 specifies
  2136. the quadrant corner and the last point AP2 specifies the end point. }
  2137. procedure ArcQuadrantTo(const AP1, AP2: TBLPoint); overload;
  2138. procedure ArcQuadrantTo(const AX1, AY1, AX2, AY2: Double); overload;
  2139. { Adds an elliptic arc to the path that follows the SVG specification.
  2140. Matches SVG 'A' path command:
  2141. https://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands }
  2142. procedure EllipticArcTo(const ARP: TBLPoint; const AXAxisRotation: Double;
  2143. const ALargeArcFlag, ASweepFlag: Boolean; const AP1: TBLPoint); overload;
  2144. procedure EllipticArcTo(const ARX, ARY, AXAxisRotation: Double;
  2145. const ALargeArcFlag, ASweepFlag: Boolean; const AX1, AY1: Double); overload;
  2146. { Closes the current figure.
  2147. Appends TBLPathCmd.Close to the path.
  2148. Matches SVG 'Z' path command:
  2149. https://www.w3.org/TR/SVG/paths.html#PathDataClosePathCommand }
  2150. procedure Close;
  2151. { Adds a closed rectangle to the path specified by ABox. }
  2152. procedure AddBox(const ABox: TBLBoxI;
  2153. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2154. procedure AddBox(const ABox: TBLBox;
  2155. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2156. { Adds a closed rectangle to the path specified by [AX0, AY0, AX1, AY1]. }
  2157. procedure AddBox(const AX0, AY0, AX1, AY1: Double;
  2158. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2159. { Adds a closed rectangle to the path specified by ARect. }
  2160. procedure AddRect(const ARect: TBLRectI;
  2161. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2162. procedure AddRect(const ARect: TBLRect;
  2163. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2164. { Adds a closed rectangle to the path specified by [AX, AY, AW, AH]. }
  2165. procedure AddRect(const AX, AY, AW, AH: Double;
  2166. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2167. { Adds a geometry to the path. }
  2168. procedure AddGeometry(const AGeometryType: TBLGeometryType;
  2169. const AGeometryData: Pointer; const AMatrix: PBLMatrix2D = nil;
  2170. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW);
  2171. { Adds a closed circle to the path. }
  2172. procedure AddCircle(const ACircle: TBLCircle;
  2173. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2174. procedure AddCircle(const ACircle: TBLCircle; const AMatrix: TBLMatrix2D;
  2175. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2176. { Adds a closed ellipse to the path. }
  2177. procedure AddEllipse(const AEllipse: TBLEllipse;
  2178. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2179. procedure AddEllipse(const AEllipse: TBLEllipse; const AMatrix: TBLMatrix2D;
  2180. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2181. { Adds a closed rounded ractangle to the path. }
  2182. procedure AddRoundRect(const ARoundRect: TBLRoundRect;
  2183. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2184. procedure AddRoundRect(const ARoundRect: TBLRoundRect; const AMatrix: TBLMatrix2D;
  2185. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2186. { Adds an open arc to the path. }
  2187. procedure AddArc(const AArc: TBLArc;
  2188. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2189. procedure AddArc(const AArc: TBLArc; const AMatrix: TBLMatrix2D;
  2190. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2191. { Adds a closed chord to the path. }
  2192. procedure AddChord(const AChord: TBLArc;
  2193. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2194. procedure AddChord(const AChord: TBLArc; const AMatrix: TBLMatrix2D;
  2195. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2196. { Adds a closed pie to the path. }
  2197. procedure AddPie(const APie: TBLArc;
  2198. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2199. procedure AddPie(const APie: TBLArc; const AMatrix: TBLMatrix2D;
  2200. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2201. { Adds an open line to the path. }
  2202. procedure AddLine(const ALine: TBLLine;
  2203. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2204. procedure AddLine(const ALine: TBLLine; const AMatrix: TBLMatrix2D;
  2205. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2206. { Adds a closed triangle. }
  2207. procedure AddTriangle(const ATriangle: TBLTriangle;
  2208. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2209. procedure AddTriangle(const ATriangle: TBLTriangle; const AMatrix: TBLMatrix2D;
  2210. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2211. { Adds a polyline. }
  2212. procedure AddPolyline(const APolyline: TBLArrayView<TBLPointI>;
  2213. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2214. procedure AddPolyline(const APolyline: TBLArrayView<TBLPointI>;
  2215. const AMatrix: TBLMatrix2D;
  2216. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2217. procedure AddPolyline(const APolyline: PBLPointI; const ACount: Integer;
  2218. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2219. procedure AddPolyline(const APolyline: PBLPointI; const ACount: Integer;
  2220. const AMatrix: TBLMatrix2D;
  2221. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2222. procedure AddPolyline(const APolyline: TBLArrayView<TBLPoint>;
  2223. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2224. procedure AddPolyline(const APolyline: TBLArrayView<TBLPoint>;
  2225. const AMatrix: TBLMatrix2D;
  2226. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2227. procedure AddPolyline(const APolyline: PBLPoint; const ACount: Integer;
  2228. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2229. procedure AddPolyline(const APolyline: PBLPoint; const ACount: Integer;
  2230. const AMatrix: TBLMatrix2D;
  2231. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2232. { Adds a polygon. }
  2233. procedure AddPolygon(const APolygon: TBLArrayView<TBLPointI>;
  2234. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2235. procedure AddPolygon(const APolygon: TBLArrayView<TBLPointI>;
  2236. const AMatrix: TBLMatrix2D;
  2237. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2238. procedure AddPolygon(const APolygon: PBLPointI; const ACount: Integer;
  2239. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2240. procedure AddPolygon(const APolygon: PBLPointI; const ACount: Integer;
  2241. const AMatrix: TBLMatrix2D;
  2242. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2243. procedure AddPolygon(const APolygon: TBLArrayView<TBLPoint>;
  2244. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2245. procedure AddPolygon(const APolygon: TBLArrayView<TBLPoint>;
  2246. const AMatrix: TBLMatrix2D;
  2247. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2248. procedure AddPolygon(const APolygon: PBLPoint; const ACount: Integer;
  2249. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2250. procedure AddPolygon(const APolygon: PBLPoint; const ACount: Integer;
  2251. const AMatrix: TBLMatrix2D;
  2252. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2253. { Adds an array of closed boxes. }
  2254. procedure AddBoxArray(const ABoxes: TBLArrayView<TBLBoxI>;
  2255. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2256. procedure AddBoxArray(const ABoxes: TBLArrayView<TBLBoxI>;
  2257. const AMatrix: TBLMatrix2D;
  2258. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2259. procedure AddBoxArray(const ABoxes: PBLBoxI; const ACount: Integer;
  2260. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2261. procedure AddBoxArray(const ABoxes: PBLBoxI; const ACount: Integer;
  2262. const AMatrix: TBLMatrix2D;
  2263. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2264. procedure AddBoxArray(const ABoxes: TBLArrayView<TBLBox>;
  2265. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2266. procedure AddBoxArray(const ABoxes: TBLArrayView<TBLBox>;
  2267. const AMatrix: TBLMatrix2D;
  2268. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2269. procedure AddBoxArray(const ABoxes: PBLBox; const ACount: Integer;
  2270. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2271. procedure AddBoxArray(const ABoxes: PBLBox; const ACount: Integer;
  2272. const AMatrix: TBLMatrix2D;
  2273. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2274. { Adds an array of closed rectangles. }
  2275. procedure AddRectArray(const ARects: TBLArrayView<TBLRectI>;
  2276. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2277. procedure AddRectArray(const ARects: TBLArrayView<TBLRectI>;
  2278. const AMatrix: TBLMatrix2D;
  2279. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2280. procedure AddRectArray(const ARects: PBLRectI; const ACount: Integer;
  2281. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2282. procedure AddRectArray(const ARects: PBLRectI; const ACount: Integer;
  2283. const AMatrix: TBLMatrix2D;
  2284. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2285. procedure AddRectArray(const ARects: TBLArrayView<TBLRect>;
  2286. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2287. procedure AddRectArray(const ARects: TBLArrayView<TBLRect>;
  2288. const AMatrix: TBLMatrix2D;
  2289. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2290. procedure AddRectArray(const ARects: PBLRect; const ACount: Integer;
  2291. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2292. procedure AddRectArray(const ARects: PBLRect; const ACount: Integer;
  2293. const AMatrix: TBLMatrix2D;
  2294. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2295. { Adds a closed region (converted to set of rectangles). }
  2296. procedure AddRegion(const ARegion: IBLRegion;
  2297. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2298. procedure AddRegion(const ARegion: IBLRegion; const AMatrix: TBLMatrix2D;
  2299. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2300. { Adds other APath to this path. }
  2301. procedure AddPath(const APath: IBLPath); overload;
  2302. { Adds other APath sliced by the given ARange to this path. }
  2303. procedure AddPath(const APath: IBLPath; const ARange: TBLRange); overload;
  2304. { Adds other APath translated by ATranslate to this path. }
  2305. procedure AddPath(const APath: IBLPath; const ATranslate: TBLPoint); overload;
  2306. { Adds other APath translated by ATranslate and sliced by the given ARange
  2307. to this path. }
  2308. procedure AddPath(const APath: IBLPath; const ARange: TBLRange;
  2309. const ATranslate: TBLPoint); overload;
  2310. { Adds other APath transformed by AMatrix to this path. }
  2311. procedure AddPath(const APath: IBLPath; const AMatrix: TBLMatrix2D); overload;
  2312. { Adds other APath transformed by AMatrix and sliced by the given ARange to
  2313. this path. }
  2314. procedure AddPath(const APath: IBLPath; const ARange: TBLRange;
  2315. const AMatrix: TBLMatrix2D); overload;
  2316. { Adds other APath, but reversed. }
  2317. procedure AddReversedPath(const APath: IBLPath;
  2318. const AReverseMode: TBLPathReverseMode); overload;
  2319. procedure AddReversedPath(const APath: IBLPath; const ARange: TBLRange;
  2320. const AReverseMode: TBLPathReverseMode); overload;
  2321. { Adds a stroke of APath to this path. }
  2322. procedure AddStrokedPath(const APath: IBLPath;
  2323. const AStrokeOptions: TBLStrokeOptions;
  2324. const AApproximationOptions: TBLApproximationOptions); overload;
  2325. procedure AddStrokedPath(const APath: IBLPath; const ARange: TBLRange;
  2326. const AStrokeOptions: TBLStrokeOptions;
  2327. const AApproximationOptions: TBLApproximationOptions); overload;
  2328. { Manipulation }
  2329. procedure RemoveRange(const ARange: TBLRange);
  2330. { Translates the whole path by AP. }
  2331. procedure Translate(const AP: TBLPoint); overload;
  2332. { Translates a part of the path specified by the given ARange by AP. }
  2333. procedure Translate(const ARange: TBLRange; const AP: TBLPoint); overload;
  2334. { Transforms the whole path by AMatrix. }
  2335. procedure Transform(const AMatrix: TBLMatrix2D); overload;
  2336. { Transforms a part of the path specified by the given ARange by AMatrix. }
  2337. procedure Transform(const ARange: TBLRange; const AMatrix: TBLMatrix2D); overload;
  2338. { Fits the whole path into the given ARect by taking into account fit flags
  2339. passed by AFitFlags. }
  2340. procedure FitTo(const ARect: TBLRect; const AFitFlags: TBLFitFlags = []); overload;
  2341. { Fits a part of the path specified by the given ARange into the given ARect
  2342. by taking into account fit flags passed by AFitFlags. }
  2343. procedure FitTo(const ARange: TBLRange; const ARect: TBLRect;
  2344. const AFitFlags: TBLFitFlags = []); overload;
  2345. function GetClosestVertex(const AP: TBLPoint; const AMaxDistance: Double): Integer; overload;
  2346. function GetClosestVertex(const AP: TBLPoint; const AMaxDistance: Double;
  2347. out AActualDistance: Double): Integer; overload;
  2348. { Hit tests the given point AP by respecting the given AFillRule. }
  2349. function HitTest(const AP: TBLPoint; const AFillRule: TBLFillRule): TBLHitTest;
  2350. { Tests whether the 2D path is a built-in nil instance. }
  2351. property IsNone: Boolean read GetIsNone;
  2352. { Tests whether the 2D path is empty (its size equals zero). }
  2353. property IsEmpty: Boolean read GetIsEmpty;
  2354. { Count of vertices used }
  2355. property Count: Integer read GetCount;
  2356. { Path capacity (count of allocated vertices) }
  2357. property Capacity: Integer read GetCapacity;
  2358. { Path's vertex data (read-only). }
  2359. property VertexData: PBLPoint read GetVertexData;
  2360. { End of path's vertex data (read-only). }
  2361. property VertexDataEnd: PBLPoint read GetVertexDataEnd;
  2362. { The last vertex of the path. If the very last command of the path is
  2363. TBLPathCmd.Close then the path will be iterated in reverse order to match
  2364. the initial vertex of the last figure. }
  2365. property LastVertex: TBLPoint read GetLastVertex;
  2366. { Path's command data (read-only). }
  2367. property CommandData: PBLPathCmd read GetCommandData;
  2368. { End of path's command data (read-only). }
  2369. property CommandDataEnd: PBLPathCmd read GetCommandDataEnd;
  2370. { The path data as a read-only TBLPathView. }
  2371. property View: TBLPathView read GetView;
  2372. { Update a path information if necessary. }
  2373. property InfoFlags: TBLPathFlags read GetInfoFlags;
  2374. { The bounding box of all vertices and control points.
  2375. Control box is simply bounds of all vertices the path has without further
  2376. processing. It contains both on-path and off-path points. Consider using
  2377. BoundingBox if you need a visual bounding box. }
  2378. property ControlBox: TBLBox read GetControlBox;
  2379. { The bounding box of all on-path vertices and curve extremas.
  2380. The bounding box could be smaller than a bounding box obtained by
  2381. ControlBox as it's calculated by merging only start/end points and curves
  2382. at their extremas (not control points). The resulting bounding box
  2383. represents a visual bounds of the path. }
  2384. property BoundingBox: TBLBox read GetBoundingBox;
  2385. { The range describing figures at the given AIndex. }
  2386. property FigureRanges[const AIndex: Integer]: TBLRange read GetFigureRange;
  2387. { Internal handle for use with the C API }
  2388. property Handle: PBLPathCore read GetHandle;
  2389. end;
  2390. type
  2391. { Optional callback that can be used to consume a path data. }
  2392. TBLPathSinkEvent = function(const APath: IBLPath; const AInfo: Pointer): TBLResultCode of object;
  2393. type
  2394. { Implements IBLPath }
  2395. TBLPath = class(TInterfacedObject, IBLPath)
  2396. {$REGION 'Internal Declarations'}
  2397. private
  2398. FHandle: BLPathCore;
  2399. protected
  2400. { IBLPath }
  2401. function GetIsNone: Boolean;
  2402. function GetIsEmpty: Boolean;
  2403. function GetCount: Integer;
  2404. function GetCapacity: Integer;
  2405. function GetVertexData: PBLPoint;
  2406. function GetVertexDataEnd: PBLPoint;
  2407. function GetLastVertex: TBLPoint;
  2408. function GetCommandData: PBLPathCmd;
  2409. function GetCommandDataEnd: PBLPathCmd;
  2410. function GetView: TBLPathView;
  2411. function GetInfoFlags: TBLPathFlags;
  2412. function GetControlBox: TBLBox;
  2413. function GetBoundingBox: TBLBox;
  2414. function GetFigureRange(const AIndex: Integer): TBLRange;
  2415. function GetHandle: PBLPathCore;
  2416. procedure Reset;
  2417. function Clone: IBLPath;
  2418. function Equals(const AOther: IBLPath): Boolean; reintroduce; overload;
  2419. procedure Clear;
  2420. procedure Shrink;
  2421. procedure Reserve(const ACount: Integer);
  2422. procedure SetVertexAt(const AIndex: Integer; const ACmd: TBLPathCmd;
  2423. const APt: TBLPoint; const APreserve: Boolean = False); overload;
  2424. procedure SetVertexAt(const AIndex: Integer; const ACmd: TBLPathCmd;
  2425. const AX, AY: Double; const APreserve: Boolean = False); overload;
  2426. procedure MoveTo(const AP0: TBLPoint); overload;
  2427. procedure MoveTo(const AX0, AY0: Double); overload;
  2428. procedure LineTo(const AP1: TBLPoint); overload;
  2429. procedure LineTo(const AX1, AY1: Double); overload;
  2430. procedure PolyTo(const APoly: TArray<TBLPoint>); overload;
  2431. procedure PolyTo(const APoly: PBLPoint; const ACount: Integer); overload;
  2432. procedure QuadTo(const AP1, AP2: TBLPoint); overload;
  2433. procedure QuadTo(const AX1, AY1, AX2, AY2: Double); overload;
  2434. procedure CubicTo(const AP1, AP2, AP3: TBLPoint); overload;
  2435. procedure CubicTo(const AX1, AY1, AX2, AY2, AX3, AY3: Double); overload;
  2436. procedure SmoothQuadTo(const AP2: TBLPoint); overload;
  2437. procedure SmoothQuadTo(const AX2, AY2: Double); overload;
  2438. procedure SmoothCubicTo(const AP2, AP3: TBLPoint); overload;
  2439. procedure SmoothCubicTo(const AX2, AY2, AX3, AY3: Double); overload;
  2440. procedure ArcTo(const AC, AR: TBLPoint; const AStart, ASweep: Double;
  2441. const AForceMoveTo: Boolean = False); overload;
  2442. procedure ArcTo(const ACX, ACY, ARX, ARY, AStart, ASweep: Double;
  2443. const AForceMoveTo: Boolean = False); overload;
  2444. procedure ArcQuadrantTo(const AP1, AP2: TBLPoint); overload;
  2445. procedure ArcQuadrantTo(const AX1, AY1, AX2, AY2: Double); overload;
  2446. procedure EllipticArcTo(const ARP: TBLPoint; const AXAxisRotation: Double;
  2447. const ALargeArcFlag, ASweepFlag: Boolean; const AP1: TBLPoint); overload;
  2448. procedure EllipticArcTo(const ARX, ARY, AXAxisRotation: Double;
  2449. const ALargeArcFlag, ASweepFlag: Boolean; const AX1, AY1: Double); overload;
  2450. procedure Close;
  2451. procedure AddBox(const ABox: TBLBoxI;
  2452. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2453. procedure AddBox(const ABox: TBLBox;
  2454. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2455. procedure AddBox(const AX0, AY0, AX1, AY1: Double;
  2456. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2457. procedure AddRect(const ARect: TBLRectI;
  2458. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2459. procedure AddRect(const ARect: TBLRect;
  2460. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2461. procedure AddRect(const AX, AY, AW, AH: Double;
  2462. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2463. procedure AddGeometry(const AGeometryType: TBLGeometryType;
  2464. const AGeometryData: Pointer; const AMatrix: PBLMatrix2D = nil;
  2465. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW);
  2466. procedure AddCircle(const ACircle: TBLCircle;
  2467. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2468. procedure AddCircle(const ACircle: TBLCircle; const AMatrix: TBLMatrix2D;
  2469. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2470. procedure AddEllipse(const AEllipse: TBLEllipse;
  2471. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2472. procedure AddEllipse(const AEllipse: TBLEllipse; const AMatrix: TBLMatrix2D;
  2473. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2474. procedure AddRoundRect(const ARoundRect: TBLRoundRect;
  2475. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2476. procedure AddRoundRect(const ARoundRect: TBLRoundRect; const AMatrix: TBLMatrix2D;
  2477. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2478. procedure AddArc(const AArc: TBLArc;
  2479. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2480. procedure AddArc(const AArc: TBLArc; const AMatrix: TBLMatrix2D;
  2481. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2482. procedure AddChord(const AChord: TBLArc;
  2483. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2484. procedure AddChord(const AChord: TBLArc; const AMatrix: TBLMatrix2D;
  2485. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2486. procedure AddPie(const APie: TBLArc;
  2487. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2488. procedure AddPie(const APie: TBLArc; const AMatrix: TBLMatrix2D;
  2489. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2490. procedure AddLine(const ALine: TBLLine;
  2491. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2492. procedure AddLine(const ALine: TBLLine; const AMatrix: TBLMatrix2D;
  2493. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2494. procedure AddTriangle(const ATriangle: TBLTriangle;
  2495. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2496. procedure AddTriangle(const ATriangle: TBLTriangle; const AMatrix: TBLMatrix2D;
  2497. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2498. procedure AddPolyline(const APolyline: TBLArrayView<TBLPointI>;
  2499. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2500. procedure AddPolyline(const APolyline: TBLArrayView<TBLPointI>;
  2501. const AMatrix: TBLMatrix2D;
  2502. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2503. procedure AddPolyline(const APolyline: PBLPointI; const ACount: Integer;
  2504. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2505. procedure AddPolyline(const APolyline: PBLPointI; const ACount: Integer;
  2506. const AMatrix: TBLMatrix2D;
  2507. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2508. procedure AddPolyline(const APolyline: TBLArrayView<TBLPoint>;
  2509. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2510. procedure AddPolyline(const APolyline: TBLArrayView<TBLPoint>;
  2511. const AMatrix: TBLMatrix2D;
  2512. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2513. procedure AddPolyline(const APolyline: PBLPoint; const ACount: Integer;
  2514. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2515. procedure AddPolyline(const APolyline: PBLPoint; const ACount: Integer;
  2516. const AMatrix: TBLMatrix2D;
  2517. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2518. procedure AddPolygon(const APolygon: TBLArrayView<TBLPointI>;
  2519. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2520. procedure AddPolygon(const APolygon: TBLArrayView<TBLPointI>;
  2521. const AMatrix: TBLMatrix2D;
  2522. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2523. procedure AddPolygon(const APolygon: PBLPointI; const ACount: Integer;
  2524. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2525. procedure AddPolygon(const APolygon: PBLPointI; const ACount: Integer;
  2526. const AMatrix: TBLMatrix2D;
  2527. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2528. procedure AddPolygon(const APolygon: TBLArrayView<TBLPoint>;
  2529. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2530. procedure AddPolygon(const APolygon: TBLArrayView<TBLPoint>;
  2531. const AMatrix: TBLMatrix2D;
  2532. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2533. procedure AddPolygon(const APolygon: PBLPoint; const ACount: Integer;
  2534. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2535. procedure AddPolygon(const APolygon: PBLPoint; const ACount: Integer;
  2536. const AMatrix: TBLMatrix2D;
  2537. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2538. procedure AddBoxArray(const ABoxes: TBLArrayView<TBLBoxI>;
  2539. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2540. procedure AddBoxArray(const ABoxes: TBLArrayView<TBLBoxI>;
  2541. const AMatrix: TBLMatrix2D;
  2542. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2543. procedure AddBoxArray(const ABoxes: PBLBoxI; const ACount: Integer;
  2544. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2545. procedure AddBoxArray(const ABoxes: PBLBoxI; const ACount: Integer;
  2546. const AMatrix: TBLMatrix2D;
  2547. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2548. procedure AddBoxArray(const ABoxes: TBLArrayView<TBLBox>;
  2549. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2550. procedure AddBoxArray(const ABoxes: TBLArrayView<TBLBox>;
  2551. const AMatrix: TBLMatrix2D;
  2552. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2553. procedure AddBoxArray(const ABoxes: PBLBox; const ACount: Integer;
  2554. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2555. procedure AddBoxArray(const ABoxes: PBLBox; const ACount: Integer;
  2556. const AMatrix: TBLMatrix2D;
  2557. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2558. procedure AddRectArray(const ARects: TBLArrayView<TBLRectI>;
  2559. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2560. procedure AddRectArray(const ARects: TBLArrayView<TBLRectI>;
  2561. const AMatrix: TBLMatrix2D;
  2562. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2563. procedure AddRectArray(const ARects: PBLRectI; const ACount: Integer;
  2564. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2565. procedure AddRectArray(const ARects: PBLRectI; const ACount: Integer;
  2566. const AMatrix: TBLMatrix2D;
  2567. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2568. procedure AddRectArray(const ARects: TBLArrayView<TBLRect>;
  2569. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2570. procedure AddRectArray(const ARects: TBLArrayView<TBLRect>;
  2571. const AMatrix: TBLMatrix2D;
  2572. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2573. procedure AddRectArray(const ARects: PBLRect; const ACount: Integer;
  2574. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2575. procedure AddRectArray(const ARects: PBLRect; const ACount: Integer;
  2576. const AMatrix: TBLMatrix2D;
  2577. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2578. procedure AddRegion(const ARegion: IBLRegion;
  2579. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2580. procedure AddRegion(const ARegion: IBLRegion; const AMatrix: TBLMatrix2D;
  2581. const ADirection: TBLGeometryDirection = TBLGeometryDirection.CW); overload;
  2582. procedure AddPath(const APath: IBLPath); overload;
  2583. procedure AddPath(const APath: IBLPath; const ARange: TBLRange); overload;
  2584. procedure AddPath(const APath: IBLPath; const ATranslate: TBLPoint); overload;
  2585. procedure AddPath(const APath: IBLPath; const ARange: TBLRange;
  2586. const ATranslate: TBLPoint); overload;
  2587. procedure AddPath(const APath: IBLPath; const AMatrix: TBLMatrix2D); overload;
  2588. procedure AddPath(const APath: IBLPath; const ARange: TBLRange;
  2589. const AMatrix: TBLMatrix2D); overload;
  2590. procedure AddReversedPath(const APath: IBLPath;
  2591. const AReverseMode: TBLPathReverseMode); overload;
  2592. procedure AddReversedPath(const APath: IBLPath; const ARange: TBLRange;
  2593. const AReverseMode: TBLPathReverseMode); overload;
  2594. procedure AddStrokedPath(const APath: IBLPath;
  2595. const AStrokeOptions: TBLStrokeOptions;
  2596. const AApproximationOptions: TBLApproximationOptions); overload;
  2597. procedure AddStrokedPath(const APath: IBLPath; const ARange: TBLRange;
  2598. const AStrokeOptions: TBLStrokeOptions;
  2599. const AApproximationOptions: TBLApproximationOptions); overload;
  2600. procedure RemoveRange(const ARange: TBLRange);
  2601. procedure Translate(const AP: TBLPoint); overload;
  2602. procedure Translate(const ARange: TBLRange; const AP: TBLPoint); overload;
  2603. procedure Transform(const AMatrix: TBLMatrix2D); overload;
  2604. procedure Transform(const ARange: TBLRange; const AMatrix: TBLMatrix2D); overload;
  2605. procedure FitTo(const ARect: TBLRect; const AFitFlags: TBLFitFlags = []); overload;
  2606. procedure FitTo(const ARange: TBLRange; const ARect: TBLRect;
  2607. const AFitFlags: TBLFitFlags = []); overload;
  2608. function GetClosestVertex(const AP: TBLPoint; const AMaxDistance: Double): Integer; overload;
  2609. function GetClosestVertex(const AP: TBLPoint; const AMaxDistance: Double;
  2610. out AActualDistance: Double): Integer; overload;
  2611. function HitTest(const AP: TBLPoint; const AFillRule: TBLFillRule): TBLHitTest;
  2612. {$ENDREGION 'Internal Declarations'}
  2613. public
  2614. constructor Create;
  2615. destructor Destroy; override;
  2616. function Equals(Obj: TObject): Boolean; overload; override;
  2617. end;
  2618. {$ENDREGION 'Path'}
  2619. {$REGION 'Format'}
  2620. { ============================================================================
  2621. [Enums]
  2622. ============================================================================ }
  2623. type
  2624. { Pixel format.
  2625. Compatibility Table
  2626. -------------------
  2627. +---------------------+---------------------+-----------------------------+
  2628. | Blend2D Format | Cairo Format | QImage::Format |
  2629. +---------------------+---------------------+-----------------------------+
  2630. | BL_FORMAT_PRGB32 | CAIRO_FORMAT_ARGB32 | Format_ARGB32_Premultiplied |
  2631. | BL_FORMAT_XRGB32 | CAIRO_FORMAT_RGB24 | Format_RGB32 |
  2632. | BL_FORMAT_A8 | CAIRO_FORMAT_A8 | n/a |
  2633. +---------------------+---------------------+-----------------------------+ }
  2634. TBLFormat = (
  2635. { None or invalid pixel format. }
  2636. None = BL_FORMAT_NONE,
  2637. { 32-bit premultiplied ARGB pixel format (8-bit components). }
  2638. PRGB32 = BL_FORMAT_PRGB32,
  2639. { 32-bit (X)RGB pixel format (8-bit components, alpha ignored). }
  2640. XRGB32 = BL_FORMAT_XRGB32,
  2641. { 8-bit alpha-only pixel format. }
  2642. A8 = BL_FORMAT_A8);
  2643. type
  2644. { Pixel format flags. }
  2645. TBLFormatFlag = (
  2646. { Pixel format provides RGB components. }
  2647. RGB = 0,
  2648. { Pixel format provides only alpha component. }
  2649. Alpha = 1,
  2650. { Pixel format provides LUM component (and not RGB components). }
  2651. LUM = 2,
  2652. { Indexed pixel format the requres a palette (I/O only). }
  2653. Indexed = 4,
  2654. { RGB components are premultiplied by alpha component. }
  2655. Premultiplied = 8,
  2656. { Pixel format doesn't use native byte-order (I/O only). }
  2657. ByteSwap = 9,
  2658. { The following flags are only informative. They are part of BLFormatInfo,
  2659. but doesn't have to be passed to IBLPixelConverter as they can be easily
  2660. calculated. }
  2661. { Pixel components are byte aligned (all 8bpp). }
  2662. ByteAligned = 16,
  2663. { Pixel has some undefined bits that represent no information.
  2664. For example a 32-bit XRGB pixel has 8 undefined bits that are usually set
  2665. to all ones so the format can be interpreted as premultiplied RGB as well.
  2666. There are other formats like 16_0555 where the bit has no information and
  2667. is usually set to zero. Blend2D doesn't rely on the content of such bits. }
  2668. UndefinedBits = 17,
  2669. { Little-endian format.
  2670. Note: This is not a real flag that you can test, it's only provided for
  2671. convenience to define little endian pixel formats. }
  2672. LittleEndian = 0,
  2673. { Big-endian format.
  2674. Note: This is not a real flag that you can test, it's only provided for
  2675. convenience to define little endian pixel formats. }
  2676. BigEndian = ByteSwap);
  2677. TBLFormatFlags = set of TBLFormatFlag;
  2678. type
  2679. _TBLFormatFlagsHelper = record helper for TBLFormatFlags
  2680. public const
  2681. { Pixel format provides RGB and Alpha components. }
  2682. RGBA = [TBLFormatFlag.RGB, TBLFormatFlag.Alpha];
  2683. { Pixel format provides LUM and Alpha components (and not RGB components). }
  2684. LUMA = [TBLFormatFlag.LUM, TBLFormatFlag.Alpha];
  2685. end;
  2686. { ============================================================================
  2687. [BLFormatInfo]
  2688. ============================================================================ }
  2689. type
  2690. { Provides a detailed information about a pixel format. Use the TBLFormat.Info
  2691. property to get information of Blend2D native pixel formats. }
  2692. TBLFormatInfo = record
  2693. {$REGION 'Internal Declarations'}
  2694. private
  2695. FHandle: BLFormatInfo;
  2696. function GetFlags: TBLFormatFlags; inline;
  2697. procedure SetFlags(const AValue: TBLFormatFlags); inline;
  2698. function GetPalette: PBLRgba32; inline;
  2699. {$ENDREGION 'Internal Declarations'}
  2700. public
  2701. class operator Equal(const ALeft, ARight: TBLFormatInfo): Boolean; inline; static;
  2702. class operator NotEqual(const ALeft, ARight: TBLFormatInfo): Boolean; inline; static;
  2703. public
  2704. procedure Reset; overload; inline;
  2705. procedure Reset(const ADepth: Integer; const AFlags: TBLFormatFlags;
  2706. const ARSize, AGSize, ABSize, AASize, ARShift, AGShift, ABShift,
  2707. AAShift: Byte); overload; inline;
  2708. procedure SetSizes(const ARSize, AGSize, ABSize, AASize: Byte); inline;
  2709. procedure SetShifts(const ARShift, AGShift, ABShift, AAShift: Byte); inline;
  2710. { Query Blend2D AFormat and copy it to this format info.
  2711. Raises TBLResultCode.InvalidValue if the format is invalid (and resets
  2712. this record in that case).
  2713. Note: TBLFormat.None is considered an invalid format, thus if it's passed
  2714. to Query, a TBLResultCode.InvalidValue error is raised. }
  2715. procedure Query(const AFormat: TBLFormat);
  2716. { Sanitize this record.
  2717. Sanitizer verifies whether the format is valid and updates the format
  2718. information about flags to values that Blend2D expects. For example
  2719. format flags are properly examined and simplified if possible, byte-swap
  2720. is implicitly performed for formats where a single component matches one
  2721. byte, etc... }
  2722. procedure Sanitize;
  2723. property Depth: Integer read FHandle.depth write FHandle.depth;
  2724. property Flags: TBLFormatFlags read GetFlags write SetFlags;
  2725. property RedSize: Byte read FHandle.rSize write FHandle.rSize;
  2726. property GreenSize: Byte read FHandle.gSize write FHandle.gSize;
  2727. property BlueSize: Byte read FHandle.bSize write FHandle.bSize;
  2728. property AlphaSize: Byte read FHandle.aSize write FHandle.aSize;
  2729. property RedShift: Byte read FHandle.rShift write FHandle.rShift;
  2730. property GreenShift: Byte read FHandle.gShift write FHandle.gShift;
  2731. property BlueShift: Byte read FHandle.bShift write FHandle.bShift;
  2732. property AlphaShift: Byte read FHandle.aShift write FHandle.aShift;
  2733. property Palette: PBLRgba32 read GetPalette;
  2734. end;
  2735. PBLFormatInfo = ^TBLFormatInfo;
  2736. type
  2737. { Additional information about pixel formats }
  2738. _TBLFormatHelper = record helper for TBLFormat
  2739. {$REGION 'Internal Declarations'}
  2740. private
  2741. function GetInfo: TBLFormatInfo;
  2742. {$ENDREGION 'Internal Declarations'}
  2743. public
  2744. { Information about this pixel format }
  2745. property Info: TBLFormatInfo read GetInfo;
  2746. end;
  2747. {$ENDREGION 'Format'}
  2748. {$REGION 'Image'}
  2749. { ============================================================================
  2750. [BLImage - Enums]
  2751. ============================================================================ }
  2752. type
  2753. { Flags used by TBLImageInfo. }
  2754. TBLImageInfoFlag = (
  2755. { Progressive mode. }
  2756. Progressive = 0);
  2757. TBLImageInfoFlags = set of TBLImageInfoFlag;
  2758. { ============================================================================
  2759. [BLImage - Info]
  2760. ============================================================================ }
  2761. type
  2762. { Image information provided by image codecs. }
  2763. TBLImageInfo = record
  2764. {$REGION 'Internal Declarations'}
  2765. private
  2766. FHandle: BLImageInfo;
  2767. function GetCompression: String; inline;
  2768. function GetDensity: TBLSize; inline;
  2769. function GetDepth: Integer; inline;
  2770. function GetFlags: TBLFormatFlags; inline;
  2771. function GetFormat: String; inline;
  2772. function GetFrameCount: Integer; inline;
  2773. function GetPlaneCount: Integer; inline;
  2774. function GetSize: TBLSizeI; inline;
  2775. {$ENDREGION 'Internal Declarations'}
  2776. public
  2777. procedure Reset; inline;
  2778. { Image size. }
  2779. property Size: TBLSizeI read GetSize;
  2780. { Pixel density per one meter, can contain fractions. }
  2781. property Density: TBLSize read GetDensity;
  2782. { Image flags. }
  2783. property Flags: TBLFormatFlags read GetFlags;
  2784. { Image depth. }
  2785. property Depth: Integer read GetDepth;
  2786. { Number of planes. }
  2787. property PlaneCount: Integer read GetPlaneCount;
  2788. { Number of frames (0 = unknown/unspecified). }
  2789. property FrameCount: Integer read GetFrameCount;
  2790. { Image format (as understood by codec). }
  2791. property Format: String read GetFormat;
  2792. { Image compression (as understood by codec). }
  2793. property Compression: String read GetCompression;
  2794. end;
  2795. PBLImageInfo = ^TBLImageInfo;
  2796. { ============================================================================
  2797. [BLImage - Enums]
  2798. ============================================================================ }
  2799. type
  2800. { Filter type used by IBLImage.Scale. }
  2801. TBLImageScaleFilter = (
  2802. { No filter or uninitialized. }
  2803. None = BL_IMAGE_SCALE_FILTER_NONE,
  2804. { Nearest neighbor filter (radius 1.0). }
  2805. Nearest = BL_IMAGE_SCALE_FILTER_NEAREST,
  2806. { Bilinear filter (radius 1.0). }
  2807. Bilinear = BL_IMAGE_SCALE_FILTER_BILINEAR,
  2808. { Bicubic filter (radius 2.0). }
  2809. Bicubic = BL_IMAGE_SCALE_FILTER_BICUBIC,
  2810. { Bell filter (radius 1.5). }
  2811. Bell = BL_IMAGE_SCALE_FILTER_BELL,
  2812. { Gauss filter (radius 2.0). }
  2813. Gauss = BL_IMAGE_SCALE_FILTER_GAUSS,
  2814. { Hermite filter (radius 1.0). }
  2815. Hermite = BL_IMAGE_SCALE_FILTER_HERMITE,
  2816. { Hanning filter (radius 1.0). }
  2817. Hanning = BL_IMAGE_SCALE_FILTER_HANNING,
  2818. { Catrom filter (radius 2.0). }
  2819. Catrom = BL_IMAGE_SCALE_FILTER_CATROM,
  2820. { Bessel filter (radius 3.2383). }
  2821. Bessel = BL_IMAGE_SCALE_FILTER_BESSEL,
  2822. { Sinc filter (radius 2.0, adjustable through TLImageScaleOptions). }
  2823. Sinc = BL_IMAGE_SCALE_FILTER_SINC,
  2824. { Lanczos filter (radius 2.0, adjustable through TBLImageScaleOptions). }
  2825. Lanczos = BL_IMAGE_SCALE_FILTER_LANCZOS,
  2826. { Blackman filter (radius 2.0, adjustable through TBLImageScaleOptions). }
  2827. Blackman = BL_IMAGE_SCALE_FILTER_BLACKMAN,
  2828. { Mitchell filter (radius 2.0, parameters 'b' and 'c' passed through
  2829. TBLImageScaleOptions). }
  2830. Mitchell = BL_IMAGE_SCALE_FILTER_MITCHELL,
  2831. { Filter using a user-function, must be passed through
  2832. TBLImageScaleOptions. }
  2833. User = BL_IMAGE_SCALE_FILTER_USER);
  2834. { ============================================================================
  2835. [BLImage - Typedefs]
  2836. ============================================================================ }
  2837. type
  2838. { A user function that can be used by IBLImage.Scale. }
  2839. TBLImageScaleUserFunc = function(const ADst, AArray: PDouble;
  2840. const ACount: NativeInt; const AData: Pointer): Integer; cdecl;
  2841. { ============================================================================
  2842. [BLImage - Data]
  2843. ============================================================================ }
  2844. type
  2845. { Data that describes a raster image. Used by IBLImage. }
  2846. TBLImageData = record
  2847. {$REGION 'Internal Declarations'}
  2848. private
  2849. FHandle: BLImageData;
  2850. function GetFlags: TBLFormatFlags; inline;
  2851. function GetFormat: TBLFormat; inline;
  2852. function GetSize: TBLSizeI; inline;
  2853. procedure SetFlags(const AValue: TBLFormatFlags); inline;
  2854. procedure SetFormat(const AValue: TBLFormat); inline;
  2855. procedure SetSize(const AValue: TBLSizeI); inline;
  2856. {$ENDREGION 'Internal Declarations'}
  2857. public
  2858. procedure Reset; inline;
  2859. property PixelData: Pointer read FHandle.pixelData write FHandle.pixelData;
  2860. property Stride: NativeInt read FHandle.stride write FHandle.stride;
  2861. property Size: TBLSizeI read GetSize write SetSize;
  2862. property Format: TBLFormat read GetFormat write SetFormat;
  2863. property Flags: TBLFormatFlags read GetFlags write SetFlags;
  2864. end;
  2865. PBLImageData = ^TBLImageData;
  2866. { ============================================================================
  2867. [BLImage - ScaleOptions]
  2868. ============================================================================ }
  2869. type
  2870. { Options that can used to customize image scaling. }
  2871. TBLImageScaleOptions = record
  2872. {$REGION 'Internal Declarations'}
  2873. private
  2874. FHandle: BLImageScaleOptions;
  2875. function GetUserFunc: TBLImageScaleUserFunc; inline;
  2876. procedure SetUserFunc(const AValue: TBLImageScaleUserFunc); inline;
  2877. {$ENDREGION 'Internal Declarations'}
  2878. public
  2879. procedure Reset; inline;
  2880. procedure ResetToDefaults; inline;
  2881. property UserFunc: TBLImageScaleUserFunc read GetUserFunc write SetUserFunc;
  2882. property UserData: Pointer read FHandle.userData write FHandle.userData;
  2883. property Radius: Double read FHandle.radius write FHandle.radius;
  2884. property MitchellB: Double read FHandle.mitchell.b write FHandle.mitchell.b;
  2885. property MitchellC: Double read FHandle.mitchell.c write FHandle.mitchell.c;
  2886. end;
  2887. PBLImageScaleOptions = ^TBLImageScaleOptions;
  2888. type
  2889. IBLImage = interface;
  2890. IBLImageCodec = interface;
  2891. { This event is called when IBLImage.InitializeFromData is used and the image
  2892. is destroyed. }
  2893. TBLImageDestroyEvent = procedure (const AImage: IBLImage) of object;
  2894. { 2D raster image }
  2895. IBLImage = interface
  2896. ['{9E756ED1-76AB-4318-92BD-F6D7F14447A5}']
  2897. {$REGION 'Internal Declarations'}
  2898. function GetIsNone: Boolean;
  2899. function GetIsEmpty: Boolean;
  2900. function GetWidth: Integer;
  2901. function GetHeight: Integer;
  2902. function GetSize: TBLSizeI;
  2903. function GetFormat: TBLFormat;
  2904. function GetHandle: PBLImageCore;
  2905. {$ENDREGION 'Internal Declarations'}
  2906. { Initializes a new image of a specified width, height, and format. }
  2907. procedure Initialize(const AWidth, AHeight: Integer;
  2908. const AFormat: TBLFormat = TBLFormat.PRGB32);
  2909. { Initializes a new image from external data.
  2910. The pixel data is *not* copied and must stay alive as long as the image
  2911. is alive. Use AOnDestroy to get notified when the image is destroyed and
  2912. you can safely free the pixel data. }
  2913. procedure InitializeFromData(const AWidth, AHeight: Integer;
  2914. const AFormat: TBLFormat; const APixelData: Pointer;
  2915. const AStride: Integer; const AOnDestroy: TBLImageDestroyEvent = nil);
  2916. procedure Reset;
  2917. function Clone: IBLImage;
  2918. function Equals(const AOther: IBLImage): Boolean;
  2919. procedure GetData(out AData: TBLImageData);
  2920. procedure MakeMutable; overload;
  2921. procedure MakeMutable(out AData: TBLImageData); overload;
  2922. procedure Convert(const AFormat: TBLFormat);
  2923. procedure ScaleTo(const ADest: IBLImage; const ASize: TBLSizeI;
  2924. const AFilter: TBLImageScaleFilter); overload;
  2925. procedure ScaleTo(const ADest: IBLImage; const ASize: TBLSizeI;
  2926. const AFilter: TBLImageScaleFilter; const AOptions: TBLImageScaleOptions); overload;
  2927. procedure ReadFromFile(const AFilename: String); overload;
  2928. procedure ReadFromFile(const AFilename: String;
  2929. const ACodecs: TArray<IBLImageCodec>); overload;
  2930. procedure ReadFromData(const AData: Pointer; const ASize: Integer); overload;
  2931. procedure ReadFromData(const AData: Pointer; const ASize: Integer;
  2932. const ACodecs: TArray<IBLImageCodec>); overload;
  2933. procedure ReadFromData(const AData: TBytes); overload;
  2934. procedure ReadFromData(const AData: TBytes;
  2935. const ACodecs: TArray<IBLImageCodec>); overload;
  2936. procedure ReadFromData(const AView: TBLArrayView<Byte>); overload;
  2937. procedure ReadFromData(const AView: TBLArrayView<Byte>;
  2938. const ACodecs: TArray<IBLImageCodec>); overload;
  2939. procedure WriteToFile(const AFilename: String); overload;
  2940. procedure WriteToFile(const AFilename: String; const ACodec: IBLImageCodec); overload;
  2941. function WriteToData(const ACodec: IBLImageCodec): TBytes;
  2942. { Tests whether the image is a built-in nil instance. }
  2943. property IsNone: Boolean read GetIsNone;
  2944. { Tests whether the image is empty (has no size). }
  2945. property IsEmpty: Boolean read GetIsEmpty;
  2946. { Image width. }
  2947. property Width: Integer read GetWidth;
  2948. { Image height. }
  2949. property Height: Integer read GetHeight;
  2950. { Image size. }
  2951. property Size: TBLSizeI read GetSize;
  2952. { Image format. }
  2953. property Format: TBLFormat read GetFormat;
  2954. { Internal handle for use with the C API }
  2955. property Handle: PBLImageCore read GetHandle;
  2956. end;
  2957. { Implements IBLImage }
  2958. TBLImage = class(TInterfacedObject, IBLImage)
  2959. {$REGION 'Internal Declarations'}
  2960. private type
  2961. TDestroyData = record
  2962. Image: IBLImage;
  2963. Event: TBLImageDestroyEvent;
  2964. end;
  2965. PDestroyData = ^TDestroyData;
  2966. private
  2967. FHandle: BLImageCore;
  2968. FIsReference: Boolean;
  2969. private
  2970. class procedure DoDestroy(impl, destroyData: Pointer); cdecl; static;
  2971. protected
  2972. { IBLImage }
  2973. function GetIsNone: Boolean;
  2974. function GetIsEmpty: Boolean;
  2975. function GetWidth: Integer;
  2976. function GetHeight: Integer;
  2977. function GetSize: TBLSizeI;
  2978. function GetFormat: TBLFormat;
  2979. function GetHandle: PBLImageCore;
  2980. procedure Initialize(const AWidth, AHeight: Integer;
  2981. const AFormat: TBLFormat);
  2982. procedure InitializeFromData(const AWidth, AHeight: Integer;
  2983. const AFormat: TBLFormat; const APixelData: Pointer;
  2984. const AStride: Integer; const AOnDestroy: TBLImageDestroyEvent);
  2985. procedure Reset;
  2986. function Clone: IBLImage;
  2987. function Equals(const AOther: IBLImage): Boolean; reintroduce; overload;
  2988. procedure GetData(out AData: TBLImageData);
  2989. procedure MakeMutable; overload;
  2990. procedure MakeMutable(out AData: TBLImageData); overload;
  2991. procedure Convert(const AFormat: TBLFormat);
  2992. procedure ScaleTo(const ADest: IBLImage; const ASize: TBLSizeI;
  2993. const AFilter: TBLImageScaleFilter); overload;
  2994. procedure ScaleTo(const ADest: IBLImage; const ASize: TBLSizeI;
  2995. const AFilter: TBLImageScaleFilter; const AOptions: TBLImageScaleOptions); overload;
  2996. procedure ReadFromFile(const AFilename: String); overload;
  2997. procedure ReadFromFile(const AFilename: String;
  2998. const ACodecs: TArray<IBLImageCodec>); overload;
  2999. procedure ReadFromData(const AData: Pointer; const ASize: Integer); overload;
  3000. procedure ReadFromData(const AData: Pointer; const ASize: Integer;
  3001. const ACodecs: TArray<IBLImageCodec>); overload;
  3002. procedure ReadFromData(const AData: TBytes); overload;
  3003. procedure ReadFromData(const AData: TBytes;
  3004. const ACodecs: TArray<IBLImageCodec>); overload;
  3005. procedure ReadFromData(const AView: TBLArrayView<Byte>); overload;
  3006. procedure ReadFromData(const AView: TBLArrayView<Byte>;
  3007. const ACodecs: TArray<IBLImageCodec>); overload;
  3008. procedure WriteToFile(const AFilename: String); overload;
  3009. procedure WriteToFile(const AFilename: String; const ACodec: IBLImageCodec); overload;
  3010. function WriteToData(const ACodec: IBLImageCodec): TBytes;
  3011. private
  3012. constructor Create(const AHandle: BLImageCore; const AIsReference: Boolean); overload;
  3013. {$ENDREGION 'Internal Declarations'}
  3014. public
  3015. constructor Create; overload;
  3016. constructor Create(const AWidth, AHeight: Integer;
  3017. const AFormat: TBLFormat = TBLFormat.PRGB32); overload;
  3018. destructor Destroy; override;
  3019. function Equals(Obj: TObject): Boolean; overload; override;
  3020. class procedure Scale(const ASrc, ADst: IBLImage; const ASize: TBLSizeI;
  3021. const AFilter: TBLImageScaleFilter); overload; static;
  3022. class procedure Scale(const ASrc, ADst: IBLImage; const ASize: TBLSizeI;
  3023. const AFilter: TBLImageScaleFilter; const AOptions: TBLImageScaleOptions); overload; static;
  3024. end;
  3025. {$ENDREGION 'Image'}
  3026. {$REGION 'Image Codec'}
  3027. { ============================================================================
  3028. [BLImageCodec - Enums]
  3029. ============================================================================ }
  3030. { Image codec feature bits. }
  3031. TBLImageCodecFeature = (
  3032. { Image codec supports reading images (can create IBLImageDecoder). }
  3033. Read = 0,
  3034. { Image codec supports writing images (can create IBLImageEncoder). }
  3035. Write = 1,
  3036. { Image codec supports lossless compression. }
  3037. Lossless = 2,
  3038. { Image codec supports lossy compression. }
  3039. Lossy = 3,
  3040. { Image codec supports writing multiple frames (GIF). }
  3041. MultiFrame = 4,
  3042. { Image codec supports IPTC metadata. }
  3043. IPTC = 28,
  3044. { Image codec supports EXIF metadata. }
  3045. EXIF = 29,
  3046. { Image codec supports XMP metadata. }
  3047. XMP = 30);
  3048. TBLImageCodecFeatures = set of TBLImageCodecFeature;
  3049. { ============================================================================
  3050. [BLImageDecoder]
  3051. ============================================================================ }
  3052. { Image decoder }
  3053. IBLImageDecoder = interface
  3054. ['{D68437C2-E6EF-46F1-9191-28F844EF17C6}']
  3055. {$REGION 'Internal Declarations'}
  3056. function GetIsNone: Boolean;
  3057. function GetLastResult: TBLResultCode;
  3058. function GetFrameIndex: Integer;
  3059. function GetBufferIndex: NativeInt;
  3060. function GetHandle: PBLImageDecoderCore;
  3061. {$ENDREGION 'Internal Declarations'}
  3062. procedure Reset;
  3063. function Equals(const AOther: IBLImageDecoder): Boolean;
  3064. procedure Restart;
  3065. procedure ReadInfo(const ABuffer: TBytes; out AInfo: TBLImageInfo); overload;
  3066. procedure ReadInfo(const ABuffer: TBLArrayView<Byte>; out AInfo: TBLImageInfo); overload;
  3067. procedure ReadInfo(const ABuffer: Pointer; const ASize: Integer; out AInfo: TBLImageInfo); overload;
  3068. function ReadFrame(const ABuffer: TBytes): IBLImage; overload;
  3069. function ReadFrame(const ABuffer: TBLArrayView<Byte>): IBLImage; overload;
  3070. function ReadFrame(const ABuffer: Pointer; const ASize: Integer): IBLImage; overload;
  3071. { Tests whether the image decoder is a built-in nil instance. }
  3072. property IsNone: Boolean read GetIsNone;
  3073. { Last decoding result. }
  3074. property LastResult: TBLResultCode read GetLastResult;
  3075. { Current frame index (to be decoded). }
  3076. property FrameIndex: Integer read GetFrameIndex;
  3077. { Position in source buffer. }
  3078. property BufferIndex: NativeInt read GetBufferIndex;
  3079. { Internal handle for use with the C API }
  3080. property Handle: PBLImageDecoderCore read GetHandle;
  3081. end;
  3082. { Implements IBLImageDecoder }
  3083. TBLImageDecoder = class(TInterfacedObject, IBLImageDecoder)
  3084. {$REGION 'Internal Declarations'}
  3085. private
  3086. FHandle: BLImageDecoderCore;
  3087. protected
  3088. { IBLImageDecoder }
  3089. function GetIsNone: Boolean;
  3090. function GetLastResult: TBLResultCode;
  3091. function GetFrameIndex: Integer;
  3092. function GetBufferIndex: NativeInt;
  3093. function GetHandle: PBLImageDecoderCore;
  3094. procedure Reset;
  3095. function Equals(const AOther: IBLImageDecoder): Boolean; reintroduce; overload;
  3096. procedure Restart;
  3097. procedure ReadInfo(const ABuffer: TBytes; out AInfo: TBLImageInfo); overload;
  3098. procedure ReadInfo(const ABuffer: TBLArrayView<Byte>; out AInfo: TBLImageInfo); overload;
  3099. procedure ReadInfo(const ABuffer: Pointer; const ASize: Integer; out AInfo: TBLImageInfo); overload;
  3100. function ReadFrame(const ABuffer: TBytes): IBLImage; overload;
  3101. function ReadFrame(const ABuffer: TBLArrayView<Byte>): IBLImage; overload;
  3102. function ReadFrame(const ABuffer: Pointer; const ASize: Integer): IBLImage; overload;
  3103. {$ENDREGION 'Internal Declarations'}
  3104. public
  3105. constructor Create;
  3106. destructor Destroy; override;
  3107. function Equals(Obj: TObject): Boolean; overload; override;
  3108. end;
  3109. { ============================================================================
  3110. [BLImageEncoder]
  3111. ============================================================================ }
  3112. { Image encoder }
  3113. IBLImageEncoder = interface
  3114. ['{D754FC7A-AC83-4543-8200-AE896920FFB0}']
  3115. {$REGION 'Internal Declarations'}
  3116. function GetIsNone: Boolean;
  3117. function GetLastResult: TBLResultCode;
  3118. function GetFrameIndex: Integer;
  3119. function GetBufferIndex: NativeInt;
  3120. function GetHandle: PBLImageEncoderCore;
  3121. {$ENDREGION 'Internal Declarations'}
  3122. procedure Reset;
  3123. function Equals(const AOther: IBLImageEncoder): Boolean;
  3124. procedure Restart;
  3125. { Encodes the given AImage and returns the encoded data. }
  3126. function WriteFrame(const AImage: IBLImage): TBytes;
  3127. { Tests whether the image encoder is a built-in nil instance. }
  3128. property IsNone: Boolean read GetIsNone;
  3129. { Last encoding result. }
  3130. property LastResult: TBLResultCode read GetLastResult;
  3131. { Current frame index (yet to be written). }
  3132. property FrameIndex: Integer read GetFrameIndex;
  3133. { Position in destination buffer. }
  3134. property BufferIndex: NativeInt read GetBufferIndex;
  3135. { Internal handle for use with the C API }
  3136. property Handle: PBLImageEncoderCore read GetHandle;
  3137. end;
  3138. { Implements IBLImageEncoder }
  3139. TBLImageEncoder = class(TInterfacedObject, IBLImageEncoder)
  3140. {$REGION 'Internal Declarations'}
  3141. private
  3142. FHandle: BLImageEncoderCore;
  3143. protected
  3144. { IBLImageEncoder }
  3145. function GetIsNone: Boolean;
  3146. function GetLastResult: TBLResultCode;
  3147. function GetFrameIndex: Integer;
  3148. function GetBufferIndex: NativeInt;
  3149. function GetHandle: PBLImageEncoderCore;
  3150. procedure Reset;
  3151. function Equals(const AOther: IBLImageEncoder): Boolean; reintroduce; overload;
  3152. procedure Restart;
  3153. function WriteFrame(const AImage: IBLImage): TBytes;
  3154. {$ENDREGION 'Internal Declarations'}
  3155. public
  3156. constructor Create;
  3157. destructor Destroy; override;
  3158. function Equals(Obj: TObject): Boolean; overload; override;
  3159. end;
  3160. { ============================================================================
  3161. [BLImageCodec]
  3162. ============================================================================ }
  3163. { Image codec.
  3164. Provides a unified interface for inspecting image data and creating image
  3165. decoders & encoders. }
  3166. IBLImageCodec = interface
  3167. ['{5F2E0C15-3CF5-4454-ADA4-CEE5D4A3B542}']
  3168. {$REGION 'Internal Declarations'}
  3169. function GetIsNone: Boolean;
  3170. function GetName: String;
  3171. function GetVendor: String;
  3172. function GetMimeType: String;
  3173. function GetExtensions: String;
  3174. function GetFeatures: TBLImageCodecFeatures;
  3175. function GetHandle: PBLImageCodecCore;
  3176. {$ENDREGION 'Internal Declarations'}
  3177. procedure Reset;
  3178. function Equals(const AOther: IBLImageCodec): Boolean;
  3179. { Tests whether the image codec has a given feature. }
  3180. function HasFeature(const AFeature: TBLImageCodecFeature): Boolean;
  3181. function FindByName(const AName: String): Boolean; overload;
  3182. function FindByName(const AName: String; const ACodecs: TArray<IBLImageCodec>): Boolean; overload;
  3183. function FindByExtension(const AExt: String): Boolean; overload;
  3184. function FindByExtension(const AExt: String; const ACodecs: TArray<IBLImageCodec>): Boolean; overload;
  3185. function FindByData(const AData: Pointer; const ASize: Integer): Boolean; overload;
  3186. function FindByData(const AData: Pointer; const ASize: Integer;
  3187. const ACodecs: TArray<IBLImageCodec>): Boolean; overload;
  3188. function FindByData(const AData: TBytes): Boolean; overload;
  3189. function FindByData(const AData: TBytes;
  3190. const ACodecs: TArray<IBLImageCodec>): Boolean; overload;
  3191. { Returns a score }
  3192. function InspectData(const ABuffer: TBytes): Cardinal; overload;
  3193. function InspectData(const ABuffer: TBLArrayView<Byte>): Cardinal; overload;
  3194. function InspectData(const ABuffer: Pointer; const ASize: Integer): Cardinal; overload;
  3195. { Tests whether the image codec is a built-in nil instance. }
  3196. property IsNone: Boolean read GetIsNone;
  3197. { Image codec name (i.e, "PNG", "JPEG", etc...). }
  3198. property Name: String read GetName;
  3199. { The image codec vendor (i.e. "Blend2D" for all built-in codecs). }
  3200. property Vendor: String read GetVendor;
  3201. { Mime-type associated with the image codec's format. }
  3202. property MimeType: String read GetMimeType;
  3203. { A list of file extensions used to store image of this codec, separated by
  3204. '|' character. }
  3205. property Extensions: String read GetExtensions;
  3206. { Image codec features }
  3207. property Features: TBLImageCodecFeatures read GetFeatures;
  3208. { Internal handle for use with the C API }
  3209. property Handle: PBLImageCodecCore read GetHandle;
  3210. end;
  3211. type
  3212. { Implements IBLImageCodec }
  3213. TBLImageCodec = class(TInterfacedObject, IBLImageCodec)
  3214. {$REGION 'Internal Declarations'}
  3215. private
  3216. FHandle: BLImageCodecCore;
  3217. FIsReference: Boolean;
  3218. private
  3219. class function GetBuiltInCodecs: TArray<IBLImageCodec>; static;
  3220. protected
  3221. { IBLImageCodec }
  3222. function GetIsNone: Boolean;
  3223. function GetName: String;
  3224. function GetVendor: String;
  3225. function GetMimeType: String;
  3226. function GetExtensions: String;
  3227. function GetFeatures: TBLImageCodecFeatures;
  3228. function GetHandle: PBLImageCodecCore;
  3229. procedure Reset;
  3230. function Equals(const AOther: IBLImageCodec): Boolean; reintroduce; overload;
  3231. function HasFeature(const AFeature: TBLImageCodecFeature): Boolean;
  3232. function FindByName(const AName: String): Boolean; overload;
  3233. function FindByName(const AName: String; const ACodecs: TArray<IBLImageCodec>): Boolean; overload;
  3234. function FindByExtension(const AExt: String): Boolean; overload;
  3235. function FindByExtension(const AExt: String; const ACodecs: TArray<IBLImageCodec>): Boolean; overload;
  3236. function FindByData(const AData: Pointer; const ASize: Integer): Boolean; overload;
  3237. function FindByData(const AData: Pointer; const ASize: Integer;
  3238. const ACodecs: TArray<IBLImageCodec>): Boolean; overload;
  3239. function FindByData(const AData: TBytes): Boolean; overload;
  3240. function FindByData(const AData: TBytes;
  3241. const ACodecs: TArray<IBLImageCodec>): Boolean; overload;
  3242. function InspectData(const ABuffer: TBytes): Cardinal; overload;
  3243. function InspectData(const ABuffer: TBLArrayView<Byte>): Cardinal; overload;
  3244. function InspectData(const ABuffer: Pointer; const ASize: Integer): Cardinal; overload;
  3245. protected
  3246. constructor Create(const AHandle: BLImageCodecCore; const AIsReference: Boolean); overload;
  3247. {$ENDREGION 'Internal Declarations'}
  3248. public
  3249. constructor Create; overload;
  3250. destructor Destroy; override;
  3251. function Equals(Obj: TObject): Boolean; overload; override;
  3252. class procedure AddToBuiltIn(const ACodec: IBLImageCodec); static;
  3253. class procedure RemoveFromBuiltIn(const ACodec: IBLImageCodec); static;
  3254. class property BuiltInCodecs: TArray<IBLImageCodec> read GetBuiltInCodecs;
  3255. end;
  3256. {$ENDREGION 'Image Codec'}
  3257. {$REGION 'Pattern'}
  3258. { ============================================================================
  3259. [BLPattern]
  3260. ============================================================================ }
  3261. type
  3262. { Pattern }
  3263. IBLPattern = interface
  3264. ['{BE559BED-3495-49D7-AB00-7BF092E1F53B}']
  3265. {$REGION 'Internal Declarations'}
  3266. function GetIsNone: Boolean;
  3267. function GetImage: IBLImage;
  3268. procedure SetImage(const AValue: IBLImage); overload;
  3269. function GetArea: TBLRectI;
  3270. procedure SetArea(const AValue: TBLRectI);
  3271. function GetExtendMode: TBLExtendMode;
  3272. procedure SetExtendMode(const AValue: TBLExtendMode);
  3273. function GetHasMatrix: Boolean;
  3274. function GetMatrixType: TBLMatrix2DType;
  3275. function GetMatrix: TBLMatrix2D;
  3276. procedure SetMatrix(const AValue: TBLMatrix2D);
  3277. function GetHandle: PBLPatternCore;
  3278. {$ENDREGION 'Internal Declarations'}
  3279. procedure Initialize(const AImage: IBLImage;
  3280. const AExtendMode: TBLExtendMode = TBLExtendMode.&Repeat); overload;
  3281. procedure Initialize(const AImage: IBLImage; const AExtendMode: TBLExtendMode;
  3282. const AMatrix: TBLMatrix2D); overload;
  3283. procedure Initialize(const AImage: IBLImage; const AArea: TBLRectI;
  3284. const AExtendMode: TBLExtendMode = TBLExtendMode.&Repeat); overload;
  3285. procedure Initialize(const AImage: IBLImage; const AArea: TBLRectI;
  3286. const AExtendMode: TBLExtendMode; const AMatrix: TBLMatrix2D); overload;
  3287. procedure Reset;
  3288. function Equals(const AOther: IBLPattern): Boolean;
  3289. procedure SetImage(const AValue: IBLImage; const AArea: TBLRectI); overload;
  3290. procedure ResetImage;
  3291. procedure ResetArea;
  3292. procedure ResetExtendMode;
  3293. procedure ResetMatrix;
  3294. procedure Translate(const AX, AY: Double); overload;
  3295. procedure Translate(const AP: TBLPoint); overload;
  3296. procedure Translate(const AP: TBLPointI); overload;
  3297. procedure Scale(const AXY: Double); overload;
  3298. procedure Scale(const AX, AY: Double); overload;
  3299. procedure Scale(const AP: TBLPoint); overload;
  3300. procedure Scale(const AP: TBLPointI); overload;
  3301. procedure Skew(const AX, AY: Double); overload;
  3302. procedure Skew(const AP: TBLPoint); overload;
  3303. procedure Rotate(const AAngle: Double); overload;
  3304. procedure Rotate(const AAngle, AX, AY: Double); overload;
  3305. procedure Rotate(const AAngle: Double; const AP: TBLPoint); overload;
  3306. procedure Rotate(const AAngle: Double; const AP: TBLPointI); overload;
  3307. procedure Transform(const AMatrix: TBLMatrix2D);
  3308. procedure PostTranslate(const AX, AY: Double); overload;
  3309. procedure PostTranslate(const AP: TBLPoint); overload;
  3310. procedure PostTranslate(const AP: TBLPointI); overload;
  3311. procedure PostScale(const AXY: Double); overload;
  3312. procedure PostScale(const AX, AY: Double); overload;
  3313. procedure PostScale(const AP: TBLPoint); overload;
  3314. procedure PostScale(const AP: TBLPointI); overload;
  3315. procedure PostSkew(const AX, AY: Double); overload;
  3316. procedure PostSkew(const AP: TBLPoint); overload;
  3317. procedure PostRotate(const AAngle: Double); overload;
  3318. procedure PostRotate(const AAngle, AX, AY: Double); overload;
  3319. procedure PostRotate(const AAngle: Double; const AP: TBLPoint); overload;
  3320. procedure PostRotate(const AAngle: Double; const AP: TBLPointI); overload;
  3321. procedure PostTransform(const AMatrix: TBLMatrix2D);
  3322. { Whether the pattern is a built-in null instance. }
  3323. property IsNone: Boolean read GetIsNone;
  3324. property Image: IBLImage read GetImage write SetImage;
  3325. property Area: TBLRectI read GetArea write SetArea;
  3326. property ExtendMode: TBLExtendMode read GetExtendMode write SetExtendMode;
  3327. property HasMatrix: Boolean read GetHasMatrix;
  3328. property MatrixType: TBLMatrix2DType read GetMatrixType;
  3329. property Matrix: TBLMatrix2D read GetMatrix write SetMatrix;
  3330. { Internal handle for use with the C API }
  3331. property Handle: PBLPatternCore read GetHandle;
  3332. end;
  3333. type
  3334. { Implements IBLPattern }
  3335. TBLPattern = class(TInterfacedObject, IBLPattern)
  3336. {$REGION 'Internal Declarations'}
  3337. private
  3338. FHandle: BLPatternCore;
  3339. FImage: IBLImage;
  3340. FIsReference: Boolean;
  3341. protected
  3342. { IBLPattern }
  3343. function GetIsNone: Boolean;
  3344. function GetImage: IBLImage;
  3345. procedure SetImage(const AValue: IBLImage); overload;
  3346. function GetArea: TBLRectI;
  3347. procedure SetArea(const AValue: TBLRectI);
  3348. function GetExtendMode: TBLExtendMode;
  3349. procedure SetExtendMode(const AValue: TBLExtendMode);
  3350. function GetHasMatrix: Boolean;
  3351. function GetMatrixType: TBLMatrix2DType;
  3352. function GetMatrix: TBLMatrix2D;
  3353. procedure SetMatrix(const AValue: TBLMatrix2D);
  3354. function GetHandle: PBLPatternCore;
  3355. procedure Initialize(const AImage: IBLImage;
  3356. const AExtendMode: TBLExtendMode = TBLExtendMode.&Repeat); overload;
  3357. procedure Initialize(const AImage: IBLImage; const AExtendMode: TBLExtendMode;
  3358. const AMatrix: TBLMatrix2D); overload;
  3359. procedure Initialize(const AImage: IBLImage; const AArea: TBLRectI;
  3360. const AExtendMode: TBLExtendMode = TBLExtendMode.&Repeat); overload;
  3361. procedure Initialize(const AImage: IBLImage; const AArea: TBLRectI;
  3362. const AExtendMode: TBLExtendMode; const AMatrix: TBLMatrix2D); overload;
  3363. procedure Reset;
  3364. function Equals(const AOther: IBLPattern): Boolean; reintroduce; overload;
  3365. procedure SetImage(const AValue: IBLImage; const AArea: TBLRectI); overload;
  3366. procedure ResetImage;
  3367. procedure ResetArea;
  3368. procedure ResetExtendMode;
  3369. procedure ResetMatrix;
  3370. procedure Translate(const AX, AY: Double); overload;
  3371. procedure Translate(const AP: TBLPoint); overload;
  3372. procedure Translate(const AP: TBLPointI); overload;
  3373. procedure Scale(const AXY: Double); overload;
  3374. procedure Scale(const AX, AY: Double); overload;
  3375. procedure Scale(const AP: TBLPoint); overload;
  3376. procedure Scale(const AP: TBLPointI); overload;
  3377. procedure Skew(const AX, AY: Double); overload;
  3378. procedure Skew(const AP: TBLPoint); overload;
  3379. procedure Rotate(const AAngle: Double); overload;
  3380. procedure Rotate(const AAngle, AX, AY: Double); overload;
  3381. procedure Rotate(const AAngle: Double; const AP: TBLPoint); overload;
  3382. procedure Rotate(const AAngle: Double; const AP: TBLPointI); overload;
  3383. procedure Transform(const AMatrix: TBLMatrix2D);
  3384. procedure PostTranslate(const AX, AY: Double); overload;
  3385. procedure PostTranslate(const AP: TBLPoint); overload;
  3386. procedure PostTranslate(const AP: TBLPointI); overload;
  3387. procedure PostScale(const AXY: Double); overload;
  3388. procedure PostScale(const AX, AY: Double); overload;
  3389. procedure PostScale(const AP: TBLPoint); overload;
  3390. procedure PostScale(const AP: TBLPointI); overload;
  3391. procedure PostSkew(const AX, AY: Double); overload;
  3392. procedure PostSkew(const AP: TBLPoint); overload;
  3393. procedure PostRotate(const AAngle: Double); overload;
  3394. procedure PostRotate(const AAngle, AX, AY: Double); overload;
  3395. procedure PostRotate(const AAngle: Double; const AP: TBLPoint); overload;
  3396. procedure PostRotate(const AAngle: Double; const AP: TBLPointI); overload;
  3397. procedure PostTransform(const AMatrix: TBLMatrix2D);
  3398. private
  3399. constructor Create(const AHandle: BLPatternCore;
  3400. const AIsReference: Boolean); overload;
  3401. {$ENDREGION 'Internal Declarations'}
  3402. public
  3403. constructor Create; overload;
  3404. constructor Create(const AImage: IBLImage;
  3405. const AExtendMode: TBLExtendMode = TBLExtendMode.&Repeat); overload;
  3406. constructor Create(const AImage: IBLImage; const AExtendMode: TBLExtendMode;
  3407. const AMatrix: TBLMatrix2D); overload;
  3408. constructor Create(const AImage: IBLImage; const AArea: TBLRectI;
  3409. const AExtendMode: TBLExtendMode = TBLExtendMode.&Repeat); overload;
  3410. constructor Create(const AImage: IBLImage; const AArea: TBLRectI;
  3411. const AExtendMode: TBLExtendMode; const AMatrix: TBLMatrix2D); overload;
  3412. destructor Destroy; override;
  3413. function Equals(Obj: TObject): Boolean; overload; override;
  3414. end;
  3415. {$ENDREGION 'Pattern'}
  3416. {$REGION 'Font Defs'}
  3417. { ============================================================================
  3418. [Enums]
  3419. ============================================================================ }
  3420. type
  3421. { Placement of glyphs stored in a TBLGlyphRun. }
  3422. TBLGlyphPlacementType = (
  3423. { No placement (custom handling by TBLPathSinkEvent). }
  3424. None = BL_GLYPH_PLACEMENT_TYPE_NONE,
  3425. { Each glyph has a TBLGlyphPlacement (advance + offset). }
  3426. AdvanceOffset = BL_GLYPH_PLACEMENT_TYPE_ADVANCE_OFFSET,
  3427. { Each glyph has a TBLPoint offset in design-space units. }
  3428. DesignUnits = BL_GLYPH_PLACEMENT_TYPE_DESIGN_UNITS,
  3429. { Each glyph has a TBLPoint offset in user-space units. }
  3430. UserUnits = BL_GLYPH_PLACEMENT_TYPE_USER_UNITS,
  3431. { Each glyph has a TBLPoint offset in absolute units. }
  3432. AbsoluteUnits = BL_GLYPH_PLACEMENT_TYPE_ABSOLUTE_UNITS);
  3433. type
  3434. TBLGlyphRunFlag = (
  3435. _Dummy = 0,
  3436. { Glyph-run contains USC-4 string and not glyphs (glyph-buffer only). }
  3437. UCS4Content = 28,
  3438. { Glyph-run was created from text that was not a valid unicode. }
  3439. InvalidText = 29,
  3440. { Not the whole text was mapped to glyphs (contains undefined glyphs). }
  3441. UndefinedGlyphs = 30,
  3442. { Encountered invalid font-data during text / glyph processing. }
  3443. InvalidFontData = 31);
  3444. TBLGlyphRunFlags = set of TBLGlyphRunFlag;
  3445. type
  3446. { Font-data flags. }
  3447. TBLFontDataFlag = (
  3448. { Font data references a font-collection. }
  3449. Collection = 0);
  3450. TBLFontDataFlags = set of TBLFontDataFlag;
  3451. type
  3452. { Type of a font or font-face. }
  3453. TBLFontFaceType = (
  3454. None = BL_FONT_FACE_TYPE_NONE,
  3455. { TrueType/OpenType font type. }
  3456. OpenType = BL_FONT_FACE_TYPE_OPENTYPE);
  3457. type
  3458. TBLFontFaceFlag = (
  3459. { Font uses typographic family and subfamily names. }
  3460. TypographicNames = 0,
  3461. { Font uses typographic metrics. }
  3462. TypographicMetrics = 1,
  3463. { Character to glyph mapping is available. }
  3464. CharToGlyphMapping = 2,
  3465. { Horizontal glyph metrics (advances, side bearings) is available. }
  3466. HorizontalMetrics = 4,
  3467. { Vertical glyph metrics (advances, side bearings) is available. }
  3468. VerticalMetrics = 5,
  3469. { Legacy horizontal kerning feature ('kern' table with horizontal kerning data). }
  3470. HorizontalKerning = 6,
  3471. { Legacy vertical kerning feature ('kern' table with vertical kerning data). }
  3472. VerticalKerning = 7,
  3473. { OpenType features (GDEF, GPOS, GSUB) are available. }
  3474. OpenTypeFeatures = 8,
  3475. { Panose classification is available. }
  3476. PanoseData = 9,
  3477. { Unicode coverage information is available. }
  3478. UnicodeCoverage = 10,
  3479. { Baseline for font at `y` equals 0. }
  3480. BaselineYEquals0 = 12,
  3481. { Left sidebearing point at `x == 0` (TT only). }
  3482. LSBPointXEquals0 = 13,
  3483. { Unicode variation sequences feature is available. }
  3484. VariationSequences = 28,
  3485. { OpenType Font Variations feature is available. }
  3486. OpenTypeVariations = 29,
  3487. { This is a symbol font. }
  3488. SymbolFont = 30,
  3489. { This is a last resort font. }
  3490. LastResortFont = 31);
  3491. TBLFontFaceFlags = set of TBLFontFaceFlag;
  3492. type
  3493. TBLFontFaceDiagFlag = (
  3494. { Wrong data in 'name' table. }
  3495. WrongNameData = 0,
  3496. { Fixed data read from 'name' table and possibly fixed font family/subfamily
  3497. name. }
  3498. FixedNameData = 1,
  3499. { Wrong data in 'kern' table [kerning disabled]. }
  3500. WrongKernData = 2,
  3501. { Fixed data read from 'kern' table so it can be used. }
  3502. FixedKernData = 3,
  3503. { Wrong data in 'cmap' table. }
  3504. WrongCMAPData = 4,
  3505. { Wrong format in 'cmap' (sub)table. }
  3506. WrongCMAPFormat = 5,
  3507. { Wrong data in 'GDEF' table. }
  3508. WrongGDEFData = 8,
  3509. { Wrong data in 'GPOS' table. }
  3510. WrongGPOSData = 10,
  3511. { Wrong data in 'GSUB' table. }
  3512. WrongGSUBData = 12);
  3513. TBLFontFaceDiagFlags = set of TBLFontFaceDiagFlag;
  3514. type
  3515. { Format of an outline stored in a font. }
  3516. TBLFontOutlineType = (
  3517. { None. }
  3518. None = BL_FONT_OUTLINE_TYPE_NONE,
  3519. { TrueType outlines. }
  3520. TrueType = BL_FONT_OUTLINE_TYPE_TRUETYPE,
  3521. { OpenType (CFF) outlines. }
  3522. CFF = BL_FONT_OUTLINE_TYPE_CFF,
  3523. { OpenType (CFF2) outlines (font variations support). }
  3524. CFF2 = BL_FONT_OUTLINE_TYPE_CFF2);
  3525. type
  3526. { Font stretch. }
  3527. TBLFontStretch = (
  3528. { Ultra condensed stretch. }
  3529. UltraCondensed = BL_FONT_STRETCH_ULTRA_CONDENSED,
  3530. { Extra condensed stretch. }
  3531. ExtraCondensed = BL_FONT_STRETCH_EXTRA_CONDENSED,
  3532. { Condensed stretch. }
  3533. Condensed = BL_FONT_STRETCH_CONDENSED,
  3534. { Semi condensed stretch. }
  3535. SemiCondensed = BL_FONT_STRETCH_SEMI_CONDENSED,
  3536. { Normal stretch. }
  3537. Normal = BL_FONT_STRETCH_NORMAL,
  3538. { Semi expanded stretch. }
  3539. SemiExpanded = BL_FONT_STRETCH_SEMI_EXPANDED,
  3540. { Expanded stretch. }
  3541. Expanded = BL_FONT_STRETCH_EXPANDED,
  3542. { Extra expanded stretch. }
  3543. ExtraExpanded = BL_FONT_STRETCH_EXTRA_EXPANDED,
  3544. { Ultra expanded stretch. }
  3545. UltraExpanded = BL_FONT_STRETCH_ULTRA_EXPANDED);
  3546. type
  3547. { Font style. }
  3548. TBLFontStyle = (
  3549. { Normal style. }
  3550. Normal = BL_FONT_STYLE_NORMAL,
  3551. { Oblique. }
  3552. Oblique = BL_FONT_STYLE_OBLIQUE,
  3553. { Italic. }
  3554. Italic = BL_FONT_STYLE_ITALIC);
  3555. type
  3556. { Font weight. }
  3557. TBLFontWeight = (
  3558. { Thin weight (100). }
  3559. Thin = BL_FONT_WEIGHT_THIN,
  3560. { Extra light weight (200). }
  3561. ExtraLight = BL_FONT_WEIGHT_EXTRA_LIGHT,
  3562. { Light weight (300). }
  3563. Light = BL_FONT_WEIGHT_LIGHT,
  3564. { Semi light weight (350). }
  3565. SemiLight = BL_FONT_WEIGHT_SEMI_LIGHT,
  3566. { Normal weight (400). }
  3567. Normal = BL_FONT_WEIGHT_NORMAL,
  3568. { Medium weight (500). }
  3569. Medium = BL_FONT_WEIGHT_MEDIUM,
  3570. { Semi bold weight (600). }
  3571. SemiBold = BL_FONT_WEIGHT_SEMI_BOLD,
  3572. { Bold weight (700). }
  3573. Bold = BL_FONT_WEIGHT_BOLD,
  3574. { Extra bold weight (800). }
  3575. ExtraBold = BL_FONT_WEIGHT_EXTRA_BOLD,
  3576. { Black weight (900). }
  3577. Black = BL_FONT_WEIGHT_BLACK,
  3578. { Extra black weight (950). }
  3579. ExtraBlack = BL_FONT_WEIGHT_EXTRA_BLACK);
  3580. type
  3581. { Font string identifiers used by OpenType 'name' table. }
  3582. TBLFontStringId = (
  3583. { Copyright notice. }
  3584. CopyrightNotice = BL_FONT_STRING_COPYRIGHT_NOTICE,
  3585. { Font family name. }
  3586. FamilyName = BL_FONT_STRING_FAMILY_NAME,
  3587. { Font subfamily name. }
  3588. SubfamilyName = BL_FONT_STRING_SUBFAMILY_NAME,
  3589. { Unique font identifier. }
  3590. UniqueIdentifier = BL_FONT_STRING_UNIQUE_IDENTIFIER,
  3591. { Full font name that reflects all family and relevant subfamily descriptors. }
  3592. FullName = BL_FONT_STRING_FULL_NAME,
  3593. { Version string. Should begin with the synta `Version <number>.<number>`. }
  3594. VersionString = BL_FONT_STRING_VERSION_STRING,
  3595. { PostScript name for the font. }
  3596. PostScriptName = BL_FONT_STRING_POST_SCRIPT_NAME,
  3597. { Trademark notice/information for this font. }
  3598. Trademark = BL_FONT_STRING_TRADEMARK,
  3599. { Manufacturer name. }
  3600. ManufacturerName = BL_FONT_STRING_MANUFACTURER_NAME,
  3601. { Name of the designer of the typeface. }
  3602. DesignerName = BL_FONT_STRING_DESIGNER_NAME,
  3603. { Description of the typeface. }
  3604. Description = BL_FONT_STRING_DESCRIPTION,
  3605. { URL of font vendor. }
  3606. VendorURL = BL_FONT_STRING_VENDOR_URL,
  3607. { URL of typeface designer. }
  3608. DesignerURL = BL_FONT_STRING_DESIGNER_URL,
  3609. { Description of how the font may be legally used. }
  3610. LicenseDescription = BL_FONT_STRING_LICENSE_DESCRIPTION,
  3611. { URL where additional licensing information can be found. }
  3612. LicenseInfoURL = BL_FONT_STRING_LICENSE_INFO_URL,
  3613. { Reserved. }
  3614. Reserved = BL_FONT_STRING_RESERVED,
  3615. { Typographic family name. }
  3616. TypographicFamilyName = BL_FONT_STRING_TYPOGRAPHIC_FAMILY_NAME,
  3617. { Typographic subfamily name. }
  3618. TypographicSubfamilyName = BL_FONT_STRING_TYPOGRAPHIC_SUBFAMILY_NAME,
  3619. { Compatible full name (MAC only). }
  3620. CompatibleFullName = BL_FONT_STRING_COMPATIBLE_FULL_NAME,
  3621. { Sample text - font name or any other text from the designer. }
  3622. SampleText = BL_FONT_STRING_SAMPLE_TEXT,
  3623. { PostScript CID findfont name. }
  3624. PostScriptCIDName = BL_FONT_STRING_POST_SCRIPT_CID_NAME,
  3625. { WWS family name. }
  3626. WWSFamilyName = BL_FONT_STRING_WWS_FAMILY_NAME,
  3627. { WWS subfamily name. }
  3628. WWSSubfamilyName = BL_FONT_STRING_WWS_SUBFAMILY_NAME,
  3629. { Light background palette. }
  3630. LightBackgroundPalette = BL_FONT_STRING_LIGHT_BACKGROUND_PALETTE,
  3631. { Dark background palette. }
  3632. DarkBackgroundPalette = BL_FONT_STRING_DARK_BACKGROUND_PALETTE,
  3633. { Variations PostScript name prefix. }
  3634. VariationsPostSciptPrefix = BL_FONT_STRING_VARIATIONS_POST_SCRIPT_PREFIX);
  3635. type
  3636. { Bit positions in TBLFontUnicodeCoverage record.
  3637. Each bit represents a range (or multiple ranges) of unicode characters. }
  3638. TBLFontUnicodeCoverageIndex = (
  3639. BasicLatin = BL_FONT_UC_INDEX_BASIC_LATIN, // [000000-00007F] Basic Latin.
  3640. Latin1Supplement = BL_FONT_UC_INDEX_LATIN1_SUPPLEMENT, // [000080-0000FF] Latin-1 Supplement.
  3641. LatinExtendedA = BL_FONT_UC_INDEX_LATIN_EXTENDED_A, // [000100-00017F] Latin Extended-A.
  3642. LatinExtendedB = BL_FONT_UC_INDEX_LATIN_EXTENDED_B, // [000180-00024F] Latin Extended-B.
  3643. IPAExtensions = BL_FONT_UC_INDEX_IPA_EXTENSIONS, // [000250-0002AF] IPA Extensions.
  3644. // [001D00-001D7F] Phonetic Extensions.
  3645. // [001D80-001DBF] Phonetic Extensions Supplement.
  3646. SpacingModifierLetters = BL_FONT_UC_INDEX_SPACING_MODIFIER_LETTERS, // [0002B0-0002FF] Spacing Modifier Letters.
  3647. // [00A700-00A71F] Modifier Tone Letters.
  3648. // [001DC0-001DFF] Combining Diacritical Marks Supplement.
  3649. CombiningDiacriticalMarks = BL_FONT_UC_INDEX_COMBINING_DIACRITICAL_MARKS, // [000300-00036F] Combining Diacritical Marks.
  3650. GreekAndCoptic = BL_FONT_UC_INDEX_GREEK_AND_COPTIC, // [000370-0003FF] Greek and Coptic.
  3651. Coptic = BL_FONT_UC_INDEX_COPTIC, // [002C80-002CFF] Coptic.
  3652. Cyrillic = BL_FONT_UC_INDEX_CYRILLIC, // [000400-0004FF] Cyrillic.
  3653. // [000500-00052F] Cyrillic Supplement.
  3654. // [002DE0-002DFF] Cyrillic Extended-A.
  3655. // [00A640-00A69F] Cyrillic Extended-B.
  3656. Armenian = BL_FONT_UC_INDEX_ARMENIAN, // [000530-00058F] Armenian.
  3657. Hebrew = BL_FONT_UC_INDEX_HEBREW, // [000590-0005FF] Hebrew.
  3658. Vai = BL_FONT_UC_INDEX_VAI, // [00A500-00A63F] Vai.
  3659. Arabic = BL_FONT_UC_INDEX_ARABIC, // [000600-0006FF] Arabic.
  3660. // [000750-00077F] Arabic Supplement.
  3661. NKo = BL_FONT_UC_INDEX_NKO, // [0007C0-0007FF] NKo.
  3662. Devanagari = BL_FONT_UC_INDEX_DEVANAGARI, // [000900-00097F] Devanagari.
  3663. Bengali = BL_FONT_UC_INDEX_BENGALI, // [000980-0009FF] Bengali.
  3664. Gurmukhi = BL_FONT_UC_INDEX_GURMUKHI, // [000A00-000A7F] Gurmukhi.
  3665. Gujarati = BL_FONT_UC_INDEX_GUJARATI, // [000A80-000AFF] Gujarati.
  3666. Oriya = BL_FONT_UC_INDEX_ORIYA, // [000B00-000B7F] Oriya.
  3667. Tamil = BL_FONT_UC_INDEX_TAMIL, // [000B80-000BFF] Tamil.
  3668. Telugu = BL_FONT_UC_INDEX_TELUGU, // [000C00-000C7F] Telugu.
  3669. Kannada = BL_FONT_UC_INDEX_KANNADA, // [000C80-000CFF] Kannada.
  3670. Malayalam = BL_FONT_UC_INDEX_MALAYALAM, // [000D00-000D7F] Malayalam.
  3671. Thai = BL_FONT_UC_INDEX_THAI, // [000E00-000E7F] Thai.
  3672. Lao = BL_FONT_UC_INDEX_LAO, // [000E80-000EFF] Lao.
  3673. Georgian = BL_FONT_UC_INDEX_GEORGIAN, // [0010A0-0010FF] Georgian.
  3674. // [002D00-002D2F] Georgian Supplement.
  3675. Balinese = BL_FONT_UC_INDEX_BALINESE, // [001B00-001B7F] Balinese.
  3676. HangulJamo = BL_FONT_UC_INDEX_HANGUL_JAMO, // [001100-0011FF] Hangul Jamo.
  3677. LatinExtendedAdditional = BL_FONT_UC_INDEX_LATIN_EXTENDED_ADDITIONAL, // [001E00-001EFF] Latin Extended Additional.
  3678. // [002C60-002C7F] Latin Extended-C.
  3679. // [00A720-00A7FF] Latin Extended-D.
  3680. GreekExtended = BL_FONT_UC_INDEX_GREEK_EXTENDED, // [001F00-001FFF] Greek Extended.
  3681. GeneralPunctuation = BL_FONT_UC_INDEX_GENERAL_PUNCTUATION, // [002000-00206F] General Punctuation.
  3682. // [002E00-002E7F] Supplemental Punctuation.
  3683. SuperscriptsAndSubscripts = BL_FONT_UC_INDEX_SUPERSCRIPTS_AND_SUBSCRIPTS, // [002070-00209F] Superscripts And Subscripts.
  3684. CurrencySymbols = BL_FONT_UC_INDEX_CURRENCY_SYMBOLS, // [0020A0-0020CF] Currency Symbols.
  3685. CombiningDiacriticalMarksForSymbols = BL_FONT_UC_INDEX_COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS, // [0020D0-0020FF] Combining Diacritical Marks For Symbols.
  3686. LetterlikeSymbols = BL_FONT_UC_INDEX_LETTERLIKE_SYMBOLS, // [002100-00214F] Letterlike Symbols.
  3687. NumberForms = BL_FONT_UC_INDEX_NUMBER_FORMS, // [002150-00218F] Number Forms.
  3688. Arrows = BL_FONT_UC_INDEX_ARROWS, // [002190-0021FF] Arrows.
  3689. // [0027F0-0027FF] Supplemental Arrows-A.
  3690. // [002900-00297F] Supplemental Arrows-B.
  3691. // [002B00-002BFF] Miscellaneous Symbols and Arrows.
  3692. MathematicalOperators = BL_FONT_UC_INDEX_MATHEMATICAL_OPERATORS, // [002200-0022FF] Mathematical Operators.
  3693. // [002A00-002AFF] Supplemental Mathematical Operators.
  3694. // [0027C0-0027EF] Miscellaneous Mathematical Symbols-A.
  3695. // [002980-0029FF] Miscellaneous Mathematical Symbols-B.
  3696. MiscellaneousTechnical = BL_FONT_UC_INDEX_MISCELLANEOUS_TECHNICAL, // [002300-0023FF] Miscellaneous Technical.
  3697. ControlPictures = BL_FONT_UC_INDEX_CONTROL_PICTURES, // [002400-00243F] Control Pictures.
  3698. OpticalCharacterRecognition = BL_FONT_UC_INDEX_OPTICAL_CHARACTER_RECOGNITION, // [002440-00245F] Optical Character Recognition.
  3699. EnclosedAlphanumerics = BL_FONT_UC_INDEX_ENCLOSED_ALPHANUMERICS, // [002460-0024FF] Enclosed Alphanumerics.
  3700. BoxDrawing = BL_FONT_UC_INDEX_BOX_DRAWING, // [002500-00257F] Box Drawing.
  3701. BlockElements = BL_FONT_UC_INDEX_BLOCK_ELEMENTS, // [002580-00259F] Block Elements.
  3702. GeometricShapes = BL_FONT_UC_INDEX_GEOMETRIC_SHAPES, // [0025A0-0025FF] Geometric Shapes.
  3703. MiscellaneousSymbols = BL_FONT_UC_INDEX_MISCELLANEOUS_SYMBOLS, // [002600-0026FF] Miscellaneous Symbols.
  3704. Dingbats = BL_FONT_UC_INDEX_DINGBATS, // [002700-0027BF] Dingbats.
  3705. CJKSymbolsAndPunctuation = BL_FONT_UC_INDEX_CJK_SYMBOLS_AND_PUNCTUATION, // [003000-00303F] CJK Symbols And Punctuation.
  3706. Hiragana = BL_FONT_UC_INDEX_HIRAGANA, // [003040-00309F] Hiragana.
  3707. Katakana = BL_FONT_UC_INDEX_KATAKANA, // [0030A0-0030FF] Katakana.
  3708. // [0031F0-0031FF] Katakana Phonetic Extensions.
  3709. Bopomofo = BL_FONT_UC_INDEX_BOPOMOFO, // [003100-00312F] Bopomofo.
  3710. // [0031A0-0031BF] Bopomofo Extended.
  3711. HangulCompatibilityJamo = BL_FONT_UC_INDEX_HANGUL_COMPATIBILITY_JAMO, // [003130-00318F] Hangul Compatibility Jamo.
  3712. PhagsPa = BL_FONT_UC_INDEX_PHAGS_PA, // [00A840-00A87F] Phags-pa.
  3713. EnclosedCJKLettersAndMonths = BL_FONT_UC_INDEX_ENCLOSED_CJK_LETTERS_AND_MONTHS, // [003200-0032FF] Enclosed CJK Letters And Months.
  3714. CJKCompatibility = BL_FONT_UC_INDEX_CJK_COMPATIBILITY, // [003300-0033FF] CJK Compatibility.
  3715. HangulSyllables = BL_FONT_UC_INDEX_HANGUL_SYLLABLES, // [00AC00-00D7AF] Hangul Syllables.
  3716. NonPlane = BL_FONT_UC_INDEX_NON_PLANE, // [00D800-00DFFF] Non-Plane 0 *.
  3717. Phoenician = BL_FONT_UC_INDEX_PHOENICIAN, // [010900-01091F] Phoenician.
  3718. CJKUnifiedIdeographs = BL_FONT_UC_INDEX_CJK_UNIFIED_IDEOGRAPHS, // [004E00-009FFF] CJK Unified Ideographs.
  3719. // [002E80-002EFF] CJK Radicals Supplement.
  3720. // [002F00-002FDF] Kangxi Radicals.
  3721. // [002FF0-002FFF] Ideographic Description Characters.
  3722. // [003400-004DBF] CJK Unified Ideographs Extension A.
  3723. // [020000-02A6DF] CJK Unified Ideographs Extension B.
  3724. // [003190-00319F] Kanbun.
  3725. PrivateUsePlane0 = BL_FONT_UC_INDEX_PRIVATE_USE_PLANE0, // [00E000-00F8FF] Private Use (Plane 0).
  3726. CJKStrokes = BL_FONT_UC_INDEX_CJK_STROKES, // [0031C0-0031EF] CJK Strokes.
  3727. // [00F900-00FAFF] CJK Compatibility Ideographs.
  3728. // [02F800-02FA1F] CJK Compatibility Ideographs Supplement.
  3729. AlphabeticPresentationForms = BL_FONT_UC_INDEX_ALPHABETIC_PRESENTATION_FORMS, // [00FB00-00FB4F] Alphabetic Presentation Forms.
  3730. ArabicPresentationsFormsA = BL_FONT_UC_INDEX_ARABIC_PRESENTATION_FORMS_A, // [00FB50-00FDFF] Arabic Presentation Forms-A.
  3731. CombiningHalfMarks = BL_FONT_UC_INDEX_COMBINING_HALF_MARKS, // [00FE20-00FE2F] Combining Half Marks.
  3732. VerticalForms = BL_FONT_UC_INDEX_VERTICAL_FORMS, // [00FE10-00FE1F] Vertical Forms.
  3733. // [00FE30-00FE4F] CJK Compatibility Forms.
  3734. SmallFormVariants = BL_FONT_UC_INDEX_SMALL_FORM_VARIANTS, // [00FE50-00FE6F] Small Form Variants.
  3735. ArabicPresentationFormsB = BL_FONT_UC_INDEX_ARABIC_PRESENTATION_FORMS_B, // [00FE70-00FEFF] Arabic Presentation Forms-B.
  3736. HalfwidthAndFullwidthForms = BL_FONT_UC_INDEX_HALFWIDTH_AND_FULLWIDTH_FORMS, // [00FF00-00FFEF] Halfwidth And Fullwidth Forms.
  3737. Specials = BL_FONT_UC_INDEX_SPECIALS, // [00FFF0-00FFFF] Specials.
  3738. Tibetan = BL_FONT_UC_INDEX_TIBETAN, // [000F00-000FFF] Tibetan.
  3739. Syriac = BL_FONT_UC_INDEX_SYRIAC, // [000700-00074F] Syriac.
  3740. Thaana = BL_FONT_UC_INDEX_THAANA, // [000780-0007BF] Thaana.
  3741. Sinhala = BL_FONT_UC_INDEX_SINHALA, // [000D80-000DFF] Sinhala.
  3742. Myanmar = BL_FONT_UC_INDEX_MYANMAR, // [001000-00109F] Myanmar.
  3743. Ethiopic = BL_FONT_UC_INDEX_ETHIOPIC, // [001200-00137F] Ethiopic.
  3744. // [001380-00139F] Ethiopic Supplement.
  3745. // [002D80-002DDF] Ethiopic Extended.
  3746. Cherokee = BL_FONT_UC_INDEX_CHEROKEE, // [0013A0-0013FF] Cherokee.
  3747. UnifiedCanadianAboriginalSyllabics = BL_FONT_UC_INDEX_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS, // [001400-00167F] Unified Canadian Aboriginal Syllabics.
  3748. Ogham = BL_FONT_UC_INDEX_OGHAM, // [001680-00169F] Ogham.
  3749. Runic = BL_FONT_UC_INDEX_RUNIC, // [0016A0-0016FF] Runic.
  3750. Khmer = BL_FONT_UC_INDEX_KHMER, // [001780-0017FF] Khmer.
  3751. // [0019E0-0019FF] Khmer Symbols.
  3752. Mongolian = BL_FONT_UC_INDEX_MONGOLIAN, // [001800-0018AF] Mongolian.
  3753. BraillePatterns = BL_FONT_UC_INDEX_BRAILLE_PATTERNS, // [002800-0028FF] Braille Patterns.
  3754. YiSyllablesAndRadicals = BL_FONT_UC_INDEX_YI_SYLLABLES_AND_RADICALS, // [00A000-00A48F] Yi Syllables.
  3755. // [00A490-00A4CF] Yi Radicals.
  3756. TagalogHanunooBuhidTagbanwa = BL_FONT_UC_INDEX_TAGALOG_HANUNOO_BUHID_TAGBANWA, // [001700-00171F] Tagalog.
  3757. // [001720-00173F] Hanunoo.
  3758. // [001740-00175F] Buhid.
  3759. // [001760-00177F] Tagbanwa.
  3760. OldItalic = BL_FONT_UC_INDEX_OLD_ITALIC, // [010300-01032F] Old Italic.
  3761. Gothic = BL_FONT_UC_INDEX_GOTHIC, // [010330-01034F] Gothic.
  3762. Deseret = BL_FONT_UC_INDEX_DESERET, // [010400-01044F] Deseret.
  3763. MusicalSymbols = BL_FONT_UC_INDEX_MUSICAL_SYMBOLS, // [01D000-01D0FF] Byzantine Musical Symbols.
  3764. // [01D100-01D1FF] Musical Symbols.
  3765. // [01D200-01D24F] Ancient Greek Musical Notation.
  3766. MathematicalAlphanumericSymbols = BL_FONT_UC_INDEX_MATHEMATICAL_ALPHANUMERIC_SYMBOLS, // [01D400-01D7FF] Mathematical Alphanumeric Symbols.
  3767. PrivateUsePlane15And16 = BL_FONT_UC_INDEX_PRIVATE_USE_PLANE_15_16, // [0F0000-0FFFFD] Private Use (Plane 15).
  3768. // [100000-10FFFD] Private Use (Plane 16).
  3769. VariationSelectors = BL_FONT_UC_INDEX_VARIATION_SELECTORS, // [00FE00-00FE0F] Variation Selectors.
  3770. // [0E0100-0E01EF] Variation Selectors Supplement.
  3771. Tags = BL_FONT_UC_INDEX_TAGS, // [0E0000-0E007F] Tags.
  3772. Limbu = BL_FONT_UC_INDEX_LIMBU, // [001900-00194F] Limbu.
  3773. TaiLe = BL_FONT_UC_INDEX_TAI_LE, // [001950-00197F] Tai Le.
  3774. NewTaiLue = BL_FONT_UC_INDEX_NEW_TAI_LUE, // [001980-0019DF] New Tai Lue.
  3775. Buginese = BL_FONT_UC_INDEX_BUGINESE, // [001A00-001A1F] Buginese.
  3776. Glagolitic = BL_FONT_UC_INDEX_GLAGOLITIC, // [002C00-002C5F] Glagolitic.
  3777. Tifinagh = BL_FONT_UC_INDEX_TIFINAGH, // [002D30-002D7F] Tifinagh.
  3778. YijingHexagramSymbols = BL_FONT_UC_INDEX_YIJING_HEXAGRAM_SYMBOLS, // [004DC0-004DFF] Yijing Hexagram Symbols.
  3779. SylotiNagri = BL_FONT_UC_INDEX_SYLOTI_NAGRI, // [00A800-00A82F] Syloti Nagri.
  3780. LinearBSyllabaryAndIdeograms = BL_FONT_UC_INDEX_LINEAR_B_SYLLABARY_AND_IDEOGRAMS, // [010000-01007F] Linear B Syllabary.
  3781. // [010080-0100FF] Linear B Ideograms.
  3782. // [010100-01013F] Aegean Numbers.
  3783. AncientGreekNumbers = BL_FONT_UC_INDEX_ANCIENT_GREEK_NUMBERS, // [010140-01018F] Ancient Greek Numbers.
  3784. Ugaritic = BL_FONT_UC_INDEX_UGARITIC, // [010380-01039F] Ugaritic.
  3785. OldPersian = BL_FONT_UC_INDEX_OLD_PERSIAN, // [0103A0-0103DF] Old Persian.
  3786. Shavian = BL_FONT_UC_INDEX_SHAVIAN, // [010450-01047F] Shavian.
  3787. Osmanya = BL_FONT_UC_INDEX_OSMANYA, // [010480-0104AF] Osmanya.
  3788. CypriotSyllabary = BL_FONT_UC_INDEX_CYPRIOT_SYLLABARY, // [010800-01083F] Cypriot Syllabary.
  3789. Kharoshthi = BL_FONT_UC_INDEX_KHAROSHTHI, // [010A00-010A5F] Kharoshthi.
  3790. TaiXuanJingSymbols = BL_FONT_UC_INDEX_TAI_XUAN_JING_SYMBOLS, // [01D300-01D35F] Tai Xuan Jing Symbols.
  3791. Cuneiform = BL_FONT_UC_INDEX_CUNEIFORM, // [012000-0123FF] Cuneiform.
  3792. // [012400-01247F] Cuneiform Numbers and Punctuation.
  3793. CountingRodNumerals = BL_FONT_UC_INDEX_COUNTING_ROD_NUMERALS, // [01D360-01D37F] Counting Rod Numerals.
  3794. Sundanese = BL_FONT_UC_INDEX_SUNDANESE, // [001B80-001BBF] Sundanese.
  3795. Lepcha = BL_FONT_UC_INDEX_LEPCHA, // [001C00-001C4F] Lepcha.
  3796. OlChiki = BL_FONT_UC_INDEX_OL_CHIKI, // [001C50-001C7F] Ol Chiki.
  3797. Saurashtra = BL_FONT_UC_INDEX_SAURASHTRA, // [00A880-00A8DF] Saurashtra.
  3798. KayahLi = BL_FONT_UC_INDEX_KAYAH_LI, // [00A900-00A92F] Kayah Li.
  3799. Rejang = BL_FONT_UC_INDEX_REJANG, // [00A930-00A95F] Rejang.
  3800. Cham = BL_FONT_UC_INDEX_CHAM, // [00AA00-00AA5F] Cham.
  3801. AncientSymbols = BL_FONT_UC_INDEX_ANCIENT_SYMBOLS, // [010190-0101CF] Ancient Symbols.
  3802. PhaistosDisc = BL_FONT_UC_INDEX_PHAISTOS_DISC, // [0101D0-0101FF] Phaistos Disc.
  3803. CarianLycianLydian = BL_FONT_UC_INDEX_CARIAN_LYCIAN_LYDIAN, // [0102A0-0102DF] Carian.
  3804. // [010280-01029F] Lycian.
  3805. // [010920-01093F] Lydian.
  3806. DominoAndMahjongTiles = BL_FONT_UC_INDEX_DOMINO_AND_MAHJONG_TILES, // [01F030-01F09F] Domino Tiles.
  3807. // [01F000-01F02F] Mahjong Tiles.
  3808. InternalUsage123 = BL_FONT_UC_INDEX_INTERNAL_USAGE_123, // Reserved for internal usage (123).
  3809. InternalUsage124 = BL_FONT_UC_INDEX_INTERNAL_USAGE_124, // Reserved for internal usage (124).
  3810. InternalUsage125 = BL_FONT_UC_INDEX_INTERNAL_USAGE_125, // Reserved for internal usage (125).
  3811. InternalUsage126 = BL_FONT_UC_INDEX_INTERNAL_USAGE_126, // Reserved for internal usage (126).
  3812. InternalUsage127 = BL_FONT_UC_INDEX_INTERNAL_USAGE_127); // Reserved for internal usage (127).
  3813. type
  3814. { Text direction. }
  3815. TBLTextDirection = (
  3816. { Left-to-right direction. }
  3817. LTR = BL_TEXT_DIRECTION_LTR,
  3818. { Right-to-left direction. }
  3819. RTL = BL_TEXT_DIRECTION_RTL);
  3820. type
  3821. { Text orientation. }
  3822. TBLTextOrientation = (
  3823. { Horizontal orientation. }
  3824. Horizontal = BL_TEXT_ORIENTATION_HORIZONTAL,
  3825. { Vertical orientation. }
  3826. Vertical = BL_TEXT_ORIENTATION_VERTICAL);
  3827. { ============================================================================
  3828. [BLGlyphInfo]
  3829. ============================================================================ }
  3830. type
  3831. { Contains additional information associated with a glyph used by
  3832. IBLGlyphBuffer. }
  3833. TBLGlyphInfo = record
  3834. {$REGION 'Internal Declarations'}
  3835. private
  3836. FHandle: BLGlyphInfo;
  3837. {$ENDREGION 'Internal Declarations'}
  3838. public
  3839. procedure Reset; inline;
  3840. property Cluster: Cardinal read FHandle.cluster write FHandle.cluster;
  3841. end;
  3842. PBLGlyphInfo = ^TBLGlyphInfo;
  3843. { ============================================================================
  3844. [BLGlyphPlacement]
  3845. ============================================================================ }
  3846. type
  3847. { Glyph placement.
  3848. Provides information about glyph offset (x/y) and advance (x/y). }
  3849. TBLGlyphPlacement = record
  3850. {$REGION 'Internal Declarations'}
  3851. private
  3852. FHandle: BLGlyphPlacement;
  3853. function GetPlacement: TBLPointI; inline;
  3854. procedure SetPlacement(const AValue: TBLPointI); inline;
  3855. function GetAdvance: TBLPointI; inline;
  3856. procedure SetAdvance(const AValue: TBLPointI); inline;
  3857. {$ENDREGION 'Internal Declarations'}
  3858. public
  3859. procedure Reset; inline;
  3860. property Placement: TBLPointI read GetPlacement write SetPlacement;
  3861. property Advance: TBLPointI read GetAdvance write SetAdvance;
  3862. end;
  3863. PBLGlyphPlacement = ^TBLGlyphPlacement;
  3864. { ============================================================================
  3865. [BLGlyphMappingState]
  3866. ============================================================================ }
  3867. type
  3868. { Character to glyph mapping state. }
  3869. TBLGlyphMappingState = record
  3870. {$REGION 'Internal Declarations'}
  3871. private
  3872. FHandle: BLGlyphMappingState;
  3873. function GetGlyphCount: Integer; inline;
  3874. procedure SetGlyphCount(const AValue: Integer); inline;
  3875. function GetUndefinedFirst: Integer; inline;
  3876. procedure SetUndefinedFirst(const AValue: Integer); inline;
  3877. function GetUndefinedCount: Integer; inline;
  3878. procedure SetUndefinedCount(const AValue: Integer); inline;
  3879. {$ENDREGION 'Internal Declarations'}
  3880. public
  3881. procedure Reset; inline;
  3882. { Number of glyphs or glyph-items on output. }
  3883. property GlyphCount: Integer read GetGlyphCount write SetGlyphCount;
  3884. { Index of the first undefined glyph (-1 if none). }
  3885. property UndefinedFirst: Integer read GetUndefinedFirst write SetUndefinedFirst;
  3886. { Undefined glyph count (chars that have no mapping). }
  3887. property UndefinedCount: Integer read GetUndefinedCount write SetUndefinedCount;
  3888. end;
  3889. PBLGlyphMappingState = ^TBLGlyphMappingState;
  3890. { ============================================================================
  3891. [BLGlyphOutlineSinkInfo]
  3892. ============================================================================ }
  3893. type
  3894. { Information passed to a TBLPathSinkEvent sink by IBLFont.GetGlyphOutlines. }
  3895. TBLGlyphOutlineSinkInfo = record
  3896. {$REGION 'Internal Declarations'}
  3897. private
  3898. FHandle: BLGlyphOutlineSinkInfo;
  3899. function GetGlyphIndex: Integer; inline;
  3900. procedure SetGlyphIndex(const AValue: Integer); inline;
  3901. function GetContourCount: Integer; inline;
  3902. procedure SetContourCount(const AValue: Integer); inline;
  3903. {$ENDREGION 'Internal Declarations'}
  3904. public
  3905. procedure Reset; inline;
  3906. property GlyphIndex: Integer read GetGlyphIndex write SetGlyphIndex;
  3907. property ContourCount: Integer read GetContourCount write SetContourCount;
  3908. end;
  3909. PBLGlyphOutlineSinkInfo = ^TBLGlyphOutlineSinkInfo;
  3910. { ============================================================================
  3911. [BLGlyphRun]
  3912. ============================================================================ }
  3913. type
  3914. { An entry enumerated by TBLGlyphRun.GetEnumerator }
  3915. TBLGlyphRunEntry<TPlacement: record> = record
  3916. public
  3917. { The glyph Id }
  3918. GlyphId: Cardinal;
  3919. { Glyph placement (type should match TBLGlyphRun.PlacementType) }
  3920. Placement: TPlacement;
  3921. end;
  3922. type
  3923. { TBLGlyphRun describes a set of consecutive glyphs and their placements.
  3924. TBLGlyphRun should only be used to pass glyph IDs and their placements to
  3925. the rendering context. The purpose of TBLGlyphRun is to allow rendering
  3926. glyphs, which could be shaped by various shaping engines (Blend2D, Harfbuzz,
  3927. etc).
  3928. TBLGlyphRun allows to render glyphs that are either stored in TArray<UInt16>
  3929. or TArray<UInt32> or part of a bigger structure (for example hb_glyph_info_t
  3930. used by HarfBuzz). Glyph placements at the moment use Blend2D's
  3931. TBLGlyphPlacement or TBLPoint, but it's possible to extend the data type in
  3932. the future.
  3933. See TBLGlyphRunPlacement for placement modes provided by Blend2D. }
  3934. TBLGlyphRun = record
  3935. {$REGION 'Internal Declarations'}
  3936. private type
  3937. TEnumerator<T: record> = record
  3938. private type
  3939. P = ^T;
  3940. private
  3941. FGlyphData: PByte;
  3942. FPlacementData: PByte;
  3943. FGlyphAdvance: Integer;
  3944. FPlacementAdvance: Integer;
  3945. FHigh: Integer;
  3946. FIndex: Integer;
  3947. function GetCurrent: TBLGlyphRunEntry<T>; inline;
  3948. public
  3949. constructor Create(const AHandle: _PBLGlyphRun);
  3950. function MoveNext: Boolean; inline;
  3951. property Current: TBLGlyphRunEntry<T> read GetCurrent;
  3952. end;
  3953. private type
  3954. TEnumerable<T: record> = record
  3955. private
  3956. FHandle: _PBLGlyphRun;
  3957. public
  3958. constructor Create(const AHandle: _PBLGlyphRun);
  3959. function GetEnumerator: TEnumerator<T>;
  3960. end;
  3961. private
  3962. FHandle: BLGlyphRun;
  3963. function GetSize: Integer; inline;
  3964. procedure SetSize(const AValue: Integer); inline;
  3965. function GetPlacementType: TBLGlyphPlacementType; inline;
  3966. procedure SetPlacementType(const AValue: TBLGlyphPlacementType); inline;
  3967. function GetFlags: TBLGlyphRunFlags; inline;
  3968. procedure SetFlags(const AValue: TBLGlyphRunFlags); inline;
  3969. function GetIsEmpty: Boolean; inline;
  3970. {$ENDREGION 'Internal Declarations'}
  3971. public
  3972. procedure Reset; inline;
  3973. procedure SetGlyphData(const AData: PWord); overload; inline;
  3974. procedure SetGlyphData(const AData: PCardinal); overload; inline;
  3975. procedure SetGlyphData(const AData: Pointer; const AAdvance: Integer); overload; inline;
  3976. procedure ResetGlyphIdData; inline;
  3977. procedure SetPlacementData(const AData: Pointer; const AAdvance: Integer); inline;
  3978. procedure ResetPlacementData; inline;
  3979. { Support for..in enumeration of the glyphs in the run.
  3980. The type parameter TPlacement of each entry should be a type that is
  3981. compatible with the PlacementType property.
  3982. Example:
  3983. var
  3984. GlyphRun: TBLGlyphRun;
  3985. Entry: TBLGlyphRunEntry<TBLPoint>;
  3986. begin
  3987. GlyphRun := ...;
  3988. for Entry in GlyphRun.Entries<TBLPoint> do
  3989. ...
  3990. end; }
  3991. function Entries<TPlacement: record>: TEnumerable<TPlacement>;
  3992. { Glyph id data (abstract, incremented by GlyphAdvance). }
  3993. property GlyphData: Pointer read FHandle.glyphData write FHandle.glyphData;
  3994. { Glyph placement data (abstract, incremented by PlacementAdvance). }
  3995. property PlacementData: Pointer read FHandle.placementData write FHandle.placementData;
  3996. { Size of the glyph-run in glyph units. }
  3997. property Size: Integer read GetSize write SetSize;
  3998. { Size of a GlyphId - must be either 2 (UInt16) or 4 (UInt32) bytes.
  3999. Blend2D always uses 32-bit glyph-ids, thus the glyph-run returned
  4000. by IBLGlyphBuffer has always set GlyphSize to 4. The possibility to
  4001. render glyphs of size 2 is strictly for compatibility with text shapers
  4002. that use 16-bit glyphs, which is sufficient for TrueType and OpenType
  4003. fonts.}
  4004. property GlyphSize: Byte read FHandle.glyphSize write FHandle.glyphSize;
  4005. { Type of placement }
  4006. property PlacementType: TBLGlyphPlacementType read GetPlacementType write SetPlacementType;
  4007. { Advance of GlyphData array. }
  4008. property GlyphAdvance: Shortint read FHandle.glyphAdvance write FHandle.glyphAdvance;
  4009. { Glyph-run flags. }
  4010. property Flags: TBLGlyphRunFlags read GetFlags write SetFlags;
  4011. property IsEmpty: Boolean read GetIsEmpty;
  4012. end;
  4013. PBLGlyphRun = ^TBLGlyphRun;
  4014. { ============================================================================
  4015. [BLFontFaceInfo]
  4016. ============================================================================ }
  4017. type
  4018. { Information of IBLFontFace. }
  4019. TBLFontFaceInfo = record
  4020. {$REGION 'Internal Declarations'}
  4021. private
  4022. FHandle: BLFontFaceInfo;
  4023. function GetFaceType: TBLFontFaceType; inline;
  4024. procedure SetFaceType(const AValue: TBLFontFaceType); inline;
  4025. function GetOutlineType: TBLFontOutlineType; inline;
  4026. procedure SetOutlineType(const AValue: TBLFontOutlineType); inline;
  4027. function GetGlyphCount: Integer; inline;
  4028. procedure SetGlyphCount(const AValue: Integer); inline;
  4029. function GetFaceFlags: TBLFontFaceFlags; inline;
  4030. procedure SetFaceFlags(const AValue: TBLFontFaceFlags); inline;
  4031. function GetDiagFlags: TBLFontFaceDiagFlags; inline;
  4032. procedure SetDiagFlags(const AValue: TBLFontFaceDiagFlags); inline;
  4033. {$ENDREGION 'Internal Declarations'}
  4034. public
  4035. procedure Reset; inline;
  4036. { Font-face type }
  4037. property FaceType: TBLFontFaceType read GetFaceType write SetFaceType;
  4038. { Type of outlines used by the font-face }
  4039. property OutlineType: TBLFontOutlineType read GetOutlineType write SetOutlineType;
  4040. { Number of glyphs provided by this font-face. }
  4041. property GlyphCount: Integer read GetGlyphCount write SetGlyphCount;
  4042. { Revision (read from 'head' table, represented as 16.16 fixed point). }
  4043. property Revision: Cardinal read FHandle.revision write FHandle.revision;
  4044. { Face-face index in a TTF/OTF collection or zero if not part of a collection. }
  4045. property FaceIndex: Integer read FHandle.faceIndex write FHandle.faceIndex;
  4046. { Font-face flags }
  4047. property FaceFlags: TBLFontFaceFlags read GetFaceFlags write SetFaceFlags;
  4048. { Font-face diagnostic flags }
  4049. property DiagFlags: TBLFontFaceDiagFlags read GetDiagFlags write SetDiagFlags;
  4050. end;
  4051. PBLFontFaceInfo = ^TBLFontFaceInfo;
  4052. { ============================================================================
  4053. [BLFontQueryProperties]
  4054. ============================================================================ }
  4055. type
  4056. { Properties that can be used to query IBLFont and IBLFontFace. }
  4057. TBLFontQueryProperties = record
  4058. {$REGION 'Internal Declarations'}
  4059. private
  4060. FHandle: BLFontQueryProperties;
  4061. function GetStyle: TBLFontStyle; inline;
  4062. procedure SetStyle(const AValue: TBLFontStyle); inline;
  4063. function GetWeight: TBLFontWeight; inline;
  4064. procedure SetWeight(const AValue: TBLFontWeight); inline;
  4065. function GetStretch: TBLFontStretch; inline;
  4066. procedure SetStretch(const AValue: TBLFontStretch); inline;
  4067. {$ENDREGION 'Internal Declarations'}
  4068. public
  4069. procedure Reset; inline;
  4070. { Font style }
  4071. property Style: TBLFontStyle read GetStyle write SetStyle;
  4072. { Font weight }
  4073. property Weight: TBLFontWeight read GetWeight write SetWeight;
  4074. { Font stretch }
  4075. property Stretch: TBLFontStretch read GetStretch write SetStretch;
  4076. end;
  4077. { ============================================================================
  4078. [BLFontTable]
  4079. ============================================================================ }
  4080. type
  4081. { A read only data that represents a font table or its sub-table. }
  4082. TBLFontTable = record
  4083. {$REGION 'Internal Declarations'}
  4084. private
  4085. FHandle: BLFontTable;
  4086. function GetSize: Integer; inline;
  4087. procedure SetSize(const AValue: Integer); inline;
  4088. {$ENDREGION 'Internal Declarations'}
  4089. public
  4090. procedure Reset; overload; inline;
  4091. procedure Reset(const AData: Pointer; const ASize: Integer); overload; inline;
  4092. { Pointer to the beginning of the data }
  4093. property Data: Pointer read FHandle.data write FHandle.data;
  4094. { Size of Data in bytes. }
  4095. property Size: Integer read GetSize write SetSize;
  4096. end;
  4097. PBLFontTable = ^TBLFontTable;
  4098. { ============================================================================
  4099. [BLFontFeature]
  4100. ============================================================================ }
  4101. type
  4102. { Associates a value with a generic font feature where Tag describes the
  4103. feature (as provided by the font) and Value describes its value. Some
  4104. features only allow boolean values 0 and 1 and some also allow higher
  4105. values up to 65535.
  4106. Registered OpenType features:
  4107. - https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags
  4108. - https://helpx.adobe.com/typekit/using/open-type-syntax.html }
  4109. TBLFontFeature = record
  4110. {$REGION 'Internal Declarations'}
  4111. private
  4112. FHandle: BLFontFeature;
  4113. {$ENDREGION 'Internal Declarations'}
  4114. public
  4115. procedure Reset; inline;
  4116. { Feature tag (32-bit). }
  4117. property Tag: TBLTag read FHandle.tag write FHandle.tag;
  4118. { Feature value (should not be greater than 65535). }
  4119. property Value: Cardinal read FHandle.value write FHandle.value;
  4120. end;
  4121. PBLFontFeature = ^TBLFontFeature;
  4122. { ============================================================================
  4123. [BLFontVariation]
  4124. ============================================================================ }
  4125. type
  4126. { Associates a value with a font variation feature where Tag describes
  4127. variation axis and Value defines its value. }
  4128. TBLFontVariation = record
  4129. {$REGION 'Internal Declarations'}
  4130. private
  4131. FHandle: BLFontVariation;
  4132. {$ENDREGION 'Internal Declarations'}
  4133. public
  4134. procedure Reset; inline;
  4135. { Variation tag (32-bit). }
  4136. property Tag: TBLTag read FHandle.tag write FHandle.tag;
  4137. { Variation value. }
  4138. property Value: Single read FHandle.value write FHandle.value;
  4139. end;
  4140. PBLFontVariation = ^TBLFontVariation;
  4141. { ============================================================================
  4142. [BLFontUnicodeCoverage]
  4143. ============================================================================ }
  4144. type
  4145. { Font unicode coverage.
  4146. Unicode coverage describes which unicode characters are provided by a font.
  4147. Blend2D accesses this information by reading "OS/2" table, if available. }
  4148. TBLFontUnicodeCoverage = record
  4149. {$REGION 'Internal Declarations'}
  4150. private
  4151. FHandle: BLFontUnicodeCoverage;
  4152. function GetIsEmpty: Boolean; inline;
  4153. function GetBit(const AIndex: TBLFontUnicodeCoverageIndex): Boolean;
  4154. procedure SetBit(const AIndex: TBLFontUnicodeCoverageIndex; const AValue: Boolean); overload;
  4155. {$ENDREGION 'Internal Declarations'}
  4156. public
  4157. class operator Equal(const ALeft, ARight: TBLFontUnicodeCoverage): Boolean; inline; static;
  4158. class operator NotEqual(const ALeft, ARight: TBLFontUnicodeCoverage): Boolean; inline; static;
  4159. public
  4160. procedure Reset; inline;
  4161. procedure SetBit(const AIndex: TBLFontUnicodeCoverageIndex); overload; inline;
  4162. procedure ClearBit(const AIndex: TBLFontUnicodeCoverageIndex); inline;
  4163. property IsEmpty: Boolean read GetIsEmpty;
  4164. property Bits[const AIndex: TBLFontUnicodeCoverageIndex]: Boolean read GetBit write SetBit;
  4165. end;
  4166. PBLFontUnicodeCoverage = ^TBLFontUnicodeCoverage;
  4167. { ============================================================================
  4168. [BLFontPanose]
  4169. ============================================================================ }
  4170. type
  4171. TBLFontPanoseText = record
  4172. FamilyKind: Byte;
  4173. SerifStyle: Byte;
  4174. Weight: Byte;
  4175. Proportion: Byte;
  4176. Contrast: Byte;
  4177. StrokeVariation: Byte;
  4178. ArmStyle: Byte;
  4179. Letterform: Byte;
  4180. Midline: Byte;
  4181. XHeight: Byte
  4182. end;
  4183. type
  4184. TBLFontPanoseScript = record
  4185. FamilyKind: Byte;
  4186. ToolKind: Byte;
  4187. Weight: Byte;
  4188. Spacing: Byte;
  4189. AspectRatio: Byte;
  4190. Contrast: Byte;
  4191. Topology: Byte;
  4192. Form: Byte;
  4193. Finials: Byte;
  4194. XAscent: Byte;
  4195. end;
  4196. type
  4197. TBLFontPanoseDecorative = record
  4198. FamilyKind: Byte;
  4199. DecorativeClass: Byte;
  4200. Weight: Byte;
  4201. Aspect: Byte;
  4202. Contrast: Byte;
  4203. SerifVariant: Byte;
  4204. Treatment: Byte;
  4205. Lining: Byte;
  4206. Topology: Byte;
  4207. CharacterRange: Byte;
  4208. end;
  4209. type
  4210. TBLFontPanoseSymbol = record
  4211. FamilyKind: Byte;
  4212. SymbolKind: Byte;
  4213. Weight: Byte;
  4214. Spacing: Byte;
  4215. AspectRatioAndContrast: Byte;
  4216. AspectRatio94: Byte;
  4217. AspectRatio119: Byte;
  4218. AspectRatio157: Byte;
  4219. AspectRatio163: Byte;
  4220. AspectRatio211: Byte;
  4221. end;
  4222. type
  4223. { Scaled TBLFontDesignMetrics based on font size and other properties. }
  4224. TBLFontPanose = record
  4225. {$REGION 'Internal Declarations'}
  4226. private
  4227. function GetIsEmpty: Boolean; inline;
  4228. {$ENDREGION 'Internal Declarations'}
  4229. public
  4230. procedure Reset; inline;
  4231. property IsEmpty: Boolean read GetIsEmpty;
  4232. public
  4233. case Integer of
  4234. 0: (Data: array [0..9] of Byte);
  4235. 1: (FamilyKind: Byte);
  4236. 2: (Text: TBLFontPanoseText);
  4237. 3: (Script: TBLFontPanoseScript);
  4238. 4: (Decorative: TBLFontPanoseDecorative);
  4239. 5: (Symbol: TBLFontPanoseSymbol);
  4240. end;
  4241. PBLFontPanose = ^TBLFontPanose;
  4242. { ============================================================================
  4243. [BLFontMatrix]
  4244. ============================================================================ }
  4245. type
  4246. { 2x2 transformation matrix used by IBLFont. It's similar to TBLMatrix2D,
  4247. however, it doesn't provide a translation part as it's assumed to be zero. }
  4248. TBLFontMatrix = record
  4249. {$REGION 'Internal Declarations'}
  4250. private
  4251. FHandle: BLFontMatrix;
  4252. function GetElement(const AIndex: Integer): Double; inline;
  4253. procedure SetElement(const AIndex: Integer; const AValue: Double); inline;
  4254. {$ENDREGION 'Internal Declarations'}
  4255. public
  4256. procedure Reset; overload; inline;
  4257. procedure Reset(const AM00, AM01, AM10, AM11: Double); overload; inline;
  4258. property Elements[const AIndex: Integer]: Double read GetElement write SetElement; default;
  4259. property M00: Double read FHandle.m00 write FHandle.m00;
  4260. property M01: Double read FHandle.m01 write FHandle.m01;
  4261. property M10: Double read FHandle.m10 write FHandle.m10;
  4262. property M11: Double read FHandle.m11 write FHandle.m11;
  4263. end;
  4264. PBLFontMatrix = ^TBLFontMatrix;
  4265. function BLFontMatrix(const AM00, AM01, AM10, AM11: Double): TBLFontMatrix; inline;
  4266. { ============================================================================
  4267. [BLFontMetrics]
  4268. ============================================================================ }
  4269. type
  4270. { Scaled TBLFontDesignMetrics based on font size and other properties. }
  4271. TBLFontMetrics = record
  4272. {$REGION 'Internal Declarations'}
  4273. private
  4274. FHandle: BLFontMetrics;
  4275. {$ENDREGION 'Internal Declarations'}
  4276. public
  4277. procedure Reset; inline;
  4278. { Font ascent (horizontal orientation). }
  4279. property Ascent: Single read FHandle.ascent write FHandle.ascent;
  4280. { Font ascent (vertical orientation). }
  4281. property VAscent: Single read FHandle.vAscent write FHandle.vAscent;
  4282. { Font descent (horizontal orientation). }
  4283. property Descent: Single read FHandle.descent write FHandle.descent;
  4284. { Font descent (vertical orientation). }
  4285. property VDescent: Single read FHandle.vDescent write FHandle.vDescent;
  4286. { Line gap. }
  4287. property LineGap: Single read FHandle.lineGap write FHandle.lineGap;
  4288. { Distance between the baseline and the mean line of lower-case letters. }
  4289. property XHeight: Single read FHandle.xHeight write FHandle.xHeight;
  4290. { Maximum height of a capital letter above the baseline.}
  4291. property CapHeight: Single read FHandle.capHeight write FHandle.capHeight;
  4292. { Minimum x, reported by the font. }
  4293. property XMin: Single read FHandle.xMin write FHandle.xMin;
  4294. { Minimum y, reported by the font. }
  4295. property YMin: Single read FHandle.yMin write FHandle.yMin;
  4296. { Maximum x, reported by the font. }
  4297. property XMax: Single read FHandle.xMax write FHandle.xMax;
  4298. { Maximum y, reported by the font. }
  4299. property YMax: Single read FHandle.yMax write FHandle.yMax;
  4300. { Text underline position. }
  4301. property UnderlinePosition: Single read FHandle.underlinePosition write FHandle.underlinePosition;
  4302. { Text underline thickness. }
  4303. property UnderlineThickness: Single read FHandle.underlineThickness write FHandle.underlineThickness;
  4304. { Text strikethrough position. }
  4305. property StrikethroughPosition: Single read FHandle.strikethroughPosition write FHandle.strikethroughPosition;
  4306. { Text strikethrough thickness. }
  4307. property StrikethroughThickness: Single read FHandle.strikethroughThickness write FHandle.strikethroughThickness;
  4308. end;
  4309. PBLFontMetrics = ^TBLFontMetrics;
  4310. { ============================================================================
  4311. [BLFontDesignMetrics]
  4312. ============================================================================ }
  4313. type
  4314. { Design metrics of a font.
  4315. Design metrics is information that IBLFontFace collected directly from the
  4316. font data. It means that all fields are measured in font design units.
  4317. When a new IBLFont instance is created a scaled metrics IBLFontMetrics is
  4318. automatically calculated from IBLFontDesignMetrics including other members
  4319. like transformation, etc... }
  4320. TBLFontDesignMetrics = record
  4321. {$REGION 'Internal Declarations'}
  4322. private
  4323. FHandle: BLFontDesignMetrics;
  4324. function GetGlyphBoundingBox: TBLBoxI; inline;
  4325. procedure SetGlyphBoundingBox(const AValue: TBLBoxI); inline;
  4326. {$ENDREGION 'Internal Declarations'}
  4327. public
  4328. procedure Reset; inline;
  4329. { Units per EM square. }
  4330. property UnitsPerEm: Integer read FHandle.unitsPerEm write FHandle.unitsPerEm;
  4331. { Lowest readable size in pixels. }
  4332. property LowestPPEM: Integer read FHandle.lowestPPEM write FHandle.lowestPPEM;
  4333. { Line gap. }
  4334. property LineGap: Integer read FHandle.lineGap write FHandle.lineGap;
  4335. { Distance between the baseline and the mean line of lower-case letters. }
  4336. property XHeight: Integer read FHandle.xHeight write FHandle.xHeight;
  4337. { Maximum height of a capital letter above the baseline. }
  4338. property CapHeight: Integer read FHandle.capHeight write FHandle.capHeight;
  4339. { Ascent (horizontal layout). }
  4340. property Ascent: Integer read FHandle.ascent write FHandle.ascent;
  4341. { Ascent (vertical layout). }
  4342. property VAscent: Integer read FHandle.vAscent write FHandle.vAscent;
  4343. { Descent (horizontal layout). }
  4344. property Descent: Integer read FHandle.descent write FHandle.descent;
  4345. { Descent (vertical layout). }
  4346. property VDescent: Integer read FHandle.vDescent write FHandle.vDescent;
  4347. { Minimum leading-side bearing (horizontal layout). }
  4348. property HMinLSB: Integer read FHandle.hMinLSB write FHandle.hMinLSB;
  4349. { Minimum leading-side bearing (vertical layout). }
  4350. property VMinLSB: Integer read FHandle.vMinLSB write FHandle.vMinLSB;
  4351. { Minimum trailing-side bearing (horizontal layout). }
  4352. property HMinTSB: Integer read FHandle.hMinTSB write FHandle.hMinTSB;
  4353. { Minimum trailing-side bearing (vertical layout). }
  4354. property VMinTSB: Integer read FHandle.vMinTSB write FHandle.vMinTSB;
  4355. { Maximum advance (horizontal layout). }
  4356. property HMaxAdvance: Integer read FHandle.hMaxAdvance write FHandle.hMaxAdvance;
  4357. { Maximum advance (vertical layout). }
  4358. property VMaxAdvance: Integer read FHandle.vMaxAdvance write FHandle.vMaxAdvance;
  4359. { Aggregated bounding box of all glyphs in the font.
  4360. This value is reported by the face so it's not granted to be true. }
  4361. property GlyphBoundingBox: TBLBoxI read GetGlyphBoundingBox write SetGlyphBoundingBox;
  4362. { Minimum x, reported by the font. }
  4363. property XMin: Integer read FHandle.glyphBoundingBox.x0 write FHandle.glyphBoundingBox.x0;
  4364. { Minimum y, reported by the font. }
  4365. property YMin: Integer read FHandle.glyphBoundingBox.y0 write FHandle.glyphBoundingBox.y0;
  4366. { Maximum x, reported by the font. }
  4367. property XMax: Integer read FHandle.glyphBoundingBox.x1 write FHandle.glyphBoundingBox.x1;
  4368. { Maximum y, reported by the font. }
  4369. property YMax: Integer read FHandle.glyphBoundingBox.y1 write FHandle.glyphBoundingBox.y1;
  4370. { Text underline position. }
  4371. property UnderlinePosition: Integer read FHandle.underlinePosition write FHandle.underlinePosition;
  4372. { Text underline thickness. }
  4373. property UnderlineThickness: Integer read FHandle.underlineThickness write FHandle.underlineThickness;
  4374. { Text strikethrough position. }
  4375. property StrikethroughPosition: Integer read FHandle.strikethroughPosition write FHandle.strikethroughPosition;
  4376. { Text strikethrough thickness. }
  4377. property StrikethroughThickness: Integer read FHandle.strikethroughThickness write FHandle.strikethroughThickness;
  4378. end;
  4379. PBLFontDesignMetrics = ^TBLFontDesignMetrics;
  4380. { ============================================================================
  4381. [BLTextMetrics]
  4382. ============================================================================ }
  4383. type
  4384. { Text metrics. }
  4385. TBLTextMetrics = record
  4386. {$REGION 'Internal Declarations'}
  4387. private
  4388. FHandle: BLTextMetrics;
  4389. function GetAdvance: TBLPoint; inline;
  4390. procedure SetAdvance(const AValue: TBLPoint); inline;
  4391. function GetLeadingBearing: TBLPoint; inline;
  4392. procedure SetLeadingBearing(const AValue: TBLPoint); inline;
  4393. function GetTrailingBearing: TBLPoint; inline;
  4394. procedure SetTrailingBearing(const AValue: TBLPoint); inline;
  4395. function GetBoundingBox: TBLBox; inline;
  4396. procedure SetBoundingBox(const AValue: TBLBox); inline;
  4397. {$ENDREGION 'Internal Declarations'}
  4398. public
  4399. procedure Reset; inline;
  4400. property Advance: TBLPoint read GetAdvance write SetAdvance;
  4401. property LeadingBearing: TBLPoint read GetLeadingBearing write SetLeadingBearing;
  4402. property TrailingBearing: TBLPoint read GetTrailingBearing write SetTrailingBearing;
  4403. property BoundingBox: TBLBox read GetBoundingBox write SetBoundingBox;
  4404. end;
  4405. PBLTextMetrics = ^TBLTextMetrics;
  4406. {$ENDREGION 'Font Defs'}
  4407. {$REGION 'Glyph Buffer'}
  4408. { ============================================================================
  4409. [BLGlyphBuffer]
  4410. ============================================================================ }
  4411. type
  4412. { Glyph buffer.
  4413. Can hold either text or glyphs and provides basic memory management that is
  4414. used for text shaping, character to glyph mapping, glyph substitution, and
  4415. glyph positioning.
  4416. Glyph buffer provides two separate buffers called 'primary' and 'secondary'
  4417. that serve different purposes during processing. Primary buffer always holds
  4418. actual text/glyph array, and secondary buffer is either used as a scratch
  4419. buffer during glyph substitution or to hold glyph positions after the
  4420. processing is complete and glyph positions were calculated. }
  4421. IBLGlyphBuffer = interface
  4422. ['{0B892B22-C3B5-434D-854C-FBD0FD431B7B}']
  4423. {$REGION 'Internal Declarations'}
  4424. function GetIsEmpty: Boolean;
  4425. function GetSize: Integer;
  4426. function GetFlags: TBLGlyphRunFlags;
  4427. function GetContent: PCardinal;
  4428. function GetInfoData: PBLGlyphInfo;
  4429. function GetPlacementData: PBLGlyphPlacement;
  4430. function GetGlyphRun: PBLGlyphRun;
  4431. function GetHasText: Boolean;
  4432. function GetHasGlyphs: Boolean;
  4433. function GetHasInvalidChars: Boolean;
  4434. function GetHasUndefinedChars: Boolean;
  4435. function GetHasInvalidFontData: Boolean;
  4436. function GetHandle: PBLGlyphBufferCore;
  4437. {$ENDREGION 'Internal Declarations'}
  4438. { Resets the IBLGlyphBuffer into its construction state. The content will
  4439. be cleared and allocated memory released. }
  4440. procedure Reset;
  4441. { Clears the content of IBLGlyphBuffer without releasing internal buffers. }
  4442. procedure Clear;
  4443. { Assigns a text content of this IBLGlyphBuffer. }
  4444. procedure SetText(const AText: String); overload;
  4445. procedure SetText(const AText: UTF8String); overload;
  4446. procedure SetText(const AText: UCS4String); overload;
  4447. { Assigns a text content of this IBLGlyphBuffer.
  4448. This is a generic function that accepts Pointer data, which is specified
  4449. by AEncoding. The ALength argument depends on encoding as well. If the
  4450. encoding specifies byte string (Latin1 or UTF8) then it's bytes, if the
  4451. encoding specifies UTF16 or UTF32 then it would describe the number of
  4452. UInt16 or UInt32 code points, respectively. }
  4453. procedure SetText(const AText: Pointer; const ALength: Integer;
  4454. const AEncoding: TBLTextEncoding); overload;
  4455. { Assigns glyph content of this IBLGlyphBuffer from the given AGlyphData. }
  4456. procedure SetGlyphs(const AGlyphData: TArray<Cardinal>); overload;
  4457. procedure SetGlyphs(const AGlyphData: PCardinal; const ALength: Integer); overload;
  4458. { Assigns glyph content of this IBLGlyphBuffer`from an array of glyphs or
  4459. from a foreign record that contains glyphs and possibly other members that
  4460. have to be skipped. The AGlyphIdSize can be either 16-bit (2) or 32-bit (4).
  4461. The last parameter AGlyphAdvance specifies how many bytes to advance after
  4462. a glyph value is read. }
  4463. procedure SetGlyphs(const AGlyphData: Pointer; const ASize: Integer;
  4464. const AGlyphIdSize, AGlyphAdvance: Integer); overload;
  4465. { Tests whether the glyph-buffer has AFlag set. }
  4466. function HasFlag(const AFlag: TBLGlyphRunFlag): Boolean;
  4467. property IsEmpty: Boolean read GetIsEmpty;
  4468. property Size: Integer read GetSize;
  4469. property Flags: TBLGlyphRunFlags read GetFlags;
  4470. property Content: PCardinal read GetContent;
  4471. property InfoData: PBLGlyphInfo read GetInfoData;
  4472. property PlacementData: PBLGlyphPlacement read GetPlacementData;
  4473. property GlyphRun: PBLGlyphRun read GetGlyphRun;
  4474. { Tests whether the buffer contains unicode data. }
  4475. property HasText: Boolean read GetHasText;
  4476. { Tests whether the buffer contains glyph-id data. }
  4477. property HasGlyphs: Boolean read GetHasGlyphs;
  4478. { Tests whether the input string contained invalid characters (unicode
  4479. encoding errors). }
  4480. property HasInvalidChars: Boolean read GetHasInvalidChars;
  4481. { Tests whether the input string contained undefined characters that weren't
  4482. mapped properly to glyphs. }
  4483. property HasUndefinedChars: Boolean read GetHasUndefinedChars;
  4484. { Tests whether one or more operation was terminated before completion
  4485. because of invalid data in a font. }
  4486. property HasInvalidFontData: Boolean read GetHasInvalidFontData;
  4487. { Internal handle for use with the C API }
  4488. property Handle: PBLGlyphBufferCore read GetHandle;
  4489. end;
  4490. type
  4491. { Implements IBLGlyphBuffer }
  4492. TBLGlyphBuffer = class(TInterfacedObject, IBLGlyphBuffer)
  4493. {$REGION 'Internal Declarations'}
  4494. private
  4495. FHandle: BLGlyphBufferCore;
  4496. protected
  4497. { IBLGlyphBuffer }
  4498. function GetIsEmpty: Boolean;
  4499. function GetSize: Integer;
  4500. function GetFlags: TBLGlyphRunFlags;
  4501. function GetContent: PCardinal;
  4502. function GetInfoData: PBLGlyphInfo;
  4503. function GetPlacementData: PBLGlyphPlacement;
  4504. function GetGlyphRun: PBLGlyphRun;
  4505. function GetHasText: Boolean;
  4506. function GetHasGlyphs: Boolean;
  4507. function GetHasInvalidChars: Boolean;
  4508. function GetHasUndefinedChars: Boolean;
  4509. function GetHasInvalidFontData: Boolean;
  4510. function GetHandle: PBLGlyphBufferCore;
  4511. procedure Reset;
  4512. procedure Clear;
  4513. procedure SetText(const AText: String); overload;
  4514. procedure SetText(const AText: UTF8String); overload;
  4515. procedure SetText(const AText: UCS4String); overload;
  4516. procedure SetText(const AText: Pointer; const ALength: Integer;
  4517. const AEncoding: TBLTextEncoding); overload;
  4518. procedure SetGlyphs(const AGlyphData: TArray<Cardinal>); overload;
  4519. procedure SetGlyphs(const AGlyphData: PCardinal; const ALength: Integer); overload;
  4520. procedure SetGlyphs(const AGlyphData: Pointer; const ASize: Integer;
  4521. const AGlyphIdSize, AGlyphAdvance: Integer); overload;
  4522. function HasFlag(const AFlag: TBLGlyphRunFlag): Boolean;
  4523. {$ENDREGION 'Internal Declarations'}
  4524. public
  4525. constructor Create;
  4526. destructor Destroy; override;
  4527. end;
  4528. {$ENDREGION 'Glyph Buffer'}
  4529. {$REGION 'Font'}
  4530. { ============================================================================
  4531. [BLFontData]
  4532. ============================================================================ }
  4533. type
  4534. IBLFontData = interface;
  4535. { This event is called when IBLFontData.InitializeFromData is used and the
  4536. font data is destroyed. }
  4537. TBLFontDataDestroyEvent = procedure (const AFontData: IBLFontData) of object;
  4538. { Font data }
  4539. IBLFontData = interface
  4540. ['{988C31B8-A00C-4BD0-98D9-FDF2EF6D8CAA}']
  4541. {$REGION 'Internal Declarations'}
  4542. function GetIsNone: Boolean;
  4543. function GetFaceType: TBLFontFaceType;
  4544. function GetFaceCount: Integer;
  4545. function GetFlags: TBLFontDataFlags;
  4546. function GetIsCollection: Boolean;
  4547. function GetHandle: PBLFontDataCore;
  4548. {$ENDREGION 'Internal Declarations'}
  4549. { Initializes an IBLFontData from a file specified by the given AFilename.
  4550. The AReadFlags argument allows to specify flags that will be passed to
  4551. IBLFileSystem.ReadFile to read the content of the file. It's possible to
  4552. use memory mapping to get its content, which is the recommended way for
  4553. reading system fonts. The best combination is to use the
  4554. TBLFileReadFlag.MmapEnabled flag combined with
  4555. TBLFileReadFlag.MmapAvoidSmall. This combination means to try to use
  4556. memory mapping only when the size of the font is greater than a minimum
  4557. value (determined by Blend2D), and would fallback to a regular open/read
  4558. in case the memory mapping is not possible or failed for some other
  4559. reason. Please note that not all files can be memory mapped so the
  4560. TBLFileReadFlag.MmapNoFallback flag is not recommended. }
  4561. procedure InitializeFromFile(const AFilename: String;
  4562. const AReadFlags: TBLFileReadFlags = []);
  4563. { Initializes an IBLFontData from the given AData.
  4564. The given AData would be weak copied on success so the given array can be
  4565. safely destroyed after the function returns.
  4566. The weak copy of the passed AData is internal and there is no API to
  4567. access it after the function returns. The reason for making it internal
  4568. is that multiple implementations of IBLFontData may exist and some can
  4569. only store data at table level, so Blend2D doesn't expose the detail about
  4570. how the data is stored. }
  4571. procedure InitializeFromData(const AData: TBytes); overload;
  4572. { Creates IBLFontData from the given AData of the given ASize.
  4573. AData must stay alive as long as this object is alive.
  4574. Optionally an AOnDestroy event can be used as a notifier that will be
  4575. called when the data is no longer needed. }
  4576. procedure InitializeFromData(const AData: Pointer; const ASize: Integer;
  4577. const AOnDestroy: TBLFontDataDestroyEvent = nil); overload;
  4578. procedure Reset;
  4579. function Equals(const AOther: IBLFontData): Boolean;
  4580. function GetTags(const AFaceIndex: Integer): TArray<TBLTag>;
  4581. function QueryTable(const AFaceIndex: Integer; const ATag: TBLTag;
  4582. out ATable: TBLFontTable): Integer;
  4583. function QueryTables(const AFaceIndex: Integer; const ATags: TArray<TBLTag>;
  4584. out ATables: TArray<TBLFontTable>): Integer;
  4585. { Whether the font data is a built-in null instance. }
  4586. property IsNone: Boolean read GetIsNone;
  4587. { Tests whether the font data is empty (which the same as IsNone in this
  4588. case). }
  4589. property IsEmpty: Boolean read GetIsNone;
  4590. { Type of font-face that this data describes.
  4591. It doesn't matter if the content is a single font or a collection. In
  4592. any case the FaceType would always return the type of the font-face
  4593. that will be created by IBLFontFace.CreateFromData. }
  4594. property FaceType: TBLFontFaceType read GetFaceType;
  4595. { The number of faces of this font-data.
  4596. If the data is not initialized the result would be always zero. If the
  4597. data is initialized to a single font it would be 1, and if the data is
  4598. initialized to a font collection then the return would correspond to
  4599. the number of font-faces within that collection.
  4600. You should not use FaceCount to check whether the font is a collection as
  4601. it's possible to have a font-collection with just a single font. Using
  4602. IsCollection is more reliable and would always return the right value. }
  4603. property FaceCount: Integer read GetFaceCount;
  4604. { Font-data flags }
  4605. property Flags: TBLFontDataFlags read GetFlags;
  4606. { Whether this font-data is a font-collection. }
  4607. property IsCollection: Boolean read GetIsCollection;
  4608. { Internal handle for use with the C API }
  4609. property Handle: PBLFontDataCore read GetHandle;
  4610. end;
  4611. type
  4612. { Implements IBLFontData }
  4613. TBLFontData = class(TInterfacedObject, IBLFontData)
  4614. {$REGION 'Internal Declarations'}
  4615. private type
  4616. TDestroyData = record
  4617. FontData: IBLFontData;
  4618. Event: TBLFontDataDestroyEvent;
  4619. end;
  4620. PDestroyData = ^TDestroyData;
  4621. private
  4622. FHandle: BLFontDataCore;
  4623. FIsReference: Boolean;
  4624. private
  4625. class procedure DoDestroy(impl, destroyData: Pointer); cdecl; static;
  4626. protected
  4627. { IBLFontData }
  4628. function GetIsNone: Boolean;
  4629. function GetFaceType: TBLFontFaceType;
  4630. function GetFaceCount: Integer;
  4631. function GetFlags: TBLFontDataFlags;
  4632. function GetIsCollection: Boolean;
  4633. function GetHandle: PBLFontDataCore;
  4634. procedure InitializeFromFile(const AFilename: String;
  4635. const AReadFlags: TBLFileReadFlags = []);
  4636. procedure InitializeFromData(const AData: TBytes); overload;
  4637. procedure InitializeFromData(const AData: Pointer; const ASize: Integer;
  4638. const AOnDestroy: TBLFontDataDestroyEvent = nil); overload;
  4639. procedure Reset;
  4640. function Equals(const AOther: IBLFontData): Boolean; reintroduce; overload;
  4641. function GetTags(const AFaceIndex: Integer): TArray<TBLTag>;
  4642. function QueryTable(const AFaceIndex: Integer; const ATag: TBLTag;
  4643. out ATable: TBLFontTable): Integer;
  4644. function QueryTables(const AFaceIndex: Integer; const ATags: TArray<TBLTag>;
  4645. out ATables: TArray<TBLFontTable>): Integer;
  4646. private
  4647. constructor Create(const AHandle: BLFontDataCore;
  4648. const AIsReference: Boolean); overload;
  4649. {$ENDREGION 'Internal Declarations'}
  4650. public
  4651. constructor Create; overload;
  4652. destructor Destroy; override;
  4653. function Equals(Obj: TObject): Boolean; overload; override;
  4654. end;
  4655. { ============================================================================
  4656. [BLFontFace]
  4657. ============================================================================ }
  4658. type
  4659. { Font face }
  4660. IBLFontFace = interface
  4661. ['{D51BEBAD-EB2A-41CA-B76C-5773E696CA80}']
  4662. {$REGION 'Internal Declarations'}
  4663. function GetIsNone: Boolean;
  4664. function GetWeight: TBLFontWeight;
  4665. function GetStretch: TBLFontStretch;
  4666. function GetStyle: TBLFontStyle;
  4667. function GetFaceInfo: TBLFontFaceInfo;
  4668. function GetFaceType: TBLFontFaceType;
  4669. function GetOutlineType: TBLFontOutlineType;
  4670. function GetFaceIndex: Integer;
  4671. function GetFaceFlags: TBLFontFaceFlags;
  4672. function GetHasTypographicNames: Boolean;
  4673. function GetHasTypographicMetrics: Boolean;
  4674. function GetHasCharToGlyphMapping: Boolean;
  4675. function GetHasHorizontalMetrics: Boolean;
  4676. function GetHasVerticalMetrics: Boolean;
  4677. function GetHasHorizontalKerning: Boolean;
  4678. function GetHasVerticalKerning: Boolean;
  4679. function GetHasOpenTypeFeatures: Boolean;
  4680. function GetHasPanoseData: Boolean;
  4681. function GetHasUnicodeCoverage: Boolean;
  4682. function GetHasBaselineYAt0: Boolean;
  4683. function GetHasLSBPointXAt0: Boolean;
  4684. function GetHasVariationSequences: Boolean;
  4685. function GetHasOpenTypeVariations: Boolean;
  4686. function GetIsSymbolFont: Boolean;
  4687. function GetIsLastResortFont: Boolean;
  4688. function GetDiagFlags: TBLFontFaceDiagFlags;
  4689. function GetUniqueId: TBLUniqueId;
  4690. function GetData: IBLFontData;
  4691. function GetFullName: String;
  4692. function GetFamilyName: String;
  4693. function GetSubfamilyName: String;
  4694. function GetPostScriptName: String;
  4695. function GetDesignMetrics: TBLFontDesignMetrics;
  4696. function GetUnitsPerEm: Integer;
  4697. function GetPanose: TBLFontPanose;
  4698. function GetUnicodeCoverage: TBLFontUnicodeCoverage;
  4699. function GetHandle: PBLFontFaceCore;
  4700. {$ENDREGION 'Internal Declarations'}
  4701. { Initializes an IBLFontFace from a file specified by AFileName.
  4702. This is a utility function that first creates a IBLFontData and then
  4703. calls InitializeFromData(FontData, 0). See IBLFontData.CreateFromFile
  4704. for more details, especially the use of AReadFlags is important for
  4705. system fonts.
  4706. This function offers a simplified creation of IBLFontFace directly
  4707. from a file, but doesn't provide as much flexibility as InitializeFromData
  4708. as it allows to specify a AFaceIndex, which can be used to load multiple
  4709. font-faces from a TrueType/OpenType collection. The use of
  4710. InitializeFromData is recommended for any serious font handling. }
  4711. procedure InitializeFromFile(const AFilename: String;
  4712. const AReadFlags: TBLFileReadFlags = []);
  4713. { Initializes an IBLFontFace from IBLFontData at the given AFaceIndex. }
  4714. procedure InitializeFromData(const AFontData: IBLFontData;
  4715. const AFaceIndex: Integer);
  4716. procedure Reset;
  4717. function Equals(const AOther: IBLFontFace): Boolean;
  4718. { Tests whether the font-face has a given AFlag set. }
  4719. function HasFaceFlag(const AFlag: TBLFontFaceFlag): Boolean;
  4720. { Whether the font face is a built-in null instance. }
  4721. property IsNone: Boolean read GetIsNone;
  4722. { Tests whether the font face is empty (which the same as IsNone in this
  4723. case). }
  4724. property IsEmpty: Boolean read GetIsNone;
  4725. { Font weight (returns default weight in case this is a variable font). }
  4726. property Weight: TBLFontWeight read GetWeight;
  4727. { Font stretch (returns default weight in case this is a variable font). }
  4728. property Stretch: TBLFontStretch read GetStretch;
  4729. { Font style }
  4730. property Style: TBLFontStyle read GetStyle;
  4731. { Font-face information }
  4732. property FaceInfo: TBLFontFaceInfo read GetFaceInfo;
  4733. { Font-face type }
  4734. property FaceType: TBLFontFaceType read GetFaceType;
  4735. { Font-face outline type }
  4736. property OutlineType: TBLFontOutlineType read GetOutlineType;
  4737. { Zero-based index of this font-face.
  4738. Face index does only make sense if this face is part of a TrueType
  4739. or OpenType font collection. In that case the returned value would be
  4740. the index of this face in that collection. If the face is not part of a
  4741. collection then the returned value would always be zero. }
  4742. property FaceIndex: Integer read GetFaceIndex;
  4743. { Font-face flags }
  4744. property FaceFlags: TBLFontFaceFlags read GetFaceFlags;
  4745. { Tests whether the font-face uses typographic family and subfamily names. }
  4746. property HasTypographicNames: Boolean read GetHasTypographicNames;
  4747. { Tests whether the font-face uses typographic metrics. }
  4748. property HasTypographicMetrics: Boolean read GetHasTypographicMetrics;
  4749. { Tests whether the font-face provides character to glyph mapping. }
  4750. property HasCharToGlyphMapping: Boolean read GetHasCharToGlyphMapping;
  4751. { Tests whether the font-face has horizontal glyph metrics (advances, side
  4752. bearings). }
  4753. property HasHorizontalMetrics: Boolean read GetHasHorizontalMetrics;
  4754. { Tests whether the font-face has vertical glyph metrics (advances, side
  4755. bearings). }
  4756. property HasVerticalMetrics: Boolean read GetHasVerticalMetrics;
  4757. { Tests whether the font-face has a legacy horizontal kerning feature
  4758. ('kern' table with horizontal kerning data). }
  4759. property HasHorizontalKerning: Boolean read GetHasHorizontalKerning;
  4760. { Tests whether the font-face has a legacy vertical kerning feature ('kern'
  4761. table with vertical kerning data). }
  4762. property HasVerticalKerning: Boolean read GetHasVerticalKerning;
  4763. { Tests whether the font-face has OpenType features (GDEF, GPOS, GSUB). }
  4764. property HasOpenTypeFeatures: Boolean read GetHasOpenTypeFeatures;
  4765. { Tests whether the font-face has panose classification. }
  4766. property HasPanoseData: Boolean read GetHasPanoseData;
  4767. { Tests whether the font-face has unicode coverage information. }
  4768. property HasUnicodeCoverage: Boolean read GetHasUnicodeCoverage;
  4769. { Tests whether the font-face's baseline equals 0. }
  4770. property HasBaselineYAt0: Boolean read GetHasBaselineYAt0;
  4771. { Tests whether the font-face's left sidebearing point at `x` equals 0. }
  4772. property HasLSBPointXAt0: Boolean read GetHasLSBPointXAt0;
  4773. { Tests whether the font-face has unicode variation sequences feature. }
  4774. property HasVariationSequences: Boolean read GetHasVariationSequences;
  4775. { Tests whether the font-face has OpenType Font Variations feature. }
  4776. property HasOpenTypeVariations: Boolean read GetHasOpenTypeVariations;
  4777. { This is a symbol font. }
  4778. property IsSymbolFont: Boolean read GetIsSymbolFont;
  4779. { This is a last resort font. }
  4780. property IsLastResortFont: Boolean read GetIsLastResortFont;
  4781. { Font-face diagnostics flags }
  4782. property DiagFlags: TBLFontFaceDiagFlags read GetDiagFlags;
  4783. { A unique identifier describing this IBLFontFace. }
  4784. property UniqueId: TBLUniqueId read GetUniqueId;
  4785. { IBLFontData associated with this font-face. }
  4786. property Data: IBLFontData read GetData;
  4787. { Font full name }
  4788. property FullName: String read GetFullName;
  4789. { Family name }
  4790. property FamilyName: String read GetFamilyName;
  4791. { Font subfamily name }
  4792. property SubfamilyName: String read GetSubfamilyName;
  4793. { Font PostScript name }
  4794. property PostScriptName: String read GetPostScriptName;
  4795. { Design metrics of this IBLFontFace. }
  4796. property DesignMetrics: TBLFontDesignMetrics read GetDesignMetrics;
  4797. { Units per em, which are part of font's design metrics. }
  4798. property UnitsPerEm: Integer read GetUnitsPerEm;
  4799. { PANOSE classification of this IBLFontFace. }
  4800. property Panose: TBLFontPanose read GetPanose;
  4801. { Unicode coverage of this IBLFontFace.
  4802. The returned unicode-coverage is not calculated by Blend2D so in general
  4803. the value doesn't have to be correct. Use GetCharacterCoverage to get
  4804. a coverage calculated by Blend2D at character granularity. }
  4805. property UnicodeCoverage: TBLFontUnicodeCoverage read GetUnicodeCoverage;
  4806. { Internal handle for use with the C API }
  4807. property Handle: PBLFontFaceCore read GetHandle;
  4808. end;
  4809. type
  4810. { Implements IBLFontFace }
  4811. TBLFontFace = class(TInterfacedObject, IBLFontFace)
  4812. {$REGION 'Internal Declarations'}
  4813. private
  4814. FHandle: BLFontFaceCore;
  4815. FData: IBLFontData;
  4816. FIsReference: Boolean;
  4817. protected
  4818. { IBLFontFace }
  4819. function GetIsNone: Boolean;
  4820. function GetWeight: TBLFontWeight;
  4821. function GetStretch: TBLFontStretch;
  4822. function GetStyle: TBLFontStyle;
  4823. function GetFaceInfo: TBLFontFaceInfo;
  4824. function GetFaceType: TBLFontFaceType;
  4825. function GetOutlineType: TBLFontOutlineType;
  4826. function GetFaceIndex: Integer;
  4827. function GetFaceFlags: TBLFontFaceFlags;
  4828. function GetHasTypographicNames: Boolean;
  4829. function GetHasTypographicMetrics: Boolean;
  4830. function GetHasCharToGlyphMapping: Boolean;
  4831. function GetHasHorizontalMetrics: Boolean;
  4832. function GetHasVerticalMetrics: Boolean;
  4833. function GetHasHorizontalKerning: Boolean;
  4834. function GetHasVerticalKerning: Boolean;
  4835. function GetHasOpenTypeFeatures: Boolean;
  4836. function GetHasPanoseData: Boolean;
  4837. function GetHasUnicodeCoverage: Boolean;
  4838. function GetHasBaselineYAt0: Boolean;
  4839. function GetHasLSBPointXAt0: Boolean;
  4840. function GetHasVariationSequences: Boolean;
  4841. function GetHasOpenTypeVariations: Boolean;
  4842. function GetIsSymbolFont: Boolean;
  4843. function GetIsLastResortFont: Boolean;
  4844. function GetDiagFlags: TBLFontFaceDiagFlags;
  4845. function GetUniqueId: TBLUniqueId;
  4846. function GetData: IBLFontData;
  4847. function GetFullName: String;
  4848. function GetFamilyName: String;
  4849. function GetSubfamilyName: String;
  4850. function GetPostScriptName: String;
  4851. function GetDesignMetrics: TBLFontDesignMetrics;
  4852. function GetUnitsPerEm: Integer;
  4853. function GetPanose: TBLFontPanose;
  4854. function GetUnicodeCoverage: TBLFontUnicodeCoverage;
  4855. function GetHandle: PBLFontFaceCore;
  4856. procedure InitializeFromFile(const AFilename: String;
  4857. const AReadFlags: TBLFileReadFlags = []);
  4858. procedure InitializeFromData(const AFontData: IBLFontData;
  4859. const AFaceIndex: Integer);
  4860. procedure Reset;
  4861. function Equals(const AOther: IBLFontFace): Boolean; reintroduce; overload;
  4862. function HasFaceFlag(const AFlag: TBLFontFaceFlag): Boolean;
  4863. private
  4864. constructor Create(const AHandle: BLFontFaceCore;
  4865. const AIsReference: Boolean); overload;
  4866. {$ENDREGION 'Internal Declarations'}
  4867. public
  4868. constructor Create; overload;
  4869. destructor Destroy; override;
  4870. function Equals(Obj: TObject): Boolean; overload; override;
  4871. end;
  4872. { ============================================================================
  4873. [BLFont]
  4874. ============================================================================ }
  4875. type
  4876. { Font }
  4877. IBLFont = interface
  4878. ['{47ED75E4-8E6C-4D0E-95D9-6321CD4F8694}']
  4879. {$REGION 'Internal Declarations'}
  4880. function GetIsNone: Boolean;
  4881. function GetFaceType: TBLFontFaceType;
  4882. function GetFaceFlags: TBLFontFaceFlags;
  4883. function GetSize: Single;
  4884. function GetUnitsPerEm: Integer;
  4885. function GetFace: IBLFontFace;
  4886. function GetFeatures: TArray<TBLFontFeature>;
  4887. function GetVariations: TArray<TBLFontVariation>;
  4888. function GetWeight: TBLFontWeight;
  4889. function GetStretch: TBLFontStretch;
  4890. function GetStyle: TBLFontStyle;
  4891. function GetMatrix: TBLFontMatrix;
  4892. function GetMetrics: TBLFontMetrics;
  4893. function GetMetricsPtr: PBLFontMetrics;
  4894. function GetDesignMetrics: TBLFontDesignMetrics;
  4895. function GetHandle: PBLFontCore;
  4896. {$ENDREGION 'Internal Declarations'}
  4897. procedure InitializeFromFace(const AFace: IBLFontFace;
  4898. const ASize: Single);
  4899. procedure Reset;
  4900. function Equals(const AOther: IBLFont): Boolean;
  4901. procedure Shape(const AGlyphBuffer: IBLGlyphBuffer);
  4902. procedure MapTextToGlyphs(const AGlyphBuffer: IBLGlyphBuffer); overload;
  4903. procedure MapTextToGlyphs(const AGlyphBuffer: IBLGlyphBuffer;
  4904. out AState: TBLGlyphMappingState); overload;
  4905. { TODO : Check when Blend2D updates APositioningFlags }
  4906. procedure PositionGlyphs(const AGlyphBuffer: IBLGlyphBuffer;
  4907. const APositioningFlags: Cardinal = $FFFFFFFF);
  4908. procedure ApplyKerning(const AGlyphBuffer: IBLGlyphBuffer);
  4909. procedure ApplyGSub(const AGlyphBuffer: IBLGlyphBuffer;
  4910. const AIndex: Integer; const ALookups: TBLBitWord);
  4911. procedure ApplyGPos(const AGlyphBuffer: IBLGlyphBuffer;
  4912. const AIndex: Integer; const ALookups: TBLBitWord);
  4913. function GetTextMetrics(const AGlyphBuffer: IBLGlyphBuffer): TBLTextMetrics;
  4914. function GetGlyphBounds(const AGlyphData: PCardinal;
  4915. const AGlyphAdvance, ACount: Integer): TArray<TBLBoxI>;
  4916. function GetGlyphAdvances(const AGlyphData: PCardinal;
  4917. const AGlyphAdvance, ACount: Integer): TArray<TBLGlyphPlacement>;
  4918. function GetGlyphOutlines(const AGlyphId: Cardinal;
  4919. const ASink: TBLPathSinkEvent): IBLPath; overload;
  4920. function GetGlyphOutlines(const AGlyphId: Cardinal;
  4921. const AUserMatrix: TBLMatrix2D;
  4922. const ASink: TBLPathSinkEvent): IBLPath; overload;
  4923. function GetGlyphRunOutlines(const AGlyphRun: TBLGlyphRun;
  4924. const ASink: TBLPathSinkEvent): IBLPath; overload;
  4925. function GetGlyphRunOutlines(const AGlyphRun: TBLGlyphRun;
  4926. const AUserMatrix: TBLMatrix2D;
  4927. const ASink: TBLPathSinkEvent): IBLPath; overload;
  4928. { Whether the font is a built-in null instance. }
  4929. property IsNone: Boolean read GetIsNone;
  4930. { Tests whether the font is empty (which the same as IsNone in this case). }
  4931. property IsEmpty: Boolean read GetIsNone;
  4932. { Type of the font's associated font-face }
  4933. property FaceType: TBLFontFaceType read GetFaceType;
  4934. { Flags of the font }
  4935. property FaceFlags: TBLFontFaceFlags read GetFaceFlags;
  4936. { Size of the font }
  4937. property Size: Single read GetSize;
  4938. { The "units per em" (UPEM) of the font's associated font-face. }
  4939. property UnitsPerEm: Integer read GetUnitsPerEm;
  4940. { The font's associated font-face.
  4941. Returns the same font-face, which was passed to InitializeFromFace. }
  4942. property Face: IBLFontFace read GetFace;
  4943. { The features associated with the font. }
  4944. property Features: TArray<TBLFontFeature> read GetFeatures;
  4945. { The variations associated with the font. }
  4946. property Variations: TArray<TBLFontVariation> read GetVariations;
  4947. { The weight of the font. }
  4948. property Weight: TBLFontWeight read GetWeight;
  4949. { The stretch of the font. }
  4950. property Stretch: TBLFontStretch read GetStretch;
  4951. { The style of the font. }
  4952. property Style: TBLFontStyle read GetStyle;
  4953. { The 2x2 matrix of the font.
  4954. The returned TBLFontMatrix is used to scale fonts from design units
  4955. into user units. The matrix usually has a negative M11 member as
  4956. fonts use a different coordinate system than Blend2D. }
  4957. property Matrix: TBLFontMatrix read GetMatrix;
  4958. { The scaled metrics of the font.
  4959. The returned metrics is a scale of design metrics that match the font size
  4960. and its options. }
  4961. property Metrics: TBLFontMetrics read GetMetrics;
  4962. property MetricsPtr: PBLFontMetrics read GetMetricsPtr;
  4963. { The design metrics of the font.
  4964. The returned metrics is compatible with the metrics of IBLFontFace
  4965. associated with this font. }
  4966. property DesignMetrics: TBLFontDesignMetrics read GetDesignMetrics;
  4967. { Internal handle for use with the C API }
  4968. property Handle: PBLFontCore read GetHandle;
  4969. end;
  4970. type
  4971. { Implements IBLFont }
  4972. TBLFont = class(TInterfacedObject, IBLFont)
  4973. {$REGION 'Internal Declarations'}
  4974. private
  4975. FHandle: BLFontCore;
  4976. FFace: IBLFontFace;
  4977. FSink: TBLPathSinkEvent;
  4978. FSinkPath: IBLPath;
  4979. private
  4980. class function DoSink(path: PBLPathCore; info: Pointer;
  4981. closure: Pointer): Cardinal; cdecl; static;
  4982. protected
  4983. { IBLFont }
  4984. function GetIsNone: Boolean;
  4985. function GetFaceType: TBLFontFaceType;
  4986. function GetFaceFlags: TBLFontFaceFlags;
  4987. function GetSize: Single;
  4988. function GetUnitsPerEm: Integer;
  4989. function GetFace: IBLFontFace;
  4990. function GetFeatures: TArray<TBLFontFeature>;
  4991. function GetVariations: TArray<TBLFontVariation>;
  4992. function GetWeight: TBLFontWeight;
  4993. function GetStretch: TBLFontStretch;
  4994. function GetStyle: TBLFontStyle;
  4995. function GetMatrix: TBLFontMatrix;
  4996. function GetMetrics: TBLFontMetrics;
  4997. function GetMetricsPtr: PBLFontMetrics;
  4998. function GetDesignMetrics: TBLFontDesignMetrics;
  4999. function GetHandle: PBLFontCore;
  5000. procedure InitializeFromFace(const AFace: IBLFontFace;
  5001. const ASize: Single);
  5002. procedure Reset;
  5003. function Equals(const AOther: IBLFont): Boolean; reintroduce; overload;
  5004. procedure Shape(const AGlyphBuffer: IBLGlyphBuffer);
  5005. procedure MapTextToGlyphs(const AGlyphBuffer: IBLGlyphBuffer); overload;
  5006. procedure MapTextToGlyphs(const AGlyphBuffer: IBLGlyphBuffer;
  5007. out AState: TBLGlyphMappingState); overload;
  5008. procedure PositionGlyphs(const AGlyphBuffer: IBLGlyphBuffer;
  5009. const APositioningFlags: Cardinal);
  5010. procedure ApplyKerning(const AGlyphBuffer: IBLGlyphBuffer);
  5011. procedure ApplyGSub(const AGlyphBuffer: IBLGlyphBuffer;
  5012. const AIndex: Integer; const ALookups: TBLBitWord);
  5013. procedure ApplyGPos(const AGlyphBuffer: IBLGlyphBuffer;
  5014. const AIndex: Integer; const ALookups: TBLBitWord);
  5015. function GetTextMetrics(const AGlyphBuffer: IBLGlyphBuffer): TBLTextMetrics;
  5016. function GetGlyphBounds(const AGlyphData: PCardinal;
  5017. const AGlyphAdvance, ACount: Integer): TArray<TBLBoxI>;
  5018. function GetGlyphAdvances(const AGlyphData: PCardinal;
  5019. const AGlyphAdvance, ACount: Integer): TArray<TBLGlyphPlacement>;
  5020. function GetGlyphOutlines(const AGlyphId: Cardinal;
  5021. const ASink: TBLPathSinkEvent): IBLPath; overload;
  5022. function GetGlyphOutlines(const AGlyphId: Cardinal;
  5023. const AUserMatrix: TBLMatrix2D;
  5024. const ASink: TBLPathSinkEvent): IBLPath; overload;
  5025. function GetGlyphRunOutlines(const AGlyphRun: TBLGlyphRun;
  5026. const ASink: TBLPathSinkEvent): IBLPath; overload;
  5027. function GetGlyphRunOutlines(const AGlyphRun: TBLGlyphRun;
  5028. const AUserMatrix: TBLMatrix2D;
  5029. const ASink: TBLPathSinkEvent): IBLPath; overload;
  5030. {$ENDREGION 'Internal Declarations'}
  5031. public
  5032. constructor Create;
  5033. destructor Destroy; override;
  5034. function Equals(Obj: TObject): Boolean; overload; override;
  5035. end;
  5036. {$ENDREGION 'Font'}
  5037. {$REGION 'Font Manager'}
  5038. { ============================================================================
  5039. [BLFontManager]
  5040. ============================================================================ }
  5041. type
  5042. { Font data }
  5043. IBLFontManager = interface
  5044. ['{A75AAED4-30E3-4A65-978F-590528AB2DCF}']
  5045. {$REGION 'Internal Declarations'}
  5046. function GetIsNone: Boolean;
  5047. function GetFaceCount: Integer;
  5048. function GetFamilyCount: Integer;
  5049. function GetHandle: PBLFontManagerCore;
  5050. {$ENDREGION 'Internal Declarations'}
  5051. procedure Reset;
  5052. function Equals(const AOther: IBLFontManager): Boolean;
  5053. procedure Initialize;
  5054. { Whether the font manager contains the given font AFace. }
  5055. function HasFace(const AFace: IBLFontFace): Boolean;
  5056. { Adds a font AFace to the font manager. Does nothing if the manager already
  5057. contans the font face.
  5058. Important conditions:
  5059. * TBLResultCode.FontNotInitializes is raised if the font AFace is invalid.
  5060. * TBLResultCode.OutOfMemory is raised if memory allocation failed. }
  5061. procedure AddFace(const AFace: IBLFontFace);
  5062. { Queries a font face by family name and returns the font face or nil if
  5063. not found. }
  5064. function QueryFace(const AName: String): IBLFontFace; overload;
  5065. { Queries a font face by family name and returns the font face or nil if
  5066. not found.
  5067. The AProperties parameter contains query properties that the query engine
  5068. will consider when doing the match. The best candidate will be selected
  5069. based on the following rules:
  5070. * Style has the highest priority.
  5071. * Weight has the lowest priority. }
  5072. function QueryFace(const AName: String;
  5073. const AProperties: TBLFontQueryProperties): IBLFontFace; overload;
  5074. { Queries all font-faces by family name and returns an array of font faces. }
  5075. function QueryFacesByFamilyName(const AName: String): TArray<IBLFontFace>;
  5076. { Whether the font manager is a built-in null instance. }
  5077. property IsNone: Boolean read GetIsNone;
  5078. { The number of IBLFontFace instances the font manager holds. }
  5079. property FaceCount: Integer read GetFaceCount;
  5080. { The number of unique font families the font manager holds. }
  5081. property FamilyCount: Integer read GetFamilyCount;
  5082. { Internal handle for use with the C API }
  5083. property Handle: PBLFontManagerCore read GetHandle;
  5084. end;
  5085. type
  5086. { Implements IBLFontManager }
  5087. TBLFontManager = class(TInterfacedObject, IBLFontManager)
  5088. {$REGION 'Internal Declarations'}
  5089. private
  5090. FHandle: BLFontManagerCore;
  5091. protected
  5092. { IBLFontManager }
  5093. function GetIsNone: Boolean;
  5094. function GetFaceCount: Integer;
  5095. function GetFamilyCount: Integer;
  5096. function GetHandle: PBLFontManagerCore;
  5097. procedure Reset;
  5098. function Equals(const AOther: IBLFontManager): Boolean; reintroduce; overload;
  5099. procedure Initialize;
  5100. function HasFace(const AFace: IBLFontFace): Boolean;
  5101. procedure AddFace(const AFace: IBLFontFace);
  5102. function QueryFace(const AName: String): IBLFontFace; overload;
  5103. function QueryFace(const AName: String;
  5104. const AProperties: TBLFontQueryProperties): IBLFontFace; overload;
  5105. function QueryFacesByFamilyName(const AName: String): TArray<IBLFontFace>;
  5106. {$ENDREGION 'Internal Declarations'}
  5107. public
  5108. constructor Create;
  5109. destructor Destroy; override;
  5110. function Equals(Obj: TObject): Boolean; overload; override;
  5111. end;
  5112. {$ENDREGION 'Font Manager'}
  5113. {$REGION 'Pixel Converter'}
  5114. { ============================================================================
  5115. [BLPixelConverterCreateFlags]
  5116. ============================================================================ }
  5117. type
  5118. { Flags used by IBLPixelConverter.Initialize. }
  5119. TBLPixelConverterCreateFlag = (
  5120. { Specifies that the source palette in TBLFormatInfo doesn't have to be
  5121. copied by IBLPixelConverter. The caller must ensure that the palette
  5122. would stay valid until the pixel converter is destroyed. }
  5123. DontCopyPalette = 0,
  5124. { Specifies that the source palette in TBLFormatInfo is alterable and
  5125. the pixel converter can modify it when preparing the conversion. The
  5126. modification can be irreversible so only use this flag when you are sure
  5127. that the palette passed to IBLPixelConverter.Initialize won't be needed
  5128. outside of pixel conversion.
  5129. The flag DontCopyPalette must be set as well, otherwise this flag would be
  5130. ignored. }
  5131. AlterablePalette = 1,
  5132. { When there is no built-in conversion between the given pixel formats it's
  5133. possible to use an intermediate format that is used during conversion. In
  5134. such case the base pixel converter creates two more converters that are
  5135. then used internally.
  5136. This option disables such feature - creating a pixel converter would fail
  5137. with TBLResultCode.NotImplemented error if direct conversion is not
  5138. possible. }
  5139. NoMultiStep = 2);
  5140. TBLPixelConverterCreateFlags = set of TBLPixelConverterCreateFlag;
  5141. { ============================================================================
  5142. [BLPixelConverter - Options]
  5143. ============================================================================ }
  5144. type
  5145. { Pixel conversion options. }
  5146. TBLPixelConverterOptions = record
  5147. {$REGION 'Internal Declarations'}
  5148. private
  5149. FHandle: BLPixelConverterOptions;
  5150. function GetOrigin: TBLPointI; inline;
  5151. procedure SetOrigin(const AValue: TBLPointI); inline;
  5152. function GetGap: Integer; inline;
  5153. procedure SetGap(const AValue: Integer); inline;
  5154. {$ENDREGION 'Internal Declarations'}
  5155. public
  5156. property Origin: TBLPointI read GetOrigin write SetOrigin;
  5157. property Gap: Integer read GetGap write SetGap;
  5158. end;
  5159. PBLPixelConverterOptions = ^TBLPixelConverterOptions;
  5160. { ============================================================================
  5161. [BLPixelConverter]
  5162. ============================================================================ }
  5163. type
  5164. { Provides an interface to convert pixels between various pixel formats. The
  5165. primary purpose of this class is to allow efficient conversion between
  5166. pixel formats used natively by Blend2D and pixel formats used elsewhere,
  5167. for example image codecs or native framebuffers.
  5168. Note: A default-initialized converter has a valid conversion function that
  5169. would return TBLResultCode.NotInitialized if invoked. Use IsInitialized
  5170. to test whether the pixel converter was properly initialized. }
  5171. IBLPixelConverter = interface
  5172. ['{A75AAED4-30E3-4A65-978F-590528AB2DCF}']
  5173. {$REGION 'Internal Declarations'}
  5174. function GetIsInitialized: Boolean;
  5175. function GetHandle: PBLPixelConverterCore;
  5176. {$ENDREGION 'Internal Declarations'}
  5177. { Initializes a new pixel converter that will convert pixels described by
  5178. ASrcInfo into pixels described by ADstInfo.
  5179. Use ACreateFlags to further specify the parameters of the conversion.
  5180. Note: Destination and source format information must be valid, otherwise
  5181. a TBLResultCode.InvalidValue error is raised. }
  5182. procedure Initialize(const ASrcInfo, ADstInfo: TBLFormatInfo;
  5183. const ACreateFlags: TBLPixelConverterCreateFlags = []);
  5184. procedure Reset;
  5185. { Assigns the AOther pixel converter into this one. }
  5186. procedure Assign(const AOther: IBLPixelConverter);
  5187. { Converts a single span of pixels of AWidth. }
  5188. procedure ConvertSpan(const ASrcData, ADstData: Pointer;
  5189. const AWidth: Integer); overload;
  5190. procedure ConvertSpan(const ASrcData, ADstData: Pointer;
  5191. const AWidth: Integer; const AOptions: TBLPixelConverterOptions); overload;
  5192. { Converts a rectangular area of pixels from source format to destination. }
  5193. procedure ConvertRect(const ASrcData: Pointer; const ASrcStride: Integer;
  5194. const ADstData: Pointer; const ADstStride, AWidth, AHeight: Integer); overload;
  5195. procedure ConvertRect(const ASrcData: Pointer; const ASrcStride: Integer;
  5196. const ADstData: Pointer; const ADstStride, AWidth, AHeight: Integer;
  5197. const AOptions: TBLPixelConverterOptions); overload;
  5198. { Returns True if the converter is initialized. }
  5199. property IsInitialized: Boolean read GetIsInitialized;
  5200. { Internal handle for use with the C API }
  5201. property Handle: PBLPixelConverterCore read GetHandle;
  5202. end;
  5203. type
  5204. { Implements IBLPixelConverter }
  5205. TBLPixelConverter = class(TInterfacedObject, IBLPixelConverter)
  5206. {$REGION 'Internal Declarations'}
  5207. private
  5208. FHandle: BLPixelConverterCore;
  5209. protected
  5210. { IBLPixelConverter }
  5211. function GetIsInitialized: Boolean;
  5212. function GetHandle: PBLPixelConverterCore;
  5213. procedure Initialize(const ASrcInfo, ADstInfo: TBLFormatInfo;
  5214. const ACreateFlags: TBLPixelConverterCreateFlags = []);
  5215. procedure Reset;
  5216. procedure Assign(const AOther: IBLPixelConverter);
  5217. procedure ConvertSpan(const ASrcData, ADstData: Pointer;
  5218. const AWidth: Integer); overload;
  5219. procedure ConvertSpan(const ASrcData, ADstData: Pointer;
  5220. const AWidth: Integer; const AOptions: TBLPixelConverterOptions); overload;
  5221. procedure ConvertRect(const ASrcData: Pointer; const ASrcStride: Integer;
  5222. const ADstData: Pointer; const ADstStride, AWidth, AHeight: Integer); overload;
  5223. procedure ConvertRect(const ASrcData: Pointer; const ASrcStride: Integer;
  5224. const ADstData: Pointer; const ADstStride, AWidth, AHeight: Integer;
  5225. const AOptions: TBLPixelConverterOptions); overload;
  5226. {$ENDREGION 'Internal Declarations'}
  5227. public
  5228. constructor Create;
  5229. destructor Destroy; override;
  5230. { Creates a pixel converter appropriate for the current platform. This is
  5231. useful for platforms where the display format does not match the internal
  5232. Blend2D format. For example, on macOS, iOS and Android, the red and blue
  5233. color channels need to be swapped. On Windows, Blend2D's internal format
  5234. matches the display format and no conversion is needed.
  5235. On Windows, it returns a converter that doesn't convert, but just copies
  5236. the data. However, it is more efficient to not use a pixel converter at
  5237. all on Windows.
  5238. On other platforms, it creates a converter that converts
  5239. from PRGB to PBGR. }
  5240. class function CreatePlatformConverter: IBLPixelConverter; static;
  5241. end;
  5242. {$ENDREGION 'Pixel Converter'}
  5243. {$REGION 'Style'}
  5244. { ============================================================================
  5245. [BLStyle - Enums]
  5246. ============================================================================ }
  5247. type
  5248. { Style type. }
  5249. TBLStyleType = (
  5250. { No style, nothing will be paint. }
  5251. None = BL_STYLE_TYPE_NONE,
  5252. { Solid color style. }
  5253. Solid = BL_STYLE_TYPE_SOLID,
  5254. { Pattern style. }
  5255. Pattern = BL_STYLE_TYPE_PATTERN,
  5256. { Gradient style. }
  5257. Gradient = BL_STYLE_TYPE_GRADIENT);
  5258. {$ENDREGION 'Style'}
  5259. {$REGION 'Context'}
  5260. { ============================================================================
  5261. [BLContext - Enums]
  5262. ============================================================================ }
  5263. type
  5264. { Rendering context type. }
  5265. TBLContextType = (
  5266. { No rendering context. }
  5267. None = BL_CONTEXT_TYPE_NONE,
  5268. { Dummy rendering context. }
  5269. Dummy = BL_CONTEXT_TYPE_DUMMY,
  5270. { Software-accelerated rendering context. }
  5271. Raster = BL_CONTEXT_TYPE_RASTER);
  5272. type
  5273. { Rendering context hint. }
  5274. TBLContextHint = (
  5275. { Rendering quality. }
  5276. RenderingQuality = BL_CONTEXT_HINT_RENDERING_QUALITY,
  5277. { Gradient quality. }
  5278. GradientQuality = BL_CONTEXT_HINT_GRADIENT_QUALITY,
  5279. { Pattern quality. }
  5280. PatternQuality = BL_CONTEXT_HINT_PATTERN_QUALITY);
  5281. type
  5282. { Describes a rendering operation type - fill or stroke.
  5283. The rendering context allows to get and set fill & stroke options directly
  5284. or via "style" functions that take the rendering operation type (OpType)
  5285. and dispatch the call to the right function. }
  5286. TBLContextOpType = (
  5287. { Fill operation type. }
  5288. Fill = BL_CONTEXT_OP_TYPE_FILL,
  5289. { Stroke operation type. }
  5290. Stroke = BL_CONTEXT_OP_TYPE_STROKE);
  5291. type
  5292. { Rendering context flush-flags, use with IBLContext.Flush. }
  5293. TBLContextFlushFlag = (
  5294. _Dummy = 0,
  5295. { Flush the command queue and wait for its completion (will block). }
  5296. Sync = 31);
  5297. TBLContextFlushFlags = set of TBLContextFlushFlag;
  5298. type
  5299. { Rendering context create-flags. }
  5300. TBLContextCreateFlag = (
  5301. { Fallbacks to a synchronous rendering in case that the rendering engine
  5302. wasn't able to acquire threads. This flag only makes sense when the
  5303. asynchronous mode was specified by having TBLContextCreateInfo.ThreadCount
  5304. greater than 0. If the rendering context fails to acquire at least one
  5305. thread it would fallback to synchronous mode with no worker threads.
  5306. Note: If this flag is specified with TBLContextCreateInfo.ThreadCount = 1
  5307. it means to immediately fallback to synchronous rendering. It's only
  5308. practical to use this flag with 2 or more requested threads. }
  5309. FallbackToSync = 3,
  5310. { If this flag is specified and asynchronous rendering is enabled then
  5311. the context would create its own isolated thread-pool, which is useful
  5312. for debugging purposes.
  5313. Do not use this flag in production as rendering contexts with isolated
  5314. thread-pool have to create and destroy all threads they use. This flag
  5315. is only useful for testing, debugging, and isolated benchmarking. }
  5316. IsolatedThreadPool = 24,
  5317. { If this flag is specified and JIT pipeline generation enabled then the
  5318. rendering context would create its own isolated JIT runtime. which is
  5319. useful for debugging purposes. This flag will be ignored if JIT pipeline
  5320. generation is either not supported or was disabled by other flags.
  5321. Do not use this flag in production as rendering contexts with isolated
  5322. JIT runtime do not use global pipeline cache, that's it, after the
  5323. rendering context is destroyed the JIT runtime is destroyed with it with
  5324. all compiled pipelines. This flag is only useful for testing, debugging,
  5325. and isolated benchmarking. }
  5326. IsolatedJit = 25,
  5327. { Override CPU features when creating isolated context. }
  5328. OverrideCpuFeatures = 26);
  5329. TBLContextCreateFlags = set of TBLContextCreateFlag;
  5330. type
  5331. { Specifies a rendering context property that can be specific to the rendering
  5332. context implementation and that doesn't have its own C and C++ API.
  5333. Different rendering context implementations may expose various properties
  5334. that users can query to get more details about the rendering context itself,
  5335. rendering details (like optimizations or possibly limitations), memory
  5336. details, and other information that was collected during the rendering.
  5337. Properties are never part of the rendering context state - they are
  5338. stateless and are not subject to Save and Restore. Many properties are
  5339. purely informative, but some not, e.g. AccumulatedErrorFlags. }
  5340. TBLContextProperty = (
  5341. { Number of threads that the rendering context uses for rendering. }
  5342. ThreadCount = BL_CONTEXT_PROPERTY_THREAD_COUNT,
  5343. { Accumulated errors collected during the lifetime of the rendering
  5344. context. }
  5345. AccumulatedErrorFlags = BL_CONTEXT_PROPERTY_ACCUMULATED_ERROR_FLAGS);
  5346. type
  5347. { Error flags that are accumulated during the rendering context lifetime and
  5348. that can be queried through TBLContext.QueryAccumulatedErrorFlags. The
  5349. reason why these flags exist is that errors can happen during asynchronous
  5350. rendering, and there is no way the user can catch these errors. }
  5351. TBLContextErrorFlag = (
  5352. { The rendering context returned or encountered TBLResultCode.InvalidValue,
  5353. which is mostly related to function argument handling. It's very likely
  5354. some argument was wrong when calling TBLContext API. }
  5355. InvalidValue = 0,
  5356. { Invalid state describes something wrong, for example pipeline compilation
  5357. problem. }
  5358. InvalidState = 1,
  5359. { The rendering context has encountered invalid geometry. }
  5360. InvalidGeometry = 2,
  5361. { The rendering context has encountered invalid glyph. }
  5362. InvalidGlyph = 3,
  5363. { The rendering context has encountered invalid or uninitialized font. }
  5364. InvalidFont = 4,
  5365. { Thread pool was exhausted and couldn't acquire the requested number of
  5366. threads. }
  5367. ThreadPoolExhausted = 29,
  5368. { Out of memory condition. }
  5369. OutOfMemory = 30,
  5370. { Unknown error, which we don't have flag for. }
  5371. UnknownError = 31);
  5372. TBLContextErrorFlags = set of TBLContextErrorFlag;
  5373. type
  5374. { Clip mode. }
  5375. TBLClipMode = (
  5376. { Clipping to a rectangle that is aligned to the pixel grid. }
  5377. AlignedRect = BL_CLIP_MODE_ALIGNED_RECT,
  5378. { Clipping to a rectangle that is not aligned to pixel grid. }
  5379. UnalignedRect = BL_CLIP_MODE_UNALIGNED_RECT,
  5380. { Clipping to a non-rectangular area that is defined by using mask. }
  5381. Mask = BL_CLIP_MODE_MASK);
  5382. type
  5383. { Composition & blending operator. }
  5384. TBLCompOp = (
  5385. { Source-over [default]. }
  5386. SrcOver = BL_COMP_OP_SRC_OVER,
  5387. { Source-copy. }
  5388. SrcCopy = BL_COMP_OP_SRC_COPY,
  5389. { Source-in. }
  5390. SrcIn = BL_COMP_OP_SRC_IN,
  5391. { Source-out. }
  5392. SrcOut = BL_COMP_OP_SRC_OUT,
  5393. { Source-atop. }
  5394. SrcAtop = BL_COMP_OP_SRC_ATOP,
  5395. { Destination-over. }
  5396. DstOver = BL_COMP_OP_DST_OVER,
  5397. { Destination-copy [nop]. }
  5398. DstCopy = BL_COMP_OP_DST_COPY,
  5399. { Destination-in. }
  5400. DstIn = BL_COMP_OP_DST_IN,
  5401. { Destination-out. }
  5402. DstOut = BL_COMP_OP_DST_OUT,
  5403. { Destination-atop. }
  5404. DstAtop = BL_COMP_OP_DST_ATOP,
  5405. { Xor. }
  5406. ExclusiveOr = BL_COMP_OP_XOR,
  5407. { Clear. }
  5408. Clear = BL_COMP_OP_CLEAR,
  5409. { Plus. }
  5410. Plus = BL_COMP_OP_PLUS,
  5411. { Minus. }
  5412. Minus = BL_COMP_OP_MINUS,
  5413. { Modulate. }
  5414. Modulate = BL_COMP_OP_MODULATE,
  5415. { Multiply. }
  5416. Multiply = BL_COMP_OP_MULTIPLY,
  5417. { Screen. }
  5418. Screen = BL_COMP_OP_SCREEN,
  5419. { Overlay. }
  5420. Overlay = BL_COMP_OP_OVERLAY,
  5421. { Darken. }
  5422. Darken = BL_COMP_OP_DARKEN,
  5423. { Lighten. }
  5424. Lighten = BL_COMP_OP_LIGHTEN,
  5425. { Color dodge. }
  5426. ColorDodge = BL_COMP_OP_COLOR_DODGE,
  5427. { Color burn. }
  5428. ColorBurn = BL_COMP_OP_COLOR_BURN,
  5429. { Linear burn. }
  5430. LinearBurn = BL_COMP_OP_LINEAR_BURN,
  5431. { Linear light. }
  5432. LinearLight = BL_COMP_OP_LINEAR_LIGHT,
  5433. { Pin light. }
  5434. PinLight = BL_COMP_OP_PIN_LIGHT,
  5435. { Hard-light. }
  5436. HardLight = BL_COMP_OP_HARD_LIGHT,
  5437. { Soft-light. }
  5438. SoftLight = BL_COMP_OP_SOFT_LIGHT,
  5439. { Difference. }
  5440. Difference = BL_COMP_OP_DIFFERENCE,
  5441. { Exclusion. }
  5442. Exclusion = BL_COMP_OP_EXCLUSION);
  5443. type
  5444. { Gradient rendering quality. }
  5445. TBLGradientQuality = (
  5446. { Nearest neighbor. }
  5447. Nearest = BL_GRADIENT_QUALITY_NEAREST);
  5448. type
  5449. { Pattern quality. }
  5450. TBLPatternQuality = (
  5451. { Nearest neighbor. }
  5452. Nearest = BL_PATTERN_QUALITY_NEAREST,
  5453. { Bilinear. }
  5454. Bilinear = BL_PATTERN_QUALITY_BILINEAR);
  5455. type
  5456. { Rendering quality. }
  5457. TBLRenderingQuality = (
  5458. { Render using anti-aliasing. }
  5459. AntiAlias = BL_RENDERING_QUALITY_ANTIALIAS);
  5460. { ============================================================================
  5461. [BLContext - CreateInfo]
  5462. ============================================================================ }
  5463. type
  5464. { Information that can be used to customize the rendering context. }
  5465. TBLContextCreateInfo = record
  5466. {$REGION 'Internal Declarations'}
  5467. private
  5468. FHandle: BLContextCreateInfo;
  5469. function GetFlags: TBLContextCreateFlags; inline;
  5470. procedure SetFlags(const AValue: TBLContextCreateFlags); inline;
  5471. {$ENDREGION 'Internal Declarations'}
  5472. public
  5473. procedure Reset; inline;
  5474. { Create flags, see TBLContextCreateFlags. }
  5475. property Flags: TBLContextCreateFlags read GetFlags write SetFlags;
  5476. { Number of worker threads to use for asynchronous rendering, if non-zero.
  5477. If ThreadCount is zero it means to initialize the context for synchronous
  5478. rendering. This means that every operation will take effect immediately.
  5479. If ThreadCount is 1 it means that the rendering will be asynchronous, but
  5480. no thread would be acquired from a thread-pool, because the user thread
  5481. will be used as a worker. And finally, if ThreadCount is greater than 1
  5482. then total of ThreadCount - 1 threads will be acquired from thread-pool
  5483. and used as additional workers. }
  5484. property ThreadCount: Integer read FHandle.threadCount write FHandle.threadCount;
  5485. { CPU features to use in isolated JIT runtime (if supported), only used
  5486. when Flags contains TBLContextCreateFlag.OverrideCpuFeatures. }
  5487. property CpuFeatures: Cardinal read FHandle.cpuFeatures write FHandle.cpuFeatures;
  5488. { Maximum number of commands to be queued.
  5489. If this parameter is zero the queue size will be determined automatically.
  5490. TODO: To be documented, has no effect at the moment. }
  5491. property CommandQueueLimit: Integer read FHandle.commandQueueLimit write FHandle.commandQueueLimit;
  5492. end;
  5493. PBLContextCreateInfo = ^TBLContextCreateInfo;
  5494. { ============================================================================
  5495. [BLContext - Cookie]
  5496. ============================================================================ }
  5497. type
  5498. { Holds an arbitrary 128-bit value (cookie) that can be used to match other
  5499. cookies. Blend2D uses cookies in places where it allows to "lock" some
  5500. state that can only be unlocked by a matching cookie. Please don't confuse
  5501. cookies with a security of any kind, it's just an arbitrary data that must
  5502. match to proceed with a certain operation.
  5503. Cookies can be used with IBLContext.Save and IBLContextRestore operations. }
  5504. TBLContextCookie = record
  5505. {$REGION 'Internal Declarations'}
  5506. private
  5507. FHandle: BLContextCookie;
  5508. function GetIsEmpty: Boolean; inline;
  5509. {$ENDREGION 'Internal Declarations'}
  5510. public
  5511. class operator Equal(const ALeft, ARight: TBLContextCookie): Boolean; inline; static;
  5512. class operator NotEqual(const ALeft, ARight: TBLContextCookie): Boolean; inline; static;
  5513. public
  5514. procedure Reset; overload; inline;
  5515. procedure Reset(const AOther: TBLContextCookie); overload; inline;
  5516. procedure Reset(const AData0, AData1: UInt64); overload; inline;
  5517. function Equals(const AOther: TBLContextCookie): Boolean; inline;
  5518. property IsEmpty: Boolean read GetIsEmpty;
  5519. end;
  5520. PBLContextCookie = ^TBLContextCookie;
  5521. { ============================================================================
  5522. [BLContext - Hints]
  5523. ============================================================================ }
  5524. type
  5525. { Rendering context hints. }
  5526. TBLContextHints = record
  5527. {$REGION 'Internal Declarations'}
  5528. private
  5529. FHandle: BLContextHints;
  5530. function GetGradientQuality: TBLGradientQuality; inline;
  5531. function GetPatternQuality: TBLPatternQuality; inline;
  5532. function GetRenderingQuality: TBLRenderingQuality; inline;
  5533. procedure SetGradientQuality(const AValue: TBLGradientQuality); inline;
  5534. procedure SetPatternQuality(const AValue: TBLPatternQuality); inline;
  5535. procedure SetRenderingQuality(const AValue: TBLRenderingQuality); inline;
  5536. {$ENDREGION 'Internal Declarations'}
  5537. public
  5538. property RenderingQuality: TBLRenderingQuality read GetRenderingQuality write SetRenderingQuality;
  5539. property GradientQuality: TBLGradientQuality read GetGradientQuality write SetGradientQuality;
  5540. property PatternQuality: TBLPatternQuality read GetPatternQuality write SetPatternQuality;
  5541. end;
  5542. PBLContextHints = ^TBLContextHints;
  5543. { ============================================================================
  5544. [BLContext - State]
  5545. ============================================================================ }
  5546. type
  5547. { Rendering context state.
  5548. This state is not meant to be created by users, it's only provided for users
  5549. that want to introspect the rendering context state. }
  5550. TBLContextState = record
  5551. {$REGION 'Internal Declarations'}
  5552. private
  5553. FHandle: BLContextState;
  5554. function GetApproximationOptions: TBLApproximationOptions; inline;
  5555. function GetCompOp: TBLCompOp; inline;
  5556. function GetFillRule: TBLFillRule; inline;
  5557. function GetFillStyle: TBLStyleType; overload; inline;
  5558. function GetHints: TBLContextHints; inline;
  5559. function GetMetaMatrix: TBLMatrix2D; inline;
  5560. function GetSavedStateCount: Integer; inline;
  5561. function GetStrokeOptions: TBLStrokeOptions; inline;
  5562. function GetStrokeStyle: TBLStyleType; overload; inline;
  5563. function GetTargetImage: IBLImage; inline;
  5564. function GetTargetSize: TBLSize; inline;
  5565. function GetUserMatrix: TBLMatrix2D; inline;
  5566. function GetFillAlpha: Double; inline;
  5567. function GetStrokeAlpha: Double; inline;
  5568. {$ENDREGION 'Internal Declarations'}
  5569. public
  5570. { Target image or image object with nil impl in case that the rendering
  5571. context doesn't render to an image. }
  5572. property TargetImage: IBLImage read GetTargetImage;
  5573. { Current size of the target in abstract units, pixels if rendering to
  5574. IBLImage. }
  5575. property TargetSize: TBLSize read GetTargetSize;
  5576. { Current context hints. }
  5577. property Hints: TBLContextHints read GetHints;
  5578. { Current composition operator. }
  5579. property CompOp: TBLCompOp read GetCompOp;
  5580. { Current fill rule. }
  5581. property FillRule: TBLFillRule read GetFillRule;
  5582. { Current type of a style for fill operations. }
  5583. property FillStyle: TBLStyleType read GetFillStyle;
  5584. { Current type of a style for stroke operations. }
  5585. property StrokeStyle: TBLStyleType read GetStrokeStyle;
  5586. { Approximation options. }
  5587. property ApproximationOptions: TBLApproximationOptions read GetApproximationOptions;
  5588. { Current global alpha value [0, 1]. }
  5589. property GlobalAlpha: Double read FHandle.globalAlpha;
  5590. { Current fill alpha }
  5591. property FillAlpha: Double read GetFillAlpha;
  5592. { Current stroke alpha }
  5593. property StrokeAlpha: Double read GetStrokeAlpha;
  5594. { Current stroke options. }
  5595. property StrokeOptions: TBLStrokeOptions read GetStrokeOptions;
  5596. { Current meta transformation matrix. }
  5597. property MetaMatrix: TBLMatrix2D read GetMetaMatrix;
  5598. { Current user transformation matrix. }
  5599. property UserMatrix: TBLMatrix2D read GetUserMatrix;
  5600. { Count of saved states in the context. }
  5601. property SavedStateCount: Integer read GetSavedStateCount;
  5602. end;
  5603. PBLContextState = ^TBLContextState;
  5604. { ============================================================================
  5605. [BLContext]
  5606. ============================================================================ }
  5607. type
  5608. { Rendering context }
  5609. IBLContext = interface
  5610. ['{079F0FF5-12D6-4D53-B5AA-79C1AEE83068}']
  5611. {$REGION 'Internal Declarations'}
  5612. function GetTargetSize: TBLSize;
  5613. function GetTargetWidth: Double;
  5614. function GetTargetHeight: Double;
  5615. function GetTargetImage: IBLImage;
  5616. function GetContextType: TBLContextType;
  5617. function GetIsNone: Boolean;
  5618. function GetSavedStateCount: Integer;
  5619. function GetMetaMatrix: TBLMatrix2D;
  5620. function GetUserMatrix: TBLMatrix2D;
  5621. procedure SetUserMatrix(const AValue: TBLMatrix2D);
  5622. function GetHints: TBLContextHints;
  5623. procedure SetHints(const AValue: TBLContextHints);
  5624. function GetRenderingQuality: TBLRenderingQuality;
  5625. procedure SetRenderingQuality(const AValue: TBLRenderingQuality);
  5626. function GetGradientQuality: TBLGradientQuality;
  5627. procedure SetGradientQuality(const AValue: TBLGradientQuality);
  5628. function GetPatternQuality: TBLPatternQuality;
  5629. procedure SetPatternQuality(const AValue: TBLPatternQuality);
  5630. function GetApproximationOptions: TBLApproximationOptions;
  5631. function GetFlattenMode: TBLFlattenMode;
  5632. procedure SetFlattenMode(const AValue: TBLFlattenMode);
  5633. function GetFlattenTolerance: Double;
  5634. procedure SetFlattenTolerance(const AValue: Double);
  5635. function GetCompOp: TBLCompOp;
  5636. procedure SetCompOp(const AValue: TBLCompOp);
  5637. function GetGlobalAlpha: Double;
  5638. procedure SetGlobalAlpha(const AValue: Double);
  5639. function GetFillStyle: TBLStyleType; overload;
  5640. function GetStrokeStyle: TBLStyleType; overload;
  5641. function GetFillAlpha: Double;
  5642. procedure SetFillAlpha(const AValue: Double);
  5643. function GetStrokeAlpha: Double;
  5644. procedure SetStrokeAlpha(const AValue: Double);
  5645. function GetFillColor: TBLRgba32;
  5646. procedure SetFillColor(const AValue: TBLRgba32);
  5647. function GetFillColor64: TBLRgba64;
  5648. procedure SetFillColor64(const AValue: TBLRgba64);
  5649. function GetFillColorF: TBLRgba;
  5650. procedure SetFillColorF(const AValue: TBLRgba);
  5651. function GetStrokeColor: TBLRgba32;
  5652. procedure SetStrokeColor(const AValue: TBLRgba32);
  5653. function GetStrokeColor64: TBLRgba64;
  5654. procedure SetStrokeColor64(const AValue: TBLRgba64);
  5655. function GetStrokeColorF: TBLRgba;
  5656. procedure SetStrokeColorF(const AValue: TBLRgba);
  5657. function GetFillPattern: IBLPattern;
  5658. procedure SetFillPattern(const AValue: IBLPattern);
  5659. function GetStrokePattern: IBLPattern;
  5660. procedure SetStrokePattern(const AValue: IBLPattern);
  5661. function GetFillGradient: IBLGradient;
  5662. procedure SetFillGradient(const AValue: IBLGradient);
  5663. function GetStrokeGradient: IBLGradient;
  5664. procedure SetStrokeGradient(const AValue: IBLGradient);
  5665. function GetFillRule: TBLFillRule;
  5666. procedure SetFillRule(const AValue: TBLFillRule);
  5667. function GetStrokeWidth: Double;
  5668. procedure SetStrokeWidth(const AValue: Double);
  5669. function GetStrokeMiterLimit: Double;
  5670. procedure SetStrokeMiterLimit(const AValue: Double);
  5671. function GetStrokeJoin: TBLStrokeJoin;
  5672. procedure SetStrokeJoin(const AValue: TBLStrokeJoin);
  5673. function GetStrokeStartCap: TBLStrokeCap;
  5674. procedure SetStrokeStartCap(const AValue: TBLStrokeCap);
  5675. function GetStrokeEndCap: TBLStrokeCap;
  5676. procedure SetStrokeEndCap(const AValue: TBLStrokeCap);
  5677. function GetStrokeDashOffset: Double;
  5678. procedure SetStrokeDashOffset(const AValue: Double);
  5679. function GetStrokeDashArray: TArray<Double>;
  5680. procedure SetStrokeDashArray(const AValue: TArray<Double>);
  5681. function GetStrokeTransformOrder: TBLStrokeTransformOrder;
  5682. procedure SetStrokeTransformOrder(const AValue: TBLStrokeTransformOrder);
  5683. function GetStrokeOptions: TBLStrokeOptions;
  5684. procedure SetStrokeOptions(const AValue: TBLStrokeOptions);
  5685. function GetHandle: PBLContextCore;
  5686. {$ENDREGION 'Internal Declarations'}
  5687. { Resets this rendering context to the default constructed one.
  5688. Similar behavior to the destructor, but the context will still be valid
  5689. after Reset and would behave like a default constructed context. }
  5690. procedure Reset;
  5691. { Whether this and AOther point to the same rendering context. }
  5692. function Equals(const AOther: IBLContext): Boolean; overload;
  5693. { Starts rendering to the given AImage.
  5694. If this operation succeeds then the rendering context will have exclusive
  5695. access to the image data. This means that no other renderer can use it
  5696. during rendering. }
  5697. procedure Start(const AImage: IBLImage); overload;
  5698. procedure Start(const AImage: IBLImage;
  5699. const ACreateInfo: TBLContextCreateInfo); overload;
  5700. { Waits for completion of all render commands and detaches the rendering
  5701. context from the rendering target. After Finish completes the rendering
  5702. context implementation would be released and replaced by a built-in null
  5703. instance (no context). }
  5704. procedure Finish;
  5705. { Flushes the context }
  5706. procedure Flush(const AFlags: TBLContextFlushFlags);
  5707. { Queries the number of threads that the rendering context uses.
  5708. If the returned value is zero it means that the rendering is synchronous,
  5709. otherwise it describes the number of threads used for asynchronous
  5710. rendering which include the user thread. For example if the returned value
  5711. is 2 it means that the rendering context uses the user thread and one more
  5712. worker. }
  5713. function QueryThreadCount: Integer;
  5714. { Queries accumulated errors as flags.
  5715. Errors may accumulate during the lifetime of the rendering context. }
  5716. function QueryAccumulatedErrorFlags: TBLContextErrorFlags;
  5717. { Saves the current rendering context state.
  5718. Blend2D uses optimizations that make Save a cheap operation. Only core
  5719. values are actually saved in Save, others will only be saved if they
  5720. are modified. This means that consecutive calls to Save and Restore
  5721. do almost nothing. }
  5722. procedure Save; overload;
  5723. { Saves the current rendering context state and creates a restoration
  5724. ACookie.
  5725. If you use a ACookie to save a state you have to use the same cookie to
  5726. restore it otherwise the Restore would fail. Please note that cookies
  5727. are not a means of security, they are provided for making it easier to
  5728. guarantee that a code that you may not control won't break your context. }
  5729. procedure Save(out ACookie: TBLContextCookie); overload;
  5730. { Restores the top-most saved context-state.
  5731. Possible errors:
  5732. * TBLResultCode.NoStatesToRestore: There are no saved states to restore.
  5733. * TBLResultCode.NoMatchingCookie: Previous state was saved with cookie,
  5734. which was not provided. You would need the correct cookie to restore
  5735. such state. }
  5736. procedure Restore; overload;
  5737. { Restores to the point that matches the given ACookie.
  5738. More than one state can be restored in case that the ACookie points to
  5739. some previous state in the list.
  5740. Possible errors:
  5741. * TBLResultCode.NoStatesToRestore: There are no saved states to restore.
  5742. * TBLResultCode.NoMatchingCookie: The cookie did't match any saved state. }
  5743. procedure Restore(const ACookie: TBLContextCookie); overload;
  5744. { Resets user matrix to identity. }
  5745. procedure ResetMatrix;
  5746. procedure Translate(const AX, AY: Double); overload;
  5747. procedure Translate(const APoint: TBLPointI); overload;
  5748. procedure Translate(const APoint: TBLPoint); overload;
  5749. procedure Scale(const AXY: Double); overload;
  5750. procedure Scale(const AX, AY: Double); overload;
  5751. procedure Scale(const APoint: TBLPointI); overload;
  5752. procedure Scale(const APoint: TBLPoint); overload;
  5753. procedure Skew(const AX, AY: Double); overload;
  5754. procedure Skew(const APoint: TBLPoint); overload;
  5755. procedure Rotate(const AAngle: Double); overload;
  5756. procedure Rotate(const AAngle, AX, AY: Double); overload;
  5757. procedure Rotate(const AAngle: Double; const APoint: TBLPointI); overload;
  5758. procedure Rotate(const AAngle: Double; const APoint: TBLPoint); overload;
  5759. procedure Transform(const AMatrix: TBLMatrix2D);
  5760. procedure PostTranslate(const AX, AY: Double); overload;
  5761. procedure PostTranslate(const APoint: TBLPointI); overload;
  5762. procedure PostTranslate(const APoint: TBLPoint); overload;
  5763. procedure PostScale(const AXY: Double); overload;
  5764. procedure PostScale(const AX, AY: Double); overload;
  5765. procedure PostScale(const APoint: TBLPointI); overload;
  5766. procedure PostScale(const APoint: TBLPoint); overload;
  5767. procedure PostSkew(const AX, AY: Double); overload;
  5768. procedure PostSkew(const APoint: TBLPoint); overload;
  5769. procedure PostRotate(const AAngle: Double); overload;
  5770. procedure PostRotate(const AAngle, AX, AY: Double); overload;
  5771. procedure PostRotate(const AAngle: Double; const APoint: TBLPointI); overload;
  5772. procedure PostRotate(const AAngle: Double; const APoint: TBLPoint); overload;
  5773. procedure PostTransform(const AMatrix: TBLMatrix2D);
  5774. { Store the result of combining the current MetaMatrix and UserMatrix
  5775. to MetaMatrix and reset UserMatrix to identity.
  5776. Please note that this operation is irreversible. The only way to restore
  5777. both matrices to the state before the call to UserToMeta is to use
  5778. Save and Restore functions. }
  5779. procedure UserToMeta;
  5780. { These are alternatives to the FillColor, FillColor64, FillPattern and
  5781. FillGradient properties. }
  5782. procedure GetFillStyle(out ARgba: TBLRgba32); overload;
  5783. procedure GetFillStyle(out ARgba: TBLRgba64); overload;
  5784. procedure GetFillStyle(out ARgba: TBLRgba); overload;
  5785. procedure GetFillStyle(out APattern: IBLPattern); overload;
  5786. procedure GetFillStyle(out AGradient: IBLGradient); overload;
  5787. procedure SetFillStyle(const ARgba: TBLRgba32); overload;
  5788. procedure SetFillStyle(const ARgba: TBLRgba64); overload;
  5789. procedure SetFillStyle(const ARgba: TBLRgba); overload;
  5790. procedure SetFillStyle(const APattern: IBLPattern); overload;
  5791. procedure SetFillStyle(const AGradient: IBLGradient); overload;
  5792. procedure SetFillStyle(const AImage: IBLImage); overload;
  5793. { These are alternatives to the StrokeColor, StrokeColor64, StrokePattern
  5794. and StrokeGradient properties. }
  5795. procedure GetStrokeStyle(out ARgba: TBLRgba32); overload;
  5796. procedure GetStrokeStyle(out ARgba: TBLRgba64); overload;
  5797. procedure GetStrokeStyle(out ARgba: TBLRgba); overload;
  5798. procedure GetStrokeStyle(out APattern: IBLPattern); overload;
  5799. procedure GetStrokeStyle(out AGradient: IBLGradient); overload;
  5800. procedure SetStrokeStyle(const ARgba: TBLRgba32); overload;
  5801. procedure SetStrokeStyle(const ARgba: TBLRgba64); overload;
  5802. procedure SetStrokeStyle(const ARgba: TBLRgba); overload;
  5803. procedure SetStrokeStyle(const APattern: IBLPattern); overload;
  5804. procedure SetStrokeStyle(const AGradient: IBLGradient); overload;
  5805. procedure SetStrokeStyle(const AImage: IBLImage); overload;
  5806. { Restores clipping to the last saved state or to the context default
  5807. clipping if there is no saved state.
  5808. If there are no saved states then it resets clipping completely to the
  5809. initial state that was used when the rendering context was created. }
  5810. procedure RestoreClipping;
  5811. procedure ClipToRect(const ARect: TBLRectI); overload;
  5812. procedure ClipToRect(const ARect: TBLRect); overload;
  5813. procedure ClipToRect(const AX, AY, AW, AH: Double); overload;
  5814. { Clear everything. }
  5815. procedure ClearAll;
  5816. { Clears a rectangle ARect. }
  5817. procedure ClearRect(const ARect: TBLRectI); overload;
  5818. procedure ClearRect(const ARect: TBLRect); overload;
  5819. procedure ClearRect(const AX, AY, AW, AH: Double); overload;
  5820. { Fills everything. }
  5821. procedure FillAll;
  5822. { Fills a box. }
  5823. procedure FillBox(const ABox: TBLBoxI); overload;
  5824. procedure FillBox(const ABox: TBLBox); overload;
  5825. procedure FillBox(const AX0, AY0, AX1, AY1: Double); overload;
  5826. { Fills a rectangle ARect. }
  5827. procedure FillRect(const ARect: TBLRectI); overload;
  5828. procedure FillRect(const ARect: TBLRect); overload;
  5829. procedure FillRect(const AX, AY, AW, AH: Double); overload;
  5830. { Fills a circle. }
  5831. procedure FillCircle(const ACircle: TBLCircle); overload;
  5832. procedure FillCircle(const ACX, ACY, AR: Double); overload;
  5833. { Fills an ellipse. }
  5834. procedure FillEllipse(const AEllipse: TBLEllipse); overload;
  5835. procedure FillEllipse(const ACX, ACY, ARX, ARY: Double); overload;
  5836. { Fills a rounded rectangle. }
  5837. procedure FillRoundRect(const ARoundRect: TBLRoundRect); overload;
  5838. procedure FillRoundRect(const ARect: TBLRect; const AR: Double); overload;
  5839. procedure FillRoundRect(const ARect: TBLRect; const ARX, ARY: Double); overload;
  5840. procedure FillRoundRect(const AX, AY, AW, AH, AR: Double); overload;
  5841. procedure FillRoundRect(const AX, AY, AW, AH, ARX, ARY: Double); overload;
  5842. { Fills a chord. }
  5843. procedure FillChord(const AChord: TBLArc); overload;
  5844. procedure FillChord(const ACX, ACY, AR, AStart, ASweep: Double); overload;
  5845. procedure FillChord(const ACX, ACY, ARX, ARY, AStart, ASweep: Double); overload;
  5846. { Fills a pie. }
  5847. procedure FillPie(const APie: TBLArc); overload;
  5848. procedure FillPie(const ACX, ACY, AR, AStart, ASweep: Double); overload;
  5849. procedure FillPie(const ACX, ACY, ARX, ARY, AStart, ASweep: Double); overload;
  5850. { Fills a triangle. }
  5851. procedure FillTriangle(const ATriangle: TBLTriangle); overload;
  5852. procedure FillTriangle(const AX0, AY0, AX1, AY1, AX2, AY2: Double); overload;
  5853. { Fills a polygon. }
  5854. procedure FillPolygon(const APoly: TArray<TBLPoint>); overload;
  5855. procedure FillPolygon(const APoly: TBLArrayView<TBLPoint>); overload;
  5856. procedure FillPolygon(const APoly: PBLPoint; const ACount: Integer); overload;
  5857. procedure FillPolygon(const APoly: TArray<TBLPointI>); overload;
  5858. procedure FillPolygon(const APoly: TBLArrayView<TBLPointI>); overload;
  5859. procedure FillPolygon(const APoly: PBLPointI; const ACount: Integer); overload;
  5860. { Fills an array of boxes. }
  5861. procedure FillBoxArray(const ABoxes: TArray<TBLBox>); overload;
  5862. procedure FillBoxArray(const ABoxes: TBLArrayView<TBLBox>); overload;
  5863. procedure FillBoxArray(const ABoxes: PBLBox; const ACount: Integer); overload;
  5864. procedure FillBoxArray(const ABoxes: TArray<TBLBoxI>); overload;
  5865. procedure FillBoxArray(const ABoxes: TBLArrayView<TBLBoxI>); overload;
  5866. procedure FillBoxArray(const ABoxes: PBLBoxI; const ACount: Integer); overload;
  5867. { Fills an array of rectangles. }
  5868. procedure FillRectArray(const ARects: TArray<TBLRect>); overload;
  5869. procedure FillRectArray(const ARects: TBLArrayView<TBLRect>); overload;
  5870. procedure FillRectArray(const ARects: PBLRect; const ACount: Integer); overload;
  5871. procedure FillRectArray(const ARects: TArray<TBLRectI>); overload;
  5872. procedure FillRectArray(const ARects: TBLArrayView<TBLRectI>); overload;
  5873. procedure FillRectArray(const ARects: PBLRectI; const ACount: Integer); overload;
  5874. { Fills the given ARegion. }
  5875. procedure FillRegion(const ARegion: IBLRegion);
  5876. { Fills the given Path. }
  5877. procedure FillPath(const APath: IBLPath);
  5878. { Fills the passed text by using the given AFont. }
  5879. procedure FillText(const ADst: TBLPointI; const AFont: IBLFont;
  5880. const AText: String); overload;
  5881. procedure FillText(const ADst: TBLPoint; const AFont: IBLFont;
  5882. const AText: String); overload;
  5883. procedure FillText(const ADst: TBLPointI; const AFont: IBLFont;
  5884. const AText: UTF8String); overload;
  5885. procedure FillText(const ADst: TBLPoint; const AFont: IBLFont;
  5886. const AText: UTF8String); overload;
  5887. procedure FillText(const ADst: TBLPointI; const AFont: IBLFont;
  5888. const AText: UCS4String); overload;
  5889. procedure FillText(const ADst: TBLPoint; const AFont: IBLFont;
  5890. const AText: UCS4String); overload;
  5891. { Fills the passed AGlyphRun by using the given AFont. }
  5892. procedure FillGlyphRun(const ADst: TBLPointI; const AFont: IBLFont;
  5893. const AGlyphRun: TBLGlyphRun); overload;
  5894. procedure FillGlyphRun(const ADst: TBLPoint; const AFont: IBLFont;
  5895. const AGlyphRun: TBLGlyphRun); overload;
  5896. procedure FillGlyphRun(const ADst: TBLPointI; const AFont: IBLFont;
  5897. const AGlyphRun: PBLGlyphRun); overload;
  5898. procedure FillGlyphRun(const ADst: TBLPoint; const AFont: IBLFont;
  5899. const AGlyphRun: PBLGlyphRun); overload;
  5900. { Strokes a box. }
  5901. procedure StrokeBox(const ABox: TBLBoxI); overload;
  5902. procedure StrokeBox(const ABox: TBLBox); overload;
  5903. procedure StrokeBox(const AX0, AY0, AX1, AY1: Double); overload;
  5904. { Strokes a rectangle. }
  5905. procedure StrokeRect(const ARect: TBLRectI); overload;
  5906. procedure StrokeRect(const ARect: TBLRect); overload;
  5907. procedure StrokeRect(const AX, AY, AW, AH: Double); overload;
  5908. { Strokes a line. }
  5909. procedure StrokeLine(const ALine: TBLLine); overload;
  5910. procedure StrokeLine(const AP0, AP1: TBLPoint); overload;
  5911. procedure StrokeLine(const AX0, AY0, AX1, AY1: Double); overload;
  5912. { Strokes a circle. }
  5913. procedure StrokeCircle(const ACircle: TBLCircle); overload;
  5914. procedure StrokeCircle(const ACX, ACY, AR: Double); overload;
  5915. { Strokes an ellipse. }
  5916. procedure StrokeEllipse(const AEllipse: TBLEllipse); overload;
  5917. procedure StrokeEllipse(const ACX, ACY, ARX, ARY: Double); overload;
  5918. { Strokes a rounded rectangle. }
  5919. procedure StrokeRoundRect(const ARoundRect: TBLRoundRect); overload;
  5920. procedure StrokeRoundRect(const ARect: TBLRect; const AR: Double); overload;
  5921. procedure StrokeRoundRect(const ARect: TBLRect; const ARX, ARY: Double); overload;
  5922. procedure StrokeRoundRect(const AX, AY, AW, AH, AR: Double); overload;
  5923. procedure StrokeRoundRect(const AX, AY, AW, AH, ARX, ARY: Double); overload;
  5924. { Strokes an arc. }
  5925. procedure StrokeArc(const AArc: TBLArc); overload;
  5926. procedure StrokeArc(const ACX, ACY, AR, AStart, ASweep: Double); overload;
  5927. procedure StrokeArc(const ACX, ACY, ARX, ARY, AStart, ASweep: Double); overload;
  5928. { Strokes a chord. }
  5929. procedure StrokeChord(const AChord: TBLArc); overload;
  5930. procedure StrokeChord(const ACX, ACY, AR, AStart, ASweep: Double); overload;
  5931. procedure StrokeChord(const ACX, ACY, ARX, ARY, AStart, ASweep: Double); overload;
  5932. { Strokes a pie. }
  5933. procedure StrokePie(const APie: TBLArc); overload;
  5934. procedure StrokePie(const ACX, ACY, AR, AStart, ASweep: Double); overload;
  5935. procedure StrokePie(const ACX, ACY, ARX, ARY, AStart, ASweep: Double); overload;
  5936. { Strokes a triangle. }
  5937. procedure StrokeTriangle(const ATriangle: TBLTriangle); overload;
  5938. procedure StrokeTriangle(const AX0, AY0, AX1, AY1, AX2, AY2: Double); overload;
  5939. { Strokes a polyline. }
  5940. procedure StrokePolyline(const APoly: TArray<TBLPoint>); overload;
  5941. procedure StrokePolyline(const APoly: TBLArrayView<TBLPoint>); overload;
  5942. procedure StrokePolyline(const APoly: PBLPoint; const ACount: Integer); overload;
  5943. procedure StrokePolyline(const APoly: TArray<TBLPointI>); overload;
  5944. procedure StrokePolyline(const APoly: TBLArrayView<TBLPointI>); overload;
  5945. procedure StrokePolyline(const APoly: PBLPointI; const ACount: Integer); overload;
  5946. { Strokes a polygon. }
  5947. procedure StrokePolygon(const APoly: TArray<TBLPoint>); overload;
  5948. procedure StrokePolygon(const APoly: TBLArrayView<TBLPoint>); overload;
  5949. procedure StrokePolygon(const APoly: PBLPoint; const ACount: Integer); overload;
  5950. procedure StrokePolygon(const APoly: TArray<TBLPointI>); overload;
  5951. procedure StrokePolygon(const APoly: TBLArrayView<TBLPointI>); overload;
  5952. procedure StrokePolygon(const APoly: PBLPointI; const ACount: Integer); overload;
  5953. { Strokes an array of boxes. }
  5954. procedure StrokeBoxArray(const ABoxes: TArray<TBLBox>); overload;
  5955. procedure StrokeBoxArray(const ABoxes: TBLArrayView<TBLBox>); overload;
  5956. procedure StrokeBoxArray(const ABoxes: PBLBox; const ACount: Integer); overload;
  5957. procedure StrokeBoxArray(const ABoxes: TArray<TBLBoxI>); overload;
  5958. procedure StrokeBoxArray(const ABoxes: TBLArrayView<TBLBoxI>); overload;
  5959. procedure StrokeBoxArray(const ABoxes: PBLBoxI; const ACount: Integer); overload;
  5960. { Strokes an array of rectangles. }
  5961. procedure StrokeRectArray(const ARects: TArray<TBLRect>); overload;
  5962. procedure StrokeRectArray(const ARects: TBLArrayView<TBLRect>); overload;
  5963. procedure StrokeRectArray(const ARects: PBLRect; const ACount: Integer); overload;
  5964. procedure StrokeRectArray(const ARects: TArray<TBLRectI>); overload;
  5965. procedure StrokeRectArray(const ARects: TBLArrayView<TBLRectI>); overload;
  5966. procedure StrokeRectArray(const ARects: PBLRectI; const ACount: Integer); overload;
  5967. { Strokes the given Path. }
  5968. procedure StrokePath(const APath: IBLPath);
  5969. { Strokes the passed text by using the given AFont. }
  5970. procedure StrokeText(const ADst: TBLPointI; const AFont: IBLFont;
  5971. const AText: String); overload;
  5972. procedure StrokeText(const ADst: TBLPoint; const AFont: IBLFont;
  5973. const AText: String); overload;
  5974. procedure StrokeText(const ADst: TBLPointI; const AFont: IBLFont;
  5975. const AText: UTF8String); overload;
  5976. procedure StrokeText(const ADst: TBLPoint; const AFont: IBLFont;
  5977. const AText: UTF8String); overload;
  5978. procedure StrokeText(const ADst: TBLPointI; const AFont: IBLFont;
  5979. const AText: UCS4String); overload;
  5980. procedure StrokeText(const ADst: TBLPoint; const AFont: IBLFont;
  5981. const AText: UCS4String); overload;
  5982. { Strokes the passed AGlyphRun by using the given AFont. }
  5983. procedure StrokeGlyphRun(const ADst: TBLPointI; const AFont: IBLFont;
  5984. const AGlyphRun: TBLGlyphRun); overload;
  5985. procedure StrokeGlyphRun(const ADst: TBLPoint; const AFont: IBLFont;
  5986. const AGlyphRun: TBLGlyphRun); overload;
  5987. { Blits source image ASrc at coordinates specified by ADst. }
  5988. procedure BlitImage(const ADst: TBLPoint; const ASrc: IBLImage); overload;
  5989. procedure BlitImage(const ADst: TBLPointI; const ASrc: IBLImage); overload;
  5990. { Blits an area of source image ASrc specified by ASrcArea at coordinates
  5991. specified by ADst.}
  5992. procedure BlitImage(const ADst: TBLPoint; const ASrc: IBLImage;
  5993. const ASrcArea: TBLRectI); overload;
  5994. procedure BlitImage(const ADst: TBLPointI; const ASrc: IBLImage;
  5995. const ASrcArea: TBLRectI); overload;
  5996. { Blits a source image ASrc scaled to fit into ADst rectangle. }
  5997. procedure BlitImage(const ADst: TBLRect; const ASrc: IBLImage); overload;
  5998. procedure BlitImage(const ADst: TBLRectI; const ASrc: IBLImage); overload;
  5999. { Blits an area of source image ASrc specified by ASrcArea scaled to fit
  6000. into ADst rectangle. }
  6001. procedure BlitImage(const ADst: TBLRect; const ASrc: IBLImage;
  6002. const ASrcArea: TBLRectI); overload;
  6003. procedure BlitImage(const ADst: TBLRectI; const ASrc: IBLImage;
  6004. const ASrcArea: TBLRectI); overload;
  6005. { Target size in abstract units (pixels in case of IBLImage) }
  6006. property TargetSize: TBLSize read GetTargetSize;
  6007. { Target width in abstract units (pixels in case of IBLImage) }
  6008. property TargetWidth: Double read GetTargetWidth;
  6009. { Target width in abstract units (pixels in case of IBLImage) }
  6010. property TargetHeight: Double read GetTargetHeight;
  6011. { Returns the target image or nil if there is no target image.
  6012. Note: The rendering context doesn't own the image, but it increases its
  6013. writer count, which means that the image will not be destroyed even when
  6014. user destroys it during the rendering (in such case it will be destroyed
  6015. after the rendering ends when the writer count goes to zero). This means
  6016. that the rendering context must hold the image and not the pointer to
  6017. the IBLImage passed to either the constructor or Start function. So the
  6018. returned pointer is not the same as the pointer passed to Start, but it
  6019. points to the same impl. }
  6020. property TargetImage: IBLImage read GetTargetImage;
  6021. { The type of this context }
  6022. property ContextType: TBLContextType read GetContextType;
  6023. { Whether the context is a built-in null instance. }
  6024. property IsNone: Boolean read GetIsNone;
  6025. { The number of saved states in the context (0 means no saved states). }
  6026. property SavedStateCount: Integer read GetSavedStateCount;
  6027. { Meta-matrix.
  6028. Meta matrix is a core transformation matrix that is normally not changed
  6029. by transformations applied to the context. Instead it acts as a secondary
  6030. matrix used to create the final transformation matrix from meta and user
  6031. matrices.
  6032. Meta matrix can be used to scale the whole context for HI-DPI rendering
  6033. or to change the orientation of the image being rendered, however, the
  6034. number of use-cases is unlimited.
  6035. To change the meta-matrix you must first change user-matrix and then call
  6036. UserToMeta, which would update meta-matrix and clear user-matrix.
  6037. See UserMatrix and UserToMeta. }
  6038. property MetaMatrix: TBLMatrix2D read GetMetaMatrix;
  6039. { User-matrix.
  6040. User matrix contains all transformations that happened to the rendering
  6041. context unless the context was restored or UserToMeta was called. }
  6042. property UserMatrix: TBLMatrix2D read GetUserMatrix write SetUserMatrix;
  6043. { Rendering hints. }
  6044. property Hints: TBLContextHints read GetHints write SetHints;
  6045. property RenderingQuality: TBLRenderingQuality read GetRenderingQuality write SetRenderingQuality;
  6046. property GradientQuality: TBLGradientQuality read GetGradientQuality write SetGradientQuality;
  6047. property PatternQuality: TBLPatternQuality read GetPatternQuality write SetPatternQuality;
  6048. { Approximation options. }
  6049. property ApproximationOptions: TBLApproximationOptions read GetApproximationOptions;
  6050. { Flatten mode. }
  6051. property FlattenMode: TBLFlattenMode read GetFlattenMode write SetFlattenMode;
  6052. { Tolerance used for curve flattening. }
  6053. property FlattenTolerance: Double read GetFlattenTolerance write SetFlattenTolerance;
  6054. { Composition operator. }
  6055. property CompOp: TBLCompOp read GetCompOp write SetCompOp;
  6056. { Global alpha value. }
  6057. property GlobalAlpha: Double read GetGlobalAlpha write SetGlobalAlpha;
  6058. { Fill style }
  6059. property FillStyle: TBLStyleType read GetFillStyle;
  6060. { Stroke style }
  6061. property StrokeStyle: TBLStyleType read GetStrokeStyle;
  6062. { Fill alpha }
  6063. property FillAlpha: Double read GetFillAlpha write SetFillAlpha;
  6064. { Stroke alpha }
  6065. property StrokeAlpha: Double read GetStrokeAlpha write SetStrokeAlpha;
  6066. { Fill color }
  6067. property FillColor: TBLRgba32 read GetFillColor write SetFillColor;
  6068. property FillColor64: TBLRgba64 read GetFillColor64 write SetFillColor64;
  6069. property FillColorF: TBLRgba read GetFillColorF write SetFillColorF;
  6070. { Stroke color }
  6071. property StrokeColor: TBLRgba32 read GetStrokeColor write SetStrokeColor;
  6072. property StrokeColor64: TBLRgba64 read GetStrokeColor64 write SetStrokeColor64;
  6073. property StrokeColorF: TBLRgba read GetStrokeColorF write SetStrokeColorF;
  6074. { Fill Pattern }
  6075. property FillPattern: IBLPattern read GetFillPattern write SetFillPattern;
  6076. { Stroke Pattern }
  6077. property StrokePattern: IBLPattern read GetStrokePattern write SetStrokePattern;
  6078. { Fill Gradient }
  6079. property FillGradient: IBLGradient read GetFillGradient write SetFillGradient;
  6080. { Stroke Gradient }
  6081. property StrokeGradient: IBLGradient read GetStrokeGradient write SetStrokeGradient;
  6082. { Fill rule }
  6083. property FillRule: TBLFillRule read GetFillRule write SetFillRule;
  6084. { Stroke width }
  6085. property StrokeWidth: Double read GetStrokeWidth write SetStrokeWidth;
  6086. { Stroke miter-limit. }
  6087. property StrokeMiterLimit: Double read GetStrokeMiterLimit write SetStrokeMiterLimit;
  6088. { Stroke join }
  6089. property StrokeJoin: TBLStrokeJoin read GetStrokeJoin write SetStrokeJoin;
  6090. { Stroke start-cap }
  6091. property StrokeStartCap: TBLStrokeCap read GetStrokeStartCap write SetStrokeStartCap;
  6092. { Stroke end-cap }
  6093. property StrokeEndCap: TBLStrokeCap read GetStrokeEndCap write SetStrokeEndCap;
  6094. { Stroke dash-offset. }
  6095. property StrokeDashOffset: Double read GetStrokeDashOffset write SetStrokeDashOffset;
  6096. { Stroke dash-array. }
  6097. property StrokeDashArray: TArray<Double> read GetStrokeDashArray write SetStrokeDashArray;
  6098. { Stroke transform order }
  6099. property StrokeTransformOrder: TBLStrokeTransformOrder read GetStrokeTransformOrder write SetStrokeTransformOrder;
  6100. { All stroke options }
  6101. property StrokeOptions: TBLStrokeOptions read GetStrokeOptions write SetStrokeOptions;
  6102. { Internal handle for use with the C API }
  6103. property Handle: PBLContextCore read GetHandle;
  6104. end;
  6105. type
  6106. { Implements IBLContext }
  6107. TBLContext = class(TInterfacedObject, IBLContext)
  6108. {$REGION 'Internal Declarations'}
  6109. private
  6110. FHandle: BLContextCore;
  6111. protected
  6112. { IBLContext }
  6113. function GetTargetSize: TBLSize;
  6114. function GetTargetWidth: Double;
  6115. function GetTargetHeight: Double;
  6116. function GetTargetImage: IBLImage;
  6117. function GetContextType: TBLContextType;
  6118. function GetIsNone: Boolean;
  6119. function GetSavedStateCount: Integer;
  6120. function GetMetaMatrix: TBLMatrix2D;
  6121. function GetUserMatrix: TBLMatrix2D;
  6122. procedure SetUserMatrix(const AValue: TBLMatrix2D);
  6123. function GetHints: TBLContextHints;
  6124. procedure SetHints(const AValue: TBLContextHints);
  6125. function GetRenderingQuality: TBLRenderingQuality;
  6126. procedure SetRenderingQuality(const AValue: TBLRenderingQuality);
  6127. function GetGradientQuality: TBLGradientQuality;
  6128. procedure SetGradientQuality(const AValue: TBLGradientQuality);
  6129. function GetPatternQuality: TBLPatternQuality;
  6130. procedure SetPatternQuality(const AValue: TBLPatternQuality);
  6131. function GetApproximationOptions: TBLApproximationOptions;
  6132. function GetFlattenMode: TBLFlattenMode;
  6133. procedure SetFlattenMode(const AValue: TBLFlattenMode);
  6134. function GetFlattenTolerance: Double;
  6135. procedure SetFlattenTolerance(const AValue: Double);
  6136. function GetCompOp: TBLCompOp;
  6137. procedure SetCompOp(const AValue: TBLCompOp);
  6138. function GetGlobalAlpha: Double;
  6139. procedure SetGlobalAlpha(const AValue: Double);
  6140. function GetFillStyle: TBLStyleType; overload;
  6141. function GetStrokeStyle: TBLStyleType; overload;
  6142. function GetFillAlpha: Double;
  6143. procedure SetFillAlpha(const AValue: Double);
  6144. function GetStrokeAlpha: Double;
  6145. procedure SetStrokeAlpha(const AValue: Double);
  6146. function GetFillColor: TBLRgba32;
  6147. procedure SetFillColor(const AValue: TBLRgba32);
  6148. function GetFillColor64: TBLRgba64;
  6149. procedure SetFillColor64(const AValue: TBLRgba64);
  6150. function GetFillColorF: TBLRgba;
  6151. procedure SetFillColorF(const AValue: TBLRgba);
  6152. function GetStrokeColor: TBLRgba32;
  6153. procedure SetStrokeColor(const AValue: TBLRgba32);
  6154. function GetStrokeColor64: TBLRgba64;
  6155. procedure SetStrokeColor64(const AValue: TBLRgba64);
  6156. function GetStrokeColorF: TBLRgba;
  6157. procedure SetStrokeColorF(const AValue: TBLRgba);
  6158. function GetFillPattern: IBLPattern;
  6159. procedure SetFillPattern(const AValue: IBLPattern);
  6160. function GetStrokePattern: IBLPattern;
  6161. procedure SetStrokePattern(const AValue: IBLPattern);
  6162. function GetFillGradient: IBLGradient;
  6163. procedure SetFillGradient(const AValue: IBLGradient);
  6164. function GetStrokeGradient: IBLGradient;
  6165. procedure SetStrokeGradient(const AValue: IBLGradient);
  6166. function GetFillRule: TBLFillRule;
  6167. procedure SetFillRule(const AValue: TBLFillRule);
  6168. function GetStrokeWidth: Double;
  6169. procedure SetStrokeWidth(const AValue: Double);
  6170. function GetStrokeMiterLimit: Double;
  6171. procedure SetStrokeMiterLimit(const AValue: Double);
  6172. function GetStrokeJoin: TBLStrokeJoin;
  6173. procedure SetStrokeJoin(const AValue: TBLStrokeJoin);
  6174. function GetStrokeStartCap: TBLStrokeCap;
  6175. procedure SetStrokeStartCap(const AValue: TBLStrokeCap);
  6176. function GetStrokeEndCap: TBLStrokeCap;
  6177. procedure SetStrokeEndCap(const AValue: TBLStrokeCap);
  6178. function GetStrokeDashOffset: Double;
  6179. procedure SetStrokeDashOffset(const AValue: Double);
  6180. function GetStrokeDashArray: TArray<Double>;
  6181. procedure SetStrokeDashArray(const AValue: TArray<Double>);
  6182. function GetStrokeTransformOrder: TBLStrokeTransformOrder;
  6183. procedure SetStrokeTransformOrder(const AValue: TBLStrokeTransformOrder);
  6184. function GetStrokeOptions: TBLStrokeOptions;
  6185. procedure SetStrokeOptions(const AValue: TBLStrokeOptions);
  6186. function GetHandle: PBLContextCore;
  6187. procedure Reset;
  6188. function Equals(const AOther: IBLContext): Boolean; reintroduce; overload;
  6189. procedure Start(const AImage: IBLImage); overload;
  6190. procedure Start(const AImage: IBLImage;
  6191. const ACreateInfo: TBLContextCreateInfo); overload;
  6192. procedure Finish;
  6193. procedure Flush(const AFlags: TBLContextFlushFlags);
  6194. function QueryThreadCount: Integer;
  6195. function QueryAccumulatedErrorFlags: TBLContextErrorFlags;
  6196. procedure Save; overload;
  6197. procedure Save(out ACookie: TBLContextCookie); overload;
  6198. procedure Restore; overload;
  6199. procedure Restore(const ACookie: TBLContextCookie); overload;
  6200. procedure ResetMatrix;
  6201. procedure Translate(const AX, AY: Double); overload;
  6202. procedure Translate(const APoint: TBLPointI); overload;
  6203. procedure Translate(const APoint: TBLPoint); overload;
  6204. procedure Scale(const AXY: Double); overload;
  6205. procedure Scale(const AX, AY: Double); overload;
  6206. procedure Scale(const APoint: TBLPointI); overload;
  6207. procedure Scale(const APoint: TBLPoint); overload;
  6208. procedure Skew(const AX, AY: Double); overload;
  6209. procedure Skew(const APoint: TBLPoint); overload;
  6210. procedure Rotate(const AAngle: Double); overload;
  6211. procedure Rotate(const AAngle, AX, AY: Double); overload;
  6212. procedure Rotate(const AAngle: Double; const APoint: TBLPointI); overload;
  6213. procedure Rotate(const AAngle: Double; const APoint: TBLPoint); overload;
  6214. procedure Transform(const AMatrix: TBLMatrix2D);
  6215. procedure PostTranslate(const AX, AY: Double); overload;
  6216. procedure PostTranslate(const APoint: TBLPointI); overload;
  6217. procedure PostTranslate(const APoint: TBLPoint); overload;
  6218. procedure PostScale(const AXY: Double); overload;
  6219. procedure PostScale(const AX, AY: Double); overload;
  6220. procedure PostScale(const APoint: TBLPointI); overload;
  6221. procedure PostScale(const APoint: TBLPoint); overload;
  6222. procedure PostSkew(const AX, AY: Double); overload;
  6223. procedure PostSkew(const APoint: TBLPoint); overload;
  6224. procedure PostRotate(const AAngle: Double); overload;
  6225. procedure PostRotate(const AAngle, AX, AY: Double); overload;
  6226. procedure PostRotate(const AAngle: Double; const APoint: TBLPointI); overload;
  6227. procedure PostRotate(const AAngle: Double; const APoint: TBLPoint); overload;
  6228. procedure PostTransform(const AMatrix: TBLMatrix2D);
  6229. procedure UserToMeta;
  6230. procedure GetFillStyle(out ARgba: TBLRgba32); overload;
  6231. procedure GetFillStyle(out ARgba: TBLRgba64); overload;
  6232. procedure GetFillStyle(out ARgba: TBLRgba); overload;
  6233. procedure GetFillStyle(out APattern: IBLPattern); overload;
  6234. procedure GetFillStyle(out AGradient: IBLGradient); overload;
  6235. procedure SetFillStyle(const ARgba: TBLRgba32); overload;
  6236. procedure SetFillStyle(const ARgba: TBLRgba64); overload;
  6237. procedure SetFillStyle(const ARgba: TBLRgba); overload;
  6238. procedure SetFillStyle(const APattern: IBLPattern); overload;
  6239. procedure SetFillStyle(const AGradient: IBLGradient); overload;
  6240. procedure SetFillStyle(const AImage: IBLImage); overload;
  6241. procedure GetStrokeStyle(out ARgba: TBLRgba32); overload;
  6242. procedure GetStrokeStyle(out ARgba: TBLRgba64); overload;
  6243. procedure GetStrokeStyle(out ARgba: TBLRgba); overload;
  6244. procedure GetStrokeStyle(out APattern: IBLPattern); overload;
  6245. procedure GetStrokeStyle(out AGradient: IBLGradient); overload;
  6246. procedure SetStrokeStyle(const ARgba: TBLRgba32); overload;
  6247. procedure SetStrokeStyle(const ARgba: TBLRgba64); overload;
  6248. procedure SetStrokeStyle(const ARgba: TBLRgba); overload;
  6249. procedure SetStrokeStyle(const APattern: IBLPattern); overload;
  6250. procedure SetStrokeStyle(const AGradient: IBLGradient); overload;
  6251. procedure SetStrokeStyle(const AImage: IBLImage); overload;
  6252. procedure RestoreClipping;
  6253. procedure ClipToRect(const ARect: TBLRectI); overload;
  6254. procedure ClipToRect(const ARect: TBLRect); overload;
  6255. procedure ClipToRect(const AX, AY, AW, AH: Double); overload;
  6256. procedure ClearAll;
  6257. procedure ClearRect(const ARect: TBLRectI); overload;
  6258. procedure ClearRect(const ARect: TBLRect); overload;
  6259. procedure ClearRect(const AX, AY, AW, AH: Double); overload;
  6260. procedure FillAll;
  6261. procedure FillBox(const ABox: TBLBoxI); overload;
  6262. procedure FillBox(const ABox: TBLBox); overload;
  6263. procedure FillBox(const AX0, AY0, AX1, AY1: Double); overload;
  6264. procedure FillRect(const ARect: TBLRectI); overload;
  6265. procedure FillRect(const ARect: TBLRect); overload;
  6266. procedure FillRect(const AX, AY, AW, AH: Double); overload;
  6267. procedure FillCircle(const ACircle: TBLCircle); overload;
  6268. procedure FillCircle(const ACX, ACY, AR: Double); overload;
  6269. procedure FillEllipse(const AEllipse: TBLEllipse); overload;
  6270. procedure FillEllipse(const ACX, ACY, ARX, ARY: Double); overload;
  6271. procedure FillRoundRect(const ARoundRect: TBLRoundRect); overload;
  6272. procedure FillRoundRect(const ARect: TBLRect; const AR: Double); overload;
  6273. procedure FillRoundRect(const ARect: TBLRect; const ARX, ARY: Double); overload;
  6274. procedure FillRoundRect(const AX, AY, AW, AH, AR: Double); overload;
  6275. procedure FillRoundRect(const AX, AY, AW, AH, ARX, ARY: Double); overload;
  6276. procedure FillChord(const AChord: TBLArc); overload;
  6277. procedure FillChord(const ACX, ACY, AR, AStart, ASweep: Double); overload;
  6278. procedure FillChord(const ACX, ACY, ARX, ARY, AStart, ASweep: Double); overload;
  6279. procedure FillPie(const APie: TBLArc); overload;
  6280. procedure FillPie(const ACX, ACY, AR, AStart, ASweep: Double); overload;
  6281. procedure FillPie(const ACX, ACY, ARX, ARY, AStart, ASweep: Double); overload;
  6282. procedure FillTriangle(const ATriangle: TBLTriangle); overload;
  6283. procedure FillTriangle(const AX0, AY0, AX1, AY1, AX2, AY2: Double); overload;
  6284. procedure FillPolygon(const APoly: TArray<TBLPoint>); overload;
  6285. procedure FillPolygon(const APoly: TBLArrayView<TBLPoint>); overload;
  6286. procedure FillPolygon(const APoly: PBLPoint; const ACount: Integer); overload;
  6287. procedure FillPolygon(const APoly: TArray<TBLPointI>); overload;
  6288. procedure FillPolygon(const APoly: TBLArrayView<TBLPointI>); overload;
  6289. procedure FillPolygon(const APoly: PBLPointI; const ACount: Integer); overload;
  6290. procedure FillBoxArray(const ABoxes: TArray<TBLBox>); overload;
  6291. procedure FillBoxArray(const ABoxes: TBLArrayView<TBLBox>); overload;
  6292. procedure FillBoxArray(const ABoxes: PBLBox; const ACount: Integer); overload;
  6293. procedure FillBoxArray(const ABoxes: TArray<TBLBoxI>); overload;
  6294. procedure FillBoxArray(const ABoxes: TBLArrayView<TBLBoxI>); overload;
  6295. procedure FillBoxArray(const ABoxes: PBLBoxI; const ACount: Integer); overload;
  6296. procedure FillRectArray(const ARects: TArray<TBLRect>); overload;
  6297. procedure FillRectArray(const ARects: TBLArrayView<TBLRect>); overload;
  6298. procedure FillRectArray(const ARects: PBLRect; const ACount: Integer); overload;
  6299. procedure FillRectArray(const ARects: TArray<TBLRectI>); overload;
  6300. procedure FillRectArray(const ARects: TBLArrayView<TBLRectI>); overload;
  6301. procedure FillRectArray(const ARects: PBLRectI; const ACount: Integer); overload;
  6302. procedure FillRegion(const ARegion: IBLRegion);
  6303. procedure FillPath(const APath: IBLPath);
  6304. procedure FillText(const ADst: TBLPointI; const AFont: IBLFont;
  6305. const AText: String); overload;
  6306. procedure FillText(const ADst: TBLPoint; const AFont: IBLFont;
  6307. const AText: String); overload;
  6308. procedure FillText(const ADst: TBLPointI; const AFont: IBLFont;
  6309. const AText: UTF8String); overload;
  6310. procedure FillText(const ADst: TBLPoint; const AFont: IBLFont;
  6311. const AText: UTF8String); overload;
  6312. procedure FillText(const ADst: TBLPointI; const AFont: IBLFont;
  6313. const AText: UCS4String); overload;
  6314. procedure FillText(const ADst: TBLPoint; const AFont: IBLFont;
  6315. const AText: UCS4String); overload;
  6316. procedure FillGlyphRun(const ADst: TBLPointI; const AFont: IBLFont;
  6317. const AGlyphRun: TBLGlyphRun); overload;
  6318. procedure FillGlyphRun(const ADst: TBLPoint; const AFont: IBLFont;
  6319. const AGlyphRun: TBLGlyphRun); overload;
  6320. procedure FillGlyphRun(const ADst: TBLPointI; const AFont: IBLFont;
  6321. const AGlyphRun: PBLGlyphRun); overload;
  6322. procedure FillGlyphRun(const ADst: TBLPoint; const AFont: IBLFont;
  6323. const AGlyphRun: PBLGlyphRun); overload;
  6324. procedure StrokeBox(const ABox: TBLBoxI); overload;
  6325. procedure StrokeBox(const ABox: TBLBox); overload;
  6326. procedure StrokeBox(const AX0, AY0, AX1, AY1: Double); overload;
  6327. procedure StrokeRect(const ARect: TBLRectI); overload;
  6328. procedure StrokeRect(const ARect: TBLRect); overload;
  6329. procedure StrokeRect(const AX, AY, AW, AH: Double); overload;
  6330. procedure StrokeLine(const ALine: TBLLine); overload;
  6331. procedure StrokeLine(const AP0, AP1: TBLPoint); overload;
  6332. procedure StrokeLine(const AX0, AY0, AX1, AY1: Double); overload;
  6333. procedure StrokeCircle(const ACircle: TBLCircle); overload;
  6334. procedure StrokeCircle(const ACX, ACY, AR: Double); overload;
  6335. procedure StrokeEllipse(const AEllipse: TBLEllipse); overload;
  6336. procedure StrokeEllipse(const ACX, ACY, ARX, ARY: Double); overload;
  6337. procedure StrokeRoundRect(const ARoundRect: TBLRoundRect); overload;
  6338. procedure StrokeRoundRect(const ARect: TBLRect; const AR: Double); overload;
  6339. procedure StrokeRoundRect(const ARect: TBLRect; const ARX, ARY: Double); overload;
  6340. procedure StrokeRoundRect(const AX, AY, AW, AH, AR: Double); overload;
  6341. procedure StrokeRoundRect(const AX, AY, AW, AH, ARX, ARY: Double); overload;
  6342. procedure StrokeArc(const AArc: TBLArc); overload;
  6343. procedure StrokeArc(const ACX, ACY, AR, AStart, ASweep: Double); overload;
  6344. procedure StrokeArc(const ACX, ACY, ARX, ARY, AStart, ASweep: Double); overload;
  6345. procedure StrokeChord(const AChord: TBLArc); overload;
  6346. procedure StrokeChord(const ACX, ACY, AR, AStart, ASweep: Double); overload;
  6347. procedure StrokeChord(const ACX, ACY, ARX, ARY, AStart, ASweep: Double); overload;
  6348. procedure StrokePie(const APie: TBLArc); overload;
  6349. procedure StrokePie(const ACX, ACY, AR, AStart, ASweep: Double); overload;
  6350. procedure StrokePie(const ACX, ACY, ARX, ARY, AStart, ASweep: Double); overload;
  6351. procedure StrokeTriangle(const ATriangle: TBLTriangle); overload;
  6352. procedure StrokeTriangle(const AX0, AY0, AX1, AY1, AX2, AY2: Double); overload;
  6353. procedure StrokePolyline(const APoly: TArray<TBLPoint>); overload;
  6354. procedure StrokePolyline(const APoly: TBLArrayView<TBLPoint>); overload;
  6355. procedure StrokePolyline(const APoly: PBLPoint; const ACount: Integer); overload;
  6356. procedure StrokePolyline(const APoly: TArray<TBLPointI>); overload;
  6357. procedure StrokePolyline(const APoly: TBLArrayView<TBLPointI>); overload;
  6358. procedure StrokePolyline(const APoly: PBLPointI; const ACount: Integer); overload;
  6359. procedure StrokePolygon(const APoly: TArray<TBLPoint>); overload;
  6360. procedure StrokePolygon(const APoly: TBLArrayView<TBLPoint>); overload;
  6361. procedure StrokePolygon(const APoly: PBLPoint; const ACount: Integer); overload;
  6362. procedure StrokePolygon(const APoly: TArray<TBLPointI>); overload;
  6363. procedure StrokePolygon(const APoly: TBLArrayView<TBLPointI>); overload;
  6364. procedure StrokePolygon(const APoly: PBLPointI; const ACount: Integer); overload;
  6365. procedure StrokeBoxArray(const ABoxes: TArray<TBLBox>); overload;
  6366. procedure StrokeBoxArray(const ABoxes: TBLArrayView<TBLBox>); overload;
  6367. procedure StrokeBoxArray(const ABoxes: PBLBox; const ACount: Integer); overload;
  6368. procedure StrokeBoxArray(const ABoxes: TArray<TBLBoxI>); overload;
  6369. procedure StrokeBoxArray(const ABoxes: TBLArrayView<TBLBoxI>); overload;
  6370. procedure StrokeBoxArray(const ABoxes: PBLBoxI; const ACount: Integer); overload;
  6371. procedure StrokeRectArray(const ARects: TArray<TBLRect>); overload;
  6372. procedure StrokeRectArray(const ARects: TBLArrayView<TBLRect>); overload;
  6373. procedure StrokeRectArray(const ARects: PBLRect; const ACount: Integer); overload;
  6374. procedure StrokeRectArray(const ARects: TArray<TBLRectI>); overload;
  6375. procedure StrokeRectArray(const ARects: TBLArrayView<TBLRectI>); overload;
  6376. procedure StrokeRectArray(const ARects: PBLRectI; const ACount: Integer); overload;
  6377. procedure StrokePath(const APath: IBLPath);
  6378. procedure StrokeText(const ADst: TBLPointI; const AFont: IBLFont;
  6379. const AText: String); overload;
  6380. procedure StrokeText(const ADst: TBLPoint; const AFont: IBLFont;
  6381. const AText: String); overload;
  6382. procedure StrokeText(const ADst: TBLPointI; const AFont: IBLFont;
  6383. const AText: UTF8String); overload;
  6384. procedure StrokeText(const ADst: TBLPoint; const AFont: IBLFont;
  6385. const AText: UTF8String); overload;
  6386. procedure StrokeText(const ADst: TBLPointI; const AFont: IBLFont;
  6387. const AText: UCS4String); overload;
  6388. procedure StrokeText(const ADst: TBLPoint; const AFont: IBLFont;
  6389. const AText: UCS4String); overload;
  6390. procedure StrokeGlyphRun(const ADst: TBLPointI; const AFont: IBLFont;
  6391. const AGlyphRun: TBLGlyphRun); overload;
  6392. procedure StrokeGlyphRun(const ADst: TBLPoint; const AFont: IBLFont;
  6393. const AGlyphRun: TBLGlyphRun); overload;
  6394. procedure BlitImage(const ADst: TBLPoint; const ASrc: IBLImage); overload;
  6395. procedure BlitImage(const ADst: TBLPointI; const ASrc: IBLImage); overload;
  6396. procedure BlitImage(const ADst: TBLPoint; const ASrc: IBLImage;
  6397. const ASrcArea: TBLRectI); overload;
  6398. procedure BlitImage(const ADst: TBLPointI; const ASrc: IBLImage;
  6399. const ASrcArea: TBLRectI); overload;
  6400. procedure BlitImage(const ADst: TBLRect; const ASrc: IBLImage); overload;
  6401. procedure BlitImage(const ADst: TBLRectI; const ASrc: IBLImage); overload;
  6402. procedure BlitImage(const ADst: TBLRect; const ASrc: IBLImage;
  6403. const ASrcArea: TBLRectI); overload;
  6404. procedure BlitImage(const ADst: TBLRectI; const ASrc: IBLImage;
  6405. const ASrcArea: TBLRectI); overload;
  6406. public
  6407. procedure AfterConstruction; override;
  6408. {$ENDREGION 'Internal Declarations'}
  6409. public
  6410. { Creates a default constructed rendering context.
  6411. Default constructed means that the instance is valid, but uninitialized,
  6412. which means the rendering context does not have attached any target. Any
  6413. attempt to use uninitialized context results in
  6414. TBLResultCode.NotInitialized error. }
  6415. constructor Create; overload;
  6416. { Creates a new rendering context for rendering to the image ATarget. }
  6417. constructor Create(const ATarget: IBLImage); overload;
  6418. { Creates a new rendering context for rendering to the image ATarget.
  6419. This overload accepts create options that can be used to change the
  6420. implementation of the rendering context. }
  6421. constructor Create(const ATarget: IBLImage;
  6422. const ACreateInfo: TBLContextCreateInfo); overload;
  6423. destructor Destroy; override;
  6424. function Equals(Obj: TObject): Boolean; overload; override;
  6425. end;
  6426. {$ENDREGION 'Context'}
  6427. {$REGION 'Runtime'}
  6428. { ============================================================================
  6429. [Constants]
  6430. ============================================================================ }
  6431. { Blend2D runtime limits.
  6432. Note: These constanst are used across Blend2D, but they are not designed to
  6433. be ABI stable. New versions of Blend2D can increase certain limits without
  6434. notice. Use runtime to query the limits dynamically, see
  6435. TBLRuntimeBuildInfo. }
  6436. const
  6437. { Maximum width and height of an image. }
  6438. BL_MAX_IMAGE_SIZE = BL_RUNTIME_MAX_IMAGE_SIZE;
  6439. { Maximum number of threads for asynchronous operations (including rendering). }
  6440. BL_MAX_THREAD_COUNT = BL_RUNTIME_MAX_THREAD_COUNT;
  6441. { ============================================================================
  6442. [Enums]
  6443. ============================================================================ }
  6444. type
  6445. { Blend2D runtime build type. }
  6446. TBLRuntimeBuildType = (
  6447. { Describes a Blend2D debug build. }
  6448. Debug = BL_RUNTIME_BUILD_TYPE_DEBUG,
  6449. { Describes a Blend2D release build. }
  6450. Release = BL_RUNTIME_BUILD_TYPE_RELEASE);
  6451. type
  6452. { CPU architectures }
  6453. TBLRuntimeCpuArch = (
  6454. { Unknown architecture. }
  6455. Unknown = BL_RUNTIME_CPU_ARCH_UNKNOWN,
  6456. { 32-bit or 64-bit X86 architecture. }
  6457. X86 = BL_RUNTIME_CPU_ARCH_X86,
  6458. { 32-bit or 64-bit ARM architecture. }
  6459. ARM = BL_RUNTIME_CPU_ARCH_ARM,
  6460. { 32-bit or 64-bit MIPS architecture. }
  6461. MIPS = BL_RUNTIME_CPU_ARCH_MIPS);
  6462. type
  6463. {! CPU features Blend2D supports. }
  6464. TBLRuntimeCpuFeature = (
  6465. SSE2 = 0,
  6466. SSE3 = 1,
  6467. SSSE3 = 2,
  6468. SSE4_1 = 3,
  6469. SSE4_2 = 4,
  6470. AVX = 5,
  6471. AVX2 = 6);
  6472. TBLRuntimeCpuFeatures = set of TBLRuntimeCpuFeature;
  6473. type
  6474. { Runtime cleanup flags that can be used through BLRuntime.Cleanup }
  6475. TBLRuntimeCleanupFlag = (
  6476. { Cleanup object memory pool. }
  6477. ObjectPool = 0,
  6478. { Cleanup zeroed memory pool. }
  6479. ZeroedPool = 1,
  6480. { Cleanup thread pool (would join unused threads). }
  6481. ThreadPool = 4);
  6482. TBLRuntimeCleanupFlags = set of TBLRuntimeCleanupFlag;
  6483. type
  6484. _TBLRuntimeCleanupFlagsHelper = record helper for TBLRuntimeCleanupFlags
  6485. public const
  6486. Everything = [TBLRuntimeCleanupFlag.ObjectPool,
  6487. TBLRuntimeCleanupFlag.ZeroedPool,
  6488. TBLRuntimeCleanupFlag.ThreadPool];
  6489. end;
  6490. { ============================================================================
  6491. [BLRuntime - BuildInfo]
  6492. ============================================================================ }
  6493. type
  6494. { Blend2D build information. }
  6495. TBLRuntimeBuildInfo = record
  6496. {$REGION 'Internal Declarations'}
  6497. private
  6498. FHandle: BLRuntimeBuildInfo;
  6499. function GetBuildType: TBLRuntimeBuildType; inline;
  6500. function GetBaselineCpuFeatures: TBLRuntimeCpuFeatures; inline;
  6501. function GetSupportedCpuFeatures: TBLRuntimeCpuFeatures; inline;
  6502. {$ENDREGION 'Internal Declarations'}
  6503. public
  6504. { Blend2D version stored as (Major shl 16) or (Minor shl 8) or Patch }
  6505. property Version: Cardinal read FHandle.version.version;
  6506. { Decomposed Blend2D version }
  6507. property PatchVersion: Byte read FHandle.version.patchVersion;
  6508. property MinorVersion: Byte read FHandle.version.minorVersion;
  6509. property MajorVersion: Word read FHandle.version.majorVersion;
  6510. { Blend2D build type }
  6511. property BuildType: TBLRuntimeBuildType read GetBuildType;
  6512. { Baseline CPU features.
  6513. These features describe CPU features that were detected at compile-time.
  6514. Baseline features are used to compile all source files so they represent
  6515. the minimum feature-set the target CPU must support to run Blend2D.
  6516. Official Blend2D builds set baseline at SSE2 on X86 target and NEON on
  6517. ARM target. Custom builds can set use different baseline. }
  6518. property BaselineCpuFeatures: TBLRuntimeCpuFeatures read GetBaselineCpuFeatures;
  6519. { Supported CPU features.
  6520. These features do not represent the features that the host CPU must
  6521. support, instead, they represent all features that Blend2D can take
  6522. advantage of in C++ code that uses instruction intrinsics. For example if
  6523. AVX2 is part of SupportedCpuFeatures it means that Blend2D can take
  6524. advantage of it if there is a separate code-path. }
  6525. property SupportedCpuFeatures: TBLRuntimeCpuFeatures read GetSupportedCpuFeatures;
  6526. { Maximum size of an image (both width and height). }
  6527. property MaxImageSize: Integer read FHandle.maxImageSize;
  6528. { Maximum number of threads for asynchronous operations, including
  6529. rendering. }
  6530. property MaxThreadCount: Integer read FHandle.maxThreadCount;
  6531. end;
  6532. PBLRuntimeBuildInfo = ^TBLRuntimeBuildInfo;
  6533. { ============================================================================
  6534. [BLRuntime - SystemInfo]
  6535. ============================================================================ }
  6536. type
  6537. { System information queried by the runtime. }
  6538. TBLRuntimeSystemInfo = record
  6539. {$REGION 'Internal Declarations'}
  6540. private
  6541. FHandle: BLRuntimeSystemInfo;
  6542. function GetCpuArch: TBLRuntimeCpuArch; inline;
  6543. function GetCpuFeatures: TBLRuntimeCpuFeatures; inline;
  6544. {$ENDREGION 'Internal Declarations'}
  6545. public
  6546. { Host CPU architecture }
  6547. property CpuArch: TBLRuntimeCpuArch read GetCpuArch;
  6548. { Host CPU features }
  6549. property CpuFeatures: TBLRuntimeCpuFeatures read GetCpuFeatures;
  6550. { Number of cores of the host CPU/CPUs. }
  6551. property CoreCount: Integer read FHandle.coreCount;
  6552. { Number of threads of the host CPU/CPUs. }
  6553. property ThreadCount: Integer read FHandle.threadCount;
  6554. { Minimum stack size of a worker thread used by Blend2D. }
  6555. property ThreadStackSize: Integer read FHandle.threadStackSize;
  6556. { Allocation granularity of virtual memory (includes thread's stack). }
  6557. property AllocationGranularity: Integer read FHandle.allocationGranularity;
  6558. end;
  6559. PBLRuntimeSystemInfo = ^TBLRuntimeSystemInfo;
  6560. { ============================================================================
  6561. [BLRuntime - MemoryInfo]
  6562. ============================================================================ }
  6563. type
  6564. { Provides information about resources allocated by Blend2D. }
  6565. TBLRuntimeResourceInfo = record
  6566. {$REGION 'Internal Declarations'}
  6567. private
  6568. FHandle: BLRuntimeResourceInfo;
  6569. {$ENDREGION 'Internal Declarations'}
  6570. public
  6571. { Virtual memory used at this time. }
  6572. property VMUsed: NativeInt read FHandle.vmUsed;
  6573. { Virtual memory reserved (allocated internally). }
  6574. property VMReserved: NativeInt read FHandle.vmReserved;
  6575. { Overhead required to manage virtual memory allocations. }
  6576. property VMOverhead: NativeInt read FHandle.vmOverhead;
  6577. { Number of blocks of virtual memory allocated. }
  6578. property VMBlockCount: NativeInt read FHandle.vmBlockCount;
  6579. { Zeroed memory used at this time. }
  6580. property ZMUsed: NativeInt read FHandle.zmUsed;
  6581. { Zeroed memory reserved (allocated internally). }
  6582. property ZMReserved: NativeInt read FHandle.zmReserved;
  6583. { Overhead required to manage zeroed memory allocations. }
  6584. property ZMOverhead: NativeInt read FHandle.zmOverhead;
  6585. { Number of blocks of zeroed memory allocated. }
  6586. property ZMBlockCount: NativeInt read FHandle.zmBlockCount;
  6587. { Count of dynamic pipelines created and cached. }
  6588. property DynamicPipelineCount: NativeInt read FHandle.dynamicPipelineCount;
  6589. { Number of active file handles used by Blend2D.
  6590. Note: File handles are counted by IBLFile - when a file is opened a global
  6591. counter is incremented and when it's closed it's decremented.
  6592. This means that this number represents the actual use of IBLFile and
  6593. doesn't consider the origin of the use (it's either Blend2D or user). }
  6594. property FileHandleCount: NativeInt read FHandle.fileHandleCount;
  6595. { Number of active file mappings used by Blend2D.
  6596. Note: Blend2D maps file content to TBytes container, so this number
  6597. represents the actual number of TBytes instances that contain a mapped
  6598. file. }
  6599. property FileMappingCount: NativeInt read FHandle.fileMappingCount;
  6600. end;
  6601. PBLRuntimeMemoryInfo = ^TBLRuntimeResourceInfo;
  6602. { ============================================================================
  6603. [BLRuntime]
  6604. ============================================================================ }
  6605. type
  6606. TBLRuntime = class // static
  6607. public
  6608. class procedure Cleanup(const AFlags: TBLRuntimeCleanupFlags); static;
  6609. class procedure QueryBuildInfo(out AInfo: TBLRuntimeBuildInfo); static;
  6610. class procedure QuerySystemInfo(out AInfo: TBLRuntimeSystemInfo); static;
  6611. class procedure QueryResourceInfo(out AInfo: TBLRuntimeResourceInfo); static;
  6612. class procedure LogMessage(const AMessage: String); overload; static;
  6613. class procedure LogMessage(const AMessage: String; const AArgs: array of const); overload; static;
  6614. end;
  6615. {$ENDREGION 'Runtime'}
  6616. {$REGION 'Internal'}
  6617. procedure _BLCheck(const AResult: BLResultCode);
  6618. {$ENDREGION 'Internal'}
  6619. implementation
  6620. uses
  6621. System.TypInfo;
  6622. {$POINTERMATH ON}
  6623. {$REGION 'Utils'}
  6624. type
  6625. IBLArray = interface
  6626. ['{F0CABAA5-F756-483D-95F1-4EBC134793D9}']
  6627. function Handle: PBLArrayCore;
  6628. procedure RevokeOwnership;
  6629. end;
  6630. type
  6631. TBLArray = class(TInterfacedObject, IBLArray)
  6632. private
  6633. FHandle: BLArrayCore;
  6634. FIsReference: Boolean;
  6635. protected
  6636. { IBLArray }
  6637. function Handle: PBLArrayCore;
  6638. procedure RevokeOwnership;
  6639. public
  6640. constructor Create(const AType: BLImplType);
  6641. destructor Destroy; override;
  6642. end;
  6643. type
  6644. TBLUtils = class // static
  6645. public
  6646. class function ArrayElementType<T>: BLImplType; static;
  6647. class function CreateBLArray<T: record>: IBLArray; static;
  6648. class function BLArrayToArray<T: record>(const AArray: BLArrayCore): TArray<T>; overload; static;
  6649. class function BLArrayToArray<T: record>(const AArray: IBLArray): TArray<T>; overload; static;
  6650. class function ArrayToBLArray<T: record>(const AArray: TArray<T>): IBLArray; static;
  6651. end;
  6652. { TBLArray }
  6653. constructor TBLArray.Create(const AType: BLImplType);
  6654. begin
  6655. inherited Create;
  6656. blArrayInit(@FHandle, AType);
  6657. end;
  6658. destructor TBLArray.Destroy;
  6659. begin
  6660. if (not FIsReference) then
  6661. blArrayDestroy(@FHandle);
  6662. inherited;
  6663. end;
  6664. function TBLArray.Handle: PBLArrayCore;
  6665. begin
  6666. Result := @FHandle;
  6667. end;
  6668. procedure TBLArray.RevokeOwnership;
  6669. begin
  6670. FIsReference := True;
  6671. end;
  6672. { TBLUtils }
  6673. class function TBLUtils.ArrayElementType<T>: BLImplType;
  6674. var
  6675. Info: PTypeInfo;
  6676. Data: PTypeData;
  6677. begin
  6678. Info := TypeInfo(T);
  6679. case GetTypeKind(T) of
  6680. tkInteger,
  6681. tkEnumeration:
  6682. case GetTypeData(Info)^.OrdType of
  6683. otSByte: Exit(BL_IMPL_TYPE_ARRAY_I8);
  6684. otUByte: Exit(BL_IMPL_TYPE_ARRAY_U8);
  6685. otSWord: Exit(BL_IMPL_TYPE_ARRAY_I16);
  6686. otUWord: Exit(BL_IMPL_TYPE_ARRAY_U16);
  6687. otSLong: Exit(BL_IMPL_TYPE_ARRAY_I32);
  6688. otULong: Exit(BL_IMPL_TYPE_ARRAY_U32);
  6689. end;
  6690. tkInt64:
  6691. begin
  6692. Data := GetTypeData(Info);
  6693. if (Data^.MaxInt64Value > Data^.MinInt64Value) then
  6694. Exit(BL_IMPL_TYPE_ARRAY_I64)
  6695. else
  6696. Exit(BL_IMPL_TYPE_ARRAY_U64);
  6697. end;
  6698. tkFloat:
  6699. begin
  6700. Data := GetTypeData(Info);
  6701. case Data^.FloatType of
  6702. ftSingle : Exit(BL_IMPL_TYPE_ARRAY_F32);
  6703. ftDouble : Exit(BL_IMPL_TYPE_ARRAY_F64);
  6704. end;
  6705. end;
  6706. tkRecord:
  6707. case SizeOf(T) of
  6708. 1: Exit(BL_IMPL_TYPE_ARRAY_STRUCT_1);
  6709. 2: Exit(BL_IMPL_TYPE_ARRAY_STRUCT_2);
  6710. 3: Exit(BL_IMPL_TYPE_ARRAY_STRUCT_3);
  6711. 4: Exit(BL_IMPL_TYPE_ARRAY_STRUCT_4);
  6712. 6: Exit(BL_IMPL_TYPE_ARRAY_STRUCT_6);
  6713. 8: Exit(BL_IMPL_TYPE_ARRAY_STRUCT_8);
  6714. 10: Exit(BL_IMPL_TYPE_ARRAY_STRUCT_10);
  6715. 12: Exit(BL_IMPL_TYPE_ARRAY_STRUCT_12);
  6716. 16: Exit(BL_IMPL_TYPE_ARRAY_STRUCT_16);
  6717. 20: Exit(BL_IMPL_TYPE_ARRAY_STRUCT_20);
  6718. 24: Exit(BL_IMPL_TYPE_ARRAY_STRUCT_24);
  6719. 32: Exit(BL_IMPL_TYPE_ARRAY_STRUCT_32);
  6720. end;
  6721. end;
  6722. Assert(False, 'Unsupported array element type');
  6723. Result := BL_IMPL_TYPE_NULL;
  6724. end;
  6725. class function TBLUtils.ArrayToBLArray<T>(const AArray: TArray<T>): IBLArray;
  6726. var
  6727. A: PBLArrayCore;
  6728. Count: Integer;
  6729. begin
  6730. Result := TBLArray.Create(ArrayElementType<T>);
  6731. Count := Length(AArray);
  6732. if (Count <> 0) then
  6733. begin
  6734. A := Result.Handle;
  6735. _BLCheck(blArrayReserve(A, Count));
  6736. _BLCheck(blArrayAppendView(A, @AArray[0], Count));
  6737. end;
  6738. end;
  6739. class function TBLUtils.BLArrayToArray<T>(const AArray: BLArrayCore): TArray<T>;
  6740. var
  6741. Impl: PBLArrayImpl;
  6742. Count: Integer;
  6743. begin
  6744. Impl := AArray.impl;
  6745. Assert(Assigned(Impl) and (Impl.itemSize = SizeOf(T)));
  6746. Count := Impl.size;
  6747. if (Count = 0) then
  6748. Exit(nil);
  6749. SetLength(Result, Count);
  6750. Move(Impl.data^, Result[0], Count * SizeOf(T));
  6751. end;
  6752. class function TBLUtils.BLArrayToArray<T>(const AArray: IBLArray): TArray<T>;
  6753. var
  6754. Impl: PBLArrayImpl;
  6755. Count: Integer;
  6756. begin
  6757. Impl := AArray.Handle.impl;
  6758. Assert(Assigned(Impl) and (Impl.itemSize = SizeOf(T)));
  6759. Count := Impl.size;
  6760. if (Count = 0) then
  6761. Exit(nil);
  6762. SetLength(Result, Count);
  6763. Move(Impl.data^, Result[0], Count * SizeOf(T));
  6764. end;
  6765. class function TBLUtils.CreateBLArray<T>: IBLArray;
  6766. begin
  6767. Result := TBLArray.Create(ArrayElementType<T>);
  6768. end;
  6769. {$ENDREGION 'Utils'}
  6770. {$REGION 'Error Handling'}
  6771. var
  6772. GErrorHandler: TBLErrorHandler = nil;
  6773. GErrorUserData: Pointer = nil;
  6774. GLastError: TBLResultCode = TBLResultCode.Success;
  6775. procedure BLSetErrorHandler(const AHandler: TBLErrorHandler;
  6776. const AUserData: Pointer);
  6777. begin
  6778. GErrorHandler := AHandler;
  6779. GErrorUserData := AUserData;
  6780. end;
  6781. procedure ExceptionErrorHandler(const AResultCode: TBLResultCode;
  6782. const AUserData: Pointer);
  6783. begin
  6784. raise EBlend2DError.Create(AResultCode);
  6785. end;
  6786. procedure BLSetExceptionErrorHandler;
  6787. begin
  6788. GErrorHandler := ExceptionErrorHandler;
  6789. GErrorUserData := nil;
  6790. end;
  6791. procedure GetLastErrorHandler(const AResultCode: TBLResultCode;
  6792. const AUserData: Pointer);
  6793. begin
  6794. GLastError := AResultCode;
  6795. end;
  6796. function BLGetLastError: TBLResultCode;
  6797. begin
  6798. Result := GLastError;
  6799. GLastError := TBLResultCode.Success;
  6800. end;
  6801. procedure BLSetGetLastErrorHandler;
  6802. begin
  6803. GErrorHandler := GetLastErrorHandler;
  6804. GErrorUserData := nil;
  6805. end;
  6806. { _TBLResultCodeHelper }
  6807. function _TBLResultCodeHelper.ToString: String;
  6808. const
  6809. ERROR_STRINGS: array [BL_ERROR_START_INDEX..Ord(High(TBLResultCode))] of String = (
  6810. 'Out of memory',
  6811. 'Invalid value/argument',
  6812. 'Invalid state',
  6813. 'Invalid handle or file.',
  6814. 'Value too large',
  6815. 'Not initialized (some instance is built-in none when it shouldn''t be).',
  6816. 'Not implemented',
  6817. 'Operation not permitted',
  6818. 'IO error',
  6819. 'Device or resource busy',
  6820. 'Operation interrupted',
  6821. 'Try again',
  6822. 'Timed out',
  6823. 'Broken pipe',
  6824. 'File is not seekable',
  6825. 'Too many levels of symlinks',
  6826. 'File is too large',
  6827. 'File/directory already exists',
  6828. 'Access denied',
  6829. 'Media changed',
  6830. 'The file/FS is read-only',
  6831. 'Device doesn''t exist',
  6832. 'Not found, no entry (fs)',
  6833. 'No media in drive/device',
  6834. 'No more data / end of file',
  6835. 'No more files',
  6836. 'No space left on device',
  6837. 'Directory is not empty',
  6838. 'Not a file',
  6839. 'Not a directory',
  6840. 'Not same device',
  6841. 'Not a block device',
  6842. 'File/path name is invalid',
  6843. 'File/path name is too long',
  6844. 'Too many open files',
  6845. 'Too many open files by OS',
  6846. 'Too many symbolic links on FS',
  6847. 'Too many threads',
  6848. 'Thread pool is exhausted and couldn''t acquire the requested thread count',
  6849. 'File is empty (not specific to any OS error).',
  6850. 'File open failed',
  6851. 'Not a root device/directory',
  6852. 'Unknown system error that failed to translate to Blend2D result code.',
  6853. 'Invalid data alignment.',
  6854. 'Invalid data signature or header.',
  6855. 'Invalid or corrupted data.',
  6856. 'Invalid string (invalid data of either UTF8, UTF16, or UTF32).',
  6857. 'Truncated data (more data required than memory/stream provides).',
  6858. 'Input data too large to be processed.',
  6859. 'Decompression failed due to invalid data (RLE, Huffman, etc).',
  6860. 'Invalid geometry (invalid path data or shape).',
  6861. 'Returned when there is no matching vertex in path data.',
  6862. 'No matching cookie (BLContext).',
  6863. 'No states to restore (BLContext).',
  6864. 'The size of the image is too large.',
  6865. 'Image codec for a required format doesn''t exist.',
  6866. 'Unknown or invalid file format that cannot be read.',
  6867. 'Image codec doesn''t support reading the file format.',
  6868. 'Image codec doesn''t support writing the file format.',
  6869. 'Multiple IHDR chunks are not allowed (PNG).',
  6870. 'Invalid IDAT chunk (PNG).',
  6871. 'Invalid IEND chunk (PNG).',
  6872. 'Invalid PLTE chunk (PNG).',
  6873. 'Invalid tRNS chunk (PNG).',
  6874. 'Invalid filter type (PNG).',
  6875. 'Unsupported feature (JPEG).',
  6876. 'Invalid SOS marker or header (JPEG).',
  6877. 'Invalid SOF marker (JPEG).',
  6878. 'Multiple SOF markers (JPEG).',
  6879. 'Unsupported SOF marker (JPEG).',
  6880. 'Font doesn''t have any data as it''s not initialized.',
  6881. 'Font or font-face was not matched (TBLFontManager).',
  6882. 'Font has no character to glyph mapping data.',
  6883. 'Font has missing an important table.',
  6884. 'Font feature is not available.',
  6885. 'Font has an invalid CFF data.',
  6886. 'Font program terminated because the execution reached the limit.',
  6887. 'Invalid glyph identifier.');
  6888. begin
  6889. if (Self = TBLResultCode.Success) then
  6890. Result := 'Success'
  6891. else if (Ord(Self) >= Low(ERROR_STRINGS)) and (Ord(Self) <= High(ERROR_STRINGS)) then
  6892. Result := ERROR_STRINGS[Ord(Self)]
  6893. else
  6894. Result := Format('Unknown error (%d)', [Ord(Self)]);
  6895. end;
  6896. { EBlend2DError }
  6897. constructor EBlend2DError.Create(const AResultCode: TBLResultCode);
  6898. begin
  6899. inherited Create(AResultCode.ToString);
  6900. FResultCode := AResultCode;
  6901. end;
  6902. {$ENDREGION 'Error Handling'}
  6903. {$REGION 'General'}
  6904. { TBLRange }
  6905. function BLRange(const AStart, AFinish: Integer): TBLRange; inline;
  6906. begin
  6907. Result.Reset(AStart, AFinish);
  6908. end;
  6909. class operator TBLRange.Equal(const ALeft, ARight: TBLRange): Boolean;
  6910. begin
  6911. Result := ALeft.Equals(ARight);
  6912. end;
  6913. function TBLRange.Equals(const AOther: TBLRange): Boolean;
  6914. begin
  6915. Result := (FHandle.start = AOther.FHandle.start) and
  6916. (FHandle.&end = AOther.FHandle.&end);
  6917. end;
  6918. function TBLRange.GetFinish: Integer;
  6919. begin
  6920. Result := FHandle.&end;
  6921. end;
  6922. function TBLRange.GetStart: Integer;
  6923. begin
  6924. Result := FHandle.start;
  6925. end;
  6926. class operator TBLRange.NotEqual(const ALeft, ARight: TBLRange): Boolean;
  6927. begin
  6928. Result := not ALeft.Equals(ARight);
  6929. end;
  6930. procedure TBLRange.Reset;
  6931. begin
  6932. FHandle.start := 0;
  6933. FHandle.&end := 0;
  6934. end;
  6935. procedure TBLRange.Reset(const AStart, AFinish: Integer);
  6936. begin
  6937. FHandle.start := AStart;
  6938. FHandle.&end := AFinish;
  6939. end;
  6940. procedure TBLRange.SetFinish(const AValue: Integer);
  6941. begin
  6942. FHandle.&end := AValue;
  6943. end;
  6944. procedure TBLRange.SetStart(const AValue: Integer);
  6945. begin
  6946. FHandle.start := AValue;
  6947. end;
  6948. {$ENDREGION 'General'}
  6949. {$REGION 'Array'}
  6950. { TBLArrayView<T> }
  6951. function TBLArrayView<T>.GetLast: Pointer;
  6952. begin
  6953. Result := FHandle.data;
  6954. Inc(P(Result), FHandle.size);
  6955. end;
  6956. function TBLArrayView<T>.GetLength: Integer;
  6957. begin
  6958. Result := FHandle.size;
  6959. end;
  6960. procedure TBLArrayView<T>.Reset;
  6961. begin
  6962. FHandle.data := nil;
  6963. FHandle.size := 0;
  6964. end;
  6965. procedure TBLArrayView<T>.Reset(const AData: Pointer; const ALength: Integer);
  6966. begin
  6967. FHandle.data := AData;
  6968. FHandle.size := ALength;
  6969. end;
  6970. {$ENDREGION 'Array'}
  6971. {$REGION 'Color'}
  6972. { TBLRgba32 }
  6973. function BLRgba32: TBLRgba32; overload; inline;
  6974. begin
  6975. Result.FHandle.value := 0;
  6976. end;
  6977. function BLRgba32(const AValue: Cardinal): TBLRgba32; inline;
  6978. begin
  6979. Result.FHandle.value := AValue;
  6980. end;
  6981. function BLRgba32(const AR, AG, AB: Byte; const AA: Byte = 255): TBLRgba32; overload; inline;
  6982. begin
  6983. Result.Reset(AR, AG, AB, AA);
  6984. end;
  6985. function BLRgba32(const AValue: TBLRgba64): TBLRgba32; overload; inline;
  6986. begin
  6987. Result.Reset(AValue);
  6988. end;
  6989. function BLRgba32(const AValue: TBLRgba): TBLRgba32; overload; inline;
  6990. begin
  6991. Result.Reset(AValue);
  6992. end;
  6993. class operator TBLRgba32.Implicit(const AValue: Cardinal): TBLRgba32;
  6994. begin
  6995. Result.FHandle.value := AValue;
  6996. end;
  6997. class operator TBLRgba32.Equal(const ALeft, ARight: TBLRgba32): Boolean;
  6998. begin
  6999. Result := (ALeft.FHandle.value = ARight.FHandle.value);
  7000. end;
  7001. function TBLRgba32.GetIsOpaque: Boolean;
  7002. begin
  7003. Result := (FHandle.value >= $FF000000);
  7004. end;
  7005. function TBLRgba32.GetIsTransparent: Boolean;
  7006. begin
  7007. Result := (FHandle.value <= $00FFFFFF);
  7008. end;
  7009. class operator TBLRgba32.Implicit(const AValue: TBLRgba32): Cardinal;
  7010. begin
  7011. Result := AValue.FHandle.value;
  7012. end;
  7013. class operator TBLRgba32.NotEqual(const ALeft, ARight: TBLRgba32): Boolean;
  7014. begin
  7015. Result := (ALeft.FHandle.value <> ARight.FHandle.value);
  7016. end;
  7017. procedure TBLRgba32.Reset;
  7018. begin
  7019. FHandle.value := 0;
  7020. end;
  7021. procedure TBLRgba32.Reset(const AValue: Cardinal);
  7022. begin
  7023. FHandle.value := AValue;
  7024. end;
  7025. procedure TBLRgba32.Reset(const AR, AG, AB, AA: Byte);
  7026. begin
  7027. FHandle.value := (AA shl 24) or (AR shl 16) or (AG shl 8) or AB;
  7028. end;
  7029. { TBLRgba64 }
  7030. function BLRgba64: TBLRgba64; overload; inline;
  7031. begin
  7032. Result.FHandle.value := 0;
  7033. end;
  7034. function BLRgba64(const AValue: UInt64): TBLRgba64; overload; inline;
  7035. begin
  7036. Result.FHandle.value := AValue;
  7037. end;
  7038. function BLRgba64(const AR, AG, AB: Word; const AA: Word = $FFFF): TBLRgba64; overload; inline;
  7039. begin
  7040. Result.Reset(AR, AG, AB, AA);
  7041. end;
  7042. function BLRgba64(const AValue: TBLRgba32): TBLRgba64; overload; inline;
  7043. begin
  7044. Result.Reset(AValue);
  7045. end;
  7046. function BLRgba64(const AValue: TBLRgba): TBLRgba32; overload; inline;
  7047. begin
  7048. Result.Reset(AValue);
  7049. end;
  7050. class operator TBLRgba64.Equal(const ALeft, ARight: TBLRgba64): Boolean;
  7051. begin
  7052. Result := (ALeft.FHandle.value = ARight.FHandle.value);
  7053. end;
  7054. function TBLRgba64.GetIsOpaque: Boolean;
  7055. begin
  7056. Result := (FHandle.value >= $FFFF000000000000);
  7057. end;
  7058. function TBLRgba64.GetIsTransparent: Boolean;
  7059. begin
  7060. Result := (FHandle.value <= $0000FFFFFFFFFFFF);
  7061. end;
  7062. class operator TBLRgba64.Implicit(const AValue: UInt64): TBLRgba64;
  7063. begin
  7064. Result.FHandle.value := AValue;
  7065. end;
  7066. class operator TBLRgba64.Implicit(const AValue: TBLRgba64): UInt64;
  7067. begin
  7068. Result := AValue.FHandle.value;
  7069. end;
  7070. class operator TBLRgba64.NotEqual(const ALeft, ARight: TBLRgba64): Boolean;
  7071. begin
  7072. Result := (ALeft.FHandle.value <> ARight.FHandle.value);
  7073. end;
  7074. procedure TBLRgba64.Reset(const AValue: TBLRgba32);
  7075. begin
  7076. FHandle.r := AValue.FHandle.r or (AValue.FHandle.r shl 8);
  7077. FHandle.g := AValue.FHandle.g or (AValue.FHandle.g shl 8);
  7078. FHandle.b := AValue.FHandle.b or (AValue.FHandle.b shl 8);
  7079. FHandle.a := AValue.FHandle.a or (AValue.FHandle.a shl 8);
  7080. end;
  7081. procedure TBLRgba64.Reset(const AR, AG, AB, AA: Word);
  7082. begin
  7083. FHandle.value := (UInt64(AA) shl 48) or (UInt64(AR) shl 32)
  7084. or (UInt64(AG) shl 16) or UInt64(AB);
  7085. end;
  7086. procedure TBLRgba64.Reset(const AValue: UInt64);
  7087. begin
  7088. FHandle.value := AValue;
  7089. end;
  7090. procedure TBLRgba64.Reset;
  7091. begin
  7092. FHandle.value := 0;
  7093. end;
  7094. { TBLRgba }
  7095. function BLRgba: TBLRgba; overload; inline;
  7096. begin
  7097. Result.Reset;
  7098. end;
  7099. function BLRgba(const AR, AG, AB: Single; const AA: Single = 1): TBLRgba; overload; inline;
  7100. begin
  7101. Result.Reset(AR, AG, AB, AA);
  7102. end;
  7103. function BLRgba(const ARgba: TBLRgba32): TBLRgba; overload; inline;
  7104. begin
  7105. Result.Reset(ARgba);
  7106. end;
  7107. function BLRgba(const ARgba: TBLRgba64): TBLRgba; overload; inline;
  7108. begin
  7109. Result.Reset(ARgba);
  7110. end;
  7111. class operator TBLRgba.Equal(const ALeft, ARight: TBLRgba): Boolean;
  7112. begin
  7113. Result := (ALeft.FHandle.r = ARight.FHandle.r)
  7114. and (ALeft.FHandle.g = ARight.FHandle.g)
  7115. and (ALeft.FHandle.b = ARight.FHandle.b)
  7116. and (ALeft.FHandle.a = ARight.FHandle.a);
  7117. end;
  7118. class operator TBLRgba.Equal(const ALeft: TBLRgba;
  7119. const ARight: TBLRgba32): Boolean;
  7120. begin
  7121. Result := (ALeft = BLRgba(ARight));
  7122. end;
  7123. class operator TBLRgba.Equal(const ALeft: TBLRgba;
  7124. const ARight: TBLRgba64): Boolean;
  7125. begin
  7126. Result := (ALeft = BLRgba(ARight));
  7127. end;
  7128. function TBLRgba.GetIsOpaque: Boolean;
  7129. begin
  7130. Result := (FHandle.a >= 1);
  7131. end;
  7132. function TBLRgba.GetIsTransparent: Boolean;
  7133. begin
  7134. Result := (FHandle.a = 0);
  7135. end;
  7136. class operator TBLRgba.NotEqual(const ALeft: TBLRgba;
  7137. const ARight: TBLRgba32): Boolean;
  7138. begin
  7139. Result := (ALeft <> BLRgba(ARight));
  7140. end;
  7141. class operator TBLRgba.NotEqual(const ALeft: TBLRgba;
  7142. const ARight: TBLRgba64): Boolean;
  7143. begin
  7144. Result := (ALeft <> BLRgba(ARight));
  7145. end;
  7146. class operator TBLRgba.NotEqual(const ALeft, ARight: TBLRgba): Boolean;
  7147. begin
  7148. Result := not (ALeft = ARight);
  7149. end;
  7150. procedure TBLRgba.Reset(const ARgba: TBLRgba64);
  7151. const
  7152. FACTOR = 1.0 / 65535.0;
  7153. begin
  7154. FHandle.r := ARgba.R * FACTOR;
  7155. FHandle.g := ARgba.G * FACTOR;
  7156. FHandle.b := ARgba.B * FACTOR;
  7157. FHandle.a := ARgba.A * FACTOR;
  7158. end;
  7159. procedure TBLRgba.Reset(const ARgba: TBLRgba32);
  7160. const
  7161. FACTOR = 1.0 / 255.0;
  7162. begin
  7163. FHandle.r := ARgba.R * FACTOR;
  7164. FHandle.g := ARgba.G * FACTOR;
  7165. FHandle.b := ARgba.B * FACTOR;
  7166. FHandle.a := ARgba.A * FACTOR;
  7167. end;
  7168. procedure TBLRgba.Reset;
  7169. begin
  7170. FHandle.r := 0;
  7171. FHandle.g := 0;
  7172. FHandle.b := 0;
  7173. FHandle.a := 0;
  7174. end;
  7175. procedure TBLRgba.Reset(const AR, AG, AB, AA: Single);
  7176. begin
  7177. FHandle.r := AR;
  7178. FHandle.g := AG;
  7179. FHandle.b := AB;
  7180. FHandle.a := AA;
  7181. end;
  7182. { _TBLRgba32Helper }
  7183. procedure _TBLRgba32Helper.Reset(const AValue: TBLRgba64);
  7184. var
  7185. Hi, Lo: UInt32;
  7186. begin
  7187. Hi := AValue.FHandle.value shr 32;
  7188. Lo := AValue.FHandle.value;
  7189. FHandle.value := (Hi and $FF000000) or
  7190. ((Lo and $FF000000) shr 16) or
  7191. ((Hi and $0000FF00) shl 8) or
  7192. ((Lo and $0000FF00) shr 8);
  7193. end;
  7194. procedure _TBLRgba32Helper.Reset(const AValue: TBLRgba);
  7195. begin
  7196. FHandle.a := EnsureRange(Trunc(AValue.A * 255.0), 0, 255);
  7197. FHandle.r := EnsureRange(Trunc(AValue.R * 255.0), 0, 255);
  7198. FHandle.g := EnsureRange(Trunc(AValue.G * 255.0), 0, 255);
  7199. FHandle.b := EnsureRange(Trunc(AValue.B * 255.0), 0, 255);
  7200. end;
  7201. { _TBLRgba64Helper }
  7202. procedure _TBLRgba64Helper.Reset(const AValue: TBLRgba);
  7203. begin
  7204. FHandle.a := EnsureRange(Trunc(AValue.A * 65535.0), 0, 65535);
  7205. FHandle.r := EnsureRange(Trunc(AValue.R * 65535.0), 0, 65535);
  7206. FHandle.g := EnsureRange(Trunc(AValue.G * 65535.0), 0, 65535);
  7207. FHandle.b := EnsureRange(Trunc(AValue.B * 65535.0), 0, 65535);
  7208. end;
  7209. {$ENDREGION 'Color'}
  7210. {$REGION 'Geometry'}
  7211. function BLPointI: TBLPointI; overload; inline;
  7212. begin
  7213. Result.Reset;
  7214. end;
  7215. function BLPointI(const AX, AY: Integer): TBLPointI; overload; inline;
  7216. begin
  7217. Result.Reset(AX, AY);
  7218. end;
  7219. { TBLPointI }
  7220. class operator TBLPointI.Add(const ALeft, ARight: TBLPointI): TBLPointI;
  7221. begin
  7222. Result.Reset(ALeft.FHandle.x + ARight.FHandle.x, ALeft.FHandle.y + ARight.FHandle.y);
  7223. end;
  7224. class operator TBLPointI.Add(const ALeft: Integer;
  7225. const ARight: TBLPointI): TBLPointI;
  7226. begin
  7227. Result.Reset(ALeft + ARight.FHandle.x, ALeft + ARight.FHandle.y);
  7228. end;
  7229. class operator TBLPointI.Add(const ALeft: TBLPointI;
  7230. const ARight: Integer): TBLPointI;
  7231. begin
  7232. Result.Reset(ALeft.FHandle.x + ARight, ALeft.FHandle.y + ARight);
  7233. end;
  7234. class operator TBLPointI.Equal(const ALeft, ARight: TBLPointI): Boolean;
  7235. begin
  7236. Result := ALeft.Equals(ARight);
  7237. end;
  7238. function TBLPointI.Equals(const AOther: TBLPointI): Boolean;
  7239. begin
  7240. Result := (FHandle.x = AOther.FHandle.x)
  7241. and (FHandle.y = AOther.FHandle.y);
  7242. end;
  7243. class operator TBLPointI.IntDivide(const ALeft: TBLPointI;
  7244. const ARight: Integer): TBLPointI;
  7245. begin
  7246. Result.Reset(ALeft.FHandle.x div ARight, ALeft.FHandle.y div ARight);
  7247. end;
  7248. class operator TBLPointI.IntDivide(const ALeft: Integer;
  7249. const ARight: TBLPointI): TBLPointI;
  7250. begin
  7251. Result.Reset(ALeft div ARight.FHandle.x, ALeft div ARight.FHandle.y);
  7252. end;
  7253. class operator TBLPointI.IntDivide(const ALeft, ARight: TBLPointI): TBLPointI;
  7254. begin
  7255. Result.Reset(ALeft.FHandle.x div ARight.FHandle.x, ALeft.FHandle.y div ARight.FHandle.y);
  7256. end;
  7257. class operator TBLPointI.Multiply(const ALeft, ARight: TBLPointI): TBLPointI;
  7258. begin
  7259. Result.Reset(ALeft.FHandle.x * ARight.FHandle.x, ALeft.FHandle.y * ARight.FHandle.y);
  7260. end;
  7261. class operator TBLPointI.Multiply(const ALeft: Integer;
  7262. const ARight: TBLPointI): TBLPointI;
  7263. begin
  7264. Result.Reset(ALeft * ARight.FHandle.x, ALeft * ARight.FHandle.y);
  7265. end;
  7266. class operator TBLPointI.Multiply(const ALeft: TBLPointI;
  7267. const ARight: Integer): TBLPointI;
  7268. begin
  7269. Result.Reset(ALeft.FHandle.x * ARight, ALeft.FHandle.y * ARight);
  7270. end;
  7271. class operator TBLPointI.Negative(const AValue: TBLPointI): TBLPointI;
  7272. begin
  7273. Result.Reset(-AValue.FHandle.x, -AValue.FHandle.y);
  7274. end;
  7275. class operator TBLPointI.NotEqual(const ALeft, ARight: TBLPointI): Boolean;
  7276. begin
  7277. Result := not ALeft.Equals(ARight);
  7278. end;
  7279. procedure TBLPointI.Reset(const AX, AY: Integer);
  7280. begin
  7281. FHandle.x := AX;
  7282. FHandle.y := AY;
  7283. end;
  7284. class operator TBLPointI.Subtract(const ALeft: TBLPointI;
  7285. const ARight: Integer): TBLPointI;
  7286. begin
  7287. Result.Reset(ALeft.FHandle.x - ARight, ALeft.FHandle.y - ARight);
  7288. end;
  7289. class operator TBLPointI.Subtract(const ALeft: Integer;
  7290. const ARight: TBLPointI): TBLPointI;
  7291. begin
  7292. Result.Reset(ALeft - ARight.FHandle.x, ALeft - ARight.FHandle.y);
  7293. end;
  7294. class operator TBLPointI.Subtract(const ALeft, ARight: TBLPointI): TBLPointI;
  7295. begin
  7296. Result.Reset(ALeft.FHandle.x - ARight.FHandle.x, ALeft.FHandle.y - ARight.FHandle.y);
  7297. end;
  7298. procedure TBLPointI.Reset;
  7299. begin
  7300. FHandle.x := 0;
  7301. FHandle.y := 0;
  7302. end;
  7303. { TBLSizeI }
  7304. function BLSizeI: TBLSizeI; overload; inline;
  7305. begin
  7306. Result.Reset;
  7307. end;
  7308. function BLSizeI(const AW, AH: Integer): TBLSizeI; overload; inline;
  7309. begin
  7310. Result.Reset(AW, AH);
  7311. end;
  7312. class operator TBLSizeI.Equal(const ALeft, ARight: TBLSizeI): Boolean;
  7313. begin
  7314. Result := ALeft.Equals(ARight);
  7315. end;
  7316. function TBLSizeI.Equals(const AOther: TBLSizeI): Boolean;
  7317. begin
  7318. Result := (FHandle.w = AOther.FHandle.w)
  7319. and (FHandle.h = AOther.FHandle.h);
  7320. end;
  7321. class operator TBLSizeI.NotEqual(const ALeft, ARight: TBLSizeI): Boolean;
  7322. begin
  7323. Result := not ALeft.Equals(ARight);
  7324. end;
  7325. procedure TBLSizeI.Reset(const AW, AH: Integer);
  7326. begin
  7327. FHandle.w := AW;
  7328. FHandle.h := AH;
  7329. end;
  7330. procedure TBLSizeI.Reset;
  7331. begin
  7332. FHandle.w := 0;
  7333. FHandle.h := 0;
  7334. end;
  7335. { TBLBoxI }
  7336. function BLBoxI: TBLBoxI; overload; inline;
  7337. begin
  7338. Result.Reset;
  7339. end;
  7340. function BLBoxI(const AX0, AY0, AX1, AY1: Integer): TBLBoxI; overload; inline;
  7341. begin
  7342. Result.Reset(AX0, AY0, AX1, AY1);
  7343. end;
  7344. function TBLBoxI.Contains(const AX, AY: Integer): Boolean;
  7345. begin
  7346. Result := (AX >= FHandle.x0) and (AY >= FHandle.y0)
  7347. and (AX < FHandle.x1) and (AY < FHandle.y1);
  7348. end;
  7349. function TBLBoxI.Contains(const AP: TBLPointI): Boolean;
  7350. begin
  7351. Result := (AP.FHandle.x >= FHandle.x0) and (AP.FHandle.y >= FHandle.y0)
  7352. and (AP.FHandle.x < FHandle.x1) and (AP.FHandle.y < FHandle.y1);
  7353. end;
  7354. class operator TBLBoxI.Equal(const ALeft, ARight: TBLBoxI): Boolean;
  7355. begin
  7356. Result := ALeft.Equals(ARight);
  7357. end;
  7358. function TBLBoxI.Equals(const AOther: TBLBoxI): Boolean;
  7359. begin
  7360. Result := (FHandle.x0 = AOther.FHandle.x0)
  7361. and (FHandle.y0 = AOther.FHandle.y0)
  7362. and (FHandle.x1 = AOther.FHandle.x1)
  7363. and (FHandle.y1 = AOther.FHandle.y0);
  7364. end;
  7365. function TBLBoxI.GetHeight: Integer;
  7366. begin
  7367. Result := FHandle.y1 - FHandle.y0;
  7368. end;
  7369. function TBLBoxI.GetWidth: Integer;
  7370. begin
  7371. Result := FHandle.x1 - FHandle.y0;
  7372. end;
  7373. class operator TBLBoxI.NotEqual(const ALeft, ARight: TBLBoxI): Boolean;
  7374. begin
  7375. Result := not ALeft.Equals(ARight);
  7376. end;
  7377. procedure TBLBoxI.Reset(const AX0, AY0, AX1, AY1: Integer);
  7378. begin
  7379. FHandle.x0 := AX0;
  7380. FHandle.y0 := AY0;
  7381. FHandle.x1 := AX1;
  7382. FHandle.y1 := AY1;
  7383. end;
  7384. procedure TBLBoxI.Reset;
  7385. begin
  7386. FHandle.x0 := 0;
  7387. FHandle.y0 := 0;
  7388. FHandle.x1 := 0;
  7389. FHandle.y1 := 0;
  7390. end;
  7391. procedure TBLBoxI.SetHeight(const AValue: Integer);
  7392. begin
  7393. FHandle.y1 := FHandle.y0 + AValue;
  7394. end;
  7395. procedure TBLBoxI.SetWidth(const AValue: Integer);
  7396. begin
  7397. FHandle.x1 := FHandle.x0 + AValue;
  7398. end;
  7399. { TBLRectI }
  7400. function BLRectI: TBLRectI; inline;
  7401. begin
  7402. Result.Reset;
  7403. end;
  7404. function BLRectI(const AX, AY, AW, AH: Integer): TBLRectI; inline;
  7405. begin
  7406. Result.Reset(AX, AY, AW, AH);
  7407. end;
  7408. class operator TBLRectI.Equal(const ALeft, ARight: TBLRectI): Boolean;
  7409. begin
  7410. Result := ALeft.Equals(ARight);
  7411. end;
  7412. function TBLRectI.Equals(const AOther: TBLRectI): Boolean;
  7413. begin
  7414. Result := (FHandle.x = AOther.FHandle.x)
  7415. and (FHandle.y = AOther.FHandle.y)
  7416. and (FHandle.w = AOther.FHandle.w)
  7417. and (FHandle.h = AOther.FHandle.h);
  7418. end;
  7419. class operator TBLRectI.NotEqual(const ALeft, ARight: TBLRectI): Boolean;
  7420. begin
  7421. Result := not ALeft.Equals(ARight);
  7422. end;
  7423. procedure TBLRectI.Reset(const AX, AY, AW, AH: Integer);
  7424. begin
  7425. FHandle.x := AX;
  7426. FHandle.y := AY;
  7427. FHandle.w := AW;
  7428. FHandle.h := AH;
  7429. end;
  7430. procedure TBLRectI.Reset;
  7431. begin
  7432. FHandle.x := 0;
  7433. FHandle.y := 0;
  7434. FHandle.w := 0;
  7435. FHandle.h := 0;
  7436. end;
  7437. { TBLPoint }
  7438. function BLPoint: TBLPoint; overload; inline;
  7439. begin
  7440. Result.Reset;
  7441. end;
  7442. function BLPoint(const AX, AY: Double): TBLPoint; inline;
  7443. begin
  7444. Result.Reset(AX, AY);
  7445. end;
  7446. class operator TBLPoint.Add(const ALeft, ARight: TBLPoint): TBLPoint;
  7447. begin
  7448. Result.Reset(ALeft.FHandle.x + ARight.FHandle.x, ALeft.FHandle.y + ARight.FHandle.y);
  7449. end;
  7450. class operator TBLPoint.Divide(const ALeft: TBLPoint;
  7451. const ARight: Double): TBLPoint;
  7452. begin
  7453. Result.Reset(ALeft.FHandle.x / ARight, ALeft.FHandle.y / ARight);
  7454. end;
  7455. class operator TBLPoint.Divide(const ALeft: Double;
  7456. const ARight: TBLPoint): TBLPoint;
  7457. begin
  7458. Result.Reset(ALeft / ARight.FHandle.x, ALeft / ARight.FHandle.y);
  7459. end;
  7460. class operator TBLPoint.Divide(const ALeft, ARight: TBLPoint): TBLPoint;
  7461. begin
  7462. Result.Reset(ALeft.FHandle.x / ARight.FHandle.x, ALeft.FHandle.y / ARight.FHandle.y);
  7463. end;
  7464. class operator TBLPoint.Add(const ALeft: Double;
  7465. const ARight: TBLPoint): TBLPoint;
  7466. begin
  7467. Result.Reset(ALeft + ARight.FHandle.x, ALeft + ARight.FHandle.y);
  7468. end;
  7469. class operator TBLPoint.Add(const ALeft: TBLPoint;
  7470. const ARight: Double): TBLPoint;
  7471. begin
  7472. Result.Reset(ALeft.FHandle.x + ARight, ALeft.FHandle.y + ARight);
  7473. end;
  7474. class operator TBLPoint.Equal(const ALeft, ARight: TBLPoint): Boolean;
  7475. begin
  7476. Result := ALeft.Equals(ARight);
  7477. end;
  7478. function TBLPoint.Equals(const AOther: TBLPoint): Boolean;
  7479. begin
  7480. Result := (FHandle.x = AOther.FHandle.x)
  7481. and (FHandle.y = AOther.FHandle.y);
  7482. end;
  7483. class operator TBLPoint.Multiply(const ALeft, ARight: TBLPoint): TBLPoint;
  7484. begin
  7485. Result.Reset(ALeft.FHandle.x * ARight.FHandle.x, ALeft.FHandle.y * ARight.FHandle.y);
  7486. end;
  7487. class operator TBLPoint.Multiply(const ALeft: Double;
  7488. const ARight: TBLPoint): TBLPoint;
  7489. begin
  7490. Result.Reset(ALeft * ARight.FHandle.x, ALeft * ARight.FHandle.y);
  7491. end;
  7492. class operator TBLPoint.Multiply(const ALeft: TBLPoint;
  7493. const ARight: Double): TBLPoint;
  7494. begin
  7495. Result.Reset(ALeft.FHandle.x * ARight, ALeft.FHandle.y * ARight);
  7496. end;
  7497. class operator TBLPoint.Negative(const AValue: TBLPoint): TBLPoint;
  7498. begin
  7499. Result.Reset(-AValue.FHandle.x, -AValue.FHandle.y);
  7500. end;
  7501. class operator TBLPoint.NotEqual(const ALeft, ARight: TBLPoint): Boolean;
  7502. begin
  7503. Result := not ALeft.Equals(ARight);
  7504. end;
  7505. procedure TBLPoint.Reset(const AX, AY: Double);
  7506. begin
  7507. FHandle.x := AX;
  7508. FHandle.y := AY;
  7509. end;
  7510. class operator TBLPoint.Subtract(const ALeft: TBLPoint;
  7511. const ARight: Double): TBLPoint;
  7512. begin
  7513. Result.Reset(ALeft.FHandle.x - ARight, ALeft.FHandle.y - ARight);
  7514. end;
  7515. class operator TBLPoint.Subtract(const ALeft: Double;
  7516. const ARight: TBLPoint): TBLPoint;
  7517. begin
  7518. Result.Reset(ALeft - ARight.FHandle.x, ALeft - ARight.FHandle.y);
  7519. end;
  7520. class operator TBLPoint.Subtract(const ALeft, ARight: TBLPoint): TBLPoint;
  7521. begin
  7522. Result.Reset(ALeft.FHandle.x - ARight.FHandle.x, ALeft.FHandle.y - ARight.FHandle.y);
  7523. end;
  7524. procedure TBLPoint.Reset;
  7525. begin
  7526. FHandle.x := 0;
  7527. FHandle.y := 0;
  7528. end;
  7529. { TBLSize }
  7530. function BLSize: TBLSize; overload; inline;
  7531. begin
  7532. Result.Reset;
  7533. end;
  7534. function BLSize(const AW, AH: Double): TBLSize; overload; inline;
  7535. begin
  7536. Result.Reset(AW, AH);
  7537. end;
  7538. class operator TBLSize.Equal(const ALeft, ARight: TBLSize): Boolean;
  7539. begin
  7540. Result := ALeft.Equals(ARight);
  7541. end;
  7542. function TBLSize.Equals(const AOther: TBLSize): Boolean;
  7543. begin
  7544. Result := (FHandle.w = AOther.FHandle.w)
  7545. and (FHandle.h = AOther.FHandle.h);
  7546. end;
  7547. class operator TBLSize.NotEqual(const ALeft, ARight: TBLSize): Boolean;
  7548. begin
  7549. Result := not ALeft.Equals(ARight);
  7550. end;
  7551. procedure TBLSize.Reset(const AW, AH: Double);
  7552. begin
  7553. FHandle.w := AW;
  7554. FHandle.h := AH;
  7555. end;
  7556. procedure TBLSize.Reset;
  7557. begin
  7558. FHandle.w := 0;
  7559. FHandle.h := 0;
  7560. end;
  7561. { TBLBox }
  7562. function BLBox: TBLBox; overload; inline;
  7563. begin
  7564. Result.Reset;
  7565. end;
  7566. function BLBox(const AX0, AY0, AX1, AY1: Double): TBLBox; inline;
  7567. begin
  7568. Result.Reset(AX0, AY0, AX1, AY1);
  7569. end;
  7570. function TBLBox.Contains(const AX, AY: Double): Boolean;
  7571. begin
  7572. Result := (AX >= FHandle.x0) and (AY >= FHandle.y0)
  7573. and (AX < FHandle.x1) and (AY < FHandle.y1);
  7574. end;
  7575. class operator TBLBox.Add(const ALeft: TBLPoint; const ARight: TBLBox): TBLBox;
  7576. begin
  7577. Result.Reset(ALeft.FHandle.x + ARight.FHandle.x0,
  7578. ALeft.FHandle.y + ARight.FHandle.y0,
  7579. ALeft.FHandle.x + ARight.FHandle.x1,
  7580. ALeft.FHandle.y + ARight.FHandle.y1);
  7581. end;
  7582. class operator TBLBox.Add(const ALeft: TBLBox; const ARight: TBLPoint): TBLBox;
  7583. begin
  7584. Result.Reset(ALeft.FHandle.x0 + ARight.FHandle.x,
  7585. ALeft.FHandle.y0 + ARight.FHandle.y,
  7586. ALeft.FHandle.x1 + ARight.FHandle.x,
  7587. ALeft.FHandle.y1 + ARight.FHandle.y);
  7588. end;
  7589. class operator TBLBox.Add(const ALeft: Double; const ARight: TBLBox): TBLBox;
  7590. begin
  7591. Result.Reset(ALeft + ARight.FHandle.x0,
  7592. ALeft + ARight.FHandle.y0,
  7593. ALeft + ARight.FHandle.x1,
  7594. ALeft + ARight.FHandle.y1);
  7595. end;
  7596. class operator TBLBox.Add(const ALeft: TBLBox; const ARight: Double): TBLBox;
  7597. begin
  7598. Result.Reset(ALeft.FHandle.x0 + ARight,
  7599. ALeft.FHandle.y0 + ARight,
  7600. ALeft.FHandle.x1 + ARight,
  7601. ALeft.FHandle.y1 + ARight);
  7602. end;
  7603. function TBLBox.Contains(const AP: TBLPoint): Boolean;
  7604. begin
  7605. Result := (AP.FHandle.x >= FHandle.x0) and (AP.FHandle.y >= FHandle.y0)
  7606. and (AP.FHandle.x < FHandle.x1) and (AP.FHandle.y < FHandle.y1);
  7607. end;
  7608. class operator TBLBox.Divide(const ALeft: TBLPoint;
  7609. const ARight: TBLBox): TBLBox;
  7610. begin
  7611. Result.Reset(ALeft.FHandle.x / ARight.FHandle.x0,
  7612. ALeft.FHandle.y / ARight.FHandle.y0,
  7613. ALeft.FHandle.x / ARight.FHandle.x1,
  7614. ALeft.FHandle.y / ARight.FHandle.y1);
  7615. end;
  7616. class operator TBLBox.Divide(const ALeft: TBLBox;
  7617. const ARight: TBLPoint): TBLBox;
  7618. begin
  7619. Result.Reset(ALeft.FHandle.x0 / ARight.FHandle.x,
  7620. ALeft.FHandle.y0 / ARight.FHandle.y,
  7621. ALeft.FHandle.x1 / ARight.FHandle.x,
  7622. ALeft.FHandle.y1 / ARight.FHandle.y);
  7623. end;
  7624. class operator TBLBox.Divide(const ALeft: Double; const ARight: TBLBox): TBLBox;
  7625. begin
  7626. Result.Reset(ALeft / ARight.FHandle.x0,
  7627. ALeft / ARight.FHandle.y0,
  7628. ALeft / ARight.FHandle.x1,
  7629. ALeft / ARight.FHandle.y1);
  7630. end;
  7631. class operator TBLBox.Divide(const ALeft: TBLBox; const ARight: Double): TBLBox;
  7632. begin
  7633. Result.Reset(ALeft.FHandle.x0 / ARight,
  7634. ALeft.FHandle.y0 / ARight,
  7635. ALeft.FHandle.x1 / ARight,
  7636. ALeft.FHandle.y1 / ARight);
  7637. end;
  7638. class operator TBLBox.Equal(const ALeft, ARight: TBLBox): Boolean;
  7639. begin
  7640. Result := ALeft.Equals(ARight);
  7641. end;
  7642. function TBLBox.Equals(const AOther: TBLBox): Boolean;
  7643. begin
  7644. Result := (FHandle.x0 = AOther.FHandle.x0)
  7645. and (FHandle.y0 = AOther.FHandle.y0)
  7646. and (FHandle.x1 = AOther.FHandle.x1)
  7647. and (FHandle.y1 = AOther.FHandle.y0);
  7648. end;
  7649. function TBLBox.GetHeight: Double;
  7650. begin
  7651. Result := FHandle.y1 - FHandle.y0;
  7652. end;
  7653. function TBLBox.GetWidth: Double;
  7654. begin
  7655. Result := FHandle.x1 - FHandle.x0;
  7656. end;
  7657. class operator TBLBox.Multiply(const ALeft: TBLPoint;
  7658. const ARight: TBLBox): TBLBox;
  7659. begin
  7660. Result.Reset(ALeft.FHandle.x * ARight.FHandle.x0,
  7661. ALeft.FHandle.y * ARight.FHandle.y0,
  7662. ALeft.FHandle.x * ARight.FHandle.x1,
  7663. ALeft.FHandle.y * ARight.FHandle.y1);
  7664. end;
  7665. class operator TBLBox.Multiply(const ALeft: TBLBox;
  7666. const ARight: TBLPoint): TBLBox;
  7667. begin
  7668. Result.Reset(ALeft.FHandle.x0 * ARight.FHandle.x,
  7669. ALeft.FHandle.y0 * ARight.FHandle.y,
  7670. ALeft.FHandle.x1 * ARight.FHandle.x,
  7671. ALeft.FHandle.y1 * ARight.FHandle.y);
  7672. end;
  7673. class operator TBLBox.Multiply(const ALeft: Double;
  7674. const ARight: TBLBox): TBLBox;
  7675. begin
  7676. Result.Reset(ALeft * ARight.FHandle.x0,
  7677. ALeft * ARight.FHandle.y0,
  7678. ALeft * ARight.FHandle.x1,
  7679. ALeft * ARight.FHandle.y1);
  7680. end;
  7681. class operator TBLBox.Multiply(const ALeft: TBLBox;
  7682. const ARight: Double): TBLBox;
  7683. begin
  7684. Result.Reset(ALeft.FHandle.x0 * ARight,
  7685. ALeft.FHandle.y0 * ARight,
  7686. ALeft.FHandle.x1 * ARight,
  7687. ALeft.FHandle.y1 * ARight);
  7688. end;
  7689. class operator TBLBox.NotEqual(const ALeft, ARight: TBLBox): Boolean;
  7690. begin
  7691. Result := not ALeft.Equals(ARight);
  7692. end;
  7693. procedure TBLBox.Reset;
  7694. begin
  7695. FHandle.x0 := 0;
  7696. FHandle.y0 := 0;
  7697. FHandle.x1 := 0;
  7698. FHandle.y1 := 0;
  7699. end;
  7700. procedure TBLBox.Reset(const AX0, AY0, AX1, AY1: Double);
  7701. begin
  7702. FHandle.x0 := AX0;
  7703. FHandle.y0 := AY0;
  7704. FHandle.x1 := AX1;
  7705. FHandle.y1 := AY1;
  7706. end;
  7707. procedure TBLBox.SetHeight(const AValue: Double);
  7708. begin
  7709. FHandle.y1 := FHandle.y0 + AValue;
  7710. end;
  7711. procedure TBLBox.SetWidth(const AValue: Double);
  7712. begin
  7713. FHandle.x1 := FHandle.x0 + AValue;
  7714. end;
  7715. class operator TBLBox.Subtract(const ALeft: TBLPoint;
  7716. const ARight: TBLBox): TBLBox;
  7717. begin
  7718. Result.Reset(ALeft.FHandle.x - ARight.FHandle.x0,
  7719. ALeft.FHandle.y - ARight.FHandle.y0,
  7720. ALeft.FHandle.x - ARight.FHandle.x1,
  7721. ALeft.FHandle.y - ARight.FHandle.y1);
  7722. end;
  7723. class operator TBLBox.Subtract(const ALeft: TBLBox;
  7724. const ARight: TBLPoint): TBLBox;
  7725. begin
  7726. Result.Reset(ALeft.FHandle.x0 - ARight.FHandle.x,
  7727. ALeft.FHandle.y0 - ARight.FHandle.y,
  7728. ALeft.FHandle.x1 - ARight.FHandle.x,
  7729. ALeft.FHandle.y1 - ARight.FHandle.y);
  7730. end;
  7731. class operator TBLBox.Subtract(const ALeft: Double;
  7732. const ARight: TBLBox): TBLBox;
  7733. begin
  7734. Result.Reset(ALeft - ARight.FHandle.x0,
  7735. ALeft - ARight.FHandle.y0,
  7736. ALeft - ARight.FHandle.x1,
  7737. ALeft - ARight.FHandle.y1);
  7738. end;
  7739. class operator TBLBox.Subtract(const ALeft: TBLBox;
  7740. const ARight: Double): TBLBox;
  7741. begin
  7742. Result.Reset(ALeft.FHandle.x0 - ARight,
  7743. ALeft.FHandle.y0 - ARight,
  7744. ALeft.FHandle.x1 - ARight,
  7745. ALeft.FHandle.y1 - ARight);
  7746. end;
  7747. { TBLRect }
  7748. function BLRect: TBLRect; overload; inline;
  7749. begin
  7750. Result.Reset;
  7751. end;
  7752. function BLRect(const AX, AY, AW, AH: Double): TBLRect; inline;
  7753. begin
  7754. Result.Reset(AX, AY, AW, AH);
  7755. end;
  7756. class operator TBLRect.Equal(const ALeft, ARight: TBLRect): Boolean;
  7757. begin
  7758. Result := ALeft.Equals(ARight);
  7759. end;
  7760. function TBLRect.Equals(const AOther: TBLRect): Boolean;
  7761. begin
  7762. Result := (FHandle.x = AOther.FHandle.x)
  7763. and (FHandle.y = AOther.FHandle.y)
  7764. and (FHandle.w = AOther.FHandle.w)
  7765. and (FHandle.h = AOther.FHandle.h);
  7766. end;
  7767. class operator TBLRect.NotEqual(const ALeft, ARight: TBLRect): Boolean;
  7768. begin
  7769. Result := not ALeft.Equals(ARight);
  7770. end;
  7771. procedure TBLRect.Reset(const AX, AY, AW, AH: Double);
  7772. begin
  7773. FHandle.x := AX;
  7774. FHandle.y := AY;
  7775. FHandle.w := AW;
  7776. FHandle.h := AH;
  7777. end;
  7778. procedure TBLRect.Reset;
  7779. begin
  7780. FHandle.x := 0;
  7781. FHandle.y := 0;
  7782. FHandle.w := 0;
  7783. FHandle.h := 0;
  7784. end;
  7785. { TBLLine }
  7786. function BLLine: TBLLine; overload; inline;
  7787. begin
  7788. Result.Reset;
  7789. end;
  7790. function BLLine(const AX0, AY0, AX1, AY1: Double): TBLLine; overload; inline;
  7791. begin
  7792. Result.Reset(AX0, AY0, AX1, AY1);
  7793. end;
  7794. function BLLine(const AP0, AP1: TBLPoint): TBLLine; overload; inline;
  7795. begin
  7796. Result.Reset(AP0, AP1);
  7797. end;
  7798. class operator TBLLine.Equal(const ALeft, ARight: TBLLine): Boolean;
  7799. begin
  7800. Result := ALeft.Equals(ARight);
  7801. end;
  7802. function TBLLine.Equals(const AOther: TBLLine): Boolean;
  7803. begin
  7804. Result := (FHandle.x0 = AOther.FHandle.x0)
  7805. and (FHandle.y0 = AOther.FHandle.y0)
  7806. and (FHandle.x1 = AOther.FHandle.x1)
  7807. and (FHandle.y1 = AOther.FHandle.y1);
  7808. end;
  7809. class operator TBLLine.NotEqual(const ALeft, ARight: TBLLine): Boolean;
  7810. begin
  7811. Result := not ALeft.Equals(ARight);
  7812. end;
  7813. procedure TBLLine.Reset(const AX0, AY0, AX1, AY1: Double);
  7814. begin
  7815. FHandle.x0 := AX0;
  7816. FHandle.y0 := AY0;
  7817. FHandle.x1 := AX1;
  7818. FHandle.y1 := AY1;
  7819. end;
  7820. procedure TBLLine.Reset(const AP0, AP1: TBLPoint);
  7821. begin
  7822. FHandle.x0 := AP0.FHandle.x;
  7823. FHandle.y0 := AP0.FHandle.y;
  7824. FHandle.x1 := AP1.FHandle.x;
  7825. FHandle.y1 := AP1.FHandle.y;
  7826. end;
  7827. procedure TBLLine.Reset;
  7828. begin
  7829. FHandle.x0 := 0;
  7830. FHandle.y0 := 0;
  7831. FHandle.x1 := 0;
  7832. FHandle.y1 := 0;
  7833. end;
  7834. { TBLTriangle }
  7835. function BLTriangle: TBLTriangle; overload; inline;
  7836. begin
  7837. Result.Reset;
  7838. end;
  7839. function BLTriangle(const AX0, AY0, AX1, AY1, AX2, AY2: Double): TBLTriangle; inline;
  7840. begin
  7841. Result.Reset(AX0, AY0, AX1, AY1, AX2, AY2);
  7842. end;
  7843. class operator TBLTriangle.Equal(const ALeft, ARight: TBLTriangle): Boolean;
  7844. begin
  7845. Result := ALeft.Equals(ARight);
  7846. end;
  7847. function TBLTriangle.Equals(const AOther: TBLTriangle): Boolean;
  7848. begin
  7849. Result := (FHandle.x0 = AOther.FHandle.x0)
  7850. and (FHandle.y0 = AOther.FHandle.y0)
  7851. and (FHandle.x1 = AOther.FHandle.x1)
  7852. and (FHandle.y1 = AOther.FHandle.y1)
  7853. and (FHandle.x2 = AOther.FHandle.x2)
  7854. and (FHandle.y2 = AOther.FHandle.y2);
  7855. end;
  7856. class operator TBLTriangle.NotEqual(const ALeft, ARight: TBLTriangle): Boolean;
  7857. begin
  7858. Result := not ALeft.Equals(ARight);
  7859. end;
  7860. procedure TBLTriangle.Reset(const AX0, AY0, AX1, AY1, AX2, AY2: Double);
  7861. begin
  7862. FHandle.x0 := AX0;
  7863. FHandle.y0 := AY0;
  7864. FHandle.x1 := AX1;
  7865. FHandle.y1 := AY1;
  7866. FHandle.x2 := AX2;
  7867. FHandle.y2 := AY2;
  7868. end;
  7869. procedure TBLTriangle.Reset;
  7870. begin
  7871. FHandle.x0 := 0;
  7872. FHandle.y0 := 0;
  7873. FHandle.x1 := 0;
  7874. FHandle.y1 := 0;
  7875. FHandle.x2 := 0;
  7876. FHandle.y2 := 0;
  7877. end;
  7878. { TBLRoundRect }
  7879. function BLRoundRect: TBLRoundRect; overload; inline;
  7880. begin
  7881. Result.Reset;
  7882. end;
  7883. function BLRoundRect(const ARect: TBLRect; const AR: Double): TBLRoundRect; overload; inline;
  7884. begin
  7885. Result.Reset(ARect, AR);
  7886. end;
  7887. function BLRoundRect(const ARect: TBLRect; const ARX, ARY: Double): TBLRoundRect; overload; inline;
  7888. begin
  7889. Result.Reset(ARect, ARX, ARY);
  7890. end;
  7891. function BLRoundRect(const AX, AY, AW, AH, AR: Double): TBLRoundRect; overload; inline;
  7892. begin
  7893. Result.Reset(AX, AY, AW, AH, AR);
  7894. end;
  7895. function BLRoundRect(const AX, AY, AW, AH, ARX, ARY: Double): TBLRoundRect; overload; inline;
  7896. begin
  7897. Result.Reset(AX, AY, AW, AH, ARX, ARY);
  7898. end;
  7899. class operator TBLRoundRect.Equal(const ALeft, ARight: TBLRoundRect): Boolean;
  7900. begin
  7901. Result := ALeft.Equals(ARight);
  7902. end;
  7903. function TBLRoundRect.Equals(const AOther: TBLRoundRect): Boolean;
  7904. begin
  7905. Result := (FHandle.x = AOther.FHandle.x)
  7906. and (FHandle.y = AOther.FHandle.y)
  7907. and (FHandle.w = AOther.FHandle.w)
  7908. and (FHandle.h = AOther.FHandle.h)
  7909. and (FHandle.rx = AOther.FHandle.rx)
  7910. and (FHandle.ry = AOther.FHandle.ry);
  7911. end;
  7912. class operator TBLRoundRect.NotEqual(const ALeft,
  7913. ARight: TBLRoundRect): Boolean;
  7914. begin
  7915. Result := not ALeft.Equals(ARight);
  7916. end;
  7917. procedure TBLRoundRect.Reset(const ARect: TBLRect; const AR: Double);
  7918. begin
  7919. FHandle.x := ARect.FHandle.x;
  7920. FHandle.y := ARect.FHandle.y;
  7921. FHandle.w := ARect.FHandle.w;
  7922. FHandle.h := ARect.FHandle.h;
  7923. FHandle.rx := AR;
  7924. FHandle.ry := AR;
  7925. end;
  7926. procedure TBLRoundRect.Reset(const AX, AY, AW, AH, AR: Double);
  7927. begin
  7928. FHandle.x := AX;
  7929. FHandle.y := AY;
  7930. FHandle.w := AW;
  7931. FHandle.h := AH;
  7932. FHandle.rx := AR;
  7933. FHandle.ry := AR;
  7934. end;
  7935. procedure TBLRoundRect.Reset(const AX, AY, AW, AH, ARX, ARY: Double);
  7936. begin
  7937. FHandle.x := AX;
  7938. FHandle.y := AY;
  7939. FHandle.w := AW;
  7940. FHandle.h := AH;
  7941. FHandle.rx := ARX;
  7942. FHandle.ry := ARY;
  7943. end;
  7944. procedure TBLRoundRect.Reset(const ARect: TBLRect; const ARX, ARY: Double);
  7945. begin
  7946. FHandle.x := ARect.FHandle.x;
  7947. FHandle.y := ARect.FHandle.y;
  7948. FHandle.w := ARect.FHandle.w;
  7949. FHandle.h := ARect.FHandle.h;
  7950. FHandle.rx := ARX;
  7951. FHandle.ry := ARY;
  7952. end;
  7953. procedure TBLRoundRect.Reset;
  7954. begin
  7955. FHandle.x := 0;
  7956. FHandle.y := 0;
  7957. FHandle.w := 0;
  7958. FHandle.h := 0;
  7959. FHandle.rx := 0;
  7960. FHandle.ry := 0;
  7961. end;
  7962. { TBLCircle }
  7963. function BLCircle: TBLCircle; overload; inline;
  7964. begin
  7965. Result.Reset;
  7966. end;
  7967. function BLCircle(const ACX, ACY, AR: Double): TBLCircle; inline;
  7968. begin
  7969. Result.Reset(ACX, ACY, AR);
  7970. end;
  7971. class operator TBLCircle.Equal(const ALeft, ARight: TBLCircle): Boolean;
  7972. begin
  7973. Result := ALeft.Equals(ARight);
  7974. end;
  7975. function TBLCircle.Equals(const AOther: TBLCircle): Boolean;
  7976. begin
  7977. Result := (FHandle.cx = AOther.FHandle.cx)
  7978. and (FHandle.cy = AOther.FHandle.cy)
  7979. and (FHandle.r = AOther.FHandle.r);
  7980. end;
  7981. class operator TBLCircle.NotEqual(const ALeft, ARight: TBLCircle): Boolean;
  7982. begin
  7983. Result := not ALeft.Equals(ARight);
  7984. end;
  7985. procedure TBLCircle.Reset(const ACX, ACY, AR: Double);
  7986. begin
  7987. FHandle.cx := ACX;
  7988. FHandle.cy := ACY;
  7989. FHandle.r := AR;
  7990. end;
  7991. procedure TBLCircle.Reset;
  7992. begin
  7993. FHandle.cx := 0;
  7994. FHandle.cy := 0;
  7995. FHandle.r := 0;
  7996. end;
  7997. { TBLEllipse }
  7998. function BLEllipse: TBLEllipse; overload; inline;
  7999. begin
  8000. Result.Reset;
  8001. end;
  8002. function BLEllipse(const ACX, ACY, ARX, ARY: Double): TBLEllipse; inline;
  8003. begin
  8004. Result.Reset(ACX, ACY, ARX, ARY);
  8005. end;
  8006. class operator TBLEllipse.Equal(const ALeft, ARight: TBLEllipse): Boolean;
  8007. begin
  8008. Result := ALeft.Equals(ARight);
  8009. end;
  8010. function TBLEllipse.Equals(const AOther: TBLEllipse): Boolean;
  8011. begin
  8012. Result := (FHandle.cx = AOther.FHandle.cx)
  8013. and (FHandle.cy = AOther.FHandle.cy)
  8014. and (FHandle.rx = AOther.FHandle.rx)
  8015. and (FHandle.ry = AOther.FHandle.ry);
  8016. end;
  8017. class operator TBLEllipse.NotEqual(const ALeft, ARight: TBLEllipse): Boolean;
  8018. begin
  8019. Result := not ALeft.Equals(ARight);
  8020. end;
  8021. procedure TBLEllipse.Reset(const ACX, ACY, ARX, ARY: Double);
  8022. begin
  8023. FHandle.cx := ACX;
  8024. FHandle.cy := ACY;
  8025. FHandle.rx := ARX;
  8026. FHandle.ry := ARY;
  8027. end;
  8028. procedure TBLEllipse.Reset;
  8029. begin
  8030. FHandle.cx := 0;
  8031. FHandle.cy := 0;
  8032. FHandle.rx := 0;
  8033. FHandle.ry := 0;
  8034. end;
  8035. { TBLArc }
  8036. function BLArc: TBLArc; overload; inline;
  8037. begin
  8038. Result.Reset;
  8039. end;
  8040. function BLArc(const ACX, ACY, AR, AStart, ASweep: Double): TBLArc; overload; inline;
  8041. begin
  8042. Result.Reset(ACX, ACY, AR, AStart, ASweep);
  8043. end;
  8044. function BLArc(const ACX, ACY, ARX, ARY, AStart, ASweep: Double): TBLArc; overload; inline;
  8045. begin
  8046. Result.Reset(ACX, ACY, ARX, ARY, AStart, ASweep);
  8047. end;
  8048. class operator TBLArc.Equal(const ALeft, ARight: TBLArc): Boolean;
  8049. begin
  8050. Result := ALeft.Equals(ARight);
  8051. end;
  8052. function TBLArc.Equals(const AOther: TBLArc): Boolean;
  8053. begin
  8054. Result := (FHandle.cx = AOther.FHandle.cx)
  8055. and (FHandle.cy = AOther.FHandle.cy)
  8056. and (FHandle.rx = AOther.FHandle.rx)
  8057. and (FHandle.ry = AOther.FHandle.ry)
  8058. and (FHandle.start = AOther.FHandle.start)
  8059. and (FHandle.sweep = AOther.FHandle.sweep);
  8060. end;
  8061. class operator TBLArc.NotEqual(const ALeft, ARight: TBLArc): Boolean;
  8062. begin
  8063. Result := not ALeft.Equals(ARight);
  8064. end;
  8065. procedure TBLArc.Reset(const ACX, ACY, ARX, ARY, AStart, ASweep: Double);
  8066. begin
  8067. FHandle.cx := ACX;
  8068. FHandle.cy := ACY;
  8069. FHandle.rx := ARX;
  8070. FHandle.ry := ARY;
  8071. FHandle.start := AStart;
  8072. FHandle.sweep := ASweep;
  8073. end;
  8074. procedure TBLArc.Reset(const ACX, ACY, AR, AStart, ASweep: Double);
  8075. begin
  8076. FHandle.cx := ACX;
  8077. FHandle.cy := ACY;
  8078. FHandle.rx := AR;
  8079. FHandle.ry := AR;
  8080. FHandle.start := AStart;
  8081. FHandle.sweep := ASweep;
  8082. end;
  8083. procedure TBLArc.Reset;
  8084. begin
  8085. FHandle.cx := 0;
  8086. FHandle.cy := 0;
  8087. FHandle.rx := 0;
  8088. FHandle.ry := 0;
  8089. FHandle.start := 0;
  8090. FHandle.sweep := 0;
  8091. end;
  8092. { Globals }
  8093. function BLAbs(const AA: TBLPoint): TBLPoint; overload; inline;
  8094. begin
  8095. Result.Reset(Abs(AA.FHandle.x), Abs(AA.FHandle.y));
  8096. end;
  8097. function BLAbs(const AA: TBLSize): TBLSize; overload; inline;
  8098. begin
  8099. Result.Reset(Abs(AA.FHandle.w), Abs(AA.FHandle.h));
  8100. end;
  8101. function BLMin(const AA, AB: TBLPoint): TBLPoint; overload; inline;
  8102. begin
  8103. Result.Reset(Min(AA.FHandle.x, AB.FHandle.x), Min(AA.FHandle.y, AB.FHandle.y));
  8104. end;
  8105. function BLMin(const AA: TBLPoint; const AB: Double): TBLPoint; overload; inline;
  8106. begin
  8107. Result.Reset(Min(AA.FHandle.x, AB), Min(AA.FHandle.y, AB));
  8108. end;
  8109. function BLMin(const AA: Double; const AB: TBLPoint): TBLPoint; overload; inline;
  8110. begin
  8111. Result.Reset(Min(AA, AB.FHandle.x), Min(AA, AB.FHandle.y));
  8112. end;
  8113. function BLMin(const AA, AB: TBLSize): TBLSize; overload; inline;
  8114. begin
  8115. Result.Reset(Min(AA.FHandle.w, AB.FHandle.w), Min(AA.FHandle.h, AB.FHandle.h));
  8116. end;
  8117. function BLMax(const AA, AB: TBLPoint): TBLPoint; overload; inline;
  8118. begin
  8119. Result.Reset(Max(AA.FHandle.x, AB.FHandle.x), Max(AA.FHandle.y, AB.FHandle.y));
  8120. end;
  8121. function BLMax(const AA: TBLPoint; const AB: Double): TBLPoint; overload; inline;
  8122. begin
  8123. Result.Reset(Max(AA.FHandle.x, AB), Max(AA.FHandle.y, AB));
  8124. end;
  8125. function BLMax(const AA: Double; const AB: TBLPoint): TBLPoint; overload; inline;
  8126. begin
  8127. Result.Reset(Max(AA, AB.FHandle.x), Max(AA, AB.FHandle.y));
  8128. end;
  8129. function BLMax(const AA, AB: TBLSize): TBLSize; overload; inline;
  8130. begin
  8131. Result.Reset(Max(AA.FHandle.w, AB.FHandle.w), Max(AA.FHandle.h, AB.FHandle.h));
  8132. end;
  8133. function BLClamp(const AA: TBLPoint; const AB, AC: Double): TBLPoint; inline;
  8134. begin
  8135. Result := BLMin(AC, BLMax(AA, AB));
  8136. end;
  8137. {$ENDREGION 'Geometry'}
  8138. {$REGION 'Matrix'}
  8139. { TBLMatrix2D }
  8140. function BLMatrix2D: TBLMatrix2D; overload; inline;
  8141. begin
  8142. Result.Reset;
  8143. end;
  8144. function BLMatrix2D(const AM00, AM01, AM10, AM11, AM20, AM21: Double): TBLMatrix2D; overload; inline;
  8145. begin
  8146. Result.Reset(AM00, AM01, AM10, AM11, AM20, AM21);
  8147. end;
  8148. class operator TBLMatrix2D.Equal(const ALeft, ARight: TBLMatrix2D): Boolean;
  8149. begin
  8150. Result := ALeft.Equals(ARight);
  8151. end;
  8152. function TBLMatrix2D.Equals(const AOther: TBLMatrix2D): Boolean;
  8153. begin
  8154. Result := (FHandle.m00 = AOther.FHandle.m00)
  8155. and (FHandle.m01 = AOther.FHandle.m01)
  8156. and (FHandle.m10 = AOther.FHandle.m10)
  8157. and (FHandle.m11 = AOther.FHandle.m11)
  8158. and (FHandle.m20 = AOther.FHandle.m20)
  8159. and (FHandle.m21 = AOther.FHandle.m21);
  8160. end;
  8161. function TBLMatrix2D.GetDeterminant: Double;
  8162. begin
  8163. Result := (FHandle.m00 * FHandle.m11) - (FHandle.m01 * FHandle.m10);
  8164. end;
  8165. function TBLMatrix2D.GetElement(const AIndex: TBLMatrix2DValue): Double;
  8166. begin
  8167. Result := FHandle.m[Ord(AIndex)];
  8168. end;
  8169. function TBLMatrix2D.GetMatrixType: TBLMatrix2DType;
  8170. begin
  8171. Result := TBLMatrix2DType(blMatrix2DGetType(@FHandle));
  8172. end;
  8173. class function TBLMatrix2D.Invert(const ASrc: TBLMatrix2D;
  8174. out ADst: TBLMatrix2D): Boolean;
  8175. begin
  8176. Result := (blMatrix2DInvert(@ADst.FHandle, @ASrc.FHandle) = BL_SUCCESS);
  8177. end;
  8178. function TBLMatrix2D.Invert: Boolean;
  8179. begin
  8180. Result := (blMatrix2DInvert(@FHandle, @FHandle) = BL_SUCCESS);
  8181. end;
  8182. class function TBLMatrix2D.MakeIdentity: TBLMatrix2D;
  8183. begin
  8184. Result.Reset(1, 0, 0, 1, 0, 0);
  8185. end;
  8186. class function TBLMatrix2D.MakeRotation(const AAngle, AX,
  8187. AY: Double): TBLMatrix2D;
  8188. begin
  8189. Result.ResetToRotation(AAngle, AX, AY);
  8190. end;
  8191. class function TBLMatrix2D.MakeRotation(const AAngle: Double): TBLMatrix2D;
  8192. begin
  8193. Result.ResetToRotation(AAngle, 0, 0);
  8194. end;
  8195. class function TBLMatrix2D.MakeRotation(const AAngle: Double;
  8196. const AP: TBLPoint): TBLMatrix2D;
  8197. begin
  8198. Result.ResetToRotation(AAngle, AP.FHandle.x, AP.FHandle.y);
  8199. end;
  8200. class function TBLMatrix2D.MakeScaling(const AX, AY: Double): TBLMatrix2D;
  8201. begin
  8202. Result.Reset(AX, 0, 0, AY, 0, 0);
  8203. end;
  8204. class function TBLMatrix2D.MakeScaling(const AP: TBLPoint): TBLMatrix2D;
  8205. begin
  8206. Result.Reset(AP.FHandle.x, 0, 0, AP.FHandle.y, 0, 0);
  8207. end;
  8208. class function TBLMatrix2D.MakeScaling(const AP: TBLPointI): TBLMatrix2D;
  8209. begin
  8210. Result.Reset(AP.FHandle.x, 0, 0, AP.FHandle.y, 0, 0);
  8211. end;
  8212. class function TBLMatrix2D.MakeScaling(const AXY: Double): TBLMatrix2D;
  8213. begin
  8214. Result.Reset(AXY, 0, 0, AXY, 0, 0);
  8215. end;
  8216. class function TBLMatrix2D.MakeSinCos(const ASin, ACos: Double;
  8217. const ATranslate: TBLPoint): TBLMatrix2D;
  8218. begin
  8219. Result.Reset(ACos, ASin, -ASin, ACos, ATranslate.FHandle.x, ATranslate.FHandle.y);
  8220. end;
  8221. class function TBLMatrix2D.MakeSinCos(const ASin, ACos, ATranslateX,
  8222. ATranslateY: Double): TBLMatrix2D;
  8223. begin
  8224. Result.Reset(ACos, ASin, -ASin, ACos, ATranslateX, ATranslateY);
  8225. end;
  8226. class function TBLMatrix2D.MakeSkewing(const AX, AY: Double): TBLMatrix2D;
  8227. begin
  8228. Result.ResetToSkewing(AX, AY);
  8229. end;
  8230. class function TBLMatrix2D.MakeSkewing(const AP: TBLPoint): TBLMatrix2D;
  8231. begin
  8232. Result.ResetToSkewing(AP.FHandle.x, AP.FHandle.y);
  8233. end;
  8234. class function TBLMatrix2D.MakeTranslation(const AP: TBLPointI): TBLMatrix2D;
  8235. begin
  8236. Result.Reset(1, 0, 0, 1, AP.FHandle.x, AP.FHandle.y);
  8237. end;
  8238. class function TBLMatrix2D.MakeTranslation(const AP: TBLPoint): TBLMatrix2D;
  8239. begin
  8240. Result.Reset(1, 0, 0, 1, AP.FHandle.x, AP.FHandle.y);
  8241. end;
  8242. class function TBLMatrix2D.MakeTranslation(const AX, AY: Double): TBLMatrix2D;
  8243. begin
  8244. Result.Reset(1, 0, 0, 1, AX, AY);
  8245. end;
  8246. function TBLMatrix2D.MapPoint(const AP: TBLPoint): TBLPoint;
  8247. begin
  8248. Result.Reset(
  8249. (AP.FHandle.x * FHandle.m00) + (AP.FHandle.y * FHandle.m10) + FHandle.m20,
  8250. (AP.FHandle.x * FHandle.m01) + (AP.FHandle.y * FHandle.m11) + FHandle.m21);
  8251. end;
  8252. function TBLMatrix2D.MapPoint(const AX, AY: Double): TBLPoint;
  8253. begin
  8254. Result.Reset(
  8255. (AX * FHandle.m00) + (AY * FHandle.m10) + FHandle.m20,
  8256. (AX * FHandle.m01) + (AY * FHandle.m11) + FHandle.m21);
  8257. end;
  8258. function TBLMatrix2D.MapVector(const AX, AY: Double): TBLPoint;
  8259. begin
  8260. Result.Reset(
  8261. (AX * FHandle.m00) + (AY * FHandle.m10),
  8262. (AX * FHandle.m01) + (AY * FHandle.m11));
  8263. end;
  8264. function TBLMatrix2D.MapVector(const AV: TBLPoint): TBLPoint;
  8265. begin
  8266. Result.Reset(
  8267. (AV.FHandle.x * FHandle.m00) + (AV.FHandle.y * FHandle.m10),
  8268. (AV.FHandle.x * FHandle.m01) + (AV.FHandle.y * FHandle.m11));
  8269. end;
  8270. class operator TBLMatrix2D.NotEqual(const ALeft, ARight: TBLMatrix2D): Boolean;
  8271. begin
  8272. Result := not ALeft.Equals(ARight);
  8273. end;
  8274. procedure TBLMatrix2D.PostRotate(const AAngle, AX, AY: Double);
  8275. var
  8276. Data: array [0..2] of Double;
  8277. begin
  8278. Data[0] := AAngle;
  8279. Data[1] := AX;
  8280. Data[2] := AY;
  8281. _BLCheck(blMatrix2DApplyOp(@FHandle, BL_MATRIX2D_OP_POST_ROTATE_PT, @Data));
  8282. end;
  8283. procedure TBLMatrix2D.PostRotate(const AAngle: Double; const AP: TBLPoint);
  8284. var
  8285. Data: array [0..2] of Double;
  8286. begin
  8287. Data[0] := AAngle;
  8288. Data[1] := AP.FHandle.x;
  8289. Data[2] := AP.FHandle.y;
  8290. _BLCheck(blMatrix2DApplyOp(@FHandle, BL_MATRIX2D_OP_POST_ROTATE_PT, @Data));
  8291. end;
  8292. procedure TBLMatrix2D.PostRotate(const AAngle: Double);
  8293. begin
  8294. _BLCheck(blMatrix2DApplyOp(@FHandle, BL_MATRIX2D_OP_POST_ROTATE, @AAngle));
  8295. end;
  8296. procedure TBLMatrix2D.PostScale(const AP: TBLPoint);
  8297. begin
  8298. PostScale(AP.FHandle.x, AP.FHandle.y);
  8299. end;
  8300. procedure TBLMatrix2D.PostScale(const AX, AY: Double);
  8301. begin
  8302. FHandle.m00 := FHandle.m00 * AX;
  8303. FHandle.m01 := FHandle.m01 * AY;
  8304. FHandle.m10 := FHandle.m10 * AX;
  8305. FHandle.m11 := FHandle.m11 * AY;
  8306. FHandle.m20 := FHandle.m10 * AX;
  8307. FHandle.m21 := FHandle.m11 * AY;
  8308. end;
  8309. procedure TBLMatrix2D.PostScale(const AXY: Double);
  8310. begin
  8311. PostScale(AXY, AXY);
  8312. end;
  8313. procedure TBLMatrix2D.PostScale(const AP: TBLPointI);
  8314. begin
  8315. PostScale(AP.FHandle.x, AP.FHandle.y);
  8316. end;
  8317. procedure TBLMatrix2D.PostSkew(const AX, AY: Double);
  8318. var
  8319. Data: array [0..1] of Double;
  8320. begin
  8321. Data[0] := AX;
  8322. Data[1] := AY;
  8323. _BLCheck(blMatrix2DApplyOp(@FHandle, BL_MATRIX2D_OP_POST_SKEW, @Data));
  8324. end;
  8325. procedure TBLMatrix2D.PostSkew(const AP: TBLPoint);
  8326. begin
  8327. _BLCheck(blMatrix2DApplyOp(@FHandle, BL_MATRIX2D_OP_POST_SKEW, @AP));
  8328. end;
  8329. procedure TBLMatrix2D.PostTransform(const AMatrix: TBLMatrix2D);
  8330. begin
  8331. _BLCheck(blMatrix2DApplyOp(@FHandle, BL_MATRIX2D_OP_POST_TRANSFORM, @AMatrix));
  8332. end;
  8333. procedure TBLMatrix2D.PostTranslate(const AX, AY: Double);
  8334. begin
  8335. FHandle.m20 := FHandle.m20 + AX;
  8336. FHandle.m21 := FHandle.m21 + AY;
  8337. end;
  8338. procedure TBLMatrix2D.PostTranslate(const AP: TBLPoint);
  8339. begin
  8340. FHandle.m20 := FHandle.m20 + AP.FHandle.x;
  8341. FHandle.m21 := FHandle.m21 + AP.FHandle.y;
  8342. end;
  8343. procedure TBLMatrix2D.PostTranslate(const AP: TBLPointI);
  8344. begin
  8345. FHandle.m20 := FHandle.m20 + AP.FHandle.x;
  8346. FHandle.m21 := FHandle.m21 + AP.FHandle.y;
  8347. end;
  8348. procedure TBLMatrix2D.Reset(const AM00, AM01, AM10, AM11, AM20, AM21: Double);
  8349. begin
  8350. FHandle.m00 := AM00;
  8351. FHandle.m01 := AM01;
  8352. FHandle.m10 := AM10;
  8353. FHandle.m11 := AM11;
  8354. FHandle.m20 := AM20;
  8355. FHandle.m21 := AM21;
  8356. end;
  8357. procedure TBLMatrix2D.Reset;
  8358. begin
  8359. FHandle.m00 := 1;
  8360. FHandle.m01 := 0;
  8361. FHandle.m10 := 0;
  8362. FHandle.m11 := 1;
  8363. FHandle.m20 := 0;
  8364. FHandle.m21 := 0;
  8365. end;
  8366. procedure TBLMatrix2D.ResetToRotation(const AAngle: Double);
  8367. begin
  8368. _BLCheck(blMatrix2DSetRotation(@FHandle, AAngle, 0, 0));
  8369. end;
  8370. procedure TBLMatrix2D.ResetToRotation(const AAngle, AX, AY: Double);
  8371. begin
  8372. _BLCheck(blMatrix2DSetRotation(@FHandle, AAngle, AX, AY));
  8373. end;
  8374. procedure TBLMatrix2D.ResetToRotation(const AAngle: Double; const AP: TBLPoint);
  8375. begin
  8376. _BLCheck(blMatrix2DSetRotation(@FHandle, AAngle, AP.FHandle.x, AP.FHandle.y));
  8377. end;
  8378. procedure TBLMatrix2D.ResetToScaling(const AX, AY: Double);
  8379. begin
  8380. Reset(AX, 0, 0, AY, 0, 0);
  8381. end;
  8382. procedure TBLMatrix2D.ResetToScaling(const AP: TBLPoint);
  8383. begin
  8384. Reset(AP.FHandle.x, 0, 0, AP.FHandle.y, 0, 0);
  8385. end;
  8386. procedure TBLMatrix2D.ResetToScaling(const AXY: Double);
  8387. begin
  8388. Reset(AXY, 0, 0, AXY, 0, 0);
  8389. end;
  8390. procedure TBLMatrix2D.ResetToScaling(const AP: TBLPointI);
  8391. begin
  8392. Reset(AP.FHandle.x, 0, 0, AP.FHandle.y, 0, 0);
  8393. end;
  8394. procedure TBLMatrix2D.ResetToSinCos(const ASin, ACos, ATranslateX,
  8395. ATranslateY: Double);
  8396. begin
  8397. Reset(ACos, ASin, -ASin, ACos, ATranslateX, ATranslateY);
  8398. end;
  8399. procedure TBLMatrix2D.ResetToSinCos(const ASin, ACos: Double;
  8400. const ATranslate: TBLPoint);
  8401. begin
  8402. Reset(ACos, ASin, -ASin, ACos, ATranslate.FHandle.x, ATranslate.FHandle.y);
  8403. end;
  8404. procedure TBLMatrix2D.ResetToSkewing(const AP: TBLPoint);
  8405. begin
  8406. _BLCheck(blMatrix2DSetSkewing(@FHandle, AP.FHandle.x, AP.FHandle.y));
  8407. end;
  8408. procedure TBLMatrix2D.ResetToSkewing(const AX, AY: Double);
  8409. begin
  8410. _BLCheck(blMatrix2DSetSkewing(@FHandle, AX, AY));
  8411. end;
  8412. procedure TBLMatrix2D.ResetToTranslation(const AP: TBLPointI);
  8413. begin
  8414. Reset(1, 0, 0, 1, AP.FHandle.x, AP.FHandle.y);
  8415. end;
  8416. procedure TBLMatrix2D.ResetToTranslation(const AP: TBLPoint);
  8417. begin
  8418. Reset(1, 0, 0, 1, AP.FHandle.x, AP.FHandle.y);
  8419. end;
  8420. procedure TBLMatrix2D.ResetToTranslation(const AX, AY: Double);
  8421. begin
  8422. Reset(1, 0, 0, 1, AX, AY);
  8423. end;
  8424. procedure TBLMatrix2D.Rotate(const AAngle: Double);
  8425. begin
  8426. _BLCheck(blMatrix2DApplyOp(@FHandle, BL_MATRIX2D_OP_ROTATE, @AAngle));
  8427. end;
  8428. procedure TBLMatrix2D.Rotate(const AAngle: Double; const AP: TBLPoint);
  8429. var
  8430. Data: array [0..2] of Double;
  8431. begin
  8432. Data[0] := AAngle;
  8433. Data[1] := AP.FHandle.x;
  8434. Data[2] := AP.FHandle.y;
  8435. _BLCheck(blMatrix2DApplyOp(@FHandle, BL_MATRIX2D_OP_ROTATE_PT, @Data));
  8436. end;
  8437. procedure TBLMatrix2D.Rotate(const AAngle, AX, AY: Double);
  8438. var
  8439. Data: array [0..2] of Double;
  8440. begin
  8441. Data[0] := AAngle;
  8442. Data[1] := AX;
  8443. Data[2] := AY;
  8444. _BLCheck(blMatrix2DApplyOp(@FHandle, BL_MATRIX2D_OP_ROTATE_PT, @Data));
  8445. end;
  8446. procedure TBLMatrix2D.Scale(const AXY: Double);
  8447. begin
  8448. FHandle.m00 := FHandle.m00 * AXY;
  8449. FHandle.m01 := FHandle.m01 * AXY;
  8450. FHandle.m10 := FHandle.m10 * AXY;
  8451. FHandle.m11 := FHandle.m11 * AXY;
  8452. end;
  8453. procedure TBLMatrix2D.Scale(const AP: TBLPointI);
  8454. begin
  8455. Scale(AP.FHandle.x, AP.FHandle.y);
  8456. end;
  8457. procedure TBLMatrix2D.Scale(const AP: TBLPoint);
  8458. begin
  8459. Scale(AP.FHandle.x, AP.FHandle.y);
  8460. end;
  8461. procedure TBLMatrix2D.Scale(const AX, AY: Double);
  8462. begin
  8463. FHandle.m00 := FHandle.m00 * AX;
  8464. FHandle.m01 := FHandle.m01 * AX;
  8465. FHandle.m10 := FHandle.m10 * AY;
  8466. FHandle.m11 := FHandle.m11 * AY;
  8467. end;
  8468. procedure TBLMatrix2D.SetElement(const AIndex: TBLMatrix2DValue;
  8469. const AValue: Double);
  8470. begin
  8471. FHandle.m[Ord(AIndex)] := AValue;
  8472. end;
  8473. procedure TBLMatrix2D.Skew(const AP: TBLPoint);
  8474. begin
  8475. _BLCheck(blMatrix2DApplyOp(@FHandle, BL_MATRIX2D_OP_SKEW, @AP));
  8476. end;
  8477. procedure TBLMatrix2D.Skew(const AX, AY: Double);
  8478. var
  8479. Data: array [0..1] of Double;
  8480. begin
  8481. Data[0] := AX;
  8482. Data[1] := AY;
  8483. _BLCheck(blMatrix2DApplyOp(@FHandle, BL_MATRIX2D_OP_SKEW, @Data));
  8484. end;
  8485. procedure TBLMatrix2D.Transform(const AMatrix: TBLMatrix2D);
  8486. begin
  8487. _BLCheck(blMatrix2DApplyOp(@FHandle, BL_MATRIX2D_OP_TRANSFORM, @AMatrix));
  8488. end;
  8489. procedure TBLMatrix2D.Translate(const AX, AY: Double);
  8490. begin
  8491. FHandle.m20 := FHandle.m20 + (AX * FHandle.m00) + (AY * FHandle.m10);
  8492. FHandle.m21 := FHandle.m21 + (AX * FHandle.m01) + (AY * FHandle.m11);
  8493. end;
  8494. procedure TBLMatrix2D.Translate(const AP: TBLPoint);
  8495. begin
  8496. Translate(AP.FHandle.x, AP.FHandle.y);
  8497. end;
  8498. procedure TBLMatrix2D.Translate(const AP: TBLPointI);
  8499. begin
  8500. Translate(AP.FHandle.x, AP.FHandle.y);
  8501. end;
  8502. {$ENDREGION 'Matrix'}
  8503. {$REGION 'Random'}
  8504. { TBLRandom }
  8505. class operator TBLRandom.Equal(const ALeft, ARight: TBLRandom): Boolean;
  8506. begin
  8507. Result := ALeft.Equals(ARight);
  8508. end;
  8509. function TBLRandom.Equals(const AOther: TBLRandom): Boolean;
  8510. begin
  8511. Result := (FHandle.data[0] = AOther.FHandle.data[0])
  8512. and (FHandle.data[1] = AOther.FHandle.data[1]);
  8513. end;
  8514. function TBLRandom.NextDouble: Double;
  8515. begin
  8516. Result := blRandomNextDouble(@FHandle);
  8517. end;
  8518. function TBLRandom.NextUInt32: UInt32;
  8519. begin
  8520. Result := blRandomNextUInt32(@FHandle);
  8521. end;
  8522. function TBLRandom.NextUInt64: UInt64;
  8523. begin
  8524. Result := blRandomNextUInt64(@FHandle);
  8525. end;
  8526. class operator TBLRandom.NotEqual(const ALeft, ARight: TBLRandom): Boolean;
  8527. begin
  8528. Result := not ALeft.Equals(ARight);
  8529. end;
  8530. procedure TBLRandom.Reset(const ASeed: UInt64);
  8531. begin
  8532. blRandomReset(@FHandle, ASeed);
  8533. end;
  8534. {$ENDREGION 'Random'}
  8535. {$REGION 'Gradient'}
  8536. { TBLGradientStop }
  8537. function BLGradientStop(const AOffset: Double; const ARgba: TBLRgba32): TBLGradientStop; overload; inline;
  8538. begin
  8539. Result.Reset(AOffset, ARgba);
  8540. end;
  8541. function BLGradientStop(const AOffset: Double; const ARgba: TBLRgba64): TBLGradientStop; overload; inline;
  8542. begin
  8543. Result.Reset(AOffset, ARgba);
  8544. end;
  8545. class operator TBLGradientStop.Equal(const ALeft,
  8546. ARight: TBLGradientStop): Boolean;
  8547. begin
  8548. Result := (ALeft.FHandle.offset = ARight.FHandle.offset)
  8549. and (ALeft.FHandle.rgba.value = ARight.FHandle.rgba.value);
  8550. end;
  8551. function TBLGradientStop.Equals(const AOther: TBLGradientStop): Boolean;
  8552. begin
  8553. Result := (Self = AOther);
  8554. end;
  8555. function TBLGradientStop.GetRgba: TBLRgba64;
  8556. begin
  8557. Result.FHandle.value := FHandle.rgba.value;
  8558. end;
  8559. class operator TBLGradientStop.NotEqual(const ALeft,
  8560. ARight: TBLGradientStop): Boolean;
  8561. begin
  8562. Result := not (ALeft = ARight);
  8563. end;
  8564. procedure TBLGradientStop.Reset(const AOffset: Double; const ARgba: TBLRgba64);
  8565. begin
  8566. FHandle.offset := AOffset;
  8567. FHandle.rgba.value := ARgba.FHandle.value;
  8568. end;
  8569. procedure TBLGradientStop.Reset(const AOffset: Double; const ARgba: TBLRgba32);
  8570. begin
  8571. FHandle.offset := AOffset;
  8572. TBLRgba64(FHandle.rgba).Reset(ARgba);
  8573. end;
  8574. procedure TBLGradientStop.Reset;
  8575. begin
  8576. FHandle.offset := 0;
  8577. FHandle.rgba.value := 0;
  8578. end;
  8579. procedure TBLGradientStop.SetRgba(const AValue: TBLRgba64);
  8580. begin
  8581. FHandle.rgba.value := AValue.FHandle.value;
  8582. end;
  8583. { TBLLinearGradientValues }
  8584. function BLLinearGradientValues(const AX0, AY0, AX1, AY1: Double): TBLLinearGradientValues; inline;
  8585. begin
  8586. Result.Reset(AX0, AY0, AX1, AY1);
  8587. end;
  8588. procedure TBLLinearGradientValues.Reset(const AX0, AY0, AX1, AY1: Double);
  8589. begin
  8590. FHandle.x0 := AX0;
  8591. FHandle.y0 := AY0;
  8592. FHandle.x1 := AX1;
  8593. FHandle.y1 := AY1;
  8594. end;
  8595. procedure TBLLinearGradientValues.Reset;
  8596. begin
  8597. FillChar(FHandle, SizeOf(FHandle), 0);
  8598. end;
  8599. { TBLRadialGradientValues }
  8600. function BLRadialGradientValues(const AX0, AY0, AX1, AY1, AR0: Double): TBLRadialGradientValues; inline;
  8601. begin
  8602. Result.Reset(AX0, AY0, AX1, AY1, AR0);
  8603. end;
  8604. procedure TBLRadialGradientValues.Reset(const AX0, AY0, AX1, AY1, AR0: Double);
  8605. begin
  8606. FHandle.x0 := AX0;
  8607. FHandle.y0 := AY0;
  8608. FHandle.x1 := AX1;
  8609. FHandle.y1 := AY1;
  8610. FHandle.r0 := AR0;
  8611. end;
  8612. procedure TBLRadialGradientValues.Reset;
  8613. begin
  8614. FillChar(FHandle, SizeOf(FHandle), 0);
  8615. end;
  8616. { TBLConicalGradientValues }
  8617. function BLConicalGradientValues(const AX0, AY0, AAngle: Double): TBLConicalGradientValues; inline;
  8618. begin
  8619. Result.Reset(AX0, AY0, AAngle);
  8620. end;
  8621. procedure TBLConicalGradientValues.Reset(const AX0, AY0, AAngle: Double);
  8622. begin
  8623. FHandle.x0 := AX0;
  8624. FHandle.y0 := AY0;
  8625. FHandle.angle := AAngle;
  8626. end;
  8627. procedure TBLConicalGradientValues.Reset;
  8628. begin
  8629. FillChar(FHandle, SizeOf(FHandle), 0);
  8630. end;
  8631. { TBLGradient }
  8632. procedure TBLGradient.AddStop(const AOffset: Double; const ARgba: TBLRgba64);
  8633. begin
  8634. _BLCheck(blGradientAddStopRgba64(@FHandle, AOffset, ARgba.FHandle.value));
  8635. end;
  8636. procedure TBLGradient.AddStop(const AOffset: Double; const ARgba: TBLRgba32);
  8637. begin
  8638. _BLCheck(blGradientAddStopRgba32(@FHandle, AOffset, ARgba.FHandle.value));
  8639. end;
  8640. constructor TBLGradient.Create;
  8641. begin
  8642. inherited;
  8643. blGradientInit(@FHandle);
  8644. end;
  8645. constructor TBLGradient.Create(const AValues: TBLRadialGradientValues;
  8646. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>);
  8647. begin
  8648. inherited Create;
  8649. _BLCheck(blGradientInitAs(@FHandle, BL_GRADIENT_TYPE_RADIAL, @AValues.FHandle,
  8650. Ord(AExtendMode), Pointer(AStops), Length(AStops), nil));
  8651. end;
  8652. constructor TBLGradient.Create(const AValues: TBLLinearGradientValues;
  8653. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>);
  8654. begin
  8655. inherited Create;
  8656. _BLCheck(blGradientInitAs(@FHandle, BL_GRADIENT_TYPE_LINEAR, @AValues.FHandle,
  8657. Ord(AExtendMode), Pointer(AStops), Length(AStops), nil));
  8658. end;
  8659. constructor TBLGradient.Create(const AType: TBLGradientType;
  8660. const AValues: PDouble);
  8661. begin
  8662. inherited Create;
  8663. _BLCheck(blGradientInitAs(@FHandle, Ord(AType), AValues, BL_EXTEND_MODE_PAD,
  8664. nil, 0, nil));
  8665. end;
  8666. constructor TBLGradient.Create(const AValues: TBLConicalGradientValues;
  8667. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>);
  8668. begin
  8669. inherited Create;
  8670. _BLCheck(blGradientInitAs(@FHandle, BL_GRADIENT_TYPE_CONICAL, @AValues.FHandle,
  8671. Ord(AExtendMode), Pointer(AStops), Length(AStops), nil));
  8672. end;
  8673. constructor TBLGradient.Create(const AValues: TBLConicalGradientValues;
  8674. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>;
  8675. const AMatrix: TBLMatrix2D);
  8676. begin
  8677. inherited Create;
  8678. _BLCheck(blGradientInitAs(@FHandle, BL_GRADIENT_TYPE_CONICAL, @AValues.FHandle,
  8679. Ord(AExtendMode), Pointer(AStops), Length(AStops), @AMatrix));
  8680. end;
  8681. constructor TBLGradient.Create(const AHandle: BLGradientCore;
  8682. const AIsReference: Boolean);
  8683. begin
  8684. inherited Create;
  8685. FHandle := AHandle;
  8686. FIsReference := AIsReference;
  8687. end;
  8688. constructor TBLGradient.Create(const AValues: TBLRadialGradientValues;
  8689. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>;
  8690. const AMatrix: TBLMatrix2D);
  8691. begin
  8692. inherited Create;
  8693. _BLCheck(blGradientInitAs(@FHandle, BL_GRADIENT_TYPE_RADIAL, @AValues.FHandle,
  8694. Ord(AExtendMode), Pointer(AStops), Length(AStops), @AMatrix));
  8695. end;
  8696. constructor TBLGradient.Create(const AValues: TBLLinearGradientValues;
  8697. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>;
  8698. const AMatrix: TBLMatrix2D);
  8699. begin
  8700. inherited Create;
  8701. _BLCheck(blGradientInitAs(@FHandle, BL_GRADIENT_TYPE_LINEAR, @AValues.FHandle,
  8702. Ord(AExtendMode), Pointer(AStops), Length(AStops), @AMatrix));
  8703. end;
  8704. destructor TBLGradient.Destroy;
  8705. begin
  8706. if (not FIsReference) then
  8707. blGradientDestroy(@FHandle);
  8708. inherited;
  8709. end;
  8710. function TBLGradient.Equals(Obj: TObject): Boolean;
  8711. begin
  8712. if (Obj = nil) then
  8713. Result := (Self = nil)
  8714. else if (Obj = Self) then
  8715. Result := True
  8716. else if (Obj is TBLGradient) then
  8717. Result := blGradientEquals(@FHandle, @TBLGradient(Obj).FHandle)
  8718. else
  8719. Result := False;
  8720. end;
  8721. function TBLGradient.Equals(const AOther: IBLGradient): Boolean;
  8722. begin
  8723. if (AOther = nil) then
  8724. Result := (Self = nil)
  8725. else
  8726. Result := blGradientEquals(@FHandle, AOther.Handle);
  8727. end;
  8728. function TBLGradient.GetAllStops: PBLGradientStop;
  8729. begin
  8730. Result := PBLGradientStop(FHandle.impl.stops.stops);
  8731. end;
  8732. function TBLGradient.GetAngle: Double;
  8733. begin
  8734. Result := FHandle.impl.values[BL_GRADIENT_VALUE_CONICAL_ANGLE];
  8735. end;
  8736. function TBLGradient.GetCapacity: Integer;
  8737. begin
  8738. Result := FHandle.impl.capacity;
  8739. end;
  8740. function TBLGradient.GetConical: TBLConicalGradientValues;
  8741. begin
  8742. Result.FHandle := FHandle.impl.conical;
  8743. end;
  8744. function TBLGradient.GetExtendMode: TBLExtendMode;
  8745. begin
  8746. Result := TBLExtendMode(FHandle.impl.extendMode);
  8747. end;
  8748. function TBLGradient.GetGradientType: TBLGradientType;
  8749. begin
  8750. Result := TBLGradientType(FHandle.impl.gradientType);
  8751. end;
  8752. function TBLGradient.GetHandle: PBLGradientCore;
  8753. begin
  8754. Result := @FHandle;
  8755. end;
  8756. function TBLGradient.GetHasMatrix: Boolean;
  8757. begin
  8758. Result := ((FHandle.impl.matrixType and BL_MATRIX2D_TYPE_IDENTITY) <> 0);
  8759. end;
  8760. function TBLGradient.GetIsEmpty: Boolean;
  8761. begin
  8762. Result := (FHandle.impl.stops.size = 0);
  8763. end;
  8764. function TBLGradient.GetIsNone: Boolean;
  8765. begin
  8766. Result := ((FHandle.impl.implTraits and BL_IMPL_TRAIT_NULL) <> 0);
  8767. end;
  8768. function TBLGradient.GetLinear: TBLLinearGradientValues;
  8769. begin
  8770. Result.FHandle := FHandle.impl.linear;
  8771. end;
  8772. function TBLGradient.GetMatrix: TBLMatrix2D;
  8773. begin
  8774. Result.FHandle := FHandle.impl.matrix;
  8775. end;
  8776. function TBLGradient.GetMatrixType: TBLMatrix2DType;
  8777. begin
  8778. Result := TBLMatrix2DType(FHandle.impl.matrixType);
  8779. end;
  8780. function TBLGradient.GetR0: Double;
  8781. begin
  8782. Result := FHandle.impl.values[BL_GRADIENT_VALUE_RADIAL_R0];
  8783. end;
  8784. function TBLGradient.GetRadial: TBLRadialGradientValues;
  8785. begin
  8786. Result.FHandle := FHandle.impl.radial;
  8787. end;
  8788. function TBLGradient.GetSize: Integer;
  8789. begin
  8790. Result := FHandle.impl.stops.size;
  8791. end;
  8792. function TBLGradient.GetStop(const AIndex: Integer): TBLGradientStop;
  8793. begin
  8794. Assert(Cardinal(AIndex) < FHandle.impl.stops.size);
  8795. Result := TBLGradientStop(FHandle.impl.stops.stops[AIndex]);
  8796. end;
  8797. function TBLGradient.GetValue(const AIndex: TBLGradientValue): Double;
  8798. begin
  8799. Result := FHandle.impl.values[Ord(AIndex)];
  8800. end;
  8801. function TBLGradient.GetX0: Double;
  8802. begin
  8803. Result := FHandle.impl.values[BL_GRADIENT_VALUE_COMMON_X0];
  8804. end;
  8805. function TBLGradient.GetX1: Double;
  8806. begin
  8807. Result := FHandle.impl.values[BL_GRADIENT_VALUE_COMMON_X1];
  8808. end;
  8809. function TBLGradient.GetY0: Double;
  8810. begin
  8811. Result := FHandle.impl.values[BL_GRADIENT_VALUE_COMMON_Y0];
  8812. end;
  8813. function TBLGradient.GetY1: Double;
  8814. begin
  8815. Result := FHandle.impl.values[BL_GRADIENT_VALUE_COMMON_Y1];
  8816. end;
  8817. function TBLGradient.IndexOfStop(const AOffset: Double): Integer;
  8818. begin
  8819. Result := blGradientIndexOfStop(@FHandle, AOffset);
  8820. end;
  8821. procedure TBLGradient.Initialize(const AValues: TBLConicalGradientValues;
  8822. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>;
  8823. const AMatrix: TBLMatrix2D);
  8824. begin
  8825. _BLCheck(blGradientCreate(@FHandle, BL_GRADIENT_TYPE_CONICAL, @AValues,
  8826. Ord(AExtendMode), Pointer(AStops), Length(AStops), @AMatrix));
  8827. end;
  8828. procedure TBLGradient.Initialize(const AValues: TBLConicalGradientValues;
  8829. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>);
  8830. begin
  8831. _BLCheck(blGradientCreate(@FHandle, BL_GRADIENT_TYPE_CONICAL, @AValues,
  8832. Ord(AExtendMode), Pointer(AStops), Length(AStops), nil));
  8833. end;
  8834. procedure TBLGradient.Initialize(const AValues: TBLRadialGradientValues;
  8835. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>);
  8836. begin
  8837. _BLCheck(blGradientCreate(@FHandle, BL_GRADIENT_TYPE_RADIAL, @AValues,
  8838. Ord(AExtendMode), Pointer(AStops), Length(AStops), nil));
  8839. end;
  8840. procedure TBLGradient.Initialize(const AValues: TBLLinearGradientValues;
  8841. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>);
  8842. begin
  8843. _BLCheck(blGradientCreate(@FHandle, BL_GRADIENT_TYPE_LINEAR, @AValues,
  8844. Ord(AExtendMode), Pointer(AStops), Length(AStops), nil));
  8845. end;
  8846. procedure TBLGradient.Initialize(const AValues: TBLRadialGradientValues;
  8847. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>;
  8848. const AMatrix: TBLMatrix2D);
  8849. begin
  8850. _BLCheck(blGradientCreate(@FHandle, BL_GRADIENT_TYPE_RADIAL, @AValues,
  8851. Ord(AExtendMode), Pointer(AStops), Length(AStops), @AMatrix));
  8852. end;
  8853. procedure TBLGradient.Initialize(const AValues: TBLLinearGradientValues;
  8854. const AExtendMode: TBLExtendMode; const AStops: TArray<TBLGradientStop>;
  8855. const AMatrix: TBLMatrix2D);
  8856. begin
  8857. _BLCheck(blGradientCreate(@FHandle, BL_GRADIENT_TYPE_LINEAR, @AValues,
  8858. Ord(AExtendMode), Pointer(AStops), Length(AStops), @AMatrix));
  8859. end;
  8860. procedure TBLGradient.PostRotate(const AAngle: Double);
  8861. begin
  8862. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_ROTATE, @AAngle));
  8863. end;
  8864. procedure TBLGradient.PostRotate(const AAngle, AX, AY: Double);
  8865. var
  8866. Data: array [0..2] of Double;
  8867. begin
  8868. Data[0] := AAngle;
  8869. Data[1] := AX;
  8870. Data[2] := AY;
  8871. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_ROTATE_PT, @Data));
  8872. end;
  8873. procedure TBLGradient.PostRotate(const AAngle: Double; const AP: TBLPointI);
  8874. var
  8875. Data: array [0..2] of Double;
  8876. begin
  8877. Data[0] := AAngle;
  8878. Data[1] := AP.FHandle.x;
  8879. Data[2] := AP.FHandle.y;
  8880. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_ROTATE_PT, @Data));
  8881. end;
  8882. procedure TBLGradient.PostRotate(const AAngle: Double; const AP: TBLPoint);
  8883. var
  8884. Data: array [0..2] of Double;
  8885. begin
  8886. Data[0] := AAngle;
  8887. Data[1] := AP.FHandle.x;
  8888. Data[2] := AP.FHandle.y;
  8889. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_ROTATE_PT, @Data));
  8890. end;
  8891. procedure TBLGradient.PostScale(const AP: TBLPoint);
  8892. begin
  8893. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SCALE, @AP));
  8894. end;
  8895. procedure TBLGradient.PostScale(const AP: TBLPointI);
  8896. var
  8897. Data: array [0..1] of Double;
  8898. begin
  8899. Data[0] := AP.FHandle.x;
  8900. Data[1] := AP.FHandle.y;
  8901. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SCALE, @Data));
  8902. end;
  8903. procedure TBLGradient.PostScale(const AX, AY: Double);
  8904. var
  8905. Data: array [0..1] of Double;
  8906. begin
  8907. Data[0] := AX;
  8908. Data[1] := AY;
  8909. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SCALE, @Data));
  8910. end;
  8911. procedure TBLGradient.PostScale(const AXY: Double);
  8912. var
  8913. Data: array [0..1] of Double;
  8914. begin
  8915. Data[0] := AXY;
  8916. Data[1] := AXY;
  8917. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SCALE, @Data));
  8918. end;
  8919. procedure TBLGradient.PostSkew(const AX, AY: Double);
  8920. var
  8921. Data: array [0..1] of Double;
  8922. begin
  8923. Data[0] := AX;
  8924. Data[1] := AY;
  8925. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SKEW, @Data));
  8926. end;
  8927. procedure TBLGradient.PostSkew(const AP: TBLPoint);
  8928. begin
  8929. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SKEW, @AP));
  8930. end;
  8931. procedure TBLGradient.PostTransform(const AMatrix: TBLMatrix2D);
  8932. begin
  8933. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_TRANSFORM, @AMatrix));
  8934. end;
  8935. procedure TBLGradient.PostTranslate(const AP: TBLPoint);
  8936. begin
  8937. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_TRANSLATE, @AP));
  8938. end;
  8939. procedure TBLGradient.PostTranslate(const AX, AY: Double);
  8940. var
  8941. Data: array [0..1] of Double;
  8942. begin
  8943. Data[0] := AX;
  8944. Data[1] := AY;
  8945. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_TRANSLATE, @Data));
  8946. end;
  8947. procedure TBLGradient.PostTranslate(const AP: TBLPointI);
  8948. var
  8949. Data: array [0..1] of Double;
  8950. begin
  8951. Data[0] := AP.FHandle.x;
  8952. Data[1] := AP.FHandle.y;
  8953. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_TRANSLATE, @Data));
  8954. end;
  8955. procedure TBLGradient.RemoveStop(const AIndex: Integer);
  8956. begin
  8957. _BLCheck(blGradientRemoveStop(@FHandle, AIndex));
  8958. end;
  8959. procedure TBLGradient.RemoveStopByOffset(const AOffset: Double;
  8960. const AAll: Boolean);
  8961. begin
  8962. _BLCheck(blGradientRemoveStopByOffset(@FHandle, AOffset, Ord(AAll)));
  8963. end;
  8964. procedure TBLGradient.RemoveStops(const ARange: TBLRange);
  8965. begin
  8966. _BLCheck(blGradientRemoveStops(@FHandle, ARange.FHandle.start, ARange.FHandle.&end));
  8967. end;
  8968. procedure TBLGradient.RemoveStopsByOffset(const AOffsetMin, AOffsetMax: Double);
  8969. begin
  8970. _BLCheck(blGradientRemoveStopsFromTo(@FHandle, AOffsetMin, AOffsetMax));
  8971. end;
  8972. procedure TBLGradient.ReplaceStop(const AIndex: Integer; const AOffset: Double;
  8973. const ARgba: TBLRgba64);
  8974. begin
  8975. _BLCheck(blGradientReplaceStopRgba64(@FHandle, AIndex, AOffset, ARgba.FHandle.value));
  8976. end;
  8977. procedure TBLGradient.ReplaceStop(const AIndex: Integer; const AOffset: Double;
  8978. const ARgba: TBLRgba32);
  8979. begin
  8980. _BLCheck(blGradientReplaceStopRgba32(@FHandle, AIndex, AOffset, ARgba.FHandle.value));
  8981. end;
  8982. procedure TBLGradient.Reserve(const ACount: Integer);
  8983. begin
  8984. _BLCheck(blGradientReserve(@FHandle, ACount));
  8985. end;
  8986. procedure TBLGradient.Reset;
  8987. begin
  8988. _BLCheck(blGradientReset(@FHandle));
  8989. end;
  8990. procedure TBLGradient.ResetExtendMode;
  8991. begin
  8992. _BLCheck(blGradientSetExtendMode(@FHandle, BL_EXTEND_MODE_PAD));
  8993. end;
  8994. procedure TBLGradient.ResetMatrix;
  8995. begin
  8996. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_RESET, nil));
  8997. end;
  8998. procedure TBLGradient.ResetStops;
  8999. begin
  9000. _BLCheck(blGradientResetStops(@FHandle));
  9001. end;
  9002. procedure TBLGradient.Rotate(const AAngle: Double; const AP: TBLPoint);
  9003. var
  9004. Data: array [0..2] of Double;
  9005. begin
  9006. Data[0] := AAngle;
  9007. Data[1] := AP.FHandle.x;
  9008. Data[2] := AP.FHandle.y;
  9009. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_ROTATE_PT, @Data));
  9010. end;
  9011. procedure TBLGradient.Rotate(const AAngle, AX, AY: Double);
  9012. var
  9013. Data: array [0..2] of Double;
  9014. begin
  9015. Data[0] := AAngle;
  9016. Data[1] := AX;
  9017. Data[2] := AY;
  9018. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_ROTATE_PT, @Data));
  9019. end;
  9020. procedure TBLGradient.Rotate(const AAngle: Double);
  9021. begin
  9022. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_ROTATE, @AAngle));
  9023. end;
  9024. procedure TBLGradient.Rotate(const AAngle: Double; const AP: TBLPointI);
  9025. var
  9026. Data: array [0..2] of Double;
  9027. begin
  9028. Data[0] := AAngle;
  9029. Data[1] := AP.FHandle.x;
  9030. Data[2] := AP.FHandle.y;
  9031. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_ROTATE_PT, @Data));
  9032. end;
  9033. procedure TBLGradient.Scale(const AX, AY: Double);
  9034. var
  9035. Data: array [0..1] of Double;
  9036. begin
  9037. Data[0] := AX;
  9038. Data[1] := AY;
  9039. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_SCALE, @Data));
  9040. end;
  9041. procedure TBLGradient.Scale(const AXY: Double);
  9042. var
  9043. Data: array [0..1] of Double;
  9044. begin
  9045. Data[0] := AXY;
  9046. Data[1] := AXY;
  9047. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_SCALE, @Data));
  9048. end;
  9049. procedure TBLGradient.Scale(const AP: TBLPointI);
  9050. var
  9051. Data: array [0..1] of Double;
  9052. begin
  9053. Data[0] := AP.FHandle.x;
  9054. Data[1] := AP.FHandle.y;
  9055. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_SCALE, @Data));
  9056. end;
  9057. procedure TBLGradient.Scale(const AP: TBLPoint);
  9058. begin
  9059. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_SCALE, @AP));
  9060. end;
  9061. procedure TBLGradient.SetAngle(const AValue: Double);
  9062. begin
  9063. _BLCheck(blGradientSetValue(@FHandle, BL_GRADIENT_VALUE_CONICAL_ANGLE, AValue));
  9064. end;
  9065. procedure TBLGradient.SetConical(const AValue: TBLConicalGradientValues);
  9066. begin
  9067. _BLCheck(blGradientSetValues(@FHandle, 0, @AValue, SizeOf(AValue) div SizeOf(Double)));
  9068. end;
  9069. procedure TBLGradient.SetExtendMode(const AValue: TBLExtendMode);
  9070. begin
  9071. _BLCheck(blGradientSetExtendMode(@FHandle, Ord(AValue)));
  9072. end;
  9073. procedure TBLGradient.SetGradientType(const AValue: TBLGradientType);
  9074. begin
  9075. _BLCheck(blGradientSetType(@FHandle, Ord(AValue)));
  9076. end;
  9077. procedure TBLGradient.SetLinear(const AValue: TBLLinearGradientValues);
  9078. begin
  9079. _BLCheck(blGradientSetValues(@FHandle, 0, @AValue, SizeOf(AValue) div SizeOf(Double)));
  9080. end;
  9081. procedure TBLGradient.SetMatrix(const AValue: TBLMatrix2D);
  9082. begin
  9083. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_ASSIGN, @AValue));
  9084. end;
  9085. procedure TBLGradient.SetR0(const AValue: Double);
  9086. begin
  9087. _BLCheck(blGradientSetValue(@FHandle, BL_GRADIENT_VALUE_RADIAL_R0, AValue));
  9088. end;
  9089. procedure TBLGradient.SetRadial(const AValue: TBLRadialGradientValues);
  9090. begin
  9091. _BLCheck(blGradientSetValues(@FHandle, 0, @AValue, SizeOf(AValue) div SizeOf(Double)));
  9092. end;
  9093. procedure TBLGradient.SetStop(const AIndex: Integer;
  9094. const AValue: TBLGradientStop);
  9095. begin
  9096. _BLCheck(blGradientReplaceStopRgba64(@FHandle, AIndex, AValue.FHandle.offset,
  9097. AValue.FHandle.rgba.value));
  9098. end;
  9099. procedure TBLGradient.SetStops(const AStops: TArray<TBLGradientStop>);
  9100. begin
  9101. _BLCheck(blGradientAssignStops(@FHandle, Pointer(AStops), Length(AStops)));
  9102. end;
  9103. procedure TBLGradient.SetValue(const AIndex: TBLGradientValue;
  9104. const AValue: Double);
  9105. begin
  9106. _BLCheck(blGradientSetValue(@FHandle, Ord(AIndex), AValue));
  9107. end;
  9108. procedure TBLGradient.SetValues(const AValues: TBLLinearGradientValues);
  9109. begin
  9110. _BLCheck(blGradientSetValues(@FHandle, 0, @AValues, SizeOf(TBLLinearGradientValues) div SizeOf(Double)));
  9111. end;
  9112. procedure TBLGradient.SetValues(const AValues: TBLRadialGradientValues);
  9113. begin
  9114. _BLCheck(blGradientSetValues(@FHandle, 0, @AValues, SizeOf(TBLRadialGradientValues) div SizeOf(Double)));
  9115. end;
  9116. procedure TBLGradient.SetValues(const AValues: TBLConicalGradientValues);
  9117. begin
  9118. _BLCheck(blGradientSetValues(@FHandle, 0, @AValues, SizeOf(TBLConicalGradientValues) div SizeOf(Double)));
  9119. end;
  9120. procedure TBLGradient.SetValues(const AIndex: TBLGradientValue;
  9121. const AValues: TArray<Double>);
  9122. begin
  9123. _BLCheck(blGradientSetValues(@FHandle, Ord(AIndex), Pointer(AValues), Length(AValues)));
  9124. end;
  9125. procedure TBLGradient.SetX0(const AValue: Double);
  9126. begin
  9127. _BLCheck(blGradientSetValue(@FHandle, BL_GRADIENT_VALUE_COMMON_X0, AValue));
  9128. end;
  9129. procedure TBLGradient.SetX1(const AValue: Double);
  9130. begin
  9131. _BLCheck(blGradientSetValue(@FHandle, BL_GRADIENT_VALUE_COMMON_X1, AValue));
  9132. end;
  9133. procedure TBLGradient.SetY0(const AValue: Double);
  9134. begin
  9135. _BLCheck(blGradientSetValue(@FHandle, BL_GRADIENT_VALUE_COMMON_Y0, AValue));
  9136. end;
  9137. procedure TBLGradient.SetY1(const AValue: Double);
  9138. begin
  9139. _BLCheck(blGradientSetValue(@FHandle, BL_GRADIENT_VALUE_COMMON_Y1, AValue));
  9140. end;
  9141. procedure TBLGradient.Shrink;
  9142. begin
  9143. _BLCheck(blGradientShrink(@FHandle));
  9144. end;
  9145. procedure TBLGradient.Skew(const AX, AY: Double);
  9146. var
  9147. Data: array [0..1] of Double;
  9148. begin
  9149. Data[0] := AX;
  9150. Data[1] := AY;
  9151. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_SKEW, @Data));
  9152. end;
  9153. procedure TBLGradient.Skew(const AP: TBLPoint);
  9154. begin
  9155. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_SKEW, @AP));
  9156. end;
  9157. procedure TBLGradient.Transform(const AMatrix: TBLMatrix2D);
  9158. begin
  9159. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_TRANSFORM, @AMatrix));
  9160. end;
  9161. procedure TBLGradient.Translate(const AP: TBLPoint);
  9162. begin
  9163. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_TRANSLATE, @AP));
  9164. end;
  9165. procedure TBLGradient.Translate(const AX, AY: Double);
  9166. var
  9167. Data: array [0..1] of Double;
  9168. begin
  9169. Data[0] := AX;
  9170. Data[1] := AY;
  9171. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_TRANSLATE, @Data));
  9172. end;
  9173. procedure TBLGradient.Translate(const AP: TBLPointI);
  9174. var
  9175. Data: array [0..1] of Double;
  9176. begin
  9177. Data[0] := AP.FHandle.x;
  9178. Data[1] := AP.FHandle.y;
  9179. _BLCheck(blGradientApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_TRANSLATE, @Data));
  9180. end;
  9181. {$ENDREGION 'Gradient'}
  9182. {$REGION 'Region'}
  9183. { TBLRegion }
  9184. procedure TBLRegion.Assign(const ABoxes: PBLBoxI; const ACount: Integer);
  9185. begin
  9186. _BLCheck(blRegionAssignBoxIArray(@FHandle, Pointer(ABoxes), ACount));
  9187. end;
  9188. procedure TBLRegion.Assign(const ABoxes: TArray<TBLBoxI>);
  9189. begin
  9190. _BLCheck(blRegionAssignBoxIArray(@FHandle, Pointer(ABoxes), Length(ABoxes)));
  9191. end;
  9192. procedure TBLRegion.Assign(const ABox: TBLBoxI);
  9193. begin
  9194. _BLCheck(blRegionAssignBoxI(@FHandle, @ABox));
  9195. end;
  9196. procedure TBLRegion.Assign(const ARects: PBLRectI; const ACount: Integer);
  9197. begin
  9198. _BLCheck(blRegionAssignRectIArray(@FHandle, Pointer(ARects), ACount));
  9199. end;
  9200. procedure TBLRegion.Assign(const ARect: TBLRectI);
  9201. begin
  9202. _BLCheck(blRegionAssignRectI(@FHandle, @ARect));
  9203. end;
  9204. procedure TBLRegion.Assign(const ARects: TArray<TBLRectI>);
  9205. begin
  9206. _BLCheck(blRegionAssignRectIArray(@FHandle, Pointer(ARects), Length(ARects)));
  9207. end;
  9208. procedure TBLRegion.Clear;
  9209. begin
  9210. _BLCheck(blRegionClear(@FHandle));
  9211. end;
  9212. function TBLRegion.Clone: IBLRegion;
  9213. begin
  9214. Result := TBLRegion.Create;
  9215. _BLCheck(blRegionAssignDeep(Result.Handle, @FHandle));
  9216. end;
  9217. class function TBLRegion.Combine(const AA, AB: IBLRegion;
  9218. const ABooleanOp: TBLBooleanOp): IBLRegion;
  9219. begin
  9220. Result := TBLRegion.Create;
  9221. if (AA <> nil) and (AB <> nil) then
  9222. _BLCheck(blRegionCombine(Result.Handle, AA.Handle, AB.Handle, Ord(ABooleanOp)));
  9223. end;
  9224. procedure TBLRegion.Combine(const ABox: TBLBoxI;
  9225. const ABooleanOp: TBLBooleanOp);
  9226. begin
  9227. _BLCheck(blRegionCombineRB(@FHandle, @FHandle, @ABox, Ord(ABooleanOp)));
  9228. end;
  9229. procedure TBLRegion.Combine(const ARegion: IBLRegion;
  9230. const ABooleanOp: TBLBooleanOp);
  9231. begin
  9232. if (ARegion <> nil) then
  9233. _BLCheck(blRegionCombine(@FHandle, @FHandle, ARegion.Handle, Ord(ABooleanOp)));
  9234. end;
  9235. class function TBLRegion.Combine(const AA, AB: TBLBoxI;
  9236. const ABooleanOp: TBLBooleanOp): IBLRegion;
  9237. begin
  9238. Result := TBLRegion.Create;
  9239. _BLCheck(blRegionCombineBB(Result.Handle, @AA, @AB, Ord(ABooleanOp)));
  9240. end;
  9241. class function TBLRegion.Combine(const AA: TBLBoxI; const AB: IBLRegion;
  9242. const ABooleanOp: TBLBooleanOp): IBLRegion;
  9243. begin
  9244. Result := TBLRegion.Create;
  9245. if (AB <> nil) then
  9246. _BLCheck(blRegionCombineBR(Result.Handle, @AA, AB.Handle, Ord(ABooleanOp)));
  9247. end;
  9248. class function TBLRegion.Combine(const AA: IBLRegion; const AB: TBLBoxI;
  9249. const ABooleanOp: TBLBooleanOp): IBLRegion;
  9250. begin
  9251. Result := TBLRegion.Create;
  9252. if (AA <> nil) then
  9253. _BLCheck(blRegionCombineRB(Result.Handle, AA.Handle, @AB, Ord(ABooleanOp)));
  9254. end;
  9255. constructor TBLRegion.Create;
  9256. begin
  9257. inherited;
  9258. blRegionInit(@FHandle);
  9259. end;
  9260. destructor TBLRegion.Destroy;
  9261. begin
  9262. blRegionDestroy(@FHandle);
  9263. inherited;
  9264. end;
  9265. function TBLRegion.Equals(Obj: TObject): Boolean;
  9266. begin
  9267. if (Obj = nil) then
  9268. Result := (Self = nil)
  9269. else if (Obj = Self) then
  9270. Result := True
  9271. else if (Obj is TBLRegion) then
  9272. Result := blRegionEquals(@FHandle, @TBLRegion(Obj).FHandle)
  9273. else
  9274. Result := False;
  9275. end;
  9276. function TBLRegion.Equals(const AOther: IBLRegion): Boolean;
  9277. begin
  9278. if (AOther = nil) then
  9279. Result := (Self = nil)
  9280. else
  9281. Result := blRegionEquals(@FHandle, AOther.Handle);
  9282. end;
  9283. function TBLRegion.GetBoundingBox: TBLBoxI;
  9284. begin
  9285. Result.FHandle := FHandle.impl.boundingBox;
  9286. end;
  9287. function TBLRegion.GetCapacity: Integer;
  9288. begin
  9289. Result := FHandle.impl.capacity;
  9290. end;
  9291. function TBLRegion.GetData: PBLBoxI;
  9292. begin
  9293. Result := Pointer(FHandle.impl.data.data);
  9294. end;
  9295. function TBLRegion.GetDataEnd: PBLBoxI;
  9296. begin
  9297. Result := Pointer(FHandle.impl.data.data);
  9298. Inc(Result, FHandle.impl.data.size);
  9299. end;
  9300. function TBLRegion.GetHandle: PBLRegionCore;
  9301. begin
  9302. Result := @FHandle;
  9303. end;
  9304. function TBLRegion.GetIsComplex: Boolean;
  9305. begin
  9306. Result := (FHandle.impl.data.size > 1);
  9307. end;
  9308. function TBLRegion.GetIsEmpty: Boolean;
  9309. begin
  9310. Result := (FHandle.impl.data.size = 0);
  9311. end;
  9312. function TBLRegion.GetIsNone: Boolean;
  9313. begin
  9314. Result := ((FHandle.impl.implTraits and BL_IMPL_TRAIT_NULL) <> 0);
  9315. end;
  9316. function TBLRegion.GetIsRect: Boolean;
  9317. begin
  9318. Result := (FHandle.impl.data.size = 1);
  9319. end;
  9320. function TBLRegion.GetRegionType: TBLRegionType;
  9321. begin
  9322. Result := TBLRegionType(Min(FHandle.impl.data.size, BL_REGION_TYPE_COMPLEX));
  9323. end;
  9324. function TBLRegion.GetSize: Integer;
  9325. begin
  9326. Result := FHandle.impl.data.size;
  9327. end;
  9328. function TBLRegion.GetView: TBLRegionView;
  9329. begin
  9330. Result.FHandle := BLArrayView(FHandle.impl.data.view);
  9331. end;
  9332. function TBLRegion.HitTest(const ABox: TBLBoxI): TBLHitTest;
  9333. begin
  9334. Result := TBLHitTest(blRegionHitTestBoxI(@FHandle, @ABox));
  9335. end;
  9336. function TBLRegion.HitTest(const APt: TBLPointI): TBLHitTest;
  9337. begin
  9338. Result := TBLHitTest(blRegionHitTest(@FHandle, @APt));
  9339. end;
  9340. class function TBLRegion.IntersectAndClip(const AA, AB: IBLRegion;
  9341. const AClipBox: TBLBoxI): IBLRegion;
  9342. begin
  9343. Result := TBLRegion.Create;
  9344. if Assigned(AA) and Assigned(AB) then
  9345. _BLCheck(blRegionIntersectAndClip(Result.Handle, AA.Handle, AB.Handle, @AClipBox));
  9346. end;
  9347. procedure TBLRegion.IntersectAndClip(const AR: IBLRegion;
  9348. const AClipBox: TBLBoxI);
  9349. begin
  9350. if Assigned(AR) then
  9351. _BLCheck(blRegionIntersectAndClip(@FHandle, @FHandle, AR.Handle, @AClipBox));
  9352. end;
  9353. procedure TBLRegion.Reserve(const ACount: Integer);
  9354. begin
  9355. _BLCheck(blRegionReserve(@FHandle, ACount));
  9356. end;
  9357. procedure TBLRegion.Reset;
  9358. begin
  9359. _BLCheck(blRegionReset(@FHandle));
  9360. end;
  9361. procedure TBLRegion.Shrink;
  9362. begin
  9363. _BLCheck(blRegionShrink(@FHandle));
  9364. end;
  9365. procedure TBLRegion.Translate(const APt: TBLPointI);
  9366. begin
  9367. _BLCheck(blRegionTranslate(@FHandle, @FHandle, @APt));
  9368. end;
  9369. class function TBLRegion.Translate(const AR: IBLRegion;
  9370. const APt: TBLPointI): IBLRegion;
  9371. begin
  9372. Result := TBLRegion.Create;
  9373. if Assigned(AR) then
  9374. _BLCheck(blRegionTranslate(Result.Handle, AR.Handle, @APt));
  9375. end;
  9376. class function TBLRegion.TranslateAndClip(const AR: IBLRegion;
  9377. const APt: TBLPointI; const AClipBox: TBLBoxI): IBLRegion;
  9378. begin
  9379. Result := TBLRegion.Create;
  9380. if Assigned(AR) then
  9381. _BLCheck(blRegionTranslateAndClip(Result.Handle, AR.Handle, @APt, @AClipBox));
  9382. end;
  9383. procedure TBLRegion.TranslateAndClip(const APt: TBLPointI;
  9384. const AClipBox: TBLBoxI);
  9385. begin
  9386. _BLCheck(blRegionTranslateAndClip(@FHandle, @FHandle, @APt, @AClipBox));
  9387. end;
  9388. {$ENDREGION 'Region'}
  9389. {$REGION 'Path'}
  9390. { TBLApproximationOptions }
  9391. class constructor TBLApproximationOptions.Create;
  9392. begin
  9393. FillChar(FDefault, SizeOf(FDefault), 0);
  9394. FDefault.flattenTolerance := 0.2;
  9395. FDefault.simplifyTolerance := 0.05;
  9396. FDefault.offsetParameter := 0.414213562;
  9397. end;
  9398. class function TBLApproximationOptions.GetDefault: TBLApproximationOptions;
  9399. begin
  9400. Result.FHandle := FDefault;
  9401. end;
  9402. function TBLApproximationOptions.GetFlattenMode: TBLFlattenMode;
  9403. begin
  9404. Result := TBLFlattenMode(FHandle.flattenMode);
  9405. end;
  9406. function TBLApproximationOptions.GetOffsetMode: TBLOffsetMode;
  9407. begin
  9408. Result := TBLOffsetMode(FHandle.offsetMode);
  9409. end;
  9410. procedure TBLApproximationOptions.SetFlattenMode(const AValue: TBLFlattenMode);
  9411. begin
  9412. FHandle.flattenMode := Ord(AValue);
  9413. end;
  9414. procedure TBLApproximationOptions.SetOffsetMode(const AValue: TBLOffsetMode);
  9415. begin
  9416. FHandle.offsetMode := Ord(AValue);
  9417. end;
  9418. { TBLStrokeOptions }
  9419. function TBLStrokeOptions.GetDashArray: TArray<Double>;
  9420. begin
  9421. Result := TBLUtils.BLArrayToArray<Double>(FHandle.dashArray);
  9422. end;
  9423. function TBLStrokeOptions.GetEndCap: TBLStrokeCap;
  9424. begin
  9425. Result := TBLStrokeCap(FHandle.options.endCap);
  9426. end;
  9427. function TBLStrokeOptions.GetJoin: TBLStrokeJoin;
  9428. begin
  9429. Result := TBLStrokeJoin(FHandle.options.join);
  9430. end;
  9431. function TBLStrokeOptions.GetStartCap: TBLStrokeCap;
  9432. begin
  9433. Result := TBLStrokeCap(FHandle.options.startCap);
  9434. end;
  9435. function TBLStrokeOptions.GetTransformOrder: TBLStrokeTransformOrder;
  9436. begin
  9437. Result := TBLStrokeTransformOrder(FHandle.options.transformOrder);
  9438. end;
  9439. procedure TBLStrokeOptions.Reset;
  9440. begin
  9441. if (FScope <> nil) then
  9442. blStrokeOptionsReset(@FHandle)
  9443. else
  9444. begin
  9445. blStrokeOptionsInit(@FHandle);
  9446. FScope := TScope.Create(@FHandle);
  9447. end;
  9448. end;
  9449. procedure TBLStrokeOptions.SetCaps(const AStartCap, AEndCap: TBLStrokeCap);
  9450. begin
  9451. FHandle.options.startCap := Ord(AStartCap);
  9452. FHandle.options.endCap := Ord(AEndCap);
  9453. end;
  9454. procedure TBLStrokeOptions.SetCaps(const ACap: TBLStrokeCap);
  9455. begin
  9456. FHandle.options.startCap := Ord(ACap);
  9457. FHandle.options.endCap := Ord(ACap);
  9458. end;
  9459. procedure TBLStrokeOptions.SetDashArray(const AValue: TArray<Double>);
  9460. var
  9461. Value: IBLArray;
  9462. begin
  9463. blArrayReset(@FHandle.dashArray);
  9464. Value := TBLUtils.ArrayToBLArray<Double>(AValue);
  9465. Value.RevokeOwnership;
  9466. FHandle.dashArray := Value.Handle^;
  9467. end;
  9468. procedure TBLStrokeOptions.SetEndCap(const AValue: TBLStrokeCap);
  9469. begin
  9470. FHandle.options.endCap := Ord(AValue);
  9471. end;
  9472. procedure TBLStrokeOptions.SetJoin(const AValue: TBLStrokeJoin);
  9473. begin
  9474. FHandle.options.join := Ord(AValue);
  9475. end;
  9476. procedure TBLStrokeOptions.SetStartCap(const AValue: TBLStrokeCap);
  9477. begin
  9478. FHandle.options.startCap := Ord(AValue);
  9479. end;
  9480. procedure TBLStrokeOptions.SetTransformOrder(
  9481. const AValue: TBLStrokeTransformOrder);
  9482. begin
  9483. FHandle.options.transformOrder := Ord(AValue);
  9484. end;
  9485. { TBLStrokeOptions.TScope }
  9486. constructor TBLStrokeOptions.TScope.Create(const AHandle: PBLStrokeOptionsCore);
  9487. begin
  9488. inherited Create;
  9489. FHandle := AHandle;
  9490. end;
  9491. destructor TBLStrokeOptions.TScope.Destroy;
  9492. begin
  9493. blStrokeOptionsDestroy(FHandle);
  9494. inherited;
  9495. end;
  9496. { TBLPathView }
  9497. function BLPathView(const ACommands: PBLPathCmd; const AVertices: PBLPoint;
  9498. const ACount: Integer): TBLPathView; inline;
  9499. begin
  9500. Result.Reset(ACommands, AVertices, ACount);
  9501. end;
  9502. function TBLPathView.GetCommands: PBLPathCmd;
  9503. begin
  9504. Result := Pointer(FHandle.commandData);
  9505. end;
  9506. function TBLPathView.GetCount: Integer;
  9507. begin
  9508. Result := FHandle.size;
  9509. end;
  9510. function TBLPathView.GetVertices: PBLPoint;
  9511. begin
  9512. Result := Pointer(FHandle.vertexData);
  9513. end;
  9514. procedure TBLPathView.Reset(const ACommands: PBLPathCmd;
  9515. const AVertices: PBLPoint; const ACount: Integer);
  9516. begin
  9517. FHandle.commandData := Pointer(ACommands);
  9518. FHandle.vertexData := Pointer(AVertices);
  9519. FHandle.size := ACount;
  9520. end;
  9521. procedure TBLPathView.Reset;
  9522. begin
  9523. FHandle.commandData := nil;
  9524. FHandle.vertexData := nil;
  9525. FHandle.size := 0;
  9526. end;
  9527. { TBLPath }
  9528. procedure TBLPath.AddArc(const AArc: TBLArc;
  9529. const ADirection: TBLGeometryDirection);
  9530. begin
  9531. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARC, @AArc, nil, Ord(ADirection)));
  9532. end;
  9533. procedure TBLPath.AddArc(const AArc: TBLArc; const AMatrix: TBLMatrix2D;
  9534. const ADirection: TBLGeometryDirection);
  9535. begin
  9536. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARC, @AArc, @AMatrix, Ord(ADirection)));
  9537. end;
  9538. procedure TBLPath.AddBox(const ABox: TBLBoxI;
  9539. const ADirection: TBLGeometryDirection);
  9540. begin
  9541. _BLCheck(blPathAddBoxI(@FHandle, @ABox, Ord(ADirection)));
  9542. end;
  9543. procedure TBLPath.AddBox(const ABox: TBLBox;
  9544. const ADirection: TBLGeometryDirection);
  9545. begin
  9546. _BLCheck(blPathAddBoxD(@FHandle, @ABox, Ord(ADirection)));
  9547. end;
  9548. procedure TBLPath.AddBox(const AX0, AY0, AX1, AY1: Double;
  9549. const ADirection: TBLGeometryDirection);
  9550. var
  9551. Box: TBLBox;
  9552. begin
  9553. Box.Reset(AX0, AY0, AX1, AY1);
  9554. _BLCheck(blPathAddBoxD(@FHandle, @Box, Ord(ADirection)));
  9555. end;
  9556. procedure TBLPath.AddBoxArray(const ABoxes: TBLArrayView<TBLBoxI>;
  9557. const ADirection: TBLGeometryDirection);
  9558. begin
  9559. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXI, @ABoxes.FHandle, nil, Ord(ADirection)));
  9560. end;
  9561. procedure TBLPath.AddBoxArray(const ABoxes: PBLBoxI; const ACount: Integer;
  9562. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9563. var
  9564. View: TBLArrayView<TBLBoxI>;
  9565. begin
  9566. View.Reset(ABoxes, ACount);
  9567. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXI, @View.FHandle, @AMatrix, Ord(ADirection)));
  9568. end;
  9569. procedure TBLPath.AddBoxArray(const ABoxes: TBLArrayView<TBLBoxI>;
  9570. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9571. begin
  9572. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXI, @ABoxes.FHandle, @AMatrix, Ord(ADirection)));
  9573. end;
  9574. procedure TBLPath.AddBoxArray(const ABoxes: PBLBoxI; const ACount: Integer;
  9575. const ADirection: TBLGeometryDirection);
  9576. var
  9577. View: TBLArrayView<TBLBoxI>;
  9578. begin
  9579. View.Reset(ABoxes, ACount);
  9580. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXI, @View.FHandle, nil, Ord(ADirection)));
  9581. end;
  9582. procedure TBLPath.AddBoxArray(const ABoxes: PBLBox; const ACount: Integer;
  9583. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9584. var
  9585. View: TBLArrayView<TBLBox>;
  9586. begin
  9587. View.Reset(ABoxes, ACount);
  9588. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXD, @View.FHandle, @AMatrix, Ord(ADirection)));
  9589. end;
  9590. procedure TBLPath.AddBoxArray(const ABoxes: PBLBox; const ACount: Integer;
  9591. const ADirection: TBLGeometryDirection);
  9592. var
  9593. View: TBLArrayView<TBLBox>;
  9594. begin
  9595. View.Reset(ABoxes, ACount);
  9596. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXD, @View.FHandle, nil, Ord(ADirection)));
  9597. end;
  9598. procedure TBLPath.AddBoxArray(const ABoxes: TBLArrayView<TBLBox>;
  9599. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9600. begin
  9601. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXD, @ABoxes.FHandle, @AMatrix, Ord(ADirection)));
  9602. end;
  9603. procedure TBLPath.AddBoxArray(const ABoxes: TBLArrayView<TBLBox>;
  9604. const ADirection: TBLGeometryDirection);
  9605. begin
  9606. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXD, @ABoxes.FHandle, nil, Ord(ADirection)));
  9607. end;
  9608. procedure TBLPath.AddChord(const AChord: TBLArc;
  9609. const ADirection: TBLGeometryDirection);
  9610. begin
  9611. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_CHORD, @AChord, nil, Ord(ADirection)));
  9612. end;
  9613. procedure TBLPath.AddChord(const AChord: TBLArc; const AMatrix: TBLMatrix2D;
  9614. const ADirection: TBLGeometryDirection);
  9615. begin
  9616. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_CHORD, @AChord, @AMatrix, Ord(ADirection)));
  9617. end;
  9618. procedure TBLPath.AddCircle(const ACircle: TBLCircle;
  9619. const ADirection: TBLGeometryDirection);
  9620. begin
  9621. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_CIRCLE, @ACircle, nil, Ord(ADirection)));
  9622. end;
  9623. procedure TBLPath.AddCircle(const ACircle: TBLCircle;
  9624. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9625. begin
  9626. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_CIRCLE, @ACircle, @AMatrix, Ord(ADirection)));
  9627. end;
  9628. procedure TBLPath.AddEllipse(const AEllipse: TBLEllipse;
  9629. const ADirection: TBLGeometryDirection);
  9630. begin
  9631. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ELLIPSE, @AEllipse, nil, Ord(ADirection)));
  9632. end;
  9633. procedure TBLPath.AddEllipse(const AEllipse: TBLEllipse;
  9634. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9635. begin
  9636. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ELLIPSE, @AEllipse, @AMatrix, Ord(ADirection)));
  9637. end;
  9638. procedure TBLPath.AddGeometry(const AGeometryType: TBLGeometryType;
  9639. const AGeometryData: Pointer; const AMatrix: PBLMatrix2D;
  9640. const ADirection: TBLGeometryDirection);
  9641. begin
  9642. _BLCheck(blPathAddGeometry(@FHandle, Ord(AGeometryType), AGeometryData,
  9643. @AMatrix, Ord(ADirection)));
  9644. end;
  9645. procedure TBLPath.AddLine(const ALine: TBLLine; const AMatrix: TBLMatrix2D;
  9646. const ADirection: TBLGeometryDirection);
  9647. begin
  9648. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_LINE, @ALine, @AMatrix, Ord(ADirection)));
  9649. end;
  9650. procedure TBLPath.AddLine(const ALine: TBLLine;
  9651. const ADirection: TBLGeometryDirection);
  9652. begin
  9653. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_LINE, @ALine, nil, Ord(ADirection)));
  9654. end;
  9655. procedure TBLPath.AddPath(const APath: IBLPath; const ARange: TBLRange);
  9656. begin
  9657. if (APath <> nil) then
  9658. _BLCheck(blPathAddPath(@FHandle, APath.Handle, @ARange));
  9659. end;
  9660. procedure TBLPath.AddPath(const APath: IBLPath);
  9661. begin
  9662. if (APath <> nil) then
  9663. _BLCheck(blPathAddPath(@FHandle, APath.Handle, nil));
  9664. end;
  9665. procedure TBLPath.AddPath(const APath: IBLPath; const ATranslate: TBLPoint);
  9666. begin
  9667. if (APath <> nil) then
  9668. _BLCheck(blPathAddTranslatedPath(@FHandle, APath.Handle, nil, @ATranslate));
  9669. end;
  9670. procedure TBLPath.AddPath(const APath: IBLPath; const ARange: TBLRange;
  9671. const AMatrix: TBLMatrix2D);
  9672. begin
  9673. if (APath <> nil) then
  9674. _BLCheck(blPathAddTransformedPath(@FHandle, APath.Handle, @ARange, @AMatrix));
  9675. end;
  9676. procedure TBLPath.AddPath(const APath: IBLPath; const AMatrix: TBLMatrix2D);
  9677. begin
  9678. if (APath <> nil) then
  9679. _BLCheck(blPathAddTransformedPath(@FHandle, APath.Handle, nil, @AMatrix));
  9680. end;
  9681. procedure TBLPath.AddPath(const APath: IBLPath; const ARange: TBLRange;
  9682. const ATranslate: TBLPoint);
  9683. begin
  9684. if (APath <> nil) then
  9685. _BLCheck(blPathAddTranslatedPath(@FHandle, APath.Handle, @ARange, @ATranslate));
  9686. end;
  9687. procedure TBLPath.AddPie(const APie: TBLArc; const AMatrix: TBLMatrix2D;
  9688. const ADirection: TBLGeometryDirection);
  9689. begin
  9690. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_PIE, @APie, @AMatrix, Ord(ADirection)));
  9691. end;
  9692. procedure TBLPath.AddPie(const APie: TBLArc;
  9693. const ADirection: TBLGeometryDirection);
  9694. begin
  9695. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_PIE, @APie, nil, Ord(ADirection)));
  9696. end;
  9697. procedure TBLPath.AddPolygon(const APolygon: TBLArrayView<TBLPoint>;
  9698. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9699. begin
  9700. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGOND, @APolygon.FHandle, @AMatrix, Ord(ADirection)));
  9701. end;
  9702. procedure TBLPath.AddPolygon(const APolygon: TBLArrayView<TBLPoint>;
  9703. const ADirection: TBLGeometryDirection);
  9704. begin
  9705. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGOND, @APolygon.FHandle, nil, Ord(ADirection)));
  9706. end;
  9707. procedure TBLPath.AddPolygon(const APolygon: PBLPoint; const ACount: Integer;
  9708. const ADirection: TBLGeometryDirection);
  9709. var
  9710. View: TBLArrayView<TBLPoint>;
  9711. begin
  9712. View.Reset(APolygon, ACount);
  9713. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGOND, @View.FHandle, nil, Ord(ADirection)));
  9714. end;
  9715. procedure TBLPath.AddPolygon(const APolygon: PBLPoint; const ACount: Integer;
  9716. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9717. var
  9718. View: TBLArrayView<TBLPoint>;
  9719. begin
  9720. View.Reset(APolygon, ACount);
  9721. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGOND, @View.FHandle, @AMatrix, Ord(ADirection)));
  9722. end;
  9723. procedure TBLPath.AddPolygon(const APolygon: TBLArrayView<TBLPointI>;
  9724. const ADirection: TBLGeometryDirection);
  9725. begin
  9726. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGONI, @APolygon.FHandle, nil, Ord(ADirection)));
  9727. end;
  9728. procedure TBLPath.AddPolygon(const APolygon: TBLArrayView<TBLPointI>;
  9729. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9730. begin
  9731. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGONI, @APolygon.FHandle, @AMatrix, Ord(ADirection)));
  9732. end;
  9733. procedure TBLPath.AddPolygon(const APolygon: PBLPointI; const ACount: Integer;
  9734. const ADirection: TBLGeometryDirection);
  9735. var
  9736. View: TBLArrayView<TBLPointI>;
  9737. begin
  9738. View.Reset(APolygon, ACount);
  9739. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGONI, @View.FHandle, nil, Ord(ADirection)));
  9740. end;
  9741. procedure TBLPath.AddPolygon(const APolygon: PBLPointI; const ACount: Integer;
  9742. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9743. var
  9744. View: TBLArrayView<TBLPointI>;
  9745. begin
  9746. View.Reset(APolygon, ACount);
  9747. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGONI, @View.FHandle, @AMatrix, Ord(ADirection)));
  9748. end;
  9749. procedure TBLPath.AddPolyline(const APolyline: TBLArrayView<TBLPoint>;
  9750. const ADirection: TBLGeometryDirection);
  9751. begin
  9752. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYLINED, @APolyline.FHandle, nil, Ord(ADirection)));
  9753. end;
  9754. procedure TBLPath.AddPolyline(const APolyline: TBLArrayView<TBLPoint>;
  9755. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9756. begin
  9757. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYLINED, @APolyline.FHandle, @AMatrix, Ord(ADirection)));
  9758. end;
  9759. procedure TBLPath.AddPolyline(const APolyline: PBLPoint; const ACount: Integer;
  9760. const ADirection: TBLGeometryDirection);
  9761. var
  9762. View: TBLArrayView<TBLPoint>;
  9763. begin
  9764. View.Reset(APolyline, ACount);
  9765. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYLINED, @View.FHandle, nil, Ord(ADirection)));
  9766. end;
  9767. procedure TBLPath.AddPolyline(const APolyline: PBLPoint; const ACount: Integer;
  9768. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9769. var
  9770. View: TBLArrayView<TBLPoint>;
  9771. begin
  9772. View.Reset(APolyline, ACount);
  9773. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYLINED, @View.FHandle, @AMatrix, Ord(ADirection)));
  9774. end;
  9775. procedure TBLPath.AddPolyline(const APolyline: TBLArrayView<TBLPointI>;
  9776. const ADirection: TBLGeometryDirection);
  9777. begin
  9778. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYLINEI, @APolyline.FHandle, nil, Ord(ADirection)));
  9779. end;
  9780. procedure TBLPath.AddPolyline(const APolyline: TBLArrayView<TBLPointI>;
  9781. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9782. begin
  9783. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYLINEI, @APolyline.FHandle, @AMatrix, Ord(ADirection)));
  9784. end;
  9785. procedure TBLPath.AddPolyline(const APolyline: PBLPointI; const ACount: Integer;
  9786. const ADirection: TBLGeometryDirection);
  9787. var
  9788. View: TBLArrayView<TBLPointI>;
  9789. begin
  9790. View.Reset(APolyline, ACount);
  9791. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYLINEI, @View.FHandle, nil, Ord(ADirection)));
  9792. end;
  9793. procedure TBLPath.AddPolyline(const APolyline: PBLPointI; const ACount: Integer;
  9794. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9795. var
  9796. View: TBLArrayView<TBLPointI>;
  9797. begin
  9798. View.Reset(APolyline, ACount);
  9799. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYLINEI, @View.FHandle, @AMatrix, Ord(ADirection)));
  9800. end;
  9801. procedure TBLPath.AddRect(const AX, AY, AW, AH: Double;
  9802. const ADirection: TBLGeometryDirection);
  9803. var
  9804. Rect: TBLRect;
  9805. begin
  9806. Rect.Reset(AX, AY, AW, AH);
  9807. _BLCheck(blPathAddRectD(@FHandle, @Rect, Ord(ADirection)));
  9808. end;
  9809. procedure TBLPath.AddRect(const ARect: TBLRect;
  9810. const ADirection: TBLGeometryDirection);
  9811. begin
  9812. _BLCheck(blPathAddRectD(@FHandle, @ARect, Ord(ADirection)));
  9813. end;
  9814. procedure TBLPath.AddRect(const ARect: TBLRectI;
  9815. const ADirection: TBLGeometryDirection);
  9816. begin
  9817. _BLCheck(blPathAddRectI(@FHandle, @ARect, Ord(ADirection)));
  9818. end;
  9819. procedure TBLPath.AddRectArray(const ARects: PBLRectI; const ACount: Integer;
  9820. const ADirection: TBLGeometryDirection);
  9821. var
  9822. View: TBLArrayView<TBLRectI>;
  9823. begin
  9824. View.Reset(ARects, ACount);
  9825. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTI, @View.FHandle, nil, Ord(ADirection)));
  9826. end;
  9827. procedure TBLPath.AddRectArray(const ARects: TBLArrayView<TBLRectI>;
  9828. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9829. begin
  9830. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTI, @ARects.FHandle, @AMatrix, Ord(ADirection)));
  9831. end;
  9832. procedure TBLPath.AddRectArray(const ARects: TBLArrayView<TBLRectI>;
  9833. const ADirection: TBLGeometryDirection);
  9834. begin
  9835. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTI, @ARects.FHandle, nil, Ord(ADirection)));
  9836. end;
  9837. procedure TBLPath.AddRectArray(const ARects: PBLRectI; const ACount: Integer;
  9838. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9839. var
  9840. View: TBLArrayView<TBLRectI>;
  9841. begin
  9842. View.Reset(ARects, ACount);
  9843. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTI, @View.FHandle, @AMatrix, Ord(ADirection)));
  9844. end;
  9845. procedure TBLPath.AddRectArray(const ARects: PBLRect; const ACount: Integer;
  9846. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9847. var
  9848. View: TBLArrayView<TBLRect>;
  9849. begin
  9850. View.Reset(ARects, ACount);
  9851. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTD, @View.FHandle, @AMatrix, Ord(ADirection)));
  9852. end;
  9853. procedure TBLPath.AddRectArray(const ARects: PBLRect; const ACount: Integer;
  9854. const ADirection: TBLGeometryDirection);
  9855. var
  9856. View: TBLArrayView<TBLRect>;
  9857. begin
  9858. View.Reset(ARects, ACount);
  9859. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTD, @View.FHandle, nil, Ord(ADirection)));
  9860. end;
  9861. procedure TBLPath.AddRectArray(const ARects: TBLArrayView<TBLRect>;
  9862. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9863. begin
  9864. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTD, @ARects.FHandle, @AMatrix, Ord(ADirection)));
  9865. end;
  9866. procedure TBLPath.AddRectArray(const ARects: TBLArrayView<TBLRect>;
  9867. const ADirection: TBLGeometryDirection);
  9868. begin
  9869. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTD, @ARects.FHandle, nil, Ord(ADirection)));
  9870. end;
  9871. procedure TBLPath.AddRegion(const ARegion: IBLRegion;
  9872. const ADirection: TBLGeometryDirection);
  9873. begin
  9874. if (ARegion <> nil) then
  9875. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_REGION, ARegion.Handle, nil, Ord(ADirection)));
  9876. end;
  9877. procedure TBLPath.AddRegion(const ARegion: IBLRegion;
  9878. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9879. begin
  9880. if (ARegion <> nil) then
  9881. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_REGION, ARegion.Handle, @AMatrix, Ord(ADirection)));
  9882. end;
  9883. procedure TBLPath.AddReversedPath(const APath: IBLPath;
  9884. const AReverseMode: TBLPathReverseMode);
  9885. begin
  9886. if (APath <> nil) then
  9887. _BLCheck(blPathAddReversedPath(@FHandle, APath.Handle, nil, Ord(AReverseMode)));
  9888. end;
  9889. procedure TBLPath.AddReversedPath(const APath: IBLPath; const ARange: TBLRange;
  9890. const AReverseMode: TBLPathReverseMode);
  9891. begin
  9892. if (APath <> nil) then
  9893. _BLCheck(blPathAddReversedPath(@FHandle, APath.Handle, @ARange, Ord(AReverseMode)));
  9894. end;
  9895. procedure TBLPath.AddRoundRect(const ARoundRect: TBLRoundRect;
  9896. const ADirection: TBLGeometryDirection);
  9897. begin
  9898. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ROUND_RECT, @ARoundRect, nil, Ord(ADirection)));
  9899. end;
  9900. procedure TBLPath.AddRoundRect(const ARoundRect: TBLRoundRect;
  9901. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9902. begin
  9903. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_ROUND_RECT, @ARoundRect, @AMatrix, Ord(ADirection)));
  9904. end;
  9905. procedure TBLPath.AddStrokedPath(const APath: IBLPath;
  9906. const AStrokeOptions: TBLStrokeOptions;
  9907. const AApproximationOptions: TBLApproximationOptions);
  9908. begin
  9909. if (APath <> nil) then
  9910. begin
  9911. _BLCheck(blPathAddStrokedPath(@FHandle, APath.Handle, nil,
  9912. @AStrokeOptions.FHandle, @AApproximationOptions.FHandle));
  9913. end;
  9914. end;
  9915. procedure TBLPath.AddStrokedPath(const APath: IBLPath; const ARange: TBLRange;
  9916. const AStrokeOptions: TBLStrokeOptions;
  9917. const AApproximationOptions: TBLApproximationOptions);
  9918. begin
  9919. if (APath <> nil) then
  9920. begin
  9921. _BLCheck(blPathAddStrokedPath(@FHandle, APath.Handle, @ARange,
  9922. @AStrokeOptions.FHandle, @AApproximationOptions.FHandle));
  9923. end;
  9924. end;
  9925. procedure TBLPath.AddTriangle(const ATriangle: TBLTriangle;
  9926. const ADirection: TBLGeometryDirection);
  9927. begin
  9928. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_TRIANGLE, @ATriangle, nil, Ord(ADirection)));
  9929. end;
  9930. procedure TBLPath.AddTriangle(const ATriangle: TBLTriangle;
  9931. const AMatrix: TBLMatrix2D; const ADirection: TBLGeometryDirection);
  9932. begin
  9933. _BLCheck(blPathAddGeometry(@FHandle, BL_GEOMETRY_TYPE_TRIANGLE, @ATriangle, @AMatrix, Ord(ADirection)));
  9934. end;
  9935. procedure TBLPath.ArcQuadrantTo(const AX1, AY1, AX2, AY2: Double);
  9936. begin
  9937. _BLCheck(blPathArcQuadrantTo(@FHandle, AX1, AY1, AX2, AY2));
  9938. end;
  9939. procedure TBLPath.ArcQuadrantTo(const AP1, AP2: TBLPoint);
  9940. begin
  9941. _BLCheck(blPathArcQuadrantTo(@FHandle, AP1.FHandle.x, AP1.FHandle.y, AP2.FHandle.x, AP2.FHandle.y));
  9942. end;
  9943. procedure TBLPath.ArcTo(const AC, AR: TBLPoint; const AStart, ASweep: Double;
  9944. const AForceMoveTo: Boolean);
  9945. begin
  9946. _BLCheck(blPathArcTo(@FHandle, AC.FHandle.x, AC.FHandle.y, AR.FHandle.x,
  9947. AR.FHandle.y, AStart, ASweep, AForceMoveTo));
  9948. end;
  9949. procedure TBLPath.ArcTo(const ACX, ACY, ARX, ARY, AStart, ASweep: Double;
  9950. const AForceMoveTo: Boolean);
  9951. begin
  9952. _BLCheck(blPathArcTo(@FHandle, ACX, ACY, ARX, ARY, AStart, ASweep, AForceMoveTo));
  9953. end;
  9954. procedure TBLPath.Clear;
  9955. begin
  9956. _BLCheck(blPathClear(@FHandle));
  9957. end;
  9958. function TBLPath.Clone: IBLPath;
  9959. begin
  9960. Result := TBLPath.Create;
  9961. _BLCheck(blPathAssignDeep(Result.Handle, @FHandle));
  9962. end;
  9963. procedure TBLPath.Close;
  9964. begin
  9965. _BLCheck(blPathClose(@FHandle));
  9966. end;
  9967. constructor TBLPath.Create;
  9968. begin
  9969. inherited Create;
  9970. blPathInit(@FHandle);
  9971. end;
  9972. procedure TBLPath.CubicTo(const AX1, AY1, AX2, AY2, AX3, AY3: Double);
  9973. begin
  9974. _BLCheck(blPathCubicTo(@FHandle, AX1, AY1, AX2, AY2, AX3, AY3));
  9975. end;
  9976. procedure TBLPath.CubicTo(const AP1, AP2, AP3: TBLPoint);
  9977. begin
  9978. _BLCheck(blPathCubicTo(@FHandle, AP1.FHandle.x, AP1.FHandle.y, AP2.FHandle.x,
  9979. AP2.FHandle.y, AP3.FHandle.x, AP3.FHandle.y));
  9980. end;
  9981. destructor TBLPath.Destroy;
  9982. begin
  9983. blPathDestroy(@FHandle);
  9984. inherited;
  9985. end;
  9986. procedure TBLPath.EllipticArcTo(const ARX, ARY, AXAxisRotation: Double;
  9987. const ALargeArcFlag, ASweepFlag: Boolean; const AX1, AY1: Double);
  9988. begin
  9989. _BLCheck(blPathEllipticArcTo(@FHandle, ARX, ARY, AXAxisRotation, ALargeArcFlag,
  9990. ASweepFlag, AX1, AY1));
  9991. end;
  9992. procedure TBLPath.EllipticArcTo(const ARP: TBLPoint;
  9993. const AXAxisRotation: Double; const ALargeArcFlag, ASweepFlag: Boolean;
  9994. const AP1: TBLPoint);
  9995. begin
  9996. _BLCheck(blPathEllipticArcTo(@FHandle, ARP.FHandle.x, ARP.FHandle.y,
  9997. AXAxisRotation, ALargeArcFlag, ASweepFlag, AP1.FHandle.x, AP1.FHandle.y));
  9998. end;
  9999. function TBLPath.Equals(Obj: TObject): Boolean;
  10000. begin
  10001. if (Obj = nil) then
  10002. Result := (Self = nil)
  10003. else if (Obj = Self) then
  10004. Result := True
  10005. else if (Obj is TBLPath) then
  10006. Result := blPathEquals(@FHandle, @TBLPath(Obj).FHandle)
  10007. else
  10008. Result := False;
  10009. end;
  10010. function TBLPath.Equals(const AOther: IBLPath): Boolean;
  10011. begin
  10012. if (AOther = nil) then
  10013. Result := (Self = nil)
  10014. else
  10015. Result := blPathEquals(@FHandle, AOther.Handle);
  10016. end;
  10017. procedure TBLPath.FitTo(const ARect: TBLRect; const AFitFlags: TBLFitFlags);
  10018. begin
  10019. _BLCheck(blPathFitTo(@FHandle, nil, @ARect, Byte(AFitFlags)));
  10020. end;
  10021. procedure TBLPath.FitTo(const ARange: TBLRange; const ARect: TBLRect;
  10022. const AFitFlags: TBLFitFlags);
  10023. begin
  10024. _BLCheck(blPathFitTo(@FHandle, @ARange, @ARect, Byte(AFitFlags)));
  10025. end;
  10026. function TBLPath.GetBoundingBox: TBLBox;
  10027. begin
  10028. _BLCheck(blPathGetBoundingBox(@FHandle, @Result));
  10029. end;
  10030. function TBLPath.GetCapacity: Integer;
  10031. begin
  10032. Result := FHandle.impl.capacity;
  10033. end;
  10034. function TBLPath.GetClosestVertex(const AP: TBLPoint;
  10035. const AMaxDistance: Double): Integer;
  10036. var
  10037. Index: NativeUInt;
  10038. ActualDistance: Double;
  10039. begin
  10040. _BLCheck(blPathGetClosestVertex(@FHandle, @AP, AMaxDistance, @Index, @ActualDistance));
  10041. Result := Index;
  10042. end;
  10043. function TBLPath.GetClosestVertex(const AP: TBLPoint;
  10044. const AMaxDistance: Double; out AActualDistance: Double): Integer;
  10045. var
  10046. Index: NativeUInt;
  10047. begin
  10048. _BLCheck(blPathGetClosestVertex(@FHandle, @AP, AMaxDistance, @Index, @AActualDistance));
  10049. Result := Index;
  10050. end;
  10051. function TBLPath.GetCommandData: PBLPathCmd;
  10052. begin
  10053. Result := Pointer(FHandle.impl.commandData);
  10054. end;
  10055. function TBLPath.GetCommandDataEnd: PBLPathCmd;
  10056. begin
  10057. Result := Pointer(FHandle.impl.commandData + FHandle.impl.size);
  10058. end;
  10059. function TBLPath.GetControlBox: TBLBox;
  10060. begin
  10061. _BLCheck(blPathGetControlBox(@FHandle, @Result));
  10062. end;
  10063. function TBLPath.GetCount: Integer;
  10064. begin
  10065. Result := FHandle.impl.size;
  10066. end;
  10067. function TBLPath.GetFigureRange(const AIndex: Integer): TBLRange;
  10068. begin
  10069. _BLCheck(blPathGetFigureRange(@FHandle, AIndex, @Result));
  10070. end;
  10071. function TBLPath.GetHandle: PBLPathCore;
  10072. begin
  10073. Result := @FHandle;
  10074. end;
  10075. function TBLPath.GetInfoFlags: TBLPathFlags;
  10076. begin
  10077. _BLCheck(blPathGetInfoFlags(@FHandle, @Result));
  10078. end;
  10079. function TBLPath.GetIsEmpty: Boolean;
  10080. begin
  10081. Result := (FHandle.impl.size = 0);
  10082. end;
  10083. function TBLPath.GetIsNone: Boolean;
  10084. begin
  10085. Result := ((FHandle.impl.implTraits and BL_IMPL_TRAIT_NULL) <> 0);
  10086. end;
  10087. function TBLPath.GetLastVertex: TBLPoint;
  10088. begin
  10089. _BLCheck(blPathGetLastVertex(@FHandle, @Result));
  10090. end;
  10091. function TBLPath.GetVertexData: PBLPoint;
  10092. begin
  10093. Result := Pointer(FHandle.impl.vertexData);
  10094. end;
  10095. function TBLPath.GetVertexDataEnd: PBLPoint;
  10096. begin
  10097. Result := Pointer(FHandle.impl.vertexData + FHandle.impl.size);
  10098. end;
  10099. function TBLPath.GetView: TBLPathView;
  10100. begin
  10101. Result.FHandle := FHandle.impl.view;
  10102. end;
  10103. function TBLPath.HitTest(const AP: TBLPoint;
  10104. const AFillRule: TBLFillRule): TBLHitTest;
  10105. begin
  10106. Result := TBLHitTest(blPathHitTest(@FHandle, @AP, Ord(AFillRule)));
  10107. end;
  10108. procedure TBLPath.LineTo(const AX1, AY1: Double);
  10109. begin
  10110. _BLCheck(blPathLineTo(@FHandle, AX1, AY1));
  10111. end;
  10112. procedure TBLPath.LineTo(const AP1: TBLPoint);
  10113. begin
  10114. _BLCheck(blPathLineTo(@FHandle, AP1.FHandle.x, AP1.FHandle.y));
  10115. end;
  10116. procedure TBLPath.MoveTo(const AX0, AY0: Double);
  10117. begin
  10118. _BLCheck(blPathMoveTo(@FHandle, AX0, AY0));
  10119. end;
  10120. procedure TBLPath.MoveTo(const AP0: TBLPoint);
  10121. begin
  10122. _BLCheck(blPathMoveTo(@FHandle, AP0.FHandle.x, AP0.FHandle.y));
  10123. end;
  10124. procedure TBLPath.PolyTo(const APoly: TArray<TBLPoint>);
  10125. begin
  10126. _BLCheck(blPathPolyTo(@FHandle, Pointer(APoly), Length(APoly)));
  10127. end;
  10128. procedure TBLPath.PolyTo(const APoly: PBLPoint; const ACount: Integer);
  10129. begin
  10130. _BLCheck(blPathPolyTo(@FHandle, _PBLPoint(APoly), ACount));
  10131. end;
  10132. procedure TBLPath.QuadTo(const AP1, AP2: TBLPoint);
  10133. begin
  10134. _BLCheck(blPathQuadTo(@FHandle, AP1.FHandle.x, AP1.FHandle.y, AP2.FHandle.x, AP2.FHandle.y));
  10135. end;
  10136. procedure TBLPath.QuadTo(const AX1, AY1, AX2, AY2: Double);
  10137. begin
  10138. _BLCheck(blPathQuadTo(@FHandle, AX1, AY1, AX2, AY2));
  10139. end;
  10140. procedure TBLPath.RemoveRange(const ARange: TBLRange);
  10141. begin
  10142. _BLCheck(blPathRemoveRange(@FHandle, @ARange.FHandle));
  10143. end;
  10144. procedure TBLPath.Reserve(const ACount: Integer);
  10145. begin
  10146. _BLCheck(blPathReserve(@FHandle, ACount));
  10147. end;
  10148. procedure TBLPath.Reset;
  10149. begin
  10150. _BLCheck(blPathReset(@FHandle));
  10151. end;
  10152. procedure TBLPath.SetVertexAt(const AIndex: Integer; const ACmd: TBLPathCmd;
  10153. const AX, AY: Double; const APreserve: Boolean);
  10154. const
  10155. FLAGS: array [Boolean] of Cardinal = (0, BL_PATH_CMD_PRESERVE);
  10156. begin
  10157. _BLCheck(blPathSetVertexAt(@FHandle, AIndex, Byte(ACmd) or FLAGS[APreserve], AX, AY));
  10158. end;
  10159. procedure TBLPath.SetVertexAt(const AIndex: Integer; const ACmd: TBLPathCmd;
  10160. const APt: TBLPoint; const APreserve: Boolean);
  10161. const
  10162. FLAGS: array [Boolean] of Cardinal = (0, BL_PATH_CMD_PRESERVE);
  10163. begin
  10164. _BLCheck(blPathSetVertexAt(@FHandle, AIndex, Byte(ACmd) or FLAGS[APreserve],
  10165. APt.FHandle.x, APt.FHandle.y));
  10166. end;
  10167. procedure TBLPath.Shrink;
  10168. begin
  10169. _BLCheck(blPathShrink(@FHandle));
  10170. end;
  10171. procedure TBLPath.SmoothCubicTo(const AX2, AY2, AX3, AY3: Double);
  10172. begin
  10173. _BLCheck(blPathSmoothCubicTo(@FHandle, AX2, AY2, AX3, AY3));
  10174. end;
  10175. procedure TBLPath.SmoothCubicTo(const AP2, AP3: TBLPoint);
  10176. begin
  10177. _BLCheck(blPathSmoothCubicTo(@FHandle, AP2.FHandle.x, AP2.FHandle.y, AP3.FHandle.x, AP3.FHandle.y));
  10178. end;
  10179. procedure TBLPath.SmoothQuadTo(const AP2: TBLPoint);
  10180. begin
  10181. _BLCheck(blPathSmoothQuadTo(@FHandle, AP2.FHandle.x, AP2.FHandle.y));
  10182. end;
  10183. procedure TBLPath.SmoothQuadTo(const AX2, AY2: Double);
  10184. begin
  10185. _BLCheck(blPathSmoothQuadTo(@FHandle, AX2, AY2));
  10186. end;
  10187. procedure TBLPath.Transform(const ARange: TBLRange; const AMatrix: TBLMatrix2D);
  10188. begin
  10189. _BLCheck(blPathTransform(@FHandle, @ARange, @AMatrix));
  10190. end;
  10191. procedure TBLPath.Transform(const AMatrix: TBLMatrix2D);
  10192. begin
  10193. _BLCheck(blPathTransform(@FHandle, nil, @AMatrix));
  10194. end;
  10195. procedure TBLPath.Translate(const ARange: TBLRange; const AP: TBLPoint);
  10196. begin
  10197. _BLCheck(blPathTranslate(@FHandle, @ARange, @AP));
  10198. end;
  10199. procedure TBLPath.Translate(const AP: TBLPoint);
  10200. begin
  10201. _BLCheck(blPathTranslate(@FHandle, nil, @AP));
  10202. end;
  10203. {$ENDREGION 'Path'}
  10204. {$REGION 'Format'}
  10205. { TBLFormatInfo }
  10206. class operator TBLFormatInfo.Equal(const ALeft, ARight: TBLFormatInfo): Boolean;
  10207. begin
  10208. Result := CompareMem(@ALeft, @ARight, SizeOf(TBLFormatInfo));
  10209. end;
  10210. function TBLFormatInfo.GetFlags: TBLFormatFlags;
  10211. begin
  10212. Cardinal(Result) := FHandle.flags;
  10213. end;
  10214. function TBLFormatInfo.GetPalette: PBLRgba32;
  10215. begin
  10216. Result := Pointer(FHandle.palette);
  10217. end;
  10218. class operator TBLFormatInfo.NotEqual(const ALeft,
  10219. ARight: TBLFormatInfo): Boolean;
  10220. begin
  10221. Result := not CompareMem(@ALeft, @ARight, SizeOf(TBLFormatInfo));
  10222. end;
  10223. procedure TBLFormatInfo.Query(const AFormat: TBLFormat);
  10224. begin
  10225. _BLCheck(blFormatInfoQuery(@FHandle, Ord(AFormat)));
  10226. end;
  10227. procedure TBLFormatInfo.Reset(const ADepth: Integer;
  10228. const AFlags: TBLFormatFlags; const ARSize, AGSize, ABSize, AASize, ARShift,
  10229. AGShift, ABShift, AAShift: Byte);
  10230. begin
  10231. FHandle.depth := ADepth;
  10232. FHandle.flags := Cardinal(AFlags);
  10233. FHandle.rSize := ARSize;
  10234. FHandle.gSize := AGSize;
  10235. FHandle.bSize := ABSize;
  10236. FHandle.aSize := AASize;
  10237. FHandle.rShift := ARShift;
  10238. FHandle.gShift := AGShift;
  10239. FHandle.bShift := ABShift;
  10240. FHandle.aShift := AAShift;
  10241. end;
  10242. procedure TBLFormatInfo.Reset;
  10243. begin
  10244. FillChar(FHandle, SizeOf(FHandle), 0);
  10245. end;
  10246. procedure TBLFormatInfo.Sanitize;
  10247. begin
  10248. _BLCheck(blFormatInfoSanitize(@FHandle));
  10249. end;
  10250. procedure TBLFormatInfo.SetFlags(const AValue: TBLFormatFlags);
  10251. begin
  10252. FHandle.flags := Cardinal(AValue);
  10253. end;
  10254. procedure TBLFormatInfo.SetShifts(const ARShift, AGShift, ABShift,
  10255. AAShift: Byte);
  10256. begin
  10257. FHandle.rShift := ARShift;
  10258. FHandle.gShift := AGShift;
  10259. FHandle.bShift := ABShift;
  10260. FHandle.aShift := AAShift;
  10261. end;
  10262. procedure TBLFormatInfo.SetSizes(const ARSize, AGSize, ABSize, AASize: Byte);
  10263. begin
  10264. FHandle.rSize := ARSize;
  10265. FHandle.gSize := AGSize;
  10266. FHandle.bSize := ABSize;
  10267. FHandle.aSize := AASize;
  10268. end;
  10269. { _TBLFormatHelper }
  10270. function _TBLFormatHelper.GetInfo: TBLFormatInfo;
  10271. begin
  10272. _BLCheck(blFormatInfoQuery(@Result.FHandle, Ord(Self)));
  10273. end;
  10274. {$ENDREGION 'Format'}
  10275. {$REGION 'Image'}
  10276. { TBLImageData }
  10277. function TBLImageData.GetFlags: TBLFormatFlags;
  10278. begin
  10279. Cardinal(Result) := FHandle.flags;
  10280. end;
  10281. function TBLImageData.GetFormat: TBLFormat;
  10282. begin
  10283. Byte(Result) := FHandle.format;
  10284. end;
  10285. function TBLImageData.GetSize: TBLSizeI;
  10286. begin
  10287. Result.FHandle := FHandle.size;
  10288. end;
  10289. procedure TBLImageData.Reset;
  10290. begin
  10291. FillChar(FHandle, SizeOf(FHandle), 0);
  10292. end;
  10293. procedure TBLImageData.SetFlags(const AValue: TBLFormatFlags);
  10294. begin
  10295. FHandle.flags := Cardinal(AValue);
  10296. end;
  10297. procedure TBLImageData.SetFormat(const AValue: TBLFormat);
  10298. begin
  10299. FHandle.format := Ord(AValue);
  10300. end;
  10301. procedure TBLImageData.SetSize(const AValue: TBLSizeI);
  10302. begin
  10303. FHandle.size := AValue.FHandle;
  10304. end;
  10305. { TBLImageInfo }
  10306. function TBLImageInfo.GetCompression: String;
  10307. begin
  10308. Result := String(UTF8String(FHandle.compression));
  10309. end;
  10310. function TBLImageInfo.GetDensity: TBLSize;
  10311. begin
  10312. Result.FHandle := FHandle.density;
  10313. end;
  10314. function TBLImageInfo.GetDepth: Integer;
  10315. begin
  10316. Result := FHandle.depth;
  10317. end;
  10318. function TBLImageInfo.GetFlags: TBLFormatFlags;
  10319. begin
  10320. Cardinal(Result) := FHandle.flags;
  10321. end;
  10322. function TBLImageInfo.GetFormat: String;
  10323. begin
  10324. Result := String(UTF8String(FHandle.format));
  10325. end;
  10326. function TBLImageInfo.GetFrameCount: Integer;
  10327. begin
  10328. Result := FHandle.frameCount;
  10329. end;
  10330. function TBLImageInfo.GetPlaneCount: Integer;
  10331. begin
  10332. Result := FHandle.planeCount;
  10333. end;
  10334. function TBLImageInfo.GetSize: TBLSizeI;
  10335. begin
  10336. Result.FHandle := FHandle.size;
  10337. end;
  10338. procedure TBLImageInfo.Reset;
  10339. begin
  10340. FillChar(FHandle, SizeOf(FHandle), 0);
  10341. end;
  10342. { TBLImageScaleOptions }
  10343. function TBLImageScaleOptions.GetUserFunc: TBLImageScaleUserFunc;
  10344. begin
  10345. Result := TBLImageScaleUserFunc(FHandle.userFunc);
  10346. end;
  10347. procedure TBLImageScaleOptions.Reset;
  10348. begin
  10349. FillChar(FHandle, SizeOf(FHandle), 0);
  10350. end;
  10351. procedure TBLImageScaleOptions.ResetToDefaults;
  10352. begin
  10353. FHandle.userFunc := nil;
  10354. FHandle.userData := nil;
  10355. FHandle.radius := 2;
  10356. FHandle.mitchell.b := 1 / 3;
  10357. FHandle.mitchell.c := 1 / 3;
  10358. FHandle.data[2] := 0;
  10359. end;
  10360. procedure TBLImageScaleOptions.SetUserFunc(const AValue: TBLImageScaleUserFunc);
  10361. begin
  10362. TBLImageScaleUserFunc(FHandle.userFunc) := AValue;
  10363. end;
  10364. { TBLImage }
  10365. constructor TBLImage.Create;
  10366. begin
  10367. inherited Create;
  10368. blImageInit(@FHandle);
  10369. end;
  10370. function TBLImage.Clone: IBLImage;
  10371. begin
  10372. Result := TBLImage.Create;
  10373. _BLCheck(blImageAssignDeep(Result.Handle, @FHandle));
  10374. end;
  10375. procedure TBLImage.Convert(const AFormat: TBLFormat);
  10376. begin
  10377. _BLCheck(blImageConvert(@FHandle, Ord(AFormat)));
  10378. end;
  10379. constructor TBLImage.Create(const AWidth, AHeight: Integer;
  10380. const AFormat: TBLFormat);
  10381. begin
  10382. inherited Create;
  10383. _BLCheck(blImageInitAs(@FHandle, AWidth, AHeight, Ord(AFormat)));
  10384. end;
  10385. constructor TBLImage.Create(const AHandle: BLImageCore;
  10386. const AIsReference: Boolean);
  10387. begin
  10388. inherited Create;
  10389. FHandle := AHandle;
  10390. FIsReference := AIsReference;
  10391. end;
  10392. destructor TBLImage.Destroy;
  10393. begin
  10394. if (not FIsReference) then
  10395. blImageDestroy(@FHandle);
  10396. inherited;
  10397. end;
  10398. class procedure TBLImage.DoDestroy(impl, destroyData: Pointer);
  10399. var
  10400. Data: PDestroyData absolute destroyData;
  10401. begin
  10402. if (Data <> nil) then
  10403. begin
  10404. Data.Event(Data.Image);
  10405. FreeMem(Data);
  10406. end;
  10407. end;
  10408. function TBLImage.Equals(Obj: TObject): Boolean;
  10409. begin
  10410. if (Obj = nil) then
  10411. Result := (Self = nil)
  10412. else if (Obj = Self) then
  10413. Result := True
  10414. else if (Obj is TBLImage) then
  10415. Result := blImageEquals(@FHandle, @TBLImage(Obj).FHandle)
  10416. else
  10417. Result := False;
  10418. end;
  10419. function TBLImage.Equals(const AOther: IBLImage): Boolean;
  10420. begin
  10421. if (AOther = nil) then
  10422. Result := (Self = nil)
  10423. else
  10424. Result := blImageEquals(@FHandle, AOther.Handle);
  10425. end;
  10426. procedure TBLImage.GetData(out AData: TBLImageData);
  10427. begin
  10428. _BLCheck(blImageGetData(@FHandle, @AData.FHandle));
  10429. end;
  10430. function TBLImage.GetFormat: TBLFormat;
  10431. begin
  10432. Result := TBLFormat(FHandle.impl.format);
  10433. end;
  10434. function TBLImage.GetHandle: PBLImageCore;
  10435. begin
  10436. Result := @FHandle;
  10437. end;
  10438. function TBLImage.GetHeight: Integer;
  10439. begin
  10440. Result := FHandle.impl.size.h;
  10441. end;
  10442. function TBLImage.GetIsEmpty: Boolean;
  10443. begin
  10444. Result := (FHandle.impl.format = BL_FORMAT_NONE);
  10445. end;
  10446. function TBLImage.GetIsNone: Boolean;
  10447. begin
  10448. Result := ((FHandle.impl.implTraits and BL_IMPL_TRAIT_NULL) <> 0);
  10449. end;
  10450. function TBLImage.GetSize: TBLSizeI;
  10451. begin
  10452. Result := TBLSizeI(FHandle.impl.size);
  10453. end;
  10454. function TBLImage.GetWidth: Integer;
  10455. begin
  10456. Result := FHandle.impl.size.w;
  10457. end;
  10458. procedure TBLImage.Initialize(const AWidth, AHeight: Integer;
  10459. const AFormat: TBLFormat);
  10460. begin
  10461. _BLCheck(blImageCreate(@FHandle, AWidth, AHeight, Ord(AFormat)));
  10462. end;
  10463. procedure TBLImage.InitializeFromData(const AWidth, AHeight: Integer;
  10464. const AFormat: TBLFormat; const APixelData: Pointer; const AStride: Integer;
  10465. const AOnDestroy: TBLImageDestroyEvent);
  10466. var
  10467. DestroyFunc: BLDestroyImplFunc;
  10468. DestroyData: PDestroyData;
  10469. begin
  10470. if Assigned(AOnDestroy) then
  10471. begin
  10472. DestroyFunc := DoDestroy;
  10473. GetMem(DestroyData, SizeOf(TDestroyData));
  10474. DestroyData.Image := Self;
  10475. DestroyData.Event := AOnDestroy;
  10476. end
  10477. else
  10478. begin
  10479. DestroyFunc := nil;
  10480. DestroyData := nil;
  10481. end;
  10482. _BLCheck(blImageCreateFromData(@FHandle, AWidth, AHeight, Ord(AFormat),
  10483. APixelData, AStride, DestroyFunc, DestroyData));
  10484. end;
  10485. procedure TBLImage.MakeMutable(out AData: TBLImageData);
  10486. begin
  10487. _BLCheck(blImageMakeMutable(@FHandle, @AData.FHandle));
  10488. end;
  10489. procedure TBLImage.MakeMutable;
  10490. var
  10491. Unused: TBLImageData;
  10492. begin
  10493. _BLCheck(blImageMakeMutable(@FHandle, @Unused.FHandle));
  10494. end;
  10495. procedure TBLImage.ReadFromData(const AData: TBytes);
  10496. begin
  10497. ReadFromData(Pointer(AData), Length(AData), nil);
  10498. end;
  10499. procedure TBLImage.ReadFromData(const AData: TBytes;
  10500. const ACodecs: TArray<IBLImageCodec>);
  10501. begin
  10502. ReadFromData(Pointer(AData), Length(AData), ACodecs);
  10503. end;
  10504. procedure TBLImage.ReadFromData(const AData: Pointer; const ASize: Integer);
  10505. begin
  10506. _BLCheck(blImageReadFromData(@FHandle, AData, ASize, nil));
  10507. end;
  10508. procedure TBLImage.ReadFromData(const AData: Pointer; const ASize: Integer;
  10509. const ACodecs: TArray<IBLImageCodec>);
  10510. var
  10511. CodecHandles: TArray<BLImageCodecCore>;
  10512. Codecs: IBLArray;
  10513. I: Integer;
  10514. begin
  10515. SetLength(CodecHandles, Length(ACodecs));
  10516. for I := 0 to Length(CodecHandles) - 1 do
  10517. CodecHandles[I] := ACodecs[I].Handle^;
  10518. Codecs := TBLUtils.ArrayToBLArray<BLImageCodecCore>(CodecHandles);
  10519. _BLCheck(blImageReadFromData(@FHandle, AData, ASize, Codecs.Handle));
  10520. end;
  10521. procedure TBLImage.ReadFromData(const AView: TBLArrayView<Byte>);
  10522. begin
  10523. ReadFromData(AView.Data, AView.Length, nil);
  10524. end;
  10525. procedure TBLImage.ReadFromData(const AView: TBLArrayView<Byte>;
  10526. const ACodecs: TArray<IBLImageCodec>);
  10527. begin
  10528. ReadFromData(AView.Data, AView.Length, ACodecs);
  10529. end;
  10530. procedure TBLImage.ReadFromFile(const AFilename: String);
  10531. begin
  10532. _BLCheck(blImageReadFromFile(@FHandle, MarshaledAString(UTF8String(AFilename)), nil));
  10533. end;
  10534. procedure TBLImage.ReadFromFile(const AFilename: String;
  10535. const ACodecs: TArray<IBLImageCodec>);
  10536. var
  10537. CodecHandles: TArray<BLImageCodecCore>;
  10538. Codecs: IBLArray;
  10539. I: Integer;
  10540. begin
  10541. SetLength(CodecHandles, Length(ACodecs));
  10542. for I := 0 to Length(CodecHandles) - 1 do
  10543. CodecHandles[I] := ACodecs[I].Handle^;
  10544. Codecs := TBLUtils.ArrayToBLArray<BLImageCodecCore>(CodecHandles);
  10545. _BLCheck(blImageReadFromFile(@FHandle, MarshaledAString(UTF8String(AFilename)), Codecs.Handle));
  10546. end;
  10547. procedure TBLImage.Reset;
  10548. begin
  10549. _BLCheck(blImageReset(@FHandle));
  10550. end;
  10551. class procedure TBLImage.Scale(const ASrc, ADst: IBLImage;
  10552. const ASize: TBLSizeI; const AFilter: TBLImageScaleFilter);
  10553. begin
  10554. if (ASrc <> nil) then
  10555. ASrc.ScaleTo(ADst, ASize, AFilter);
  10556. end;
  10557. class procedure TBLImage.Scale(const ASrc, ADst: IBLImage;
  10558. const ASize: TBLSizeI; const AFilter: TBLImageScaleFilter;
  10559. const AOptions: TBLImageScaleOptions);
  10560. begin
  10561. if (ASrc <> nil) then
  10562. ASrc.ScaleTo(ADst, ASize, AFilter, AOptions);
  10563. end;
  10564. procedure TBLImage.ScaleTo(const ADest: IBLImage; const ASize: TBLSizeI;
  10565. const AFilter: TBLImageScaleFilter);
  10566. begin
  10567. if (ADest <> nil) then
  10568. _BLCheck(blImageScale(ADest.Handle, @FHandle, @ASize, Ord(AFilter), nil));
  10569. end;
  10570. procedure TBLImage.ScaleTo(const ADest: IBLImage; const ASize: TBLSizeI;
  10571. const AFilter: TBLImageScaleFilter; const AOptions: TBLImageScaleOptions);
  10572. begin
  10573. if (ADest <> nil) then
  10574. _BLCheck(blImageScale(ADest.Handle, @FHandle, @ASize, Ord(AFilter), @AOptions.FHandle));
  10575. end;
  10576. function TBLImage.WriteToData(const ACodec: IBLImageCodec): TBytes;
  10577. var
  10578. Codec: PBLImageCodecCore;
  10579. Data: IBLArray;
  10580. begin
  10581. if (ACodec = nil) then
  10582. Codec := nil
  10583. else
  10584. Codec := ACodec.Handle;
  10585. Data := TBLUtils.CreateBLArray<Byte>;
  10586. _BLCheck(blImageWriteToData(@FHandle, Data.Handle, Codec));
  10587. Result := TBLUtils.BLArrayToArray<Byte>(Data);
  10588. end;
  10589. procedure TBLImage.WriteToFile(const AFilename: String);
  10590. begin
  10591. _BLCheck(blImageWriteToFile(@FHandle, MarshaledAString(UTF8String(AFilename)), nil));
  10592. end;
  10593. procedure TBLImage.WriteToFile(const AFilename: String;
  10594. const ACodec: IBLImageCodec);
  10595. var
  10596. Codec: PBLImageCodecCore;
  10597. begin
  10598. if (ACodec = nil) then
  10599. Codec := nil
  10600. else
  10601. Codec := ACodec.Handle;
  10602. _BLCheck(blImageWriteToFile(@FHandle, MarshaledAString(UTF8String(AFilename)), Codec));
  10603. end;
  10604. {$ENDREGION 'Image'}
  10605. {$REGION 'Image Codec'}
  10606. { TBLImageDecoder }
  10607. constructor TBLImageDecoder.Create;
  10608. begin
  10609. inherited Create;
  10610. blImageDecoderInit(@FHandle);
  10611. end;
  10612. destructor TBLImageDecoder.Destroy;
  10613. begin
  10614. blImageDecoderDestroy(@FHandle);
  10615. inherited;
  10616. end;
  10617. function TBLImageDecoder.Equals(Obj: TObject): Boolean;
  10618. begin
  10619. if (Obj = nil) then
  10620. Result := (Self = nil)
  10621. else if (Obj = Self) then
  10622. Result := True
  10623. else if (Obj is TBLImageDecoder) then
  10624. Result := (FHandle.impl = @TBLImageDecoder(Obj).FHandle.impl)
  10625. else
  10626. Result := False;
  10627. end;
  10628. function TBLImageDecoder.Equals(const AOther: IBLImageDecoder): Boolean;
  10629. begin
  10630. if (AOther = nil) then
  10631. Result := (Self = nil)
  10632. else
  10633. Result := (FHandle.impl = AOther.Handle.impl);
  10634. end;
  10635. function TBLImageDecoder.GetBufferIndex: NativeInt;
  10636. begin
  10637. Result := FHandle.impl.bufferIndex;
  10638. end;
  10639. function TBLImageDecoder.GetFrameIndex: Integer;
  10640. begin
  10641. Result := FHandle.impl.frameIndex;
  10642. end;
  10643. function TBLImageDecoder.GetHandle: PBLImageDecoderCore;
  10644. begin
  10645. Result := @FHandle;
  10646. end;
  10647. function TBLImageDecoder.GetIsNone: Boolean;
  10648. begin
  10649. Result := ((FHandle.impl.implTraits and BL_IMPL_TRAIT_NULL) <> 0);
  10650. end;
  10651. function TBLImageDecoder.GetLastResult: TBLResultCode;
  10652. begin
  10653. Result := TBLResultCode(FHandle.impl.lastResult);
  10654. end;
  10655. function TBLImageDecoder.ReadFrame(const ABuffer: Pointer;
  10656. const ASize: Integer): IBLImage;
  10657. begin
  10658. Result := TBLImage.Create;
  10659. _BLCheck(blImageDecoderReadFrame(@FHandle, Result.Handle, ABuffer, ASize));
  10660. end;
  10661. function TBLImageDecoder.ReadFrame(const ABuffer: TBLArrayView<Byte>): IBLImage;
  10662. begin
  10663. Result := TBLImage.Create;
  10664. _BLCheck(blImageDecoderReadFrame(@FHandle, Result.Handle,
  10665. ABuffer.FHandle.data, ABuffer.FHandle.size));
  10666. end;
  10667. function TBLImageDecoder.ReadFrame(const ABuffer: TBytes): IBLImage;
  10668. begin
  10669. Result := TBLImage.Create;
  10670. _BLCheck(blImageDecoderReadFrame(@FHandle, Result.Handle,
  10671. Pointer(ABuffer), Length(ABuffer)));
  10672. end;
  10673. procedure TBLImageDecoder.ReadInfo(const ABuffer: Pointer; const ASize: Integer;
  10674. out AInfo: TBLImageInfo);
  10675. begin
  10676. _BLCheck(blImageDecoderReadInfo(@FHandle, @AInfo.FHandle, ABuffer, ASize));
  10677. end;
  10678. procedure TBLImageDecoder.ReadInfo(const ABuffer: TBLArrayView<Byte>;
  10679. out AInfo: TBLImageInfo);
  10680. begin
  10681. _BLCheck(blImageDecoderReadInfo(@FHandle, @AInfo.FHandle,
  10682. ABuffer.FHandle.data, ABuffer.FHandle.size));
  10683. end;
  10684. procedure TBLImageDecoder.ReadInfo(const ABuffer: TBytes;
  10685. out AInfo: TBLImageInfo);
  10686. begin
  10687. _BLCheck(blImageDecoderReadInfo(@FHandle, @AInfo.FHandle,
  10688. Pointer(ABuffer), Length(ABuffer)));
  10689. end;
  10690. procedure TBLImageDecoder.Reset;
  10691. begin
  10692. _BLCheck(blImageDecoderReset(@FHandle));
  10693. end;
  10694. procedure TBLImageDecoder.Restart;
  10695. begin
  10696. _BLCheck(blImageDecoderRestart(@FHandle));
  10697. end;
  10698. { TBLImageEncoder }
  10699. constructor TBLImageEncoder.Create;
  10700. begin
  10701. inherited Create;
  10702. blImageEncoderInit(@FHandle);
  10703. end;
  10704. destructor TBLImageEncoder.Destroy;
  10705. begin
  10706. blImageEncoderDestroy(@FHandle);
  10707. inherited;
  10708. end;
  10709. function TBLImageEncoder.Equals(Obj: TObject): Boolean;
  10710. begin
  10711. if (Obj = nil) then
  10712. Result := (Self = nil)
  10713. else if (Obj = Self) then
  10714. Result := True
  10715. else if (Obj is TBLImageEncoder) then
  10716. Result := (FHandle.impl = @TBLImageEncoder(Obj).FHandle.impl)
  10717. else
  10718. Result := False;
  10719. end;
  10720. function TBLImageEncoder.Equals(const AOther: IBLImageEncoder): Boolean;
  10721. begin
  10722. if (AOther = nil) then
  10723. Result := (Self = nil)
  10724. else
  10725. Result := (FHandle.impl = AOther.Handle.impl);
  10726. end;
  10727. function TBLImageEncoder.GetBufferIndex: NativeInt;
  10728. begin
  10729. Result := FHandle.impl.bufferIndex;
  10730. end;
  10731. function TBLImageEncoder.GetFrameIndex: Integer;
  10732. begin
  10733. Result := FHandle.impl.frameIndex;
  10734. end;
  10735. function TBLImageEncoder.GetHandle: PBLImageEncoderCore;
  10736. begin
  10737. Result := @FHandle;
  10738. end;
  10739. function TBLImageEncoder.GetIsNone: Boolean;
  10740. begin
  10741. Result := ((FHandle.impl.implTraits and BL_IMPL_TRAIT_NULL) <> 0);
  10742. end;
  10743. function TBLImageEncoder.GetLastResult: TBLResultCode;
  10744. begin
  10745. Result := TBLResultCode(FHandle.impl.lastResult);
  10746. end;
  10747. procedure TBLImageEncoder.Reset;
  10748. begin
  10749. _BLCheck(blImageEncoderReset(@FHandle));
  10750. end;
  10751. procedure TBLImageEncoder.Restart;
  10752. begin
  10753. _BLCheck(blImageEncoderRestart(@FHandle));
  10754. end;
  10755. function TBLImageEncoder.WriteFrame(const AImage: IBLImage): TBytes;
  10756. var
  10757. Dest: IBLArray;
  10758. begin
  10759. if (AImage <> nil) then
  10760. begin
  10761. Dest := TBLUtils.CreateBLArray<Byte>;
  10762. _BLCheck(blImageEncoderWriteFrame(@FHandle, Dest.Handle, AImage.Handle));
  10763. Result := TBLUtils.BLArrayToArray<Byte>(Dest);
  10764. end;
  10765. end;
  10766. { TBLImageCodec }
  10767. class procedure TBLImageCodec.AddToBuiltIn(const ACodec: IBLImageCodec);
  10768. begin
  10769. if (ACodec <> nil) then
  10770. _BLCheck(blImageCodecAddToBuiltIn(ACodec.Handle));
  10771. end;
  10772. constructor TBLImageCodec.Create;
  10773. begin
  10774. inherited Create;
  10775. blImageCodecInit(@FHandle);
  10776. end;
  10777. constructor TBLImageCodec.Create(const AHandle: BLImageCodecCore;
  10778. const AIsReference: Boolean);
  10779. begin
  10780. inherited Create;
  10781. FHandle := AHandle;
  10782. FIsReference := AIsReference;
  10783. end;
  10784. destructor TBLImageCodec.Destroy;
  10785. begin
  10786. if (not FIsReference) then
  10787. blImageCodecDestroy(@FHandle);
  10788. inherited;
  10789. end;
  10790. function TBLImageCodec.Equals(const AOther: IBLImageCodec): Boolean;
  10791. begin
  10792. if (AOther = nil) then
  10793. Result := (Self = nil)
  10794. else
  10795. Result := (FHandle.impl = AOther.Handle.impl);
  10796. end;
  10797. function TBLImageCodec.Equals(Obj: TObject): Boolean;
  10798. begin
  10799. if (Obj = nil) then
  10800. Result := (Self = nil)
  10801. else if (Obj = Self) then
  10802. Result := True
  10803. else if (Obj is TBLImageCodec) then
  10804. Result := (FHandle.impl = @TBLImageCodec(Obj).FHandle.impl)
  10805. else
  10806. Result := False;
  10807. end;
  10808. function TBLImageCodec.FindByData(const AData: TBytes;
  10809. const ACodecs: TArray<IBLImageCodec>): Boolean;
  10810. begin
  10811. Result := FindByData(Pointer(AData), Length(AData), ACodecs);
  10812. end;
  10813. function TBLImageCodec.FindByExtension(const AExt: String;
  10814. const ACodecs: TArray<IBLImageCodec>): Boolean;
  10815. var
  10816. CodecHandles: TArray<BLImageCodecCore>;
  10817. CodecArray: IBLArray;
  10818. Codecs: PBLArrayCore;
  10819. Ext: UTF8String;
  10820. Res: BLResultCode;
  10821. I: Integer;
  10822. begin
  10823. if Assigned(ACodecs) then
  10824. begin
  10825. SetLength(CodecHandles, Length(ACodecs));
  10826. for I := 0 to Length(CodecHandles) - 1 do
  10827. CodecHandles[I] := ACodecs[I].Handle^;
  10828. CodecArray := TBLUtils.ArrayToBLArray<BLImageCodecCore>(CodecHandles);
  10829. Codecs := CodecArray.Handle;
  10830. end
  10831. else
  10832. Codecs := nil;
  10833. Ext := UTF8String(AExt);
  10834. Res := blImageCodecFindByExtension(@FHandle, MarshaledAString(Ext), Length(Ext), Codecs);
  10835. Result := (Res = BL_SUCCESS);
  10836. if (Res <> BL_ERROR_IMAGE_NO_MATCHING_CODEC) then
  10837. _BLCheck(Res);
  10838. end;
  10839. function TBLImageCodec.FindByExtension(const AExt: String): Boolean;
  10840. var
  10841. Ext: UTF8String;
  10842. Res: BLResultCode;
  10843. begin
  10844. Ext := UTF8String(AExt);
  10845. Res := blImageCodecFindByExtension(@FHandle, MarshaledAString(Ext), Length(Ext), nil);
  10846. Result := (Res = BL_SUCCESS);
  10847. if (Res <> BL_ERROR_IMAGE_NO_MATCHING_CODEC) then
  10848. _BLCheck(Res);
  10849. end;
  10850. function TBLImageCodec.FindByData(const AData: Pointer;
  10851. const ASize: Integer): Boolean;
  10852. var
  10853. Res: BLResultCode;
  10854. begin
  10855. Res := blImageCodecFindByData(@FHandle, AData, ASize, nil);
  10856. Result := (Res = BL_SUCCESS);
  10857. if (Res <> BL_ERROR_IMAGE_NO_MATCHING_CODEC) then
  10858. _BLCheck(Res);
  10859. end;
  10860. function TBLImageCodec.FindByData(const AData: Pointer; const ASize: Integer;
  10861. const ACodecs: TArray<IBLImageCodec>): Boolean;
  10862. var
  10863. CodecHandles: TArray<BLImageCodecCore>;
  10864. CodecArray: IBLArray;
  10865. Codecs: PBLArrayCore;
  10866. Res: BLResultCode;
  10867. I: Integer;
  10868. begin
  10869. if Assigned(ACodecs) then
  10870. begin
  10871. SetLength(CodecHandles, Length(ACodecs));
  10872. for I := 0 to Length(CodecHandles) - 1 do
  10873. CodecHandles[I] := ACodecs[I].Handle^;
  10874. CodecArray := TBLUtils.ArrayToBLArray<BLImageCodecCore>(CodecHandles);
  10875. Codecs := CodecArray.Handle;
  10876. end
  10877. else
  10878. Codecs := nil;
  10879. Res := blImageCodecFindByData(@FHandle, AData, ASize, Codecs);
  10880. Result := (Res = BL_SUCCESS);
  10881. if (Res <> BL_ERROR_IMAGE_NO_MATCHING_CODEC) then
  10882. _BLCheck(Res);
  10883. end;
  10884. function TBLImageCodec.FindByData(const AData: TBytes): Boolean;
  10885. var
  10886. Res: BLResultCode;
  10887. begin
  10888. Res := blImageCodecFindByData(@FHandle, Pointer(AData), Length(AData), nil);
  10889. Result := (Res = BL_SUCCESS);
  10890. if (Res <> BL_ERROR_IMAGE_NO_MATCHING_CODEC) then
  10891. _BLCheck(Res);
  10892. end;
  10893. function TBLImageCodec.FindByName(const AName: String;
  10894. const ACodecs: TArray<IBLImageCodec>): Boolean;
  10895. var
  10896. CodecHandles: TArray<BLImageCodecCore>;
  10897. CodecArray: IBLArray;
  10898. Codecs: PBLArrayCore;
  10899. Name: UTF8String;
  10900. Res: BLResultCode;
  10901. I: Integer;
  10902. begin
  10903. if Assigned(ACodecs) then
  10904. begin
  10905. SetLength(CodecHandles, Length(ACodecs));
  10906. for I := 0 to Length(CodecHandles) - 1 do
  10907. CodecHandles[I] := ACodecs[I].Handle^;
  10908. CodecArray := TBLUtils.ArrayToBLArray<BLImageCodecCore>(CodecHandles);
  10909. Codecs := CodecArray.Handle;
  10910. end
  10911. else
  10912. Codecs := nil;
  10913. Name := UTF8String(AName);
  10914. Res := blImageCodecFindByName(@FHandle, MarshaledAString(Name), Length(Name), Codecs);
  10915. Result := (Res = BL_SUCCESS);
  10916. if (Res <> BL_ERROR_IMAGE_NO_MATCHING_CODEC) then
  10917. _BLCheck(Res);
  10918. end;
  10919. function TBLImageCodec.FindByName(const AName: String): Boolean;
  10920. var
  10921. Name: UTF8String;
  10922. Res: BLResultCode;
  10923. begin
  10924. Name := UTF8String(AName);
  10925. Res := blImageCodecFindByName(@FHandle, MarshaledAString(Name), Length(Name), nil);
  10926. Result := (Res = BL_SUCCESS);
  10927. if (Res <> BL_ERROR_IMAGE_NO_MATCHING_CODEC) then
  10928. _BLCheck(Res);
  10929. end;
  10930. class function TBLImageCodec.GetBuiltInCodecs: TArray<IBLImageCodec>;
  10931. var
  10932. CodecArray: IBLArray;
  10933. CodecHandles: TArray<BLImageCodecCore>;
  10934. I: Integer;
  10935. begin
  10936. CodecArray := TBLUtils.CreateBLArray<BLImageCodecCore>;
  10937. _BLCheck(blImageCodecArrayInitBuiltInCodecs(CodecArray.Handle));
  10938. CodecHandles := TBLUtils.BLArrayToArray<BLImageCodecCore>(CodecArray);
  10939. SetLength(Result, Length(CodecHandles));
  10940. for I := 0 to Length(Result) - 1 do
  10941. Result[I] := TBLImageCodec.Create(CodecHandles[I], True);
  10942. end;
  10943. function TBLImageCodec.GetExtensions: String;
  10944. begin
  10945. Result := String(UTF8String(FHandle.impl.extensions));
  10946. end;
  10947. function TBLImageCodec.GetFeatures: TBLImageCodecFeatures;
  10948. begin
  10949. Result := TBLImageCodecFeatures(FHandle.impl.features);
  10950. end;
  10951. function TBLImageCodec.GetHandle: PBLImageCodecCore;
  10952. begin
  10953. Result := @FHandle;
  10954. end;
  10955. function TBLImageCodec.GetIsNone: Boolean;
  10956. begin
  10957. Result := ((FHandle.impl.implTraits and BL_IMPL_TRAIT_NULL) <> 0);
  10958. end;
  10959. function TBLImageCodec.GetMimeType: String;
  10960. begin
  10961. Result := String(UTF8String(FHandle.impl.mimeType));
  10962. end;
  10963. function TBLImageCodec.GetName: String;
  10964. begin
  10965. Result := String(UTF8String(FHandle.impl.name));
  10966. end;
  10967. function TBLImageCodec.GetVendor: String;
  10968. begin
  10969. Result := String(UTF8String(FHandle.impl.vendor));
  10970. end;
  10971. function TBLImageCodec.HasFeature(
  10972. const AFeature: TBLImageCodecFeature): Boolean;
  10973. begin
  10974. Result := ((FHandle.impl.features and Ord(AFeature)) <> 0);
  10975. end;
  10976. function TBLImageCodec.InspectData(const ABuffer: TBytes): Cardinal;
  10977. begin
  10978. Result := blImageCodecInspectData(@FHandle, Pointer(ABuffer), Length(ABuffer));
  10979. end;
  10980. function TBLImageCodec.InspectData(const ABuffer: TBLArrayView<Byte>): Cardinal;
  10981. begin
  10982. Result := blImageCodecInspectData(@FHandle, ABuffer.FHandle.data, ABuffer.FHandle.size);
  10983. end;
  10984. function TBLImageCodec.InspectData(const ABuffer: Pointer;
  10985. const ASize: Integer): Cardinal;
  10986. begin
  10987. Result := blImageCodecInspectData(@FHandle, ABuffer, ASize);
  10988. end;
  10989. class procedure TBLImageCodec.RemoveFromBuiltIn(const ACodec: IBLImageCodec);
  10990. begin
  10991. if (ACodec <> nil) then
  10992. _BLCheck(blImageCodecRemoveFromBuiltIn(ACodec.Handle));
  10993. end;
  10994. procedure TBLImageCodec.Reset;
  10995. begin
  10996. _BLCheck(blImageCodecReset(@FHandle));
  10997. end;
  10998. {$ENDREGION 'Image Codec'}
  10999. {$REGION 'Pattern'}
  11000. { TBLPattern }
  11001. constructor TBLPattern.Create;
  11002. begin
  11003. inherited;
  11004. blPatternInit(@FHandle);
  11005. end;
  11006. constructor TBLPattern.Create(const AImage: IBLImage;
  11007. const AExtendMode: TBLExtendMode);
  11008. begin
  11009. inherited Create;
  11010. FImage := AImage;
  11011. if (AImage = nil) then
  11012. blPatternInit(@FHandle)
  11013. else
  11014. _BLCheck(blPatternInitAs(@FHandle, AImage.Handle, nil, Ord(AExtendMode), nil));
  11015. end;
  11016. constructor TBLPattern.Create(const AImage: IBLImage;
  11017. const AExtendMode: TBLExtendMode; const AMatrix: TBLMatrix2D);
  11018. begin
  11019. inherited Create;
  11020. FImage := AImage;
  11021. if (AImage = nil) then
  11022. blPatternInit(@FHandle)
  11023. else
  11024. _BLCheck(blPatternInitAs(@FHandle, AImage.Handle, nil, Ord(AExtendMode), @AMatrix));
  11025. end;
  11026. constructor TBLPattern.Create(const AImage: IBLImage; const AArea: TBLRectI;
  11027. const AExtendMode: TBLExtendMode);
  11028. begin
  11029. inherited Create;
  11030. FImage := AImage;
  11031. if (AImage = nil) then
  11032. blPatternInit(@FHandle)
  11033. else
  11034. _BLCheck(blPatternInitAs(@FHandle, AImage.Handle, @AArea, Ord(AExtendMode), nil));
  11035. end;
  11036. constructor TBLPattern.Create(const AImage: IBLImage; const AArea: TBLRectI;
  11037. const AExtendMode: TBLExtendMode; const AMatrix: TBLMatrix2D);
  11038. begin
  11039. inherited Create;
  11040. FImage := AImage;
  11041. if (AImage = nil) then
  11042. blPatternInit(@FHandle)
  11043. else
  11044. _BLCheck(blPatternInitAs(@FHandle, AImage.Handle, @AArea, Ord(AExtendMode), @AMatrix));
  11045. end;
  11046. constructor TBLPattern.Create(const AHandle: BLPatternCore;
  11047. const AIsReference: Boolean);
  11048. begin
  11049. inherited Create;
  11050. FHandle := AHandle;
  11051. FIsReference := AIsReference;
  11052. FImage := TBLImage.Create(FHandle.impl.image, True);
  11053. end;
  11054. destructor TBLPattern.Destroy;
  11055. begin
  11056. if (not FIsReference) then
  11057. blPatternDestroy(@FHandle);
  11058. inherited;
  11059. end;
  11060. function TBLPattern.Equals(Obj: TObject): Boolean;
  11061. begin
  11062. if (Obj = nil) then
  11063. Result := (Self = nil)
  11064. else if (Obj = Self) then
  11065. Result := True
  11066. else if (Obj is TBLPattern) then
  11067. Result := blPatternEquals(@FHandle, @TBLPattern(Obj).FHandle)
  11068. else
  11069. Result := False;
  11070. end;
  11071. function TBLPattern.Equals(const AOther: IBLPattern): Boolean;
  11072. begin
  11073. if (AOther = nil) then
  11074. Result := (Self = nil)
  11075. else
  11076. Result := blPatternEquals(@FHandle, AOther.Handle)
  11077. end;
  11078. function TBLPattern.GetArea: TBLRectI;
  11079. begin
  11080. Result.FHandle := FHandle.impl.area;
  11081. end;
  11082. function TBLPattern.GetExtendMode: TBLExtendMode;
  11083. begin
  11084. Result := TBLExtendMode(FHandle.impl.extendMode);
  11085. end;
  11086. function TBLPattern.GetHandle: PBLPatternCore;
  11087. begin
  11088. Result := @FHandle;
  11089. end;
  11090. function TBLPattern.GetHasMatrix: Boolean;
  11091. begin
  11092. Result := (FHandle.impl.matrixType <> BL_MATRIX2D_TYPE_IDENTITY);
  11093. end;
  11094. function TBLPattern.GetImage: IBLImage;
  11095. begin
  11096. Result := FImage;
  11097. end;
  11098. function TBLPattern.GetIsNone: Boolean;
  11099. begin
  11100. Result := ((FHandle.impl.implTraits and BL_IMPL_TRAIT_NULL) <> 0);
  11101. end;
  11102. function TBLPattern.GetMatrix: TBLMatrix2D;
  11103. begin
  11104. Result.FHandle := FHandle.impl.matrix;
  11105. end;
  11106. function TBLPattern.GetMatrixType: TBLMatrix2DType;
  11107. begin
  11108. Result := TBLMatrix2DType(FHandle.impl.matrixType);
  11109. end;
  11110. procedure TBLPattern.Initialize(const AImage: IBLImage; const AArea: TBLRectI;
  11111. const AExtendMode: TBLExtendMode; const AMatrix: TBLMatrix2D);
  11112. begin
  11113. FImage := AImage;
  11114. if (AImage <> nil) then
  11115. _BLCheck(blPatternCreate(@FHandle, AImage.Handle, @AArea, Ord(AExtendMode), @AMatrix));
  11116. end;
  11117. procedure TBLPattern.Initialize(const AImage: IBLImage;
  11118. const AExtendMode: TBLExtendMode);
  11119. begin
  11120. FImage := AImage;
  11121. if (AImage <> nil) then
  11122. _BLCheck(blPatternCreate(@FHandle, AImage.Handle, nil, Ord(AExtendMode), nil));
  11123. end;
  11124. procedure TBLPattern.Initialize(const AImage: IBLImage;
  11125. const AExtendMode: TBLExtendMode; const AMatrix: TBLMatrix2D);
  11126. begin
  11127. FImage := AImage;
  11128. if (AImage <> nil) then
  11129. _BLCheck(blPatternCreate(@FHandle, AImage.Handle, nil, Ord(AExtendMode), @AMatrix));
  11130. end;
  11131. procedure TBLPattern.Initialize(const AImage: IBLImage; const AArea: TBLRectI;
  11132. const AExtendMode: TBLExtendMode);
  11133. begin
  11134. FImage := AImage;
  11135. if (AImage <> nil) then
  11136. _BLCheck(blPatternCreate(@FHandle, AImage.Handle, @AArea, Ord(AExtendMode), nil));
  11137. end;
  11138. procedure TBLPattern.PostRotate(const AAngle: Double);
  11139. begin
  11140. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_ROTATE, @AAngle));
  11141. end;
  11142. procedure TBLPattern.PostRotate(const AAngle, AX, AY: Double);
  11143. var
  11144. Data: array [0..2] of Double;
  11145. begin
  11146. Data[0] := AAngle;
  11147. Data[1] := AX;
  11148. Data[2] := AY;
  11149. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_ROTATE_PT, @Data));
  11150. end;
  11151. procedure TBLPattern.PostRotate(const AAngle: Double; const AP: TBLPointI);
  11152. var
  11153. Data: array [0..2] of Double;
  11154. begin
  11155. Data[0] := AAngle;
  11156. Data[1] := AP.FHandle.x;
  11157. Data[2] := AP.FHandle.y;
  11158. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_ROTATE_PT, @Data));
  11159. end;
  11160. procedure TBLPattern.PostRotate(const AAngle: Double; const AP: TBLPoint);
  11161. var
  11162. Data: array [0..2] of Double;
  11163. begin
  11164. Data[0] := AAngle;
  11165. Data[1] := AP.FHandle.x;
  11166. Data[2] := AP.FHandle.y;
  11167. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_ROTATE_PT, @Data));
  11168. end;
  11169. procedure TBLPattern.PostScale(const AP: TBLPoint);
  11170. begin
  11171. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SCALE, @AP));
  11172. end;
  11173. procedure TBLPattern.PostScale(const AP: TBLPointI);
  11174. var
  11175. Data: array [0..1] of Double;
  11176. begin
  11177. Data[0] := AP.FHandle.x;
  11178. Data[1] := AP.FHandle.y;
  11179. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SCALE, @Data));
  11180. end;
  11181. procedure TBLPattern.PostScale(const AX, AY: Double);
  11182. var
  11183. Data: array [0..1] of Double;
  11184. begin
  11185. Data[0] := AX;
  11186. Data[1] := AY;
  11187. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SCALE, @Data));
  11188. end;
  11189. procedure TBLPattern.PostScale(const AXY: Double);
  11190. var
  11191. Data: array [0..1] of Double;
  11192. begin
  11193. Data[0] := AXY;
  11194. Data[1] := AXY;
  11195. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SCALE, @Data));
  11196. end;
  11197. procedure TBLPattern.PostSkew(const AX, AY: Double);
  11198. var
  11199. Data: array [0..1] of Double;
  11200. begin
  11201. Data[0] := AX;
  11202. Data[1] := AY;
  11203. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SKEW, @Data));
  11204. end;
  11205. procedure TBLPattern.PostSkew(const AP: TBLPoint);
  11206. begin
  11207. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SKEW, @AP));
  11208. end;
  11209. procedure TBLPattern.PostTransform(const AMatrix: TBLMatrix2D);
  11210. begin
  11211. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_TRANSFORM, @AMatrix));
  11212. end;
  11213. procedure TBLPattern.PostTranslate(const AP: TBLPoint);
  11214. begin
  11215. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_TRANSLATE, @AP));
  11216. end;
  11217. procedure TBLPattern.PostTranslate(const AX, AY: Double);
  11218. var
  11219. Data: array [0..1] of Double;
  11220. begin
  11221. Data[0] := AX;
  11222. Data[1] := AY;
  11223. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_TRANSLATE, @Data));
  11224. end;
  11225. procedure TBLPattern.PostTranslate(const AP: TBLPointI);
  11226. var
  11227. Data: array [0..1] of Double;
  11228. begin
  11229. Data[0] := AP.FHandle.x;
  11230. Data[1] := AP.FHandle.y;
  11231. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_TRANSLATE, @Data));
  11232. end;
  11233. procedure TBLPattern.Reset;
  11234. begin
  11235. _BLCheck(blPatternReset(@FHandle));
  11236. end;
  11237. procedure TBLPattern.ResetArea;
  11238. var
  11239. Area: TBLRectI;
  11240. begin
  11241. Area.Reset(0, 0, 0, 0);
  11242. _BLCheck(blPatternSetArea(@FHandle, @Area));
  11243. end;
  11244. procedure TBLPattern.ResetExtendMode;
  11245. begin
  11246. _BLCheck(blPatternSetExtendMode(@FHandle, BL_EXTEND_MODE_REPEAT));
  11247. end;
  11248. procedure TBLPattern.ResetImage;
  11249. begin
  11250. FImage := TBLImage.Create;
  11251. _BLCheck(blPatternSetImage(@FHandle, FImage.Handle, nil));
  11252. end;
  11253. procedure TBLPattern.ResetMatrix;
  11254. begin
  11255. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_RESET, nil));
  11256. end;
  11257. procedure TBLPattern.Rotate(const AAngle: Double; const AP: TBLPoint);
  11258. var
  11259. Data: array [0..2] of Double;
  11260. begin
  11261. Data[0] := AAngle;
  11262. Data[1] := AP.FHandle.x;
  11263. Data[2] := AP.FHandle.y;
  11264. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_ROTATE_PT, @Data));
  11265. end;
  11266. procedure TBLPattern.Rotate(const AAngle, AX, AY: Double);
  11267. var
  11268. Data: array [0..2] of Double;
  11269. begin
  11270. Data[0] := AAngle;
  11271. Data[1] := AX;
  11272. Data[2] := AY;
  11273. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_ROTATE_PT, @Data));
  11274. end;
  11275. procedure TBLPattern.Rotate(const AAngle: Double);
  11276. begin
  11277. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_ROTATE, @AAngle));
  11278. end;
  11279. procedure TBLPattern.Rotate(const AAngle: Double; const AP: TBLPointI);
  11280. var
  11281. Data: array [0..2] of Double;
  11282. begin
  11283. Data[0] := AAngle;
  11284. Data[1] := AP.FHandle.x;
  11285. Data[2] := AP.FHandle.y;
  11286. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_ROTATE_PT, @Data));
  11287. end;
  11288. procedure TBLPattern.Scale(const AX, AY: Double);
  11289. var
  11290. Data: array [0..1] of Double;
  11291. begin
  11292. Data[0] := AX;
  11293. Data[1] := AY;
  11294. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_SCALE, @Data));
  11295. end;
  11296. procedure TBLPattern.Scale(const AXY: Double);
  11297. var
  11298. Data: array [0..1] of Double;
  11299. begin
  11300. Data[0] := AXY;
  11301. Data[1] := AXY;
  11302. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_SCALE, @Data));
  11303. end;
  11304. procedure TBLPattern.Scale(const AP: TBLPointI);
  11305. var
  11306. Data: array [0..1] of Double;
  11307. begin
  11308. Data[0] := AP.FHandle.x;
  11309. Data[1] := AP.FHandle.y;
  11310. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_SCALE, @Data));
  11311. end;
  11312. procedure TBLPattern.Scale(const AP: TBLPoint);
  11313. begin
  11314. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_SCALE, @AP));
  11315. end;
  11316. procedure TBLPattern.SetArea(const AValue: TBLRectI);
  11317. begin
  11318. _BLCheck(blPatternSetArea(@FHandle, @AValue));
  11319. end;
  11320. procedure TBLPattern.SetExtendMode(const AValue: TBLExtendMode);
  11321. begin
  11322. _BLCheck(blPatternSetExtendMode(@FHandle, Ord(AValue)));
  11323. end;
  11324. procedure TBLPattern.SetImage(const AValue: IBLImage; const AArea: TBLRectI);
  11325. begin
  11326. if (AValue <> nil) then
  11327. _BLCheck(blPatternSetImage(@FHandle, AValue.Handle, @AArea));
  11328. end;
  11329. procedure TBLPattern.SetImage(const AValue: IBLImage);
  11330. begin
  11331. if (AValue <> nil) then
  11332. _BLCheck(blPatternSetImage(@FHandle, AValue.Handle, nil));
  11333. end;
  11334. procedure TBLPattern.SetMatrix(const AValue: TBLMatrix2D);
  11335. begin
  11336. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_ASSIGN, @AValue));
  11337. end;
  11338. procedure TBLPattern.Skew(const AX, AY: Double);
  11339. var
  11340. Data: array [0..1] of Double;
  11341. begin
  11342. Data[0] := AX;
  11343. Data[1] := AY;
  11344. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_SKEW, @Data));
  11345. end;
  11346. procedure TBLPattern.Skew(const AP: TBLPoint);
  11347. begin
  11348. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_SKEW, @AP));
  11349. end;
  11350. procedure TBLPattern.Transform(const AMatrix: TBLMatrix2D);
  11351. begin
  11352. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_TRANSFORM, @AMatrix));
  11353. end;
  11354. procedure TBLPattern.Translate(const AP: TBLPoint);
  11355. begin
  11356. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_TRANSLATE, @AP));
  11357. end;
  11358. procedure TBLPattern.Translate(const AX, AY: Double);
  11359. var
  11360. Data: array [0..1] of Double;
  11361. begin
  11362. Data[0] := AX;
  11363. Data[1] := AY;
  11364. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_TRANSLATE, @Data));
  11365. end;
  11366. procedure TBLPattern.Translate(const AP: TBLPointI);
  11367. var
  11368. Data: array [0..1] of Double;
  11369. begin
  11370. Data[0] := AP.FHandle.x;
  11371. Data[1] := AP.FHandle.y;
  11372. _BLCheck(blPatternApplyMatrixOp(@FHandle, BL_MATRIX2D_OP_TRANSLATE, @Data));
  11373. end;
  11374. {$ENDREGION 'Pattern'}
  11375. {$REGION 'Font Defs'}
  11376. { TBLGlyphInfo }
  11377. procedure TBLGlyphInfo.Reset;
  11378. begin
  11379. FillChar(FHandle, SizeOf(FHandle), 0);
  11380. end;
  11381. { TBLGlyphPlacement }
  11382. function TBLGlyphPlacement.GetAdvance: TBLPointI;
  11383. begin
  11384. Result.FHandle := FHandle.advance;
  11385. end;
  11386. function TBLGlyphPlacement.GetPlacement: TBLPointI;
  11387. begin
  11388. Result.FHandle := FHandle.placement;
  11389. end;
  11390. procedure TBLGlyphPlacement.Reset;
  11391. begin
  11392. FillChar(FHandle, SizeOf(FHandle), 0);
  11393. end;
  11394. procedure TBLGlyphPlacement.SetAdvance(const AValue: TBLPointI);
  11395. begin
  11396. FHandle.advance := AValue.FHandle;
  11397. end;
  11398. procedure TBLGlyphPlacement.SetPlacement(const AValue: TBLPointI);
  11399. begin
  11400. FHandle.placement := AValue.FHandle;
  11401. end;
  11402. { TBLGlyphMappingState }
  11403. function TBLGlyphMappingState.GetGlyphCount: Integer;
  11404. begin
  11405. Result := FHandle.glyphCount;
  11406. end;
  11407. function TBLGlyphMappingState.GetUndefinedCount: Integer;
  11408. begin
  11409. Result := FHandle.undefinedCount;
  11410. end;
  11411. function TBLGlyphMappingState.GetUndefinedFirst: Integer;
  11412. begin
  11413. Result := FHandle.undefinedFirst;
  11414. end;
  11415. procedure TBLGlyphMappingState.Reset;
  11416. begin
  11417. FillChar(FHandle, SizeOf(FHandle), 0);
  11418. end;
  11419. procedure TBLGlyphMappingState.SetGlyphCount(const AValue: Integer);
  11420. begin
  11421. FHandle.glyphCount := AValue;
  11422. end;
  11423. procedure TBLGlyphMappingState.SetUndefinedCount(const AValue: Integer);
  11424. begin
  11425. FHandle.undefinedCount := AValue;
  11426. end;
  11427. procedure TBLGlyphMappingState.SetUndefinedFirst(const AValue: Integer);
  11428. begin
  11429. FHandle.undefinedFirst := AValue;
  11430. end;
  11431. { TBLGlyphOutlineSinkInfo }
  11432. function TBLGlyphOutlineSinkInfo.GetContourCount: Integer;
  11433. begin
  11434. Result := FHandle.contourCount;
  11435. end;
  11436. function TBLGlyphOutlineSinkInfo.GetGlyphIndex: Integer;
  11437. begin
  11438. Result := FHandle.glyphIndex;
  11439. end;
  11440. procedure TBLGlyphOutlineSinkInfo.Reset;
  11441. begin
  11442. FillChar(FHandle, SizeOf(FHandle), 0);
  11443. end;
  11444. procedure TBLGlyphOutlineSinkInfo.SetContourCount(const AValue: Integer);
  11445. begin
  11446. FHandle.contourCount := AValue;
  11447. end;
  11448. procedure TBLGlyphOutlineSinkInfo.SetGlyphIndex(const AValue: Integer);
  11449. begin
  11450. FHandle.glyphIndex := AValue;
  11451. end;
  11452. { TBLGlyphRun }
  11453. function TBLGlyphRun.Entries<TPlacement>: TEnumerable<TPlacement>;
  11454. begin
  11455. Result := TEnumerable<TPlacement>.Create(@FHandle);
  11456. end;
  11457. function TBLGlyphRun.GetFlags: TBLGlyphRunFlags;
  11458. begin
  11459. Cardinal(Result) := FHandle.flags;
  11460. end;
  11461. function TBLGlyphRun.GetIsEmpty: Boolean;
  11462. begin
  11463. Result := (FHandle.size = 0);
  11464. end;
  11465. function TBLGlyphRun.GetPlacementType: TBLGlyphPlacementType;
  11466. begin
  11467. Result := TBLGlyphPlacementType(FHandle.placementType);
  11468. end;
  11469. function TBLGlyphRun.GetSize: Integer;
  11470. begin
  11471. Result := FHandle.size;
  11472. end;
  11473. procedure TBLGlyphRun.Reset;
  11474. begin
  11475. FillChar(FHandle, SizeOf(FHandle), 0);
  11476. end;
  11477. procedure TBLGlyphRun.ResetGlyphIdData;
  11478. begin
  11479. FHandle.glyphData := nil;
  11480. FHandle.glyphAdvance := 0;
  11481. end;
  11482. procedure TBLGlyphRun.ResetPlacementData;
  11483. begin
  11484. FHandle.placementData := nil;
  11485. FHandle.placementAdvance := 0;
  11486. end;
  11487. procedure TBLGlyphRun.SetFlags(const AValue: TBLGlyphRunFlags);
  11488. begin
  11489. FHandle.flags := Cardinal(AValue);
  11490. end;
  11491. procedure TBLGlyphRun.SetGlyphData(const AData: Pointer;
  11492. const AAdvance: Integer);
  11493. begin
  11494. FHandle.glyphData := AData;
  11495. FHandle.glyphAdvance := AAdvance;
  11496. end;
  11497. procedure TBLGlyphRun.SetGlyphData(const AData: PCardinal);
  11498. begin
  11499. FHandle.glyphData := AData;
  11500. FHandle.glyphAdvance := SizeOf(Cardinal);
  11501. end;
  11502. procedure TBLGlyphRun.SetGlyphData(const AData: PWord);
  11503. begin
  11504. FHandle.glyphData := AData;
  11505. FHandle.glyphAdvance := SizeOf(Word);
  11506. end;
  11507. procedure TBLGlyphRun.SetPlacementData(const AData: Pointer;
  11508. const AAdvance: Integer);
  11509. begin
  11510. FHandle.placementData := AData;
  11511. FHandle.placementAdvance := AAdvance;
  11512. end;
  11513. procedure TBLGlyphRun.SetPlacementType(const AValue: TBLGlyphPlacementType);
  11514. begin
  11515. FHandle.placementType := Ord(AValue);
  11516. end;
  11517. procedure TBLGlyphRun.SetSize(const AValue: Integer);
  11518. begin
  11519. FHandle.size := AValue;
  11520. end;
  11521. { TBLGlyphRun.TEnumerable<T> }
  11522. constructor TBLGlyphRun.TEnumerable<T>.Create(const AHandle: _PBLGlyphRun);
  11523. begin
  11524. FHandle := AHandle;
  11525. end;
  11526. function TBLGlyphRun.TEnumerable<T>.GetEnumerator: TEnumerator<T>;
  11527. begin
  11528. Result := TEnumerator<T>.Create(FHandle);
  11529. end;
  11530. { TBLGlyphRun.TEnumerator<T> }
  11531. constructor TBLGlyphRun.TEnumerator<T>.Create(const AHandle: _PBLGlyphRun);
  11532. begin
  11533. FGlyphData := AHandle.glyphData;
  11534. FPlacementData := AHandle.placementData;
  11535. FGlyphAdvance := AHandle.glyphAdvance;
  11536. FPlacementAdvance := AHandle.placementAdvance;
  11537. FHigh := AHandle.size;
  11538. Dec(FHigh);
  11539. FIndex := -1;
  11540. Dec(FGlyphData, FGlyphAdvance);
  11541. Dec(FPlacementData, FPlacementAdvance);
  11542. end;
  11543. function TBLGlyphRun.TEnumerator<T>.GetCurrent: TBLGlyphRunEntry<T>;
  11544. begin
  11545. Result.GlyphId := PWord(FGlyphData)^;
  11546. Result.Placement := P(FPlacementData)^;
  11547. end;
  11548. function TBLGlyphRun.TEnumerator<T>.MoveNext: Boolean;
  11549. begin
  11550. Result := (FIndex < FHigh);
  11551. if Result then
  11552. begin
  11553. Inc(FIndex);
  11554. Inc(FGlyphData, FGlyphAdvance);
  11555. Inc(FPlacementData, FPlacementAdvance);
  11556. end;
  11557. end;
  11558. { TBLFontFaceInfo }
  11559. function TBLFontFaceInfo.GetDiagFlags: TBLFontFaceDiagFlags;
  11560. begin
  11561. Word(Result) := FHandle.diagFlags;
  11562. end;
  11563. function TBLFontFaceInfo.GetFaceFlags: TBLFontFaceFlags;
  11564. begin
  11565. Cardinal(Result) := FHandle.faceFlags;
  11566. end;
  11567. function TBLFontFaceInfo.GetFaceType: TBLFontFaceType;
  11568. begin
  11569. Result := TBLFontFaceType(FHandle.faceType);
  11570. end;
  11571. function TBLFontFaceInfo.GetGlyphCount: Integer;
  11572. begin
  11573. Result := FHandle.glyphCount;
  11574. end;
  11575. function TBLFontFaceInfo.GetOutlineType: TBLFontOutlineType;
  11576. begin
  11577. Result := TBLFontOutlineType(FHandle.outlineType);
  11578. end;
  11579. procedure TBLFontFaceInfo.Reset;
  11580. begin
  11581. FillChar(FHandle, SizeOf(FHandle), 0);
  11582. end;
  11583. procedure TBLFontFaceInfo.SetDiagFlags(const AValue: TBLFontFaceDiagFlags);
  11584. begin
  11585. FHandle.diagFlags := Word(AValue);
  11586. end;
  11587. procedure TBLFontFaceInfo.SetFaceFlags(const AValue: TBLFontFaceFlags);
  11588. begin
  11589. FHandle.faceFlags := Cardinal(AValue);
  11590. end;
  11591. procedure TBLFontFaceInfo.SetFaceType(const AValue: TBLFontFaceType);
  11592. begin
  11593. FHandle.faceType := Ord(AValue);
  11594. end;
  11595. procedure TBLFontFaceInfo.SetGlyphCount(const AValue: Integer);
  11596. begin
  11597. FHandle.glyphCount := AValue;
  11598. end;
  11599. procedure TBLFontFaceInfo.SetOutlineType(const AValue: TBLFontOutlineType);
  11600. begin
  11601. FHandle.outlineType := Ord(AValue);
  11602. end;
  11603. { TBLFontQueryProperties }
  11604. function TBLFontQueryProperties.GetStretch: TBLFontStretch;
  11605. begin
  11606. Result := TBLFontStretch(FHandle.stretch);
  11607. end;
  11608. function TBLFontQueryProperties.GetStyle: TBLFontStyle;
  11609. begin
  11610. Result := TBLFontStyle(FHandle.style);
  11611. end;
  11612. function TBLFontQueryProperties.GetWeight: TBLFontWeight;
  11613. begin
  11614. Result := TBLFontWeight(FHandle.weight);
  11615. end;
  11616. procedure TBLFontQueryProperties.Reset;
  11617. begin
  11618. FillChar(FHandle, SizeOf(FHandle), 0);
  11619. end;
  11620. procedure TBLFontQueryProperties.SetStretch(const AValue: TBLFontStretch);
  11621. begin
  11622. FHandle.stretch := Ord(AValue);
  11623. end;
  11624. procedure TBLFontQueryProperties.SetStyle(const AValue: TBLFontStyle);
  11625. begin
  11626. FHandle.style := Ord(AValue);
  11627. end;
  11628. procedure TBLFontQueryProperties.SetWeight(const AValue: TBLFontWeight);
  11629. begin
  11630. FHandle.weight := Ord(AValue);
  11631. end;
  11632. { TBLFontTable }
  11633. function TBLFontTable.GetSize: Integer;
  11634. begin
  11635. Result := FHandle.size;
  11636. end;
  11637. procedure TBLFontTable.Reset;
  11638. begin
  11639. FillChar(FHandle, SizeOf(FHandle), 0);
  11640. end;
  11641. procedure TBLFontTable.Reset(const AData: Pointer; const ASize: Integer);
  11642. begin
  11643. FHandle.data := AData;
  11644. FHandle.size := ASize;
  11645. end;
  11646. procedure TBLFontTable.SetSize(const AValue: Integer);
  11647. begin
  11648. FHandle.size := AValue;
  11649. end;
  11650. { TBLFontFeature }
  11651. procedure TBLFontFeature.Reset;
  11652. begin
  11653. FillChar(FHandle, SizeOf(FHandle), 0);
  11654. end;
  11655. { TBLFontVariation }
  11656. procedure TBLFontVariation.Reset;
  11657. begin
  11658. FillChar(FHandle, SizeOf(FHandle), 0);
  11659. end;
  11660. { TBLFontUnicodeCoverage }
  11661. procedure TBLFontUnicodeCoverage.ClearBit(
  11662. const AIndex: TBLFontUnicodeCoverageIndex);
  11663. var
  11664. I: Integer;
  11665. begin
  11666. I := Ord(AIndex);
  11667. FHandle.data[I shr 5] := FHandle.data[I shr 5] and not (1 shl (I and 31));
  11668. end;
  11669. class operator TBLFontUnicodeCoverage.Equal(const ALeft,
  11670. ARight: TBLFontUnicodeCoverage): Boolean;
  11671. begin
  11672. Result := (ALeft.FHandle.data[0] = ARight.FHandle.data[0])
  11673. and (ALeft.FHandle.data[1] = ARight.FHandle.data[1])
  11674. and (ALeft.FHandle.data[2] = ARight.FHandle.data[2])
  11675. and (ALeft.FHandle.data[3] = ARight.FHandle.data[3]);
  11676. end;
  11677. function TBLFontUnicodeCoverage.GetBit(
  11678. const AIndex: TBLFontUnicodeCoverageIndex): Boolean;
  11679. var
  11680. I: Integer;
  11681. begin
  11682. I := Ord(AIndex);
  11683. Result := (((FHandle.data[I shr 5] shr (I and 31)) and 1) <> 0);
  11684. end;
  11685. function TBLFontUnicodeCoverage.GetIsEmpty: Boolean;
  11686. begin
  11687. Result := (FHandle.data[0] = 0) and (FHandle.data[1] = 0)
  11688. and (FHandle.data[2] = 0) and (FHandle.data[3] = 0);
  11689. end;
  11690. class operator TBLFontUnicodeCoverage.NotEqual(const ALeft,
  11691. ARight: TBLFontUnicodeCoverage): Boolean;
  11692. begin
  11693. Result := not (ALeft = ARight);
  11694. end;
  11695. procedure TBLFontUnicodeCoverage.Reset;
  11696. begin
  11697. FillChar(FHandle, SizeOf(FHandle), 0);
  11698. end;
  11699. procedure TBLFontUnicodeCoverage.SetBit(
  11700. const AIndex: TBLFontUnicodeCoverageIndex; const AValue: Boolean);
  11701. begin
  11702. if (AValue) then
  11703. SetBit(AIndex)
  11704. else
  11705. ClearBit(AIndex);
  11706. end;
  11707. procedure TBLFontUnicodeCoverage.SetBit(
  11708. const AIndex: TBLFontUnicodeCoverageIndex);
  11709. var
  11710. I: Integer;
  11711. begin
  11712. I := Ord(AIndex);
  11713. FHandle.data[I shr 5] := FHandle.data[I shr 5] or (1 shl (I and 31));
  11714. end;
  11715. { TBLFontPanose }
  11716. function TBLFontPanose.GetIsEmpty: Boolean;
  11717. begin
  11718. Result := (Data[0] = 0) and (Data[1] = 0)
  11719. and (Data[2] = 0) and (Data[3] = 0)
  11720. and (Data[4] = 0) and (Data[5] = 0)
  11721. and (Data[6] = 0) and (Data[7] = 0)
  11722. and (Data[8] = 0) and (Data[9] = 0);
  11723. end;
  11724. procedure TBLFontPanose.Reset;
  11725. begin
  11726. FillChar(Self, SizeOf(Self), 0);
  11727. end;
  11728. { TBLFontMatrix }
  11729. function BLFontMatrix(const AM00, AM01, AM10, AM11: Double): TBLFontMatrix; inline;
  11730. begin
  11731. Result.Reset(AM00, AM01, AM10, AM11);
  11732. end;
  11733. function TBLFontMatrix.GetElement(const AIndex: Integer): Double;
  11734. begin
  11735. Assert(Cardinal(AIndex) < 4);
  11736. Result := FHandle.m[AIndex];
  11737. end;
  11738. procedure TBLFontMatrix.Reset;
  11739. begin
  11740. FHandle.m00 := 1;
  11741. FHandle.m01 := 0;
  11742. FHandle.m10 := 0;
  11743. FHandle.m11 := 1;
  11744. end;
  11745. procedure TBLFontMatrix.Reset(const AM00, AM01, AM10, AM11: Double);
  11746. begin
  11747. FHandle.m00 := AM00;
  11748. FHandle.m01 := AM01;
  11749. FHandle.m10 := AM10;
  11750. FHandle.m11 := AM11;
  11751. end;
  11752. procedure TBLFontMatrix.SetElement(const AIndex: Integer; const AValue: Double);
  11753. begin
  11754. Assert(Cardinal(AIndex) < 4);
  11755. FHandle.m[AIndex] := AValue;
  11756. end;
  11757. { TBLFontMetrics }
  11758. procedure TBLFontMetrics.Reset;
  11759. begin
  11760. FillChar(FHandle, SizeOf(FHandle), 0);
  11761. end;
  11762. { TBLFontDesignMetrics }
  11763. function TBLFontDesignMetrics.GetGlyphBoundingBox: TBLBoxI;
  11764. begin
  11765. Result.FHandle := FHandle.glyphBoundingBox;
  11766. end;
  11767. procedure TBLFontDesignMetrics.Reset;
  11768. begin
  11769. FillChar(FHandle, SizeOf(FHandle), 0);
  11770. end;
  11771. procedure TBLFontDesignMetrics.SetGlyphBoundingBox(const AValue: TBLBoxI);
  11772. begin
  11773. FHandle.glyphBoundingBox := AValue.FHandle;
  11774. end;
  11775. { TBLTextMetrics }
  11776. function TBLTextMetrics.GetAdvance: TBLPoint;
  11777. begin
  11778. Result.FHandle := FHandle.advance;
  11779. end;
  11780. function TBLTextMetrics.GetBoundingBox: TBLBox;
  11781. begin
  11782. Result.FHandle := FHandle.boundingBox;
  11783. end;
  11784. function TBLTextMetrics.GetLeadingBearing: TBLPoint;
  11785. begin
  11786. Result.FHandle := FHandle.leadingBearing;
  11787. end;
  11788. function TBLTextMetrics.GetTrailingBearing: TBLPoint;
  11789. begin
  11790. Result.FHandle := FHandle.trailingBearing;
  11791. end;
  11792. procedure TBLTextMetrics.Reset;
  11793. begin
  11794. FillChar(FHandle, SizeOf(FHandle), 0);
  11795. end;
  11796. procedure TBLTextMetrics.SetAdvance(const AValue: TBLPoint);
  11797. begin
  11798. FHandle.advance := AValue.FHandle;
  11799. end;
  11800. procedure TBLTextMetrics.SetBoundingBox(const AValue: TBLBox);
  11801. begin
  11802. FHandle.boundingBox := AValue.FHandle;
  11803. end;
  11804. procedure TBLTextMetrics.SetLeadingBearing(const AValue: TBLPoint);
  11805. begin
  11806. FHandle.leadingBearing := AValue.FHandle;
  11807. end;
  11808. procedure TBLTextMetrics.SetTrailingBearing(const AValue: TBLPoint);
  11809. begin
  11810. FHandle.trailingBearing := AValue.FHandle;
  11811. end;
  11812. {$ENDREGION 'Font Defs'}
  11813. {$REGION 'Glyph Buffer'}
  11814. { TBLGlyphBuffer }
  11815. procedure TBLGlyphBuffer.Clear;
  11816. begin
  11817. _BLCheck(blGlyphBufferClear(@FHandle));
  11818. end;
  11819. constructor TBLGlyphBuffer.Create;
  11820. begin
  11821. inherited;
  11822. blGlyphBufferInit(@FHandle);
  11823. end;
  11824. destructor TBLGlyphBuffer.Destroy;
  11825. begin
  11826. blGlyphBufferDestroy(@FHandle);
  11827. inherited;
  11828. end;
  11829. function TBLGlyphBuffer.GetContent: PCardinal;
  11830. begin
  11831. Result := PCardinal(FHandle.impl.data.content);
  11832. end;
  11833. function TBLGlyphBuffer.GetFlags: TBLGlyphRunFlags;
  11834. begin
  11835. Cardinal(Result) := FHandle.impl.data.flags;
  11836. end;
  11837. function TBLGlyphBuffer.GetGlyphRun: PBLGlyphRun;
  11838. begin
  11839. Result := @FHandle.impl.data.glyphRun;
  11840. end;
  11841. function TBLGlyphBuffer.GetHandle: PBLGlyphBufferCore;
  11842. begin
  11843. Result := @FHandle;
  11844. end;
  11845. function TBLGlyphBuffer.GetHasGlyphs: Boolean;
  11846. begin
  11847. Result := ((FHandle.impl.data.flags and BL_GLYPH_RUN_FLAG_UCS4_CONTENT) = 0);
  11848. end;
  11849. function TBLGlyphBuffer.GetHasInvalidChars: Boolean;
  11850. begin
  11851. Result := ((FHandle.impl.data.flags and BL_GLYPH_RUN_FLAG_INVALID_TEXT) <> 0);
  11852. end;
  11853. function TBLGlyphBuffer.GetHasInvalidFontData: Boolean;
  11854. begin
  11855. Result := ((FHandle.impl.data.flags and BL_GLYPH_RUN_FLAG_INVALID_FONT_DATA) <> 0);
  11856. end;
  11857. function TBLGlyphBuffer.GetHasText: Boolean;
  11858. begin
  11859. Result := ((FHandle.impl.data.flags and BL_GLYPH_RUN_FLAG_UCS4_CONTENT) <> 0);
  11860. end;
  11861. function TBLGlyphBuffer.GetHasUndefinedChars: Boolean;
  11862. begin
  11863. Result := ((FHandle.impl.data.flags and BL_GLYPH_RUN_FLAG_UNDEFINED_GLYPHS) <> 0);
  11864. end;
  11865. function TBLGlyphBuffer.GetInfoData: PBLGlyphInfo;
  11866. begin
  11867. Result := PBLGlyphInfo(FHandle.impl.infoData);
  11868. end;
  11869. function TBLGlyphBuffer.GetIsEmpty: Boolean;
  11870. begin
  11871. Result := (FHandle.impl.data.glyphRun.size = 0);
  11872. end;
  11873. function TBLGlyphBuffer.GetPlacementData: PBLGlyphPlacement;
  11874. begin
  11875. Result := PBLGlyphPlacement(FHandle.impl.data.placementData);
  11876. end;
  11877. function TBLGlyphBuffer.GetSize: Integer;
  11878. begin
  11879. Result := FHandle.impl.data.size;
  11880. end;
  11881. function TBLGlyphBuffer.HasFlag(const AFlag: TBLGlyphRunFlag): Boolean;
  11882. begin
  11883. Result := ((FHandle.impl.data.flags and Ord(AFlag)) <> 0);
  11884. end;
  11885. procedure TBLGlyphBuffer.Reset;
  11886. begin
  11887. _BLCheck(blGlyphBufferReset(@FHandle));
  11888. end;
  11889. procedure TBLGlyphBuffer.SetGlyphs(const AGlyphData: Pointer; const ASize,
  11890. AGlyphIdSize, AGlyphAdvance: Integer);
  11891. begin
  11892. _BLCheck(blGlyphBufferSetGlyphsFromStruct(@FHandle, AGlyphData, ASize,
  11893. AGlyphIdSize, AGlyphAdvance));
  11894. end;
  11895. procedure TBLGlyphBuffer.SetGlyphs(const AGlyphData: PCardinal;
  11896. const ALength: Integer);
  11897. begin
  11898. _BLCheck(blGlyphBufferSetGlyphs(@FHandle, Pointer(AGlyphData), ALength));
  11899. end;
  11900. procedure TBLGlyphBuffer.SetGlyphs(const AGlyphData: TArray<Cardinal>);
  11901. begin
  11902. _BLCheck(blGlyphBufferSetGlyphs(@FHandle, Pointer(AGlyphData), Length(AGlyphData)));
  11903. end;
  11904. procedure TBLGlyphBuffer.SetText(const AText: String);
  11905. begin
  11906. _BLCheck(blGlyphBufferSetText(@FHandle, PChar(AText), Length(AText), BL_TEXT_ENCODING_UTF16));
  11907. end;
  11908. procedure TBLGlyphBuffer.SetText(const AText: Pointer; const ALength: Integer;
  11909. const AEncoding: TBLTextEncoding);
  11910. begin
  11911. _BLCheck(blGlyphBufferSetText(@FHandle, AText, ALength, Ord(AEncoding)));
  11912. end;
  11913. procedure TBLGlyphBuffer.SetText(const AText: UCS4String);
  11914. begin
  11915. _BLCheck(blGlyphBufferSetText(@FHandle, Pointer(AText), Length(AText) - 1, BL_TEXT_ENCODING_UTF32));
  11916. end;
  11917. procedure TBLGlyphBuffer.SetText(const AText: UTF8String);
  11918. begin
  11919. _BLCheck(blGlyphBufferSetText(@FHandle, PUTF8Char(AText), Length(AText), BL_TEXT_ENCODING_UTF8));
  11920. end;
  11921. {$ENDREGION 'Glyph Buffer'}
  11922. {$REGION 'Font'}
  11923. { TBLFontData }
  11924. constructor TBLFontData.Create;
  11925. begin
  11926. inherited;
  11927. blFontDataInit(@FHandle);
  11928. end;
  11929. constructor TBLFontData.Create(const AHandle: BLFontDataCore;
  11930. const AIsReference: Boolean);
  11931. begin
  11932. inherited Create;
  11933. FHandle := AHandle;
  11934. FIsReference := AIsReference;
  11935. end;
  11936. destructor TBLFontData.Destroy;
  11937. begin
  11938. if (not FIsReference) then
  11939. blFontDataDestroy(@FHandle);
  11940. inherited;
  11941. end;
  11942. class procedure TBLFontData.DoDestroy(impl, destroyData: Pointer);
  11943. var
  11944. Data: PDestroyData absolute destroyData;
  11945. begin
  11946. if (Data <> nil) then
  11947. begin
  11948. Data.Event(Data.FontData);
  11949. FreeMem(Data);
  11950. end;
  11951. end;
  11952. function TBLFontData.Equals(Obj: TObject): Boolean;
  11953. begin
  11954. if (Obj = nil) then
  11955. Result := (Self = nil)
  11956. else if (Obj = Self) then
  11957. Result := True
  11958. else if (Obj is TBLFontData) then
  11959. Result := blFontDataEquals(@FHandle, @TBLFontData(Obj).FHandle)
  11960. else
  11961. Result := False;
  11962. end;
  11963. function TBLFontData.Equals(const AOther: IBLFontData): Boolean;
  11964. begin
  11965. if (AOther = nil) then
  11966. Result := (Self = nil)
  11967. else
  11968. Result := blFontDataEquals(@FHandle, AOther.Handle)
  11969. end;
  11970. function TBLFontData.GetFaceCount: Integer;
  11971. begin
  11972. Result := FHandle.impl.faceCount;
  11973. end;
  11974. function TBLFontData.GetFaceType: TBLFontFaceType;
  11975. begin
  11976. Result := TBLFontFaceType(FHandle.impl.faceType);
  11977. end;
  11978. function TBLFontData.GetFlags: TBLFontDataFlags;
  11979. begin
  11980. Byte(Result) := FHandle.impl.flags;
  11981. end;
  11982. function TBLFontData.GetHandle: PBLFontDataCore;
  11983. begin
  11984. Result := @FHandle;
  11985. end;
  11986. function TBLFontData.GetIsCollection: Boolean;
  11987. begin
  11988. Result := ((FHandle.impl.flags and BL_FONT_DATA_FLAG_COLLECTION) <> 0);
  11989. end;
  11990. function TBLFontData.GetIsNone: Boolean;
  11991. begin
  11992. Result := ((FHandle.impl.implTraits and BL_IMPL_TRAIT_NULL) <> 0);
  11993. end;
  11994. function TBLFontData.GetTags(const AFaceIndex: Integer): TArray<TBLTag>;
  11995. var
  11996. Tags: IBLArray;
  11997. begin
  11998. Tags := TBLUtils.CreateBLArray<TBLTag>;
  11999. _BLCheck(blFontDataListTags(@FHandle, AFaceIndex, Tags.Handle));
  12000. Result := TBLUtils.BLArrayToArray<TBLTag>(Tags);
  12001. end;
  12002. procedure TBLFontData.InitializeFromData(const AData: TBytes);
  12003. var
  12004. Data: IBLArray;
  12005. begin
  12006. if (AData <> nil) then
  12007. begin
  12008. Data := TBLUtils.ArrayToBLArray<Byte>(AData);
  12009. _BLCheck(blFontDataCreateFromDataArray(@FHandle, Data.Handle));
  12010. end;
  12011. end;
  12012. procedure TBLFontData.InitializeFromData(const AData: Pointer;
  12013. const ASize: Integer; const AOnDestroy: TBLFontDataDestroyEvent);
  12014. var
  12015. DestroyFunc: BLDestroyImplFunc;
  12016. DestroyData: PDestroyData;
  12017. begin
  12018. if Assigned(AOnDestroy) then
  12019. begin
  12020. DestroyFunc := DoDestroy;
  12021. GetMem(DestroyData, SizeOf(TDestroyData));
  12022. DestroyData.FontData := Self;
  12023. DestroyData.Event := AOnDestroy;
  12024. end
  12025. else
  12026. begin
  12027. DestroyFunc := nil;
  12028. DestroyData := nil;
  12029. end;
  12030. _BLCheck(blFontDataCreateFromData(@FHandle, AData, ASize, DestroyFunc, DestroyData));
  12031. end;
  12032. procedure TBLFontData.InitializeFromFile(const AFilename: String;
  12033. const AReadFlags: TBLFileReadFlags);
  12034. begin
  12035. _BLCheck(blFontDataCreateFromFile(@FHandle, MarshaledAString(UTF8String(AFilename)),
  12036. Byte(AReadFlags)));
  12037. end;
  12038. function TBLFontData.QueryTable(const AFaceIndex: Integer; const ATag: TBLTag;
  12039. out ATable: TBLFontTable): Integer;
  12040. begin
  12041. Result := blFontDataQueryTables(@FHandle, AFaceIndex, @ATable.FHandle, @ATag, 1);
  12042. end;
  12043. function TBLFontData.QueryTables(const AFaceIndex: Integer;
  12044. const ATags: TArray<TBLTag>; out ATables: TArray<TBLFontTable>): Integer;
  12045. begin
  12046. SetLength(ATables, Length(ATags));
  12047. Result := blFontDataQueryTables(@FHandle, AFaceIndex, Pointer(ATables),
  12048. Pointer(ATags), Length(ATags));
  12049. end;
  12050. procedure TBLFontData.Reset;
  12051. begin
  12052. _BLCheck(blFontDataReset(@FHandle));
  12053. end;
  12054. { TBLFontFace }
  12055. constructor TBLFontFace.Create;
  12056. begin
  12057. inherited;
  12058. blFontFaceInit(@FHandle);
  12059. end;
  12060. constructor TBLFontFace.Create(const AHandle: BLFontFaceCore;
  12061. const AIsReference: Boolean);
  12062. begin
  12063. inherited Create;
  12064. FHandle := AHandle;
  12065. FIsReference := AIsReference;
  12066. end;
  12067. destructor TBLFontFace.Destroy;
  12068. begin
  12069. if (not FIsReference) then
  12070. blFontFaceDestroy(@FHandle);
  12071. inherited;
  12072. end;
  12073. function TBLFontFace.Equals(const AOther: IBLFontFace): Boolean;
  12074. begin
  12075. if (AOther = nil) then
  12076. Result := (Self = nil)
  12077. else
  12078. Result := blFontFaceEquals(@FHandle, AOther.Handle)
  12079. end;
  12080. function TBLFontFace.Equals(Obj: TObject): Boolean;
  12081. begin
  12082. if (Obj = nil) then
  12083. Result := (Self = nil)
  12084. else if (Obj = Self) then
  12085. Result := True
  12086. else if (Obj is TBLFontFace) then
  12087. Result := blFontFaceEquals(@FHandle, @TBLFontFace(Obj).FHandle)
  12088. else
  12089. Result := False;
  12090. end;
  12091. function TBLFontFace.GetData: IBLFontData;
  12092. begin
  12093. if (FData = nil) then
  12094. FData := TBLFontData.Create(FHandle.impl.data, True);
  12095. Result := FData;
  12096. end;
  12097. function TBLFontFace.GetDesignMetrics: TBLFontDesignMetrics;
  12098. begin
  12099. Result.FHandle := FHandle.impl.designMetrics;
  12100. end;
  12101. function TBLFontFace.GetDiagFlags: TBLFontFaceDiagFlags;
  12102. begin
  12103. Word(Result) := FHandle.impl.faceInfo.diagFlags;
  12104. end;
  12105. function TBLFontFace.GetFaceFlags: TBLFontFaceFlags;
  12106. begin
  12107. Cardinal(Result) := FHandle.impl.faceInfo.faceFlags;
  12108. end;
  12109. function TBLFontFace.GetFaceIndex: Integer;
  12110. begin
  12111. Result := FHandle.impl.faceInfo.faceIndex;
  12112. end;
  12113. function TBLFontFace.GetFaceInfo: TBLFontFaceInfo;
  12114. begin
  12115. Result.FHandle := FHandle.impl.faceInfo;
  12116. end;
  12117. function TBLFontFace.GetFaceType: TBLFontFaceType;
  12118. begin
  12119. Result := TBLFontFaceType(FHandle.impl.faceInfo.faceType);
  12120. end;
  12121. function TBLFontFace.GetFamilyName: String;
  12122. var
  12123. S: UTF8String;
  12124. begin
  12125. SetString(S, FHandle.impl.familyName.impl.data, FHandle.impl.familyName.impl.size);
  12126. Result := String(S);
  12127. end;
  12128. function TBLFontFace.GetFullName: String;
  12129. var
  12130. S: UTF8String;
  12131. begin
  12132. SetString(S, FHandle.impl.fullName.impl.data, FHandle.impl.fullName.impl.size);
  12133. Result := String(S);
  12134. end;
  12135. function TBLFontFace.GetHandle: PBLFontFaceCore;
  12136. begin
  12137. Result := @FHandle;
  12138. end;
  12139. function TBLFontFace.GetHasBaselineYAt0: Boolean;
  12140. begin
  12141. Result := ((FHandle.impl.faceInfo.faceFlags and BL_FONT_FACE_FLAG_BASELINE_Y_EQUALS_0) <> 0);
  12142. end;
  12143. function TBLFontFace.GetHasCharToGlyphMapping: Boolean;
  12144. begin
  12145. Result := ((FHandle.impl.faceInfo.faceFlags and BL_FONT_FACE_FLAG_CHAR_TO_GLYPH_MAPPING) <> 0);
  12146. end;
  12147. function TBLFontFace.GetHasHorizontalKerning: Boolean;
  12148. begin
  12149. Result := ((FHandle.impl.faceInfo.faceFlags and BL_FONT_FACE_FLAG_HORIZONTAL_KERNING) <> 0);
  12150. end;
  12151. function TBLFontFace.GetHasHorizontalMetrics: Boolean;
  12152. begin
  12153. Result := ((FHandle.impl.faceInfo.faceFlags and BL_FONT_FACE_FLAG_HORIZONTAL_METRICS) <> 0);
  12154. end;
  12155. function TBLFontFace.GetHasLSBPointXAt0: Boolean;
  12156. begin
  12157. Result := ((FHandle.impl.faceInfo.faceFlags and BL_FONT_FACE_FLAG_LSB_POINT_X_EQUALS_0) <> 0);
  12158. end;
  12159. function TBLFontFace.GetHasOpenTypeFeatures: Boolean;
  12160. begin
  12161. Result := ((FHandle.impl.faceInfo.faceFlags and BL_FONT_FACE_FLAG_OPENTYPE_FEATURES) <> 0);
  12162. end;
  12163. function TBLFontFace.GetHasOpenTypeVariations: Boolean;
  12164. begin
  12165. Result := ((FHandle.impl.faceInfo.faceFlags and BL_FONT_FACE_FLAG_OPENTYPE_VARIATIONS) <> 0);
  12166. end;
  12167. function TBLFontFace.GetHasPanoseData: Boolean;
  12168. begin
  12169. Result := ((FHandle.impl.faceInfo.faceFlags and BL_FONT_FACE_FLAG_PANOSE_DATA) <> 0);
  12170. end;
  12171. function TBLFontFace.GetHasTypographicMetrics: Boolean;
  12172. begin
  12173. Result := ((FHandle.impl.faceInfo.faceFlags and BL_FONT_FACE_FLAG_TYPOGRAPHIC_METRICS) <> 0);
  12174. end;
  12175. function TBLFontFace.GetHasTypographicNames: Boolean;
  12176. begin
  12177. Result := ((FHandle.impl.faceInfo.faceFlags and BL_FONT_FACE_FLAG_TYPOGRAPHIC_NAMES) <> 0);
  12178. end;
  12179. function TBLFontFace.GetHasUnicodeCoverage: Boolean;
  12180. begin
  12181. Result := ((FHandle.impl.faceInfo.faceFlags and BL_FONT_FACE_FLAG_UNICODE_COVERAGE) <> 0);
  12182. end;
  12183. function TBLFontFace.GetHasVariationSequences: Boolean;
  12184. begin
  12185. Result := ((FHandle.impl.faceInfo.faceFlags and BL_FONT_FACE_FLAG_VARIATION_SEQUENCES) <> 0);
  12186. end;
  12187. function TBLFontFace.GetHasVerticalKerning: Boolean;
  12188. begin
  12189. Result := ((FHandle.impl.faceInfo.faceFlags and BL_FONT_FACE_FLAG_VERTICAL_KERNING) <> 0);
  12190. end;
  12191. function TBLFontFace.GetHasVerticalMetrics: Boolean;
  12192. begin
  12193. Result := ((FHandle.impl.faceInfo.faceFlags and BL_FONT_FACE_FLAG_VERTICAL_METRICS) <> 0);
  12194. end;
  12195. function TBLFontFace.GetIsLastResortFont: Boolean;
  12196. begin
  12197. Result := ((FHandle.impl.faceInfo.faceFlags and BL_FONT_FACE_FLAG_LAST_RESORT_FONT) <> 0);
  12198. end;
  12199. function TBLFontFace.GetIsNone: Boolean;
  12200. begin
  12201. Result := ((FHandle.impl.implTraits and BL_IMPL_TRAIT_NULL) <> 0);
  12202. end;
  12203. function TBLFontFace.GetIsSymbolFont: Boolean;
  12204. begin
  12205. Result := ((FHandle.impl.faceInfo.faceFlags and BL_FONT_FACE_FLAG_SYMBOL_FONT) <> 0);
  12206. end;
  12207. function TBLFontFace.GetOutlineType: TBLFontOutlineType;
  12208. begin
  12209. Result := TBLFontOutlineType(FHandle.impl.faceInfo.outlineType);
  12210. end;
  12211. function TBLFontFace.GetPanose: TBLFontPanose;
  12212. begin
  12213. Result := TBLFontPanose(FHandle.impl.panose);
  12214. end;
  12215. function TBLFontFace.GetPostScriptName: String;
  12216. var
  12217. S: UTF8String;
  12218. begin
  12219. SetString(S, FHandle.impl.postScriptName.impl.data, FHandle.impl.postScriptName.impl.size);
  12220. Result := String(S);
  12221. end;
  12222. function TBLFontFace.GetStretch: TBLFontStretch;
  12223. begin
  12224. Result := TBLFontStretch(FHandle.impl.stretch);
  12225. end;
  12226. function TBLFontFace.GetStyle: TBLFontStyle;
  12227. begin
  12228. Result := TBLFontStyle(FHandle.impl.style);
  12229. end;
  12230. function TBLFontFace.GetSubfamilyName: String;
  12231. var
  12232. S: UTF8String;
  12233. begin
  12234. SetString(S, FHandle.impl.subfamilyName.impl.data, FHandle.impl.subfamilyName.impl.size);
  12235. Result := String(S);
  12236. end;
  12237. function TBLFontFace.GetUnicodeCoverage: TBLFontUnicodeCoverage;
  12238. begin
  12239. Result.FHandle := FHandle.impl.unicodeCoverage;
  12240. end;
  12241. function TBLFontFace.GetUniqueId: TBLUniqueId;
  12242. begin
  12243. Result := FHandle.impl.uniqueId;
  12244. end;
  12245. function TBLFontFace.GetUnitsPerEm: Integer;
  12246. begin
  12247. Result := FHandle.impl.designMetrics.unitsPerEm;
  12248. end;
  12249. function TBLFontFace.GetWeight: TBLFontWeight;
  12250. begin
  12251. Result := TBLFontWeight(FHandle.impl.weight);
  12252. end;
  12253. function TBLFontFace.HasFaceFlag(const AFlag: TBLFontFaceFlag): Boolean;
  12254. begin
  12255. Result := ((FHandle.impl.faceInfo.faceFlags and Ord(AFlag)) <> 0);
  12256. end;
  12257. procedure TBLFontFace.InitializeFromData(const AFontData: IBLFontData;
  12258. const AFaceIndex: Integer);
  12259. begin
  12260. FData := AFontData;
  12261. if (AFontData <> nil) then
  12262. _BLCheck(blFontFaceCreateFromData(@FHandle, AFontData.Handle, AFaceIndex));
  12263. end;
  12264. procedure TBLFontFace.InitializeFromFile(const AFilename: String;
  12265. const AReadFlags: TBLFileReadFlags);
  12266. begin
  12267. _BLCheck(blFontFaceCreateFromFile(@FHandle, MarshaledAString(UTF8String(AFilename)),
  12268. Byte(AReadFlags)));
  12269. end;
  12270. procedure TBLFontFace.Reset;
  12271. begin
  12272. _BLCheck(blFontFaceReset(@FHandle));
  12273. end;
  12274. { TBLFont }
  12275. procedure TBLFont.ApplyGPos(const AGlyphBuffer: IBLGlyphBuffer;
  12276. const AIndex: Integer; const ALookups: TBLBitWord);
  12277. begin
  12278. if (AGlyphBuffer <> nil) then
  12279. _BLCheck(blFontApplyGPos(@FHandle, AGlyphBuffer.Handle, AIndex, ALookups));
  12280. end;
  12281. procedure TBLFont.ApplyGSub(const AGlyphBuffer: IBLGlyphBuffer;
  12282. const AIndex: Integer; const ALookups: TBLBitWord);
  12283. begin
  12284. if (AGlyphBuffer <> nil) then
  12285. _BLCheck(blFontApplyGSub(@FHandle, AGlyphBuffer.Handle, AIndex, ALookups));
  12286. end;
  12287. procedure TBLFont.ApplyKerning(const AGlyphBuffer: IBLGlyphBuffer);
  12288. begin
  12289. if (AGlyphBuffer <> nil) then
  12290. _BLCheck(blFontApplyKerning(@FHandle, AGlyphBuffer.Handle));
  12291. end;
  12292. constructor TBLFont.Create;
  12293. begin
  12294. inherited;
  12295. blFontInit(@FHandle);
  12296. end;
  12297. destructor TBLFont.Destroy;
  12298. begin
  12299. blFontDestroy(@FHandle);
  12300. inherited;
  12301. end;
  12302. class function TBLFont.DoSink(path: PBLPathCore; info,
  12303. closure: Pointer): Cardinal;
  12304. var
  12305. Font: TBLFont;
  12306. begin
  12307. Result := 0;
  12308. if Assigned(closure) then
  12309. begin
  12310. Font := TBLFont(Closure);
  12311. if Assigned(Font.FSink) then
  12312. Result := Ord(Font.FSink(Font.FSinkPath, info));
  12313. end;
  12314. end;
  12315. function TBLFont.Equals(Obj: TObject): Boolean;
  12316. begin
  12317. if (Obj = nil) then
  12318. Result := (Self = nil)
  12319. else if (Obj = Self) then
  12320. Result := True
  12321. else if (Obj is TBLFont) then
  12322. Result := blFontEquals(@FHandle, @TBLFont(Obj).FHandle)
  12323. else
  12324. Result := False;
  12325. end;
  12326. function TBLFont.Equals(const AOther: IBLFont): Boolean;
  12327. begin
  12328. if (AOther = nil) then
  12329. Result := (Self = nil)
  12330. else
  12331. Result := blFontEquals(@FHandle, AOther.Handle)
  12332. end;
  12333. function TBLFont.GetDesignMetrics: TBLFontDesignMetrics;
  12334. begin
  12335. Result.FHandle := FHandle.impl.face.impl.designMetrics;
  12336. end;
  12337. function TBLFont.GetFace: IBLFontFace;
  12338. begin
  12339. Result := FFace;
  12340. end;
  12341. function TBLFont.GetFaceFlags: TBLFontFaceFlags;
  12342. begin
  12343. Result := TBLFontFaceFlags(FHandle.impl.face.impl.faceInfo.faceFlags);
  12344. end;
  12345. function TBLFont.GetFaceType: TBLFontFaceType;
  12346. begin
  12347. Result := TBLFontFaceType(FHandle.impl.face.impl.faceInfo.faceType);
  12348. end;
  12349. function TBLFont.GetFeatures: TArray<TBLFontFeature>;
  12350. begin
  12351. Result := TBLUtils.BLArrayToArray<TBLFontFeature>(FHandle.impl.features);
  12352. end;
  12353. function TBLFont.GetGlyphAdvances(const AGlyphData: PCardinal;
  12354. const AGlyphAdvance, ACount: Integer): TArray<TBLGlyphPlacement>;
  12355. begin
  12356. SetLength(Result, ACount);
  12357. _BLCheck(blFontGetGlyphAdvances(@FHandle, Pointer(AGlyphData), AGlyphAdvance,
  12358. Pointer(Result), ACount));
  12359. end;
  12360. function TBLFont.GetGlyphBounds(const AGlyphData: PCardinal;
  12361. const AGlyphAdvance, ACount: Integer): TArray<TBLBoxI>;
  12362. begin
  12363. SetLength(Result, ACount);
  12364. _BLCheck(blFontGetGlyphBounds(@FHandle, Pointer(AGlyphData), AGlyphAdvance,
  12365. Pointer(Result), ACount));
  12366. end;
  12367. function TBLFont.GetGlyphOutlines(const AGlyphId: Cardinal;
  12368. const AUserMatrix: TBLMatrix2D; const ASink: TBLPathSinkEvent): IBLPath;
  12369. var
  12370. Sink: BLPathSinkFunc;
  12371. Closure: Pointer;
  12372. begin
  12373. Result := TBLPath.Create;
  12374. if Assigned(ASink) then
  12375. begin
  12376. FSink := ASink;
  12377. FSinkPath := Result;
  12378. Sink := DoSink;
  12379. Closure := Self;
  12380. end
  12381. else
  12382. begin
  12383. Sink := nil;
  12384. Closure := nil;
  12385. end;
  12386. _BLCheck(blFontGetGlyphOutlines(@FHandle, AGlyphId, @AUserMatrix,
  12387. Result.Handle, Sink, Closure));
  12388. end;
  12389. function TBLFont.GetGlyphOutlines(const AGlyphId: Cardinal;
  12390. const ASink: TBLPathSinkEvent): IBLPath;
  12391. var
  12392. Sink: BLPathSinkFunc;
  12393. Closure: Pointer;
  12394. begin
  12395. Result := TBLPath.Create;
  12396. if Assigned(ASink) then
  12397. begin
  12398. FSink := ASink;
  12399. FSinkPath := Result;
  12400. Sink := DoSink;
  12401. Closure := Self;
  12402. end
  12403. else
  12404. begin
  12405. Sink := nil;
  12406. Closure := nil;
  12407. end;
  12408. _BLCheck(blFontGetGlyphOutlines(@FHandle, AGlyphId, nil,
  12409. Result.Handle, Sink, Closure));
  12410. end;
  12411. function TBLFont.GetGlyphRunOutlines(const AGlyphRun: TBLGlyphRun;
  12412. const AUserMatrix: TBLMatrix2D; const ASink: TBLPathSinkEvent): IBLPath;
  12413. var
  12414. Sink: BLPathSinkFunc;
  12415. Closure: Pointer;
  12416. begin
  12417. Result := TBLPath.Create;
  12418. if Assigned(ASink) then
  12419. begin
  12420. FSink := ASink;
  12421. FSinkPath := Result;
  12422. Sink := DoSink;
  12423. Closure := Self;
  12424. end
  12425. else
  12426. begin
  12427. Sink := nil;
  12428. Closure := nil;
  12429. end;
  12430. _BLCheck(blFontGetGlyphRunOutlines(@FHandle, @AGlyphRun, @AUserMatrix,
  12431. Result.Handle, Sink, Closure));
  12432. end;
  12433. function TBLFont.GetGlyphRunOutlines(const AGlyphRun: TBLGlyphRun;
  12434. const ASink: TBLPathSinkEvent): IBLPath;
  12435. var
  12436. Sink: BLPathSinkFunc;
  12437. Closure: Pointer;
  12438. begin
  12439. Result := TBLPath.Create;
  12440. if Assigned(ASink) then
  12441. begin
  12442. FSink := ASink;
  12443. FSinkPath := Result;
  12444. Sink := DoSink;
  12445. Closure := Self;
  12446. end
  12447. else
  12448. begin
  12449. Sink := nil;
  12450. Closure := nil;
  12451. end;
  12452. _BLCheck(blFontGetGlyphRunOutlines(@FHandle, @AGlyphRun, nil,
  12453. Result.Handle, Sink, Closure));
  12454. end;
  12455. function TBLFont.GetHandle: PBLFontCore;
  12456. begin
  12457. Result := @FHandle;
  12458. end;
  12459. function TBLFont.GetIsNone: Boolean;
  12460. begin
  12461. Result := ((FHandle.impl.implTraits and BL_IMPL_TRAIT_NULL) <> 0);
  12462. end;
  12463. function TBLFont.GetMatrix: TBLFontMatrix;
  12464. begin
  12465. Result.FHandle := FHandle.impl.matrix;
  12466. end;
  12467. function TBLFont.GetMetrics: TBLFontMetrics;
  12468. begin
  12469. Result.FHandle := FHandle.impl.metrics;
  12470. end;
  12471. function TBLFont.GetMetricsPtr: PBLFontMetrics;
  12472. begin
  12473. Result := @FHandle.impl.metrics;
  12474. end;
  12475. function TBLFont.GetSize: Single;
  12476. begin
  12477. Result := FHandle.impl.metrics.size;
  12478. end;
  12479. function TBLFont.GetStretch: TBLFontStretch;
  12480. begin
  12481. Result := TBLFontStretch(FHandle.impl.stretch);
  12482. end;
  12483. function TBLFont.GetStyle: TBLFontStyle;
  12484. begin
  12485. Result := TBLFontStyle(FHandle.impl.style);
  12486. end;
  12487. function TBLFont.GetTextMetrics(
  12488. const AGlyphBuffer: IBLGlyphBuffer): TBLTextMetrics;
  12489. begin
  12490. if (AGlyphBuffer <> nil) then
  12491. _BLCheck(blFontGetTextMetrics(@FHandle, AGlyphBuffer.Handle, @Result.FHandle));
  12492. end;
  12493. function TBLFont.GetUnitsPerEm: Integer;
  12494. begin
  12495. Result := FHandle.impl.face.impl.designMetrics.unitsPerEm;
  12496. end;
  12497. function TBLFont.GetVariations: TArray<TBLFontVariation>;
  12498. begin
  12499. Result := TBLUtils.BLArrayToArray<TBLFontVariation>(FHandle.impl.variations);
  12500. end;
  12501. function TBLFont.GetWeight: TBLFontWeight;
  12502. begin
  12503. Result := TBLFontWeight(FHandle.impl.weight);
  12504. end;
  12505. procedure TBLFont.InitializeFromFace(const AFace: IBLFontFace;
  12506. const ASize: Single);
  12507. begin
  12508. if (AFace <> nil) then
  12509. _BLCheck(blFontCreateFromFace(@FHandle, AFace.Handle, ASize));
  12510. end;
  12511. procedure TBLFont.MapTextToGlyphs(const AGlyphBuffer: IBLGlyphBuffer);
  12512. begin
  12513. if (AGlyphBuffer <> nil) then
  12514. _BLCheck(blFontMapTextToGlyphs(@FHandle, AGlyphBuffer.Handle, nil));
  12515. end;
  12516. procedure TBLFont.MapTextToGlyphs(const AGlyphBuffer: IBLGlyphBuffer;
  12517. out AState: TBLGlyphMappingState);
  12518. begin
  12519. if (AGlyphBuffer <> nil) then
  12520. _BLCheck(blFontMapTextToGlyphs(@FHandle, AGlyphBuffer.Handle, @AState.FHandle));
  12521. end;
  12522. procedure TBLFont.PositionGlyphs(const AGlyphBuffer: IBLGlyphBuffer;
  12523. const APositioningFlags: Cardinal);
  12524. begin
  12525. if (AGlyphBuffer <> nil) then
  12526. _BLCheck(blFontPositionGlyphs(@FHandle, AGlyphBuffer.Handle, APositioningFlags));
  12527. end;
  12528. procedure TBLFont.Reset;
  12529. begin
  12530. _BLCheck(blFontReset(@FHandle));
  12531. end;
  12532. procedure TBLFont.Shape(const AGlyphBuffer: IBLGlyphBuffer);
  12533. begin
  12534. if (AGlyphBuffer <> nil) then
  12535. _BLCheck(blFontShape(@FHandle, AGlyphBuffer.Handle));
  12536. end;
  12537. {$ENDREGION 'Font'}
  12538. {$REGION 'Font Manager'}
  12539. { TBLFontManager }
  12540. procedure TBLFontManager.AddFace(const AFace: IBLFontFace);
  12541. begin
  12542. if (AFace <> nil) then
  12543. _BLCheck(blFontManagerAddFace(@FHandle, AFace.Handle));
  12544. end;
  12545. constructor TBLFontManager.Create;
  12546. begin
  12547. inherited;
  12548. _BLCheck(blFontManagerInit(@FHandle));
  12549. end;
  12550. destructor TBLFontManager.Destroy;
  12551. begin
  12552. blFontManagerDestroy(@FHandle);
  12553. inherited;
  12554. end;
  12555. function TBLFontManager.Equals(Obj: TObject): Boolean;
  12556. begin
  12557. if (Obj = nil) then
  12558. Result := (Self = nil)
  12559. else if (Obj = Self) then
  12560. Result := True
  12561. else if (Obj is TBLFontManager) then
  12562. Result := blFontManagerEquals(@FHandle, @TBLFontManager(Obj).FHandle)
  12563. else
  12564. Result := False;
  12565. end;
  12566. function TBLFontManager.Equals(const AOther: IBLFontManager): Boolean;
  12567. begin
  12568. if (AOther = nil) then
  12569. Result := (Self = nil)
  12570. else
  12571. Result := blFontManagerEquals(@FHandle, AOther.Handle);
  12572. end;
  12573. function TBLFontManager.GetFaceCount: Integer;
  12574. begin
  12575. Result := blFontManagerGetFaceCount(@FHandle);
  12576. end;
  12577. function TBLFontManager.GetFamilyCount: Integer;
  12578. begin
  12579. Result := blFontManagerGetFamilyCount(@FHandle);
  12580. end;
  12581. function TBLFontManager.GetHandle: PBLFontManagerCore;
  12582. begin
  12583. Result := @FHandle;
  12584. end;
  12585. function TBLFontManager.GetIsNone: Boolean;
  12586. begin
  12587. Result := ((FHandle.impl.implTraits and BL_IMPL_TRAIT_NULL) <> 0);
  12588. end;
  12589. function TBLFontManager.HasFace(const AFace: IBLFontFace): Boolean;
  12590. begin
  12591. if (AFace <> nil) then
  12592. Result := blFontManagerHasFace(@FHandle, AFace.Handle)
  12593. else
  12594. Result := False;
  12595. end;
  12596. procedure TBLFontManager.Initialize;
  12597. begin
  12598. blFontManagerCreate(@FHandle);
  12599. end;
  12600. function TBLFontManager.QueryFace(const AName: String): IBLFontFace;
  12601. var
  12602. Name: UTF8String;
  12603. Face: BLFontFaceCore;
  12604. begin
  12605. Name := UTF8String(AName);
  12606. if (blFontManagerQueryFace(@FHandle, MarshaledAString(Name), Length(Name),
  12607. nil, @Face) = BL_SUCCESS)
  12608. then
  12609. Result := TBLFontFace.Create(Face, True)
  12610. else
  12611. Result := nil;
  12612. end;
  12613. function TBLFontManager.QueryFace(const AName: String;
  12614. const AProperties: TBLFontQueryProperties): IBLFontFace;
  12615. var
  12616. Name: UTF8String;
  12617. Face: BLFontFaceCore;
  12618. begin
  12619. Name := UTF8String(AName);
  12620. if (blFontManagerQueryFace(@FHandle, MarshaledAString(Name), Length(Name),
  12621. @AProperties.FHandle, @Face) = BL_SUCCESS)
  12622. then
  12623. Result := TBLFontFace.Create(Face, True)
  12624. else
  12625. Result := nil;
  12626. end;
  12627. function TBLFontManager.QueryFacesByFamilyName(
  12628. const AName: String): TArray<IBLFontFace>;
  12629. var
  12630. Name: UTF8String;
  12631. FaceArray: IBLArray;
  12632. FaceHandles: TArray<BLFontFaceCore>;
  12633. I: Integer;
  12634. begin
  12635. Name := UTF8String(AName);
  12636. FaceArray := TBLUtils.CreateBLArray<BLFontFaceCore>;
  12637. if (blFontManagerQueryFacesByFamilyName(@FHandle, MarshaledAString(Name),
  12638. Length(Name), FaceArray.Handle) = BL_SUCCESS) then
  12639. begin
  12640. FaceHandles := TBLUtils.BLArrayToArray<BLFontFaceCore>(FaceArray);
  12641. SetLength(Result, Length(FaceHandles));
  12642. for I := 0 to Length(Result) - 1 do
  12643. Result[I] := TBLFontFace.Create(FaceHandles[I], True);
  12644. end
  12645. else
  12646. Result := nil;
  12647. end;
  12648. procedure TBLFontManager.Reset;
  12649. begin
  12650. _BLCheck(blFontManagerReset(@FHandle));
  12651. end;
  12652. {$ENDREGION 'Font Manager'}
  12653. {$REGION 'Pixel Converter'}
  12654. { TBLPixelConverterOptions }
  12655. function TBLPixelConverterOptions.GetGap: Integer;
  12656. begin
  12657. Result := FHandle.gap;
  12658. end;
  12659. function TBLPixelConverterOptions.GetOrigin: TBLPointI;
  12660. begin
  12661. Result.FHandle := FHandle.origin;
  12662. end;
  12663. procedure TBLPixelConverterOptions.SetGap(const AValue: Integer);
  12664. begin
  12665. FHandle.gap := AValue;
  12666. end;
  12667. procedure TBLPixelConverterOptions.SetOrigin(const AValue: TBLPointI);
  12668. begin
  12669. FHandle.origin := AValue.FHandle;
  12670. end;
  12671. { TBLPixelConverter }
  12672. procedure TBLPixelConverter.Assign(const AOther: IBLPixelConverter);
  12673. begin
  12674. if Assigned(AOther) then
  12675. _BLCheck(blPixelConverterAssign(@FHandle, AOther.Handle));
  12676. end;
  12677. procedure TBLPixelConverter.ConvertRect(const ASrcData: Pointer;
  12678. const ASrcStride: Integer; const ADstData: Pointer; const ADstStride, AWidth,
  12679. AHeight: Integer; const AOptions: TBLPixelConverterOptions);
  12680. begin
  12681. _BLCheck(blPixelConverterConvert(@FHandle, ADstData, ADstStride, ASrcData,
  12682. ASrcStride, AWidth, AHeight, @AOptions.FHandle));
  12683. end;
  12684. procedure TBLPixelConverter.ConvertRect(const ASrcData: Pointer;
  12685. const ASrcStride: Integer; const ADstData: Pointer; const ADstStride, AWidth,
  12686. AHeight: Integer);
  12687. begin
  12688. _BLCheck(blPixelConverterConvert(@FHandle, ADstData, ADstStride, ASrcData,
  12689. ASrcStride, AWidth, AHeight, nil));
  12690. end;
  12691. procedure TBLPixelConverter.ConvertSpan(const ASrcData, ADstData: Pointer;
  12692. const AWidth: Integer);
  12693. begin
  12694. _BLCheck(blPixelConverterConvert(@FHandle, ADstData, 0, ASrcData, 0,
  12695. AWidth, 1, nil));
  12696. end;
  12697. procedure TBLPixelConverter.ConvertSpan(const ASrcData, ADstData: Pointer;
  12698. const AWidth: Integer; const AOptions: TBLPixelConverterOptions);
  12699. begin
  12700. _BLCheck(blPixelConverterConvert(@FHandle, ADstData, 0, ASrcData, 0,
  12701. AWidth, 1, @AOptions.FHandle));
  12702. end;
  12703. constructor TBLPixelConverter.Create;
  12704. begin
  12705. inherited;
  12706. blPixelConverterInit(@FHandle);
  12707. end;
  12708. class function TBLPixelConverter.CreatePlatformConverter: IBLPixelConverter;
  12709. var
  12710. SrcFormat, DstFormat: TBLFormatInfo;
  12711. begin
  12712. Result := TBLPixelConverter.Create;
  12713. SrcFormat := TBLFormat.PRGB32.Info;
  12714. DstFormat := SrcFormat;
  12715. {$IFNDEF MSWINDOWS}
  12716. DstFormat.RedShift := SrcFormat.BlueShift;
  12717. DstFormat.BlueShift := SrcFormat.RedShift;
  12718. {$ENDIF}
  12719. Result.Initialize(SrcFormat, DstFormat, [TBLPixelConverterCreateFlag.NoMultiStep]);
  12720. end;
  12721. destructor TBLPixelConverter.Destroy;
  12722. begin
  12723. blPixelConverterDestroy(@FHandle);
  12724. inherited;
  12725. end;
  12726. function TBLPixelConverter.GetHandle: PBLPixelConverterCore;
  12727. begin
  12728. Result := @FHandle;
  12729. end;
  12730. function TBLPixelConverter.GetIsInitialized: Boolean;
  12731. begin
  12732. Result := (FHandle.internalFlags <> 0);
  12733. end;
  12734. procedure TBLPixelConverter.Initialize(const ASrcInfo, ADstInfo: TBLFormatInfo;
  12735. const ACreateFlags: TBLPixelConverterCreateFlags);
  12736. begin
  12737. _BLCheck(blPixelConverterCreate(@FHandle, @ADstInfo.FHandle,
  12738. @ASrcInfo.FHandle, Byte(ACreateFlags)));
  12739. end;
  12740. procedure TBLPixelConverter.Reset;
  12741. begin
  12742. _BLCheck(blPixelConverterReset(@FHandle));
  12743. end;
  12744. {$ENDREGION 'Pixel Converter'}
  12745. {$REGION 'Context'}
  12746. { TBLContextCreateInfo }
  12747. function TBLContextCreateInfo.GetFlags: TBLContextCreateFlags;
  12748. begin
  12749. Cardinal(Result) := FHandle.flags;
  12750. end;
  12751. procedure TBLContextCreateInfo.Reset;
  12752. begin
  12753. FillChar(FHandle, SizeOf(FHandle), 0);
  12754. end;
  12755. procedure TBLContextCreateInfo.SetFlags(const AValue: TBLContextCreateFlags);
  12756. begin
  12757. FHandle.flags := Cardinal(AValue);
  12758. end;
  12759. { TBLContextCookie }
  12760. class operator TBLContextCookie.Equal(const ALeft,
  12761. ARight: TBLContextCookie): Boolean;
  12762. begin
  12763. Result := ALeft.Equals(ARight);
  12764. end;
  12765. function TBLContextCookie.Equals(const AOther: TBLContextCookie): Boolean;
  12766. begin
  12767. Result := (FHandle.data[0] = AOther.FHandle.data[0])
  12768. and (FHandle.data[1] = AOther.FHandle.data[1]);
  12769. end;
  12770. function TBLContextCookie.GetIsEmpty: Boolean;
  12771. begin
  12772. Result := (FHandle.data[0] = 0) and (FHandle.data[1] = 0);
  12773. end;
  12774. class operator TBLContextCookie.NotEqual(const ALeft,
  12775. ARight: TBLContextCookie): Boolean;
  12776. begin
  12777. Result := not ALeft.Equals(ARight);
  12778. end;
  12779. procedure TBLContextCookie.Reset(const AData0, AData1: UInt64);
  12780. begin
  12781. FHandle.data[0] := AData0;
  12782. FHandle.data[1] := AData1;
  12783. end;
  12784. procedure TBLContextCookie.Reset(const AOther: TBLContextCookie);
  12785. begin
  12786. Self := AOther;
  12787. end;
  12788. procedure TBLContextCookie.Reset;
  12789. begin
  12790. Reset(0, 0);
  12791. end;
  12792. { TBLContextHints }
  12793. function TBLContextHints.GetGradientQuality: TBLGradientQuality;
  12794. begin
  12795. Result := TBLGradientQuality(FHandle.gradientQuality);
  12796. end;
  12797. function TBLContextHints.GetPatternQuality: TBLPatternQuality;
  12798. begin
  12799. Result := TBLPatternQuality(FHandle.patternQuality);
  12800. end;
  12801. function TBLContextHints.GetRenderingQuality: TBLRenderingQuality;
  12802. begin
  12803. Result := TBLRenderingQuality(FHandle.renderingQuality);
  12804. end;
  12805. procedure TBLContextHints.SetGradientQuality(const AValue: TBLGradientQuality);
  12806. begin
  12807. FHandle.gradientQuality := Ord(AValue);
  12808. end;
  12809. procedure TBLContextHints.SetPatternQuality(const AValue: TBLPatternQuality);
  12810. begin
  12811. FHandle.patternQuality := Ord(AValue);
  12812. end;
  12813. procedure TBLContextHints.SetRenderingQuality(const AValue: TBLRenderingQuality);
  12814. begin
  12815. FHandle.renderingQuality := Ord(AValue);
  12816. end;
  12817. { TBLContextState }
  12818. function TBLContextState.GetApproximationOptions: TBLApproximationOptions;
  12819. begin
  12820. Result.FHandle := FHandle.approximationOptions;
  12821. end;
  12822. function TBLContextState.GetCompOp: TBLCompOp;
  12823. begin
  12824. Result := TBLCompOp(FHandle.compOp);
  12825. end;
  12826. function TBLContextState.GetFillAlpha: Double;
  12827. begin
  12828. Result := FHandle.styleAlpha[BL_CONTEXT_OP_TYPE_FILL];
  12829. end;
  12830. function TBLContextState.GetFillRule: TBLFillRule;
  12831. begin
  12832. Result := TBLFillRule(FHandle.fillRule);
  12833. end;
  12834. function TBLContextState.GetFillStyle: TBLStyleType;
  12835. begin
  12836. Result := TBLStyleType(FHandle.styleType[BL_CONTEXT_OP_TYPE_FILL]);
  12837. end;
  12838. function TBLContextState.GetHints: TBLContextHints;
  12839. begin
  12840. Result.FHandle := FHandle.hints;
  12841. end;
  12842. function TBLContextState.GetMetaMatrix: TBLMatrix2D;
  12843. begin
  12844. Result.FHandle := FHandle.metaMatrix;
  12845. end;
  12846. function TBLContextState.GetSavedStateCount: Integer;
  12847. begin
  12848. Result := FHandle.savedStateCount;
  12849. end;
  12850. function TBLContextState.GetStrokeOptions: TBLStrokeOptions;
  12851. begin
  12852. Result.FHandle := FHandle.strokeOptions;
  12853. end;
  12854. function TBLContextState.GetStrokeStyle: TBLStyleType;
  12855. begin
  12856. Result := TBLStyleType(FHandle.styleType[BL_CONTEXT_OP_TYPE_STROKE]);
  12857. end;
  12858. function TBLContextState.GetTargetImage: IBLImage;
  12859. begin
  12860. if (FHandle.targetImage = nil) then
  12861. Result := nil
  12862. else
  12863. Result := TBLImage.Create(FHandle.targetImage^, True);
  12864. end;
  12865. function TBLContextState.GetTargetSize: TBLSize;
  12866. begin
  12867. Result := TBLSize(FHandle.targetSize);
  12868. end;
  12869. function TBLContextState.GetStrokeAlpha: Double;
  12870. begin
  12871. Result := FHandle.styleAlpha[BL_CONTEXT_OP_TYPE_STROKE];
  12872. end;
  12873. function TBLContextState.GetUserMatrix: TBLMatrix2D;
  12874. begin
  12875. Result.FHandle := FHandle.userMatrix;
  12876. end;
  12877. { TBLContext }
  12878. procedure TBLContext.BlitImage(const ADst: TBLPointI; const ASrc: IBLImage);
  12879. begin
  12880. _BLCheck(blContextBlitImageI(@FHandle, @ADst, ASrc.Handle, nil));
  12881. end;
  12882. procedure TBLContext.BlitImage(const ADst: TBLRect; const ASrc: IBLImage);
  12883. begin
  12884. _BLCheck(blContextBlitScaledImageD(@FHandle, @ADst, ASrc.Handle, nil));
  12885. end;
  12886. procedure TBLContext.BlitImage(const ADst: TBLPointI; const ASrc: IBLImage;
  12887. const ASrcArea: TBLRectI);
  12888. begin
  12889. _BLCheck(blContextBlitImageI(@FHandle, @ADst, ASrc.Handle, @ASrcArea));
  12890. end;
  12891. procedure TBLContext.BlitImage(const ADst: TBLPoint; const ASrc: IBLImage;
  12892. const ASrcArea: TBLRectI);
  12893. begin
  12894. _BLCheck(blContextBlitImageD(@FHandle, @ADst, ASrc.Handle, @ASrcArea));
  12895. end;
  12896. procedure TBLContext.BlitImage(const ADst: TBLPoint; const ASrc: IBLImage);
  12897. begin
  12898. _BLCheck(blContextBlitImageD(@FHandle, @ADst, ASrc.Handle, nil));
  12899. end;
  12900. procedure TBLContext.BlitImage(const ADst: TBLRectI; const ASrc: IBLImage);
  12901. begin
  12902. _BLCheck(blContextBlitScaledImageI(@FHandle, @ADst, ASrc.Handle, nil));
  12903. end;
  12904. procedure TBLContext.BlitImage(const ADst: TBLRect; const ASrc: IBLImage;
  12905. const ASrcArea: TBLRectI);
  12906. begin
  12907. _BLCheck(blContextBlitScaledImageD(@FHandle, @ADst, ASrc.Handle, @ASrcArea));
  12908. end;
  12909. procedure TBLContext.AfterConstruction;
  12910. begin
  12911. inherited;
  12912. { Blend2D requires that floating-point calculations do not raise exceptions.}
  12913. SetExceptionMask(exAllArithmeticExceptions);
  12914. end;
  12915. procedure TBLContext.BlitImage(const ADst: TBLRectI; const ASrc: IBLImage;
  12916. const ASrcArea: TBLRectI);
  12917. begin
  12918. _BLCheck(blContextBlitScaledImageI(@FHandle, @ADst, ASrc.Handle, @ASrcArea));
  12919. end;
  12920. procedure TBLContext.ClearAll;
  12921. begin
  12922. _BLCheck(blContextClearAll(@FHandle));
  12923. end;
  12924. procedure TBLContext.ClearRect(const ARect: TBLRectI);
  12925. begin
  12926. _BLCheck(blContextClearRectI(@FHandle, @ARect));
  12927. end;
  12928. procedure TBLContext.ClearRect(const ARect: TBLRect);
  12929. begin
  12930. _BLCheck(blContextClearRectD(@FHandle, @ARect));
  12931. end;
  12932. procedure TBLContext.ClearRect(const AX, AY, AW, AH: Double);
  12933. var
  12934. R: TBLRect;
  12935. begin
  12936. R.Reset(AX, AY, AW, AH);
  12937. _BLCheck(blContextClearRectD(@FHandle, @R));
  12938. end;
  12939. procedure TBLContext.ClipToRect(const AX, AY, AW, AH: Double);
  12940. var
  12941. R: TBLRect;
  12942. begin
  12943. R.Reset(AX, AY, AW, AH);
  12944. _BLCheck(blContextClipToRectD(@FHandle, @R));
  12945. end;
  12946. procedure TBLContext.ClipToRect(const ARect: TBLRect);
  12947. begin
  12948. _BLCheck(blContextClipToRectD(@FHandle, @ARect));
  12949. end;
  12950. procedure TBLContext.ClipToRect(const ARect: TBLRectI);
  12951. begin
  12952. _BLCheck(blContextClipToRectI(@FHandle, @ARect));
  12953. end;
  12954. constructor TBLContext.Create;
  12955. begin
  12956. inherited Create;
  12957. blContextInit(@FHandle);
  12958. end;
  12959. constructor TBLContext.Create(const ATarget: IBLImage);
  12960. begin
  12961. inherited Create;
  12962. if (ATarget = nil) then
  12963. blContextInit(@FHandle)
  12964. else
  12965. _BLCheck(blContextInitAs(@FHandle, ATarget.Handle, nil));
  12966. end;
  12967. constructor TBLContext.Create(const ATarget: IBLImage;
  12968. const ACreateInfo: TBLContextCreateInfo);
  12969. begin
  12970. inherited Create;
  12971. if (ATarget = nil) then
  12972. blContextInit(@FHandle)
  12973. else
  12974. _BLCheck(blContextInitAs(@FHandle, ATarget.Handle, @ACreateInfo.FHandle));
  12975. end;
  12976. destructor TBLContext.Destroy;
  12977. begin
  12978. blContextDestroy(@FHandle);
  12979. inherited;
  12980. end;
  12981. function TBLContext.Equals(Obj: TObject): Boolean;
  12982. begin
  12983. if (Obj = nil) then
  12984. Result := (Self = nil)
  12985. else if (Obj = Self) then
  12986. Result := True
  12987. else if (Obj is TBLContext) then
  12988. Result := (FHandle.impl = TBLContext(Obj).FHandle.impl)
  12989. else
  12990. Result := False;
  12991. end;
  12992. function TBLContext.Equals(const AOther: IBLContext): Boolean;
  12993. begin
  12994. if (AOther = nil) then
  12995. Result := (Self = nil)
  12996. else
  12997. Result := (FHandle.impl = AOther.Handle.impl)
  12998. end;
  12999. procedure TBLContext.FillAll;
  13000. begin
  13001. _BLCheck(blContextFillAll(@FHandle));
  13002. end;
  13003. procedure TBLContext.FillBox(const AX0, AY0, AX1, AY1: Double);
  13004. var
  13005. Box: TBLBox;
  13006. begin
  13007. Box.Reset(AX0, AY0, AX1, AY1);
  13008. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_BOXD, @Box));
  13009. end;
  13010. procedure TBLContext.FillBox(const ABox: TBLBox);
  13011. begin
  13012. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_BOXD, @ABox));
  13013. end;
  13014. procedure TBLContext.FillBox(const ABox: TBLBoxI);
  13015. begin
  13016. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_BOXI, @ABox));
  13017. end;
  13018. procedure TBLContext.FillBoxArray(const ABoxes: PBLBox; const ACount: Integer);
  13019. var
  13020. View: TBLArrayView<TBLBox>;
  13021. begin
  13022. View.Reset(ABoxes, ACount);
  13023. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXD, @View));
  13024. end;
  13025. procedure TBLContext.FillBoxArray(const ABoxes: TArray<TBLBoxI>);
  13026. var
  13027. View: TBLArrayView<TBLBoxI>;
  13028. begin
  13029. View.Reset(Pointer(ABoxes), Length(ABoxes));
  13030. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXI, @View));
  13031. end;
  13032. procedure TBLContext.FillBoxArray(const ABoxes: TBLArrayView<TBLBoxI>);
  13033. begin
  13034. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXI, @ABoxes));
  13035. end;
  13036. procedure TBLContext.FillBoxArray(const ABoxes: PBLBoxI; const ACount: Integer);
  13037. var
  13038. View: TBLArrayView<TBLBoxI>;
  13039. begin
  13040. View.Reset(ABoxes, ACount);
  13041. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXI, @View));
  13042. end;
  13043. procedure TBLContext.FillBoxArray(const ABoxes: TBLArrayView<TBLBox>);
  13044. begin
  13045. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXD, @ABoxes));
  13046. end;
  13047. procedure TBLContext.FillBoxArray(const ABoxes: TArray<TBLBox>);
  13048. var
  13049. View: TBLArrayView<TBLBox>;
  13050. begin
  13051. View.Reset(Pointer(ABoxes), Length(ABoxes));
  13052. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXD, @View));
  13053. end;
  13054. procedure TBLContext.FillChord(const ACX, ACY, ARX, ARY, AStart,
  13055. ASweep: Double);
  13056. var
  13057. Chord: TBLArc;
  13058. begin
  13059. Chord.Reset(ACX, ACY, ARX, ARY, AStart, ASweep);
  13060. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_CHORD, @Chord));
  13061. end;
  13062. procedure TBLContext.FillChord(const ACX, ACY, AR, AStart, ASweep: Double);
  13063. var
  13064. Chord: TBLArc;
  13065. begin
  13066. Chord.Reset(ACX, ACY, AR, AStart, ASweep);
  13067. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_CHORD, @Chord));
  13068. end;
  13069. procedure TBLContext.FillChord(const AChord: TBLArc);
  13070. begin
  13071. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_CHORD, @AChord));
  13072. end;
  13073. procedure TBLContext.FillCircle(const ACX, ACY, AR: Double);
  13074. var
  13075. Circle: TBLCircle;
  13076. begin
  13077. Circle.Reset(ACX, ACY, AR);
  13078. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_CIRCLE, @Circle));
  13079. end;
  13080. procedure TBLContext.FillCircle(const ACircle: TBLCircle);
  13081. begin
  13082. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_CIRCLE, @ACircle));
  13083. end;
  13084. procedure TBLContext.FillEllipse(const AEllipse: TBLEllipse);
  13085. begin
  13086. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ELLIPSE, @AEllipse));
  13087. end;
  13088. procedure TBLContext.FillEllipse(const ACX, ACY, ARX, ARY: Double);
  13089. var
  13090. Ellipse: TBLEllipse;
  13091. begin
  13092. Ellipse.Reset(ACX, ACY, ARX, ARY);
  13093. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ELLIPSE, @Ellipse));
  13094. end;
  13095. procedure TBLContext.FillGlyphRun(const ADst: TBLPoint; const AFont: IBLFont;
  13096. const AGlyphRun: TBLGlyphRun);
  13097. var
  13098. Font: PBLFontCore;
  13099. begin
  13100. if (AFont = nil) then
  13101. Font := nil
  13102. else
  13103. Font := AFont.Handle;
  13104. _BLCheck(blContextFillGlyphRunD(@FHandle, @ADst, Font, @AGlyphRun));
  13105. end;
  13106. procedure TBLContext.FillGlyphRun(const ADst: TBLPointI; const AFont: IBLFont;
  13107. const AGlyphRun: TBLGlyphRun);
  13108. var
  13109. Font: PBLFontCore;
  13110. begin
  13111. if (AFont = nil) then
  13112. Font := nil
  13113. else
  13114. Font := AFont.Handle;
  13115. _BLCheck(blContextFillGlyphRunI(@FHandle, @ADst, Font, @AGlyphRun));
  13116. end;
  13117. procedure TBLContext.FillGlyphRun(const ADst: TBLPoint; const AFont: IBLFont;
  13118. const AGlyphRun: PBLGlyphRun);
  13119. var
  13120. Font: PBLFontCore;
  13121. begin
  13122. if (AGlyphRun <> nil) then
  13123. begin
  13124. if (AFont = nil) then
  13125. Font := nil
  13126. else
  13127. Font := AFont.Handle;
  13128. _BLCheck(blContextFillGlyphRunD(@FHandle, @ADst, Font, Pointer(AGlyphRun)));
  13129. end;
  13130. end;
  13131. procedure TBLContext.FillGlyphRun(const ADst: TBLPointI; const AFont: IBLFont;
  13132. const AGlyphRun: PBLGlyphRun);
  13133. var
  13134. Font: PBLFontCore;
  13135. begin
  13136. if (AGlyphRun <> nil) then
  13137. begin
  13138. if (AFont = nil) then
  13139. Font := nil
  13140. else
  13141. Font := AFont.Handle;
  13142. _BLCheck(blContextFillGlyphRunI(@FHandle, @ADst, Font, Pointer(AGlyphRun)));
  13143. end;
  13144. end;
  13145. procedure TBLContext.FillPath(const APath: IBLPath);
  13146. begin
  13147. if (APath <> nil) then
  13148. _BLCheck(blContextFillPathD(@FHandle, APath.Handle));
  13149. end;
  13150. procedure TBLContext.FillPie(const ACX, ACY, AR, AStart, ASweep: Double);
  13151. var
  13152. Pie: TBLArc;
  13153. begin
  13154. Pie.Reset(ACX, ACY, AR, AStart, ASweep);
  13155. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_PIE, @Pie));
  13156. end;
  13157. procedure TBLContext.FillPie(const ACX, ACY, ARX, ARY, AStart, ASweep: Double);
  13158. var
  13159. Pie: TBLArc;
  13160. begin
  13161. Pie.Reset(ACX, ACY, ARX, ARY, AStart, ASweep);
  13162. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_PIE, @Pie));
  13163. end;
  13164. procedure TBLContext.FillPie(const APie: TBLArc);
  13165. begin
  13166. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_PIE, @APie));
  13167. end;
  13168. procedure TBLContext.FillPolygon(const APoly: TBLArrayView<TBLPoint>);
  13169. begin
  13170. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGOND, @APoly));
  13171. end;
  13172. procedure TBLContext.FillPolygon(const APoly: TArray<TBLPointI>);
  13173. var
  13174. View: TBLArrayView<TBLPointI>;
  13175. begin
  13176. View.Reset(Pointer(APoly), Length(APoly));
  13177. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGONI, @View));
  13178. end;
  13179. procedure TBLContext.FillPolygon(const APoly: TBLArrayView<TBLPointI>);
  13180. begin
  13181. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGONI, @APoly));
  13182. end;
  13183. procedure TBLContext.FillPolygon(const APoly: PBLPointI; const ACount: Integer);
  13184. var
  13185. View: TBLArrayView<TBLPointI>;
  13186. begin
  13187. View.Reset(APoly, ACount);
  13188. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGONI, @View));
  13189. end;
  13190. procedure TBLContext.FillPolygon(const APoly: TArray<TBLPoint>);
  13191. var
  13192. View: TBLArrayView<TBLPoint>;
  13193. begin
  13194. View.Reset(Pointer(APoly), Length(APoly));
  13195. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGOND, @View));
  13196. end;
  13197. procedure TBLContext.FillPolygon(const APoly: PBLPoint; const ACount: Integer);
  13198. var
  13199. View: TBLArrayView<TBLPoint>;
  13200. begin
  13201. View.Reset(APoly, ACount);
  13202. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGOND, @View));
  13203. end;
  13204. procedure TBLContext.FillRect(const AX, AY, AW, AH: Double);
  13205. var
  13206. R: TBLRect;
  13207. begin
  13208. R.Reset(AX, AY, AW, AH);
  13209. _BLCheck(blContextFillRectD(@FHandle, @R));
  13210. end;
  13211. procedure TBLContext.FillRect(const ARect: TBLRect);
  13212. begin
  13213. _BLCheck(blContextFillRectD(@FHandle, @ARect));
  13214. end;
  13215. procedure TBLContext.FillRect(const ARect: TBLRectI);
  13216. begin
  13217. _BLCheck(blContextFillRectI(@FHandle, @ARect));
  13218. end;
  13219. procedure TBLContext.FillRectArray(const ARects: PBLRect;
  13220. const ACount: Integer);
  13221. var
  13222. View: TBLArrayView<TBLRect>;
  13223. begin
  13224. View.Reset(ARects, ACount);
  13225. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTD, @View));
  13226. end;
  13227. procedure TBLContext.FillRectArray(const ARects: TArray<TBLRectI>);
  13228. var
  13229. View: TBLArrayView<TBLRectI>;
  13230. begin
  13231. View.Reset(Pointer(ARects), Length(ARects));
  13232. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTI, @View));
  13233. end;
  13234. procedure TBLContext.FillRectArray(const ARects: TBLArrayView<TBLRect>);
  13235. begin
  13236. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTD, @ARects));
  13237. end;
  13238. procedure TBLContext.FillRectArray(const ARects: TArray<TBLRect>);
  13239. var
  13240. View: TBLArrayView<TBLRect>;
  13241. begin
  13242. View.Reset(Pointer(ARects), Length(ARects));
  13243. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTD, @View));
  13244. end;
  13245. procedure TBLContext.FillRectArray(const ARects: TBLArrayView<TBLRectI>);
  13246. begin
  13247. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTI, @ARects));
  13248. end;
  13249. procedure TBLContext.FillRectArray(const ARects: PBLRectI;
  13250. const ACount: Integer);
  13251. var
  13252. View: TBLArrayView<TBLRectI>;
  13253. begin
  13254. View.Reset(ARects, ACount);
  13255. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTI, @View));
  13256. end;
  13257. procedure TBLContext.FillRegion(const ARegion: IBLRegion);
  13258. begin
  13259. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_REGION, ARegion.Handle));
  13260. end;
  13261. procedure TBLContext.FillRoundRect(const ARect: TBLRect; const AR: Double);
  13262. var
  13263. RoundRect: TBLRoundRect;
  13264. begin
  13265. RoundRect.Reset(ARect, AR);
  13266. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ROUND_RECT, @RoundRect));
  13267. end;
  13268. procedure TBLContext.FillRoundRect(const ARoundRect: TBLRoundRect);
  13269. begin
  13270. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ROUND_RECT, @ARoundRect));
  13271. end;
  13272. procedure TBLContext.FillRoundRect(const AX, AY, AW, AH, AR: Double);
  13273. var
  13274. RoundRect: TBLRoundRect;
  13275. begin
  13276. RoundRect.Reset(AX, AY, AW, AH, AR);
  13277. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ROUND_RECT, @RoundRect));
  13278. end;
  13279. procedure TBLContext.FillRoundRect(const ARect: TBLRect; const ARX,
  13280. ARY: Double);
  13281. var
  13282. RoundRect: TBLRoundRect;
  13283. begin
  13284. RoundRect.Reset(ARect, ARX, ARY);
  13285. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ROUND_RECT, @RoundRect));
  13286. end;
  13287. procedure TBLContext.FillRoundRect(const AX, AY, AW, AH, ARX, ARY: Double);
  13288. var
  13289. RoundRect: TBLRoundRect;
  13290. begin
  13291. RoundRect.Reset(AX, AY, AW, AH, ARX, ARY);
  13292. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ROUND_RECT, @RoundRect));
  13293. end;
  13294. procedure TBLContext.FillText(const ADst: TBLPointI; const AFont: IBLFont;
  13295. const AText: UTF8String);
  13296. var
  13297. Font: PBLFontCore;
  13298. begin
  13299. if (AText <> '') then
  13300. begin
  13301. if (AFont = nil) then
  13302. Font := nil
  13303. else
  13304. Font := AFont.Handle;
  13305. _BLCheck(blContextFillTextI(@FHandle, @ADst, Font, Pointer(AText), Length(AText), BL_TEXT_ENCODING_UTF8));
  13306. end;
  13307. end;
  13308. procedure TBLContext.FillText(const ADst: TBLPoint; const AFont: IBLFont;
  13309. const AText: String);
  13310. var
  13311. Font: PBLFontCore;
  13312. begin
  13313. if (AText <> '') then
  13314. begin
  13315. if (AFont = nil) then
  13316. Font := nil
  13317. else
  13318. Font := AFont.Handle;
  13319. _BLCheck(blContextFillTextD(@FHandle, @ADst, Font, Pointer(AText), Length(AText), BL_TEXT_ENCODING_UTF16));
  13320. end;
  13321. end;
  13322. procedure TBLContext.FillText(const ADst: TBLPointI; const AFont: IBLFont;
  13323. const AText: String);
  13324. var
  13325. Font: PBLFontCore;
  13326. begin
  13327. if (AText <> '') then
  13328. begin
  13329. if (AFont = nil) then
  13330. Font := nil
  13331. else
  13332. Font := AFont.Handle;
  13333. _BLCheck(blContextFillTextI(@FHandle, @ADst, Font, Pointer(AText), Length(AText), BL_TEXT_ENCODING_UTF16));
  13334. end;
  13335. end;
  13336. procedure TBLContext.FillText(const ADst: TBLPoint; const AFont: IBLFont;
  13337. const AText: UCS4String);
  13338. var
  13339. Font: PBLFontCore;
  13340. begin
  13341. if (AText <> nil) then
  13342. begin
  13343. if (AFont = nil) then
  13344. Font := nil
  13345. else
  13346. Font := AFont.Handle;
  13347. _BLCheck(blContextFillTextD(@FHandle, @ADst, Font, Pointer(AText), Length(AText) - 1, BL_TEXT_ENCODING_UTF32));
  13348. end;
  13349. end;
  13350. procedure TBLContext.FillText(const ADst: TBLPointI; const AFont: IBLFont;
  13351. const AText: UCS4String);
  13352. var
  13353. Font: PBLFontCore;
  13354. begin
  13355. if (AText <> nil) then
  13356. begin
  13357. if (AFont = nil) then
  13358. Font := nil
  13359. else
  13360. Font := AFont.Handle;
  13361. _BLCheck(blContextFillTextI(@FHandle, @ADst, Font, Pointer(AText), Length(AText) - 1, BL_TEXT_ENCODING_UTF32));
  13362. end;
  13363. end;
  13364. procedure TBLContext.FillText(const ADst: TBLPoint; const AFont: IBLFont;
  13365. const AText: UTF8String);
  13366. var
  13367. Font: PBLFontCore;
  13368. begin
  13369. if (AText <> '') then
  13370. begin
  13371. if (AFont = nil) then
  13372. Font := nil
  13373. else
  13374. Font := AFont.Handle;
  13375. _BLCheck(blContextFillTextD(@FHandle, @ADst, Font, Pointer(AText), Length(AText), BL_TEXT_ENCODING_UTF8));
  13376. end;
  13377. end;
  13378. procedure TBLContext.FillTriangle(const AX0, AY0, AX1, AY1, AX2, AY2: Double);
  13379. var
  13380. Triangle: TBLTriangle;
  13381. begin
  13382. Triangle.Reset(AX0, AY0, AX1, AY1, AX2, AY2);
  13383. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_TRIANGLE, @Triangle));
  13384. end;
  13385. procedure TBLContext.FillTriangle(const ATriangle: TBLTriangle);
  13386. begin
  13387. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_TRIANGLE, @ATriangle));
  13388. end;
  13389. procedure TBLContext.Finish;
  13390. begin
  13391. _BLCheck(blContextEnd(@FHandle));
  13392. end;
  13393. procedure TBLContext.Flush(const AFlags: TBLContextFlushFlags);
  13394. begin
  13395. _BLCheck(blContextFlush(@FHandle, Cardinal(AFlags)));
  13396. end;
  13397. function TBLContext.GetApproximationOptions: TBLApproximationOptions;
  13398. begin
  13399. Result.FHandle := FHandle.impl.state.approximationOptions;
  13400. end;
  13401. function TBLContext.GetCompOp: TBLCompOp;
  13402. begin
  13403. Result := TBLCompOp(FHandle.impl.state.compOp);
  13404. end;
  13405. function TBLContext.GetContextType: TBLContextType;
  13406. begin
  13407. Result := TBLContextType(FHandle.impl.contextType);
  13408. end;
  13409. function TBLContext.GetFillAlpha: Double;
  13410. begin
  13411. Result := FHandle.impl.state.styleAlpha[BL_CONTEXT_OP_TYPE_FILL];
  13412. end;
  13413. function TBLContext.GetFillColor: TBLRgba32;
  13414. var
  13415. Style: BLStyleCore;
  13416. begin
  13417. _BLCheck(blContextGetFillStyle(@FHandle, @Style));
  13418. Result.Reset(TBLRgba(Style.rgba));
  13419. end;
  13420. function TBLContext.GetFillColor64: TBLRgba64;
  13421. var
  13422. Style: BLStyleCore;
  13423. begin
  13424. _BLCheck(blContextGetFillStyle(@FHandle, @Style));
  13425. Result.Reset(TBLRgba(Style.rgba));
  13426. end;
  13427. function TBLContext.GetFillColorF: TBLRgba;
  13428. var
  13429. Style: BLStyleCore;
  13430. begin
  13431. _BLCheck(blContextGetFillStyle(@FHandle, @Style));
  13432. Result := TBLRgba(Style.rgba);
  13433. end;
  13434. function TBLContext.GetFillGradient: IBLGradient;
  13435. var
  13436. Style: BLStyleCore;
  13437. begin
  13438. _BLCheck(blContextGetFillStyle(@FHandle, @Style));
  13439. Result := TBLGradient.Create(Style.gradient, True);
  13440. end;
  13441. function TBLContext.GetFillPattern: IBLPattern;
  13442. var
  13443. Style: BLStyleCore;
  13444. begin
  13445. _BLCheck(blContextGetFillStyle(@FHandle, @Style));
  13446. Result := TBLPattern.Create(Style.pattern, True);
  13447. end;
  13448. function TBLContext.GetFillRule: TBLFillRule;
  13449. begin
  13450. Result := TBLFillRule(FHandle.impl.state.fillRule);
  13451. end;
  13452. procedure TBLContext.GetFillStyle(out ARgba: TBLRgba32);
  13453. var
  13454. Style: BLStyleCore;
  13455. begin
  13456. _BLCheck(blContextGetFillStyle(@FHandle, @Style));
  13457. ARgba.Reset(TBLRgba(Style.rgba));
  13458. end;
  13459. procedure TBLContext.GetFillStyle(out ARgba: TBLRgba64);
  13460. var
  13461. Style: BLStyleCore;
  13462. begin
  13463. _BLCheck(blContextGetFillStyle(@FHandle, @Style));
  13464. ARgba.Reset(TBLRgba(Style.rgba));
  13465. end;
  13466. procedure TBLContext.GetFillStyle(out AGradient: IBLGradient);
  13467. var
  13468. Style: BLStyleCore;
  13469. begin
  13470. _BLCheck(blContextGetFillStyle(@FHandle, @Style));
  13471. AGradient := TBLGradient.Create(Style.gradient, True);
  13472. end;
  13473. procedure TBLContext.GetFillStyle(out ARgba: TBLRgba);
  13474. var
  13475. Style: BLStyleCore;
  13476. begin
  13477. _BLCheck(blContextGetFillStyle(@FHandle, @Style));
  13478. ARgba := TBLRgba(Style.rgba);
  13479. end;
  13480. procedure TBLContext.GetFillStyle(out APattern: IBLPattern);
  13481. var
  13482. Style: BLStyleCore;
  13483. begin
  13484. _BLCheck(blContextGetFillStyle(@FHandle, @Style));
  13485. APattern := TBLPattern.Create(Style.pattern, True);
  13486. end;
  13487. function TBLContext.GetFillStyle: TBLStyleType;
  13488. begin
  13489. Result := TBLStyleType(FHandle.impl.state.styleType[BL_CONTEXT_OP_TYPE_FILL]);
  13490. end;
  13491. function TBLContext.GetFlattenMode: TBLFlattenMode;
  13492. begin
  13493. Result := TBLFlattenMode(FHandle.impl.state.approximationOptions.flattenMode);
  13494. end;
  13495. function TBLContext.GetFlattenTolerance: Double;
  13496. begin
  13497. Result := FHandle.impl.state.approximationOptions.flattenTolerance;
  13498. end;
  13499. function TBLContext.GetGlobalAlpha: Double;
  13500. begin
  13501. Result := FHandle.impl.state.globalAlpha;
  13502. end;
  13503. function TBLContext.GetGradientQuality: TBLGradientQuality;
  13504. begin
  13505. Result := TBLGradientQuality(FHandle.impl.state.hints.gradientQuality);
  13506. end;
  13507. function TBLContext.GetHandle: PBLContextCore;
  13508. begin
  13509. Result := @FHandle;
  13510. end;
  13511. function TBLContext.GetHints: TBLContextHints;
  13512. begin
  13513. Result.FHandle := FHandle.impl.state.hints;
  13514. end;
  13515. function TBLContext.GetIsNone: Boolean;
  13516. begin
  13517. Result := ((FHandle.impl.implTraits and BL_IMPL_TRAIT_NULL) <> 0);
  13518. end;
  13519. function TBLContext.GetMetaMatrix: TBLMatrix2D;
  13520. begin
  13521. Result.FHandle := FHandle.impl.state.metaMatrix;
  13522. end;
  13523. function TBLContext.GetPatternQuality: TBLPatternQuality;
  13524. begin
  13525. Result := TBLPatternQuality(FHandle.impl.state.hints.patternQuality);
  13526. end;
  13527. function TBLContext.GetRenderingQuality: TBLRenderingQuality;
  13528. begin
  13529. Result := TBLRenderingQuality(FHandle.impl.state.hints.renderingQuality);
  13530. end;
  13531. function TBLContext.GetSavedStateCount: Integer;
  13532. begin
  13533. Result := FHandle.impl.state.savedStateCount;
  13534. end;
  13535. function TBLContext.GetStrokeAlpha: Double;
  13536. begin
  13537. Result := FHandle.impl.state.styleAlpha[BL_CONTEXT_OP_TYPE_STROKE];
  13538. end;
  13539. function TBLContext.GetStrokeColor: TBLRgba32;
  13540. var
  13541. Style: BLStyleCore;
  13542. begin
  13543. _BLCheck(blContextGetStrokeStyle(@FHandle, @Style));
  13544. Result.Reset(TBLRgba(Style.rgba));
  13545. end;
  13546. function TBLContext.GetStrokeColor64: TBLRgba64;
  13547. var
  13548. Style: BLStyleCore;
  13549. begin
  13550. _BLCheck(blContextGetStrokeStyle(@FHandle, @Style));
  13551. Result.Reset(TBLRgba(Style.rgba));
  13552. end;
  13553. function TBLContext.GetStrokeColorF: TBLRgba;
  13554. var
  13555. Style: BLStyleCore;
  13556. begin
  13557. _BLCheck(blContextGetStrokeStyle(@FHandle, @Style));
  13558. Result := TBLRgba(Style.rgba);
  13559. end;
  13560. function TBLContext.GetStrokeDashArray: TArray<Double>;
  13561. begin
  13562. Result := TBLUtils.BLArrayToArray<Double>(FHandle.impl.state.strokeOptions.dashArray);
  13563. end;
  13564. function TBLContext.GetStrokeDashOffset: Double;
  13565. begin
  13566. Result := FHandle.impl.state.strokeOptions.dashOffset;
  13567. end;
  13568. function TBLContext.GetStrokeEndCap: TBLStrokeCap;
  13569. begin
  13570. Result := TBLStrokeCap(FHandle.impl.state.strokeOptions.options.endCap);
  13571. end;
  13572. function TBLContext.GetStrokeGradient: IBLGradient;
  13573. var
  13574. Style: BLStyleCore;
  13575. begin
  13576. _BLCheck(blContextGetStrokeStyle(@FHandle, @Style));
  13577. Result := TBLGradient.Create(Style.gradient, True);
  13578. end;
  13579. function TBLContext.GetStrokeJoin: TBLStrokeJoin;
  13580. begin
  13581. Result := TBLStrokeJoin(FHandle.impl.state.strokeOptions.options.join);
  13582. end;
  13583. function TBLContext.GetStrokeMiterLimit: Double;
  13584. begin
  13585. Result := FHandle.impl.state.strokeOptions.miterLimit;
  13586. end;
  13587. function TBLContext.GetStrokeOptions: TBLStrokeOptions;
  13588. begin
  13589. Result.FHandle := FHandle.impl.state.strokeOptions;
  13590. end;
  13591. function TBLContext.GetStrokePattern: IBLPattern;
  13592. var
  13593. Style: BLStyleCore;
  13594. begin
  13595. _BLCheck(blContextGetStrokeStyle(@FHandle, @Style));
  13596. Result := TBLPattern.Create(Style.pattern, True);
  13597. end;
  13598. function TBLContext.GetStrokeStartCap: TBLStrokeCap;
  13599. begin
  13600. Result := TBLStrokeCap(FHandle.impl.state.strokeOptions.options.startCap);
  13601. end;
  13602. procedure TBLContext.GetStrokeStyle(out ARgba: TBLRgba64);
  13603. var
  13604. Style: BLStyleCore;
  13605. begin
  13606. _BLCheck(blContextGetStrokeStyle(@FHandle, @Style));
  13607. ARgba.Reset(TBLRgba(Style.rgba));
  13608. end;
  13609. procedure TBLContext.GetStrokeStyle(out ARgba: TBLRgba32);
  13610. var
  13611. Style: BLStyleCore;
  13612. begin
  13613. _BLCheck(blContextGetStrokeStyle(@FHandle, @Style));
  13614. ARgba.Reset(TBLRgba(Style.rgba));
  13615. end;
  13616. procedure TBLContext.GetStrokeStyle(out AGradient: IBLGradient);
  13617. var
  13618. Style: BLStyleCore;
  13619. begin
  13620. _BLCheck(blContextGetStrokeStyle(@FHandle, @Style));
  13621. AGradient := TBLGradient.Create(Style.gradient, True);
  13622. end;
  13623. procedure TBLContext.GetStrokeStyle(out ARgba: TBLRgba);
  13624. var
  13625. Style: BLStyleCore;
  13626. begin
  13627. _BLCheck(blContextGetStrokeStyle(@FHandle, @Style));
  13628. ARgba := TBLRgba(Style.rgba);
  13629. end;
  13630. procedure TBLContext.GetStrokeStyle(out APattern: IBLPattern);
  13631. var
  13632. Style: BLStyleCore;
  13633. begin
  13634. _BLCheck(blContextGetStrokeStyle(@FHandle, @Style));
  13635. APattern := TBLPattern.Create(Style.pattern, True);
  13636. end;
  13637. function TBLContext.GetStrokeStyle: TBLStyleType;
  13638. begin
  13639. Result := TBLStyleType(FHandle.impl.state.styleType[BL_CONTEXT_OP_TYPE_STROKE]);
  13640. end;
  13641. function TBLContext.GetStrokeTransformOrder: TBLStrokeTransformOrder;
  13642. begin
  13643. Result := TBLStrokeTransformOrder(FHandle.impl.state.strokeOptions.options.transformOrder);
  13644. end;
  13645. function TBLContext.GetStrokeWidth: Double;
  13646. begin
  13647. Result := FHandle.impl.state.strokeOptions.width;
  13648. end;
  13649. function TBLContext.GetTargetHeight: Double;
  13650. begin
  13651. Result := FHandle.impl.state.targetSize.h;
  13652. end;
  13653. function TBLContext.GetTargetImage: IBLImage;
  13654. begin
  13655. if (FHandle.impl.state.targetImage = nil) then
  13656. Result := nil
  13657. else
  13658. Result := TBLImage.Create(FHandle.impl.state.targetImage^, True);
  13659. end;
  13660. function TBLContext.GetTargetSize: TBLSize;
  13661. begin
  13662. Result.FHandle := FHandle.impl.state.targetSize;
  13663. end;
  13664. function TBLContext.GetTargetWidth: Double;
  13665. begin
  13666. Result := FHandle.impl.state.targetSize.w;
  13667. end;
  13668. function TBLContext.GetUserMatrix: TBLMatrix2D;
  13669. begin
  13670. Result.FHandle := FHandle.impl.state.userMatrix;
  13671. end;
  13672. procedure TBLContext.PostRotate(const AAngle: Double; const APoint: TBLPoint);
  13673. var
  13674. Data: array [0..2] of Double;
  13675. begin
  13676. Data[0] := AAngle;
  13677. Data[1] := APoint.FHandle.x;
  13678. Data[2] := APoint.FHandle.y;
  13679. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_ROTATE_PT, @Data));
  13680. end;
  13681. procedure TBLContext.PostRotate(const AAngle: Double;
  13682. const APoint: TBLPointI);
  13683. var
  13684. Data: array [0..2] of Double;
  13685. begin
  13686. Data[0] := AAngle;
  13687. Data[1] := APoint.FHandle.x;
  13688. Data[2] := APoint.FHandle.y;
  13689. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_ROTATE_PT, @Data));
  13690. end;
  13691. procedure TBLContext.PostRotate(const AAngle: Double);
  13692. begin
  13693. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_ROTATE, @AAngle));
  13694. end;
  13695. procedure TBLContext.PostRotate(const AAngle, AX, AY: Double);
  13696. var
  13697. Data: array [0..2] of Double;
  13698. begin
  13699. Data[0] := AAngle;
  13700. Data[1] := AX;
  13701. Data[2] := AY;
  13702. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_ROTATE_PT, @Data));
  13703. end;
  13704. procedure TBLContext.PostScale(const AX, AY: Double);
  13705. var
  13706. Data: array [0..1] of Double;
  13707. begin
  13708. Data[0] := AX;
  13709. Data[1] := AY;
  13710. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SCALE, @Data));
  13711. end;
  13712. procedure TBLContext.PostScale(const AXY: Double);
  13713. var
  13714. Data: array [0..1] of Double;
  13715. begin
  13716. Data[0] := AXY;
  13717. Data[1] := AXY;
  13718. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SCALE, @Data));
  13719. end;
  13720. procedure TBLContext.PostScale(const APoint: TBLPoint);
  13721. begin
  13722. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SCALE, @APoint));
  13723. end;
  13724. procedure TBLContext.PostScale(const APoint: TBLPointI);
  13725. var
  13726. Data: array [0..1] of Double;
  13727. begin
  13728. Data[0] := APoint.FHandle.x;
  13729. Data[1] := APoint.FHandle.y;
  13730. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SCALE, @Data));
  13731. end;
  13732. procedure TBLContext.PostSkew(const AX, AY: Double);
  13733. var
  13734. Data: array [0..1] of Double;
  13735. begin
  13736. Data[0] := AX;
  13737. Data[1] := AY;
  13738. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SKEW, @Data));
  13739. end;
  13740. procedure TBLContext.PostSkew(const APoint: TBLPoint);
  13741. begin
  13742. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_SKEW, @APoint));
  13743. end;
  13744. procedure TBLContext.PostTransform(const AMatrix: TBLMatrix2D);
  13745. begin
  13746. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_TRANSFORM, @AMatrix));
  13747. end;
  13748. procedure TBLContext.PostTranslate(const AX, AY: Double);
  13749. var
  13750. Data: array [0..1] of Double;
  13751. begin
  13752. Data[0] := AX;
  13753. Data[1] := AY;
  13754. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_TRANSLATE, @Data));
  13755. end;
  13756. procedure TBLContext.PostTranslate(const APoint: TBLPointI);
  13757. var
  13758. Data: array [0..1] of Double;
  13759. begin
  13760. Data[0] := APoint.FHandle.x;
  13761. Data[1] := APoint.FHandle.y;
  13762. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_TRANSLATE, @Data));
  13763. end;
  13764. procedure TBLContext.PostTranslate(const APoint: TBLPoint);
  13765. begin
  13766. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_POST_TRANSLATE, @APoint));
  13767. end;
  13768. function TBLContext.QueryAccumulatedErrorFlags: TBLContextErrorFlags;
  13769. begin
  13770. _BLCheck(blContextQueryProperty(@FHandle,
  13771. BL_CONTEXT_PROPERTY_ACCUMULATED_ERROR_FLAGS, @Result));
  13772. end;
  13773. function TBLContext.QueryThreadCount: Integer;
  13774. begin
  13775. _BLCheck(blContextQueryProperty(@FHandle, BL_CONTEXT_PROPERTY_THREAD_COUNT,
  13776. @Result));
  13777. end;
  13778. procedure TBLContext.Reset;
  13779. begin
  13780. _BLCheck(blContextReset(@FHandle));
  13781. end;
  13782. procedure TBLContext.ResetMatrix;
  13783. begin
  13784. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_RESET, nil));
  13785. end;
  13786. procedure TBLContext.Restore(const ACookie: TBLContextCookie);
  13787. begin
  13788. _BLCheck(blContextRestore(@FHandle, @ACookie));
  13789. end;
  13790. procedure TBLContext.Restore;
  13791. begin
  13792. _BLCheck(blContextRestore(@FHandle, nil));
  13793. end;
  13794. procedure TBLContext.RestoreClipping;
  13795. begin
  13796. _BLCheck(blContextRestoreClipping(@FHandle));
  13797. end;
  13798. procedure TBLContext.Rotate(const AAngle: Double; const APoint: TBLPoint);
  13799. var
  13800. Data: array [0..2] of Double;
  13801. begin
  13802. Data[0] := AAngle;
  13803. Data[1] := APoint.FHandle.x;
  13804. Data[2] := APoint.FHandle.y;
  13805. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_ROTATE_PT, @Data));
  13806. end;
  13807. procedure TBLContext.Rotate(const AAngle, AX, AY: Double);
  13808. var
  13809. Data: array [0..2] of Double;
  13810. begin
  13811. Data[0] := AAngle;
  13812. Data[1] := AX;
  13813. Data[2] := AY;
  13814. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_ROTATE_PT, @Data));
  13815. end;
  13816. procedure TBLContext.Rotate(const AAngle: Double);
  13817. begin
  13818. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_ROTATE, @AAngle));
  13819. end;
  13820. procedure TBLContext.Rotate(const AAngle: Double; const APoint: TBLPointI);
  13821. var
  13822. Data: array [0..2] of Double;
  13823. begin
  13824. Data[0] := AAngle;
  13825. Data[1] := APoint.FHandle.x;
  13826. Data[2] := APoint.FHandle.y;
  13827. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_ROTATE_PT, @Data));
  13828. end;
  13829. procedure TBLContext.Save(out ACookie: TBLContextCookie);
  13830. begin
  13831. _BLCheck(blContextSave(@FHandle, @ACookie));
  13832. end;
  13833. procedure TBLContext.Save;
  13834. begin
  13835. _BLCheck(blContextSave(@FHandle, nil));
  13836. end;
  13837. procedure TBLContext.Scale(const AXY: Double);
  13838. var
  13839. Data: array [0..1] of Double;
  13840. begin
  13841. Data[0] := AXY;
  13842. Data[1] := AXY;
  13843. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_SCALE, @Data));
  13844. end;
  13845. procedure TBLContext.Scale(const APoint: TBLPointI);
  13846. var
  13847. Data: array [0..1] of Double;
  13848. begin
  13849. Data[0] := APoint.FHandle.x;
  13850. Data[1] := APoint.FHandle.y;
  13851. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_SCALE, @Data));
  13852. end;
  13853. procedure TBLContext.Scale(const AX, AY: Double);
  13854. var
  13855. Data: array [0..1] of Double;
  13856. begin
  13857. Data[0] := AX;
  13858. Data[1] := AY;
  13859. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_SCALE, @Data));
  13860. end;
  13861. procedure TBLContext.Scale(const APoint: TBLPoint);
  13862. begin
  13863. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_SCALE, @APoint));
  13864. end;
  13865. procedure TBLContext.SetCompOp(const AValue: TBLCompOp);
  13866. begin
  13867. _BLCheck(blContextSetCompOp(@FHandle, Ord(AValue)));
  13868. end;
  13869. procedure TBLContext.SetFillAlpha(const AValue: Double);
  13870. begin
  13871. _BLCheck(blContextSetFillAlpha(@FHandle, AValue));
  13872. end;
  13873. procedure TBLContext.SetFillColor(const AValue: TBLRgba32);
  13874. begin
  13875. _BLCheck(blContextSetFillStyleRgba32(@FHandle, AValue.FHandle.value));
  13876. end;
  13877. procedure TBLContext.SetFillColor64(const AValue: TBLRgba64);
  13878. begin
  13879. _BLCheck(blContextSetFillStyleRgba64(@FHandle, AValue.FHandle.value));
  13880. end;
  13881. procedure TBLContext.SetFillColorF(const AValue: TBLRgba);
  13882. begin
  13883. _BLCheck(blContextSetFillStyleRgba(@FHandle, @AValue));
  13884. end;
  13885. procedure TBLContext.SetFillGradient(const AValue: IBLGradient);
  13886. begin
  13887. if (AValue <> nil) then
  13888. _BLCheck(blContextSetFillStyleObject(@FHandle, AValue.Handle));
  13889. end;
  13890. procedure TBLContext.SetFillPattern(const AValue: IBLPattern);
  13891. begin
  13892. if (AValue <> nil) then
  13893. _BLCheck(blContextSetFillStyleObject(@FHandle, AValue.Handle));
  13894. end;
  13895. procedure TBLContext.SetFillRule(const AValue: TBLFillRule);
  13896. begin
  13897. _BLCheck(blContextSetFillRule(@FHandle, Ord(AValue)));
  13898. end;
  13899. procedure TBLContext.SetFillStyle(const ARgba: TBLRgba64);
  13900. begin
  13901. _BLCheck(blContextSetFillStyleRgba64(@FHandle, ARgba.FHandle.value));
  13902. end;
  13903. procedure TBLContext.SetFillStyle(const ARgba: TBLRgba32);
  13904. begin
  13905. _BLCheck(blContextSetFillStyleRgba32(@FHandle, ARgba.FHandle.value));
  13906. end;
  13907. procedure TBLContext.SetFillStyle(const APattern: IBLPattern);
  13908. begin
  13909. if (APattern <> nil) then
  13910. _BLCheck(blContextSetFillStyleObject(@FHandle, APattern.Handle));
  13911. end;
  13912. procedure TBLContext.SetFillStyle(const AImage: IBLImage);
  13913. begin
  13914. if (AImage <> nil) then
  13915. _BLCheck(blContextSetFillStyleObject(@FHandle, AImage.Handle));
  13916. end;
  13917. procedure TBLContext.SetFillStyle(const ARgba: TBLRgba);
  13918. begin
  13919. _BLCheck(blContextSetFillStyleRgba(@FHandle, @ARgba));
  13920. end;
  13921. procedure TBLContext.SetFillStyle(const AGradient: IBLGradient);
  13922. begin
  13923. if (AGradient <> nil) then
  13924. _BLCheck(blContextSetFillStyleObject(@FHandle, AGradient.Handle));
  13925. end;
  13926. procedure TBLContext.SetFlattenMode(const AValue: TBLFlattenMode);
  13927. begin
  13928. _BLCheck(blContextSetFlattenMode(@FHandle, Ord(AValue)));
  13929. end;
  13930. procedure TBLContext.SetFlattenTolerance(const AValue: Double);
  13931. begin
  13932. _BLCheck(blContextSetFlattenTolerance(@FHandle, AValue));
  13933. end;
  13934. procedure TBLContext.SetGlobalAlpha(const AValue: Double);
  13935. begin
  13936. _BLCheck(blContextSetGlobalAlpha(@FHandle, AValue));
  13937. end;
  13938. procedure TBLContext.SetGradientQuality(const AValue: TBLGradientQuality);
  13939. begin
  13940. _BLCheck(blContextSetHint(@FHandle, BL_CONTEXT_HINT_GRADIENT_QUALITY, Ord(AValue)));
  13941. end;
  13942. procedure TBLContext.SetHints(const AValue: TBLContextHints);
  13943. begin
  13944. _BLCheck(blContextSetHints(@FHandle, @AValue.FHandle));
  13945. end;
  13946. procedure TBLContext.SetPatternQuality(const AValue: TBLPatternQuality);
  13947. begin
  13948. _BLCheck(blContextSetHint(@FHandle, BL_CONTEXT_HINT_PATTERN_QUALITY, Ord(AValue)));
  13949. end;
  13950. procedure TBLContext.SetRenderingQuality(const AValue: TBLRenderingQuality);
  13951. begin
  13952. _BLCheck(blContextSetHint(@FHandle, BL_CONTEXT_HINT_RENDERING_QUALITY, Ord(AValue)));
  13953. end;
  13954. procedure TBLContext.SetStrokeAlpha(const AValue: Double);
  13955. begin
  13956. _BLCheck(blContextSetStrokeAlpha(@FHandle, AValue));
  13957. end;
  13958. procedure TBLContext.SetStrokeColor(const AValue: TBLRgba32);
  13959. begin
  13960. _BLCheck(blContextSetStrokeStyleRgba32(@FHandle, AValue.FHandle.value));
  13961. end;
  13962. procedure TBLContext.SetStrokeColor64(const AValue: TBLRgba64);
  13963. begin
  13964. _BLCheck(blContextSetStrokeStyleRgba64(@FHandle, AValue.FHandle.value));
  13965. end;
  13966. procedure TBLContext.SetStrokeColorF(const AValue: TBLRgba);
  13967. begin
  13968. _BLCheck(blContextSetStrokeStyleRgba(@FHandle, @AValue));
  13969. end;
  13970. procedure TBLContext.SetStrokeDashArray(const AValue: TArray<Double>);
  13971. var
  13972. Value: IBLArray;
  13973. begin
  13974. Value := TBLUtils.ArrayToBLArray<Double>(AValue);
  13975. _BLCheck(blContextSetStrokeDashArray(@FHandle, Value.Handle));
  13976. end;
  13977. procedure TBLContext.SetStrokeDashOffset(const AValue: Double);
  13978. begin
  13979. _BLCheck(blContextSetStrokeDashOffset(@FHandle, AValue));
  13980. end;
  13981. procedure TBLContext.SetStrokeEndCap(const AValue: TBLStrokeCap);
  13982. begin
  13983. _BLCheck(blContextSetStrokeCap(@FHandle, BL_STROKE_CAP_POSITION_END, Ord(AValue)));
  13984. end;
  13985. procedure TBLContext.SetStrokeGradient(const AValue: IBLGradient);
  13986. begin
  13987. if (AValue <> nil) then
  13988. _BLCheck(blContextSetStrokeStyleObject(@FHandle, AValue.Handle));
  13989. end;
  13990. procedure TBLContext.SetStrokeJoin(const AValue: TBLStrokeJoin);
  13991. begin
  13992. _BLCheck(blContextSetStrokeJoin(@FHandle, Ord(AValue)));
  13993. end;
  13994. procedure TBLContext.SetStrokeMiterLimit(const AValue: Double);
  13995. begin
  13996. _BLCheck(blContextSetStrokeMiterLimit(@FHandle, AValue));
  13997. end;
  13998. procedure TBLContext.SetStrokeOptions(const AValue: TBLStrokeOptions);
  13999. begin
  14000. _BLCheck(blContextSetStrokeOptions(@FHandle, @AValue.FHandle));
  14001. end;
  14002. procedure TBLContext.SetStrokePattern(const AValue: IBLPattern);
  14003. begin
  14004. if (AValue <> nil) then
  14005. _BLCheck(blContextSetStrokeStyleObject(@FHandle, AValue.Handle));
  14006. end;
  14007. procedure TBLContext.SetStrokeStartCap(const AValue: TBLStrokeCap);
  14008. begin
  14009. _BLCheck(blContextSetStrokeCap(@FHandle, BL_STROKE_CAP_POSITION_START, Ord(AValue)));
  14010. end;
  14011. procedure TBLContext.SetStrokeStyle(const ARgba: TBLRgba64);
  14012. begin
  14013. _BLCheck(blContextSetStrokeStyleRgba64(@FHandle, ARgba.FHandle.value));
  14014. end;
  14015. procedure TBLContext.SetStrokeStyle(const ARgba: TBLRgba32);
  14016. begin
  14017. _BLCheck(blContextSetStrokeStyleRgba32(@FHandle, ARgba.FHandle.value));
  14018. end;
  14019. procedure TBLContext.SetStrokeStyle(const APattern: IBLPattern);
  14020. begin
  14021. if (APattern <> nil) then
  14022. _BLCheck(blContextSetStrokeStyleObject(@FHandle, APattern.Handle));
  14023. end;
  14024. procedure TBLContext.SetStrokeStyle(const AGradient: IBLGradient);
  14025. begin
  14026. if (AGradient <> nil) then
  14027. _BLCheck(blContextSetStrokeStyleObject(@FHandle, AGradient.Handle));
  14028. end;
  14029. procedure TBLContext.SetStrokeStyle(const AImage: IBLImage);
  14030. begin
  14031. if (AImage <> nil) then
  14032. _BLCheck(blContextSetStrokeStyleObject(@FHandle, AImage.Handle));
  14033. end;
  14034. procedure TBLContext.SetStrokeStyle(const ARgba: TBLRgba);
  14035. begin
  14036. _BLCheck(blContextSetStrokeStyleRgba(@FHandle, @ARgba));
  14037. end;
  14038. procedure TBLContext.SetStrokeTransformOrder(
  14039. const AValue: TBLStrokeTransformOrder);
  14040. begin
  14041. _BLCheck(blContextSetStrokeTransformOrder(@FHandle, Ord(AValue)));
  14042. end;
  14043. procedure TBLContext.SetStrokeWidth(const AValue: Double);
  14044. begin
  14045. _BLCheck(blContextSetStrokeWidth(@FHandle, AValue));
  14046. end;
  14047. procedure TBLContext.SetUserMatrix(const AValue: TBLMatrix2D);
  14048. begin
  14049. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_ASSIGN, @AValue));
  14050. end;
  14051. procedure TBLContext.Skew(const APoint: TBLPoint);
  14052. begin
  14053. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_SKEW, @APoint));
  14054. end;
  14055. procedure TBLContext.Skew(const AX, AY: Double);
  14056. var
  14057. Data: array [0..1] of Double;
  14058. begin
  14059. Data[0] := AX;
  14060. Data[1] := AY;
  14061. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_SKEW, @Data));
  14062. end;
  14063. procedure TBLContext.Start(const AImage: IBLImage;
  14064. const ACreateInfo: TBLContextCreateInfo);
  14065. begin
  14066. if (AImage <> nil) then
  14067. _BLCheck(blContextBegin(@FHandle, AImage.Handle, @ACreateInfo.FHandle));
  14068. end;
  14069. procedure TBLContext.Start(const AImage: IBLImage);
  14070. begin
  14071. if (AImage <> nil) then
  14072. _BLCheck(blContextBegin(@FHandle, AImage.Handle, nil));
  14073. end;
  14074. procedure TBLContext.StrokeArc(const AArc: TBLArc);
  14075. begin
  14076. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_ARC, @AArc));
  14077. end;
  14078. procedure TBLContext.StrokeArc(const ACX, ACY, AR, AStart, ASweep: Double);
  14079. var
  14080. Arc: TBLArc;
  14081. begin
  14082. Arc.Reset(ACX, ACY, AR, AStart, ASweep);
  14083. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_ARC, @Arc));
  14084. end;
  14085. procedure TBLContext.StrokeArc(const ACX, ACY, ARX, ARY, AStart,
  14086. ASweep: Double);
  14087. var
  14088. Arc: TBLArc;
  14089. begin
  14090. Arc.Reset(ACX, ACY, ARX, ARY, AStart, ASweep);
  14091. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_ARC, @Arc));
  14092. end;
  14093. procedure TBLContext.StrokeBox(const AX0, AY0, AX1, AY1: Double);
  14094. var
  14095. Box: TBLBox;
  14096. begin
  14097. Box.Reset(AX0, AY0, AX1, AY1);
  14098. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_BOXD, @Box));
  14099. end;
  14100. procedure TBLContext.StrokeBox(const ABox: TBLBox);
  14101. begin
  14102. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_BOXD, @ABox));
  14103. end;
  14104. procedure TBLContext.StrokeBox(const ABox: TBLBoxI);
  14105. begin
  14106. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_BOXI, @ABox));
  14107. end;
  14108. procedure TBLContext.StrokeBoxArray(const ABoxes: PBLBoxI;
  14109. const ACount: Integer);
  14110. var
  14111. View: TBLArrayView<TBLBoxI>;
  14112. begin
  14113. View.Reset(ABoxes, ACount);
  14114. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXI, @View));
  14115. end;
  14116. procedure TBLContext.StrokeBoxArray(const ABoxes: PBLBox;
  14117. const ACount: Integer);
  14118. var
  14119. View: TBLArrayView<TBLBox>;
  14120. begin
  14121. View.Reset(ABoxes, ACount);
  14122. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXD, @View));
  14123. end;
  14124. procedure TBLContext.StrokeBoxArray(const ABoxes: TBLArrayView<TBLBox>);
  14125. begin
  14126. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXD, @ABoxes));
  14127. end;
  14128. procedure TBLContext.StrokeBoxArray(const ABoxes: TBLArrayView<TBLBoxI>);
  14129. begin
  14130. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXI, @ABoxes));
  14131. end;
  14132. procedure TBLContext.StrokeBoxArray(const ABoxes: TArray<TBLBoxI>);
  14133. var
  14134. View: TBLArrayView<TBLBoxI>;
  14135. begin
  14136. View.Reset(Pointer(ABoxes), Length(ABoxes));
  14137. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXI, @View));
  14138. end;
  14139. procedure TBLContext.StrokeBoxArray(const ABoxes: TArray<TBLBox>);
  14140. var
  14141. View: TBLArrayView<TBLBox>;
  14142. begin
  14143. View.Reset(Pointer(ABoxes), Length(ABoxes));
  14144. _BLCheck(blContextFillGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXD, @View));
  14145. end;
  14146. procedure TBLContext.StrokeChord(const AChord: TBLArc);
  14147. begin
  14148. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_CHORD, @AChord));
  14149. end;
  14150. procedure TBLContext.StrokeChord(const ACX, ACY, AR, AStart, ASweep: Double);
  14151. var
  14152. Chord: TBLArc;
  14153. begin
  14154. Chord.Reset(ACX, ACY, AR, AStart, ASweep);
  14155. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_CHORD, @Chord));
  14156. end;
  14157. procedure TBLContext.StrokeChord(const ACX, ACY, ARX, ARY, AStart,
  14158. ASweep: Double);
  14159. var
  14160. Chord: TBLArc;
  14161. begin
  14162. Chord.Reset(ACX, ACY, ARX, ARY, AStart, ASweep);
  14163. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_CHORD, @Chord));
  14164. end;
  14165. procedure TBLContext.StrokeCircle(const ACX, ACY, AR: Double);
  14166. var
  14167. Circle: TBLCircle;
  14168. begin
  14169. Circle.Reset(ACX, ACY, AR);
  14170. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_CIRCLE, @Circle));
  14171. end;
  14172. procedure TBLContext.StrokeCircle(const ACircle: TBLCircle);
  14173. begin
  14174. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_CIRCLE, @ACircle));
  14175. end;
  14176. procedure TBLContext.StrokeEllipse(const AEllipse: TBLEllipse);
  14177. begin
  14178. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_ELLIPSE, @AEllipse));
  14179. end;
  14180. procedure TBLContext.StrokeEllipse(const ACX, ACY, ARX, ARY: Double);
  14181. var
  14182. Ellipse: TBLEllipse;
  14183. begin
  14184. Ellipse.Reset(ACX, ACY, ARX, ARY);
  14185. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_ELLIPSE, @Ellipse));
  14186. end;
  14187. procedure TBLContext.StrokeGlyphRun(const ADst: TBLPointI; const AFont: IBLFont;
  14188. const AGlyphRun: TBLGlyphRun);
  14189. var
  14190. Font: PBLFontCore;
  14191. begin
  14192. if (AFont = nil) then
  14193. Font := nil
  14194. else
  14195. Font := AFont.Handle;
  14196. _BLCheck(blContextStrokeGlyphRunI(@FHandle, @ADst, Font, @AGlyphRun));
  14197. end;
  14198. procedure TBLContext.StrokeGlyphRun(const ADst: TBLPoint; const AFont: IBLFont;
  14199. const AGlyphRun: TBLGlyphRun);
  14200. var
  14201. Font: PBLFontCore;
  14202. begin
  14203. if (AFont = nil) then
  14204. Font := nil
  14205. else
  14206. Font := AFont.Handle;
  14207. _BLCheck(blContextStrokeGlyphRunD(@FHandle, @ADst, Font, @AGlyphRun));
  14208. end;
  14209. procedure TBLContext.StrokeLine(const AX0, AY0, AX1, AY1: Double);
  14210. var
  14211. Line: TBLLine;
  14212. begin
  14213. Line.Reset(AX0, AY0, AX1, AY1);
  14214. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_LINE, @Line));
  14215. end;
  14216. procedure TBLContext.StrokeLine(const AP0, AP1: TBLPoint);
  14217. var
  14218. Line: TBLLine;
  14219. begin
  14220. Line.Reset(AP0, AP1);
  14221. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_LINE, @Line));
  14222. end;
  14223. procedure TBLContext.StrokeLine(const ALine: TBLLine);
  14224. begin
  14225. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_LINE, @ALine));
  14226. end;
  14227. procedure TBLContext.StrokePath(const APath: IBLPath);
  14228. begin
  14229. if (APath <> nil) then
  14230. _BLCheck(blContextStrokePathD(@FHandle, APath.Handle));
  14231. end;
  14232. procedure TBLContext.StrokePie(const ACX, ACY, ARX, ARY, AStart,
  14233. ASweep: Double);
  14234. var
  14235. Pie: TBLArc;
  14236. begin
  14237. Pie.Reset(ACX, ACY, ARX, ARY, AStart, ASweep);
  14238. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_PIE, @Pie));
  14239. end;
  14240. procedure TBLContext.StrokePie(const ACX, ACY, AR, AStart, ASweep: Double);
  14241. var
  14242. Pie: TBLArc;
  14243. begin
  14244. Pie.Reset(ACX, ACY, AR, AStart, ASweep);
  14245. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_PIE, @Pie));
  14246. end;
  14247. procedure TBLContext.StrokePie(const APie: TBLArc);
  14248. begin
  14249. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_PIE, @APie));
  14250. end;
  14251. procedure TBLContext.StrokePolygon(const APoly: TBLArrayView<TBLPoint>);
  14252. begin
  14253. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGOND, @APoly));
  14254. end;
  14255. procedure TBLContext.StrokePolygon(const APoly: TArray<TBLPointI>);
  14256. var
  14257. View: TBLArrayView<TBLPointI>;
  14258. begin
  14259. View.Reset(Pointer(APoly), Length(APoly));
  14260. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGONI, @View));
  14261. end;
  14262. procedure TBLContext.StrokePolygon(const APoly: PBLPoint;
  14263. const ACount: Integer);
  14264. var
  14265. View: TBLArrayView<TBLPoint>;
  14266. begin
  14267. View.Reset(APoly, ACount);
  14268. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGOND, @View));
  14269. end;
  14270. procedure TBLContext.StrokePolygon(const APoly: TArray<TBLPoint>);
  14271. var
  14272. View: TBLArrayView<TBLPoint>;
  14273. begin
  14274. View.Reset(Pointer(APoly), Length(APoly));
  14275. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGOND, @View));
  14276. end;
  14277. procedure TBLContext.StrokePolygon(const APoly: PBLPointI;
  14278. const ACount: Integer);
  14279. var
  14280. View: TBLArrayView<TBLPointI>;
  14281. begin
  14282. View.Reset(APoly, ACount);
  14283. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGONI, @View));
  14284. end;
  14285. procedure TBLContext.StrokePolygon(const APoly: TBLArrayView<TBLPointI>);
  14286. begin
  14287. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYGONI, @APoly));
  14288. end;
  14289. procedure TBLContext.StrokePolyline(const APoly: TBLArrayView<TBLPointI>);
  14290. begin
  14291. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYLINEI, @APoly));
  14292. end;
  14293. procedure TBLContext.StrokePolyline(const APoly: TArray<TBLPoint>);
  14294. var
  14295. View: TBLArrayView<TBLPoint>;
  14296. begin
  14297. View.Reset(Pointer(APoly), Length(APoly));
  14298. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYLINED, @APoly));
  14299. end;
  14300. procedure TBLContext.StrokePolyline(const APoly: TBLArrayView<TBLPoint>);
  14301. begin
  14302. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYLINED, @APoly));
  14303. end;
  14304. procedure TBLContext.StrokePolyline(const APoly: PBLPoint;
  14305. const ACount: Integer);
  14306. var
  14307. View: TBLArrayView<TBLPoint>;
  14308. begin
  14309. View.Reset(APoly, ACount);
  14310. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYLINED, @APoly));
  14311. end;
  14312. procedure TBLContext.StrokePolyline(const APoly: TArray<TBLPointI>);
  14313. var
  14314. View: TBLArrayView<TBLPointI>;
  14315. begin
  14316. View.Reset(Pointer(APoly), Length(APoly));
  14317. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYLINEI, @APoly));
  14318. end;
  14319. procedure TBLContext.StrokePolyline(const APoly: PBLPointI;
  14320. const ACount: Integer);
  14321. var
  14322. View: TBLArrayView<TBLPointI>;
  14323. begin
  14324. View.Reset(APoly, ACount);
  14325. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_POLYLINEI, @APoly));
  14326. end;
  14327. procedure TBLContext.StrokeRect(const ARect: TBLRectI);
  14328. begin
  14329. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_RECTI, @ARect));
  14330. end;
  14331. procedure TBLContext.StrokeRect(const ARect: TBLRect);
  14332. begin
  14333. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_RECTD, @ARect));
  14334. end;
  14335. procedure TBLContext.StrokeRect(const AX, AY, AW, AH: Double);
  14336. var
  14337. Rect: TBLRect;
  14338. begin
  14339. Rect.Reset(AX, AY, AW, AH);
  14340. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_RECTD, @Rect));
  14341. end;
  14342. procedure TBLContext.StrokeRectArray(const ARects: PBLRect;
  14343. const ACount: Integer);
  14344. var
  14345. View: TBLArrayView<TBLRect>;
  14346. begin
  14347. View.Reset(ARects, ACount);
  14348. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTD, @View));
  14349. end;
  14350. procedure TBLContext.StrokeRectArray(const ARects: TArray<TBLRect>);
  14351. var
  14352. View: TBLArrayView<TBLRect>;
  14353. begin
  14354. View.Reset(Pointer(ARects), Length(ARects));
  14355. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTD, @View));
  14356. end;
  14357. procedure TBLContext.StrokeRectArray(const ARects: TBLArrayView<TBLRect>);
  14358. begin
  14359. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTD, @ARects));
  14360. end;
  14361. procedure TBLContext.StrokeRectArray(const ARects: TBLArrayView<TBLRectI>);
  14362. begin
  14363. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTI, @ARects));
  14364. end;
  14365. procedure TBLContext.StrokeRectArray(const ARects: PBLRectI;
  14366. const ACount: Integer);
  14367. var
  14368. View: TBLArrayView<TBLRectI>;
  14369. begin
  14370. View.Reset(ARects, ACount);
  14371. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTI, @View));
  14372. end;
  14373. procedure TBLContext.StrokeRectArray(const ARects: TArray<TBLRectI>);
  14374. var
  14375. View: TBLArrayView<TBLRectI>;
  14376. begin
  14377. View.Reset(Pointer(ARects), Length(ARects));
  14378. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTI, @View));
  14379. end;
  14380. procedure TBLContext.StrokeRoundRect(const AX, AY, AW, AH, AR: Double);
  14381. var
  14382. RoundRect: TBLRoundRect;
  14383. begin
  14384. RoundRect.Reset(AX, AY, AW, AH, AR);
  14385. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_ROUND_RECT, @RoundRect));
  14386. end;
  14387. procedure TBLContext.StrokeRoundRect(const ARect: TBLRect; const AR: Double);
  14388. var
  14389. RoundRect: TBLRoundRect;
  14390. begin
  14391. RoundRect.Reset(ARect, AR);
  14392. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_ROUND_RECT, @RoundRect));
  14393. end;
  14394. procedure TBLContext.StrokeRoundRect(const ARoundRect: TBLRoundRect);
  14395. begin
  14396. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_ROUND_RECT, @ARoundRect));
  14397. end;
  14398. procedure TBLContext.StrokeRoundRect(const ARect: TBLRect; const ARX,
  14399. ARY: Double);
  14400. var
  14401. RoundRect: TBLRoundRect;
  14402. begin
  14403. RoundRect.Reset(ARect, ARX, ARY);
  14404. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_ROUND_RECT, @RoundRect));
  14405. end;
  14406. procedure TBLContext.StrokeRoundRect(const AX, AY, AW, AH, ARX, ARY: Double);
  14407. var
  14408. RoundRect: TBLRoundRect;
  14409. begin
  14410. RoundRect.Reset(AX, AY, AW, AH, ARX, ARY);
  14411. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_ROUND_RECT, @RoundRect));
  14412. end;
  14413. procedure TBLContext.StrokeText(const ADst: TBLPoint; const AFont: IBLFont;
  14414. const AText: UCS4String);
  14415. var
  14416. Font: PBLFontCore;
  14417. begin
  14418. if (AText <> nil) then
  14419. begin
  14420. if (AFont = nil) then
  14421. Font := nil
  14422. else
  14423. Font := AFont.Handle;
  14424. _BLCheck(blContextStrokeTextD(@FHandle, @ADst, Font, Pointer(AText), Length(AText) - 1, BL_TEXT_ENCODING_UTF32));
  14425. end;
  14426. end;
  14427. procedure TBLContext.StrokeText(const ADst: TBLPoint; const AFont: IBLFont;
  14428. const AText: UTF8String);
  14429. var
  14430. Font: PBLFontCore;
  14431. begin
  14432. if (AText <> '') then
  14433. begin
  14434. if (AFont = nil) then
  14435. Font := nil
  14436. else
  14437. Font := AFont.Handle;
  14438. _BLCheck(blContextStrokeTextD(@FHandle, @ADst, Font, Pointer(AText), Length(AText), BL_TEXT_ENCODING_UTF8));
  14439. end;
  14440. end;
  14441. procedure TBLContext.StrokeText(const ADst: TBLPointI; const AFont: IBLFont;
  14442. const AText: UCS4String);
  14443. var
  14444. Font: PBLFontCore;
  14445. begin
  14446. if (AText <> nil) then
  14447. begin
  14448. if (AFont = nil) then
  14449. Font := nil
  14450. else
  14451. Font := AFont.Handle;
  14452. _BLCheck(blContextStrokeTextI(@FHandle, @ADst, Font, Pointer(AText), Length(AText) - 1, BL_TEXT_ENCODING_UTF32));
  14453. end;
  14454. end;
  14455. procedure TBLContext.StrokeText(const ADst: TBLPointI; const AFont: IBLFont;
  14456. const AText: UTF8String);
  14457. var
  14458. Font: PBLFontCore;
  14459. begin
  14460. if (AText <> '') then
  14461. begin
  14462. if (AFont = nil) then
  14463. Font := nil
  14464. else
  14465. Font := AFont.Handle;
  14466. _BLCheck(blContextStrokeTextI(@FHandle, @ADst, Font, Pointer(AText), Length(AText), BL_TEXT_ENCODING_UTF8));
  14467. end;
  14468. end;
  14469. procedure TBLContext.StrokeText(const ADst: TBLPoint; const AFont: IBLFont;
  14470. const AText: String);
  14471. var
  14472. Font: PBLFontCore;
  14473. begin
  14474. if (AText <> '') then
  14475. begin
  14476. if (AFont = nil) then
  14477. Font := nil
  14478. else
  14479. Font := AFont.Handle;
  14480. _BLCheck(blContextStrokeTextD(@FHandle, @ADst, Font, Pointer(AText), Length(AText), BL_TEXT_ENCODING_UTF16));
  14481. end;
  14482. end;
  14483. procedure TBLContext.StrokeText(const ADst: TBLPointI; const AFont: IBLFont;
  14484. const AText: String);
  14485. var
  14486. Font: PBLFontCore;
  14487. begin
  14488. if (AText <> '') then
  14489. begin
  14490. if (AFont = nil) then
  14491. Font := nil
  14492. else
  14493. Font := AFont.Handle;
  14494. _BLCheck(blContextStrokeTextI(@FHandle, @ADst, Font, Pointer(AText), Length(AText), BL_TEXT_ENCODING_UTF16));
  14495. end;
  14496. end;
  14497. procedure TBLContext.StrokeTriangle(const ATriangle: TBLTriangle);
  14498. begin
  14499. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_TRIANGLE, @ATriangle));
  14500. end;
  14501. procedure TBLContext.StrokeTriangle(const AX0, AY0, AX1, AY1, AX2, AY2: Double);
  14502. var
  14503. Triangle: TBLTriangle;
  14504. begin
  14505. Triangle.Reset(AX0, AY0, AX1, AY1, AX2, AY2);
  14506. _BLCheck(blContextStrokeGeometry(@FHandle, BL_GEOMETRY_TYPE_TRIANGLE, @Triangle));
  14507. end;
  14508. procedure TBLContext.Transform(const AMatrix: TBLMatrix2D);
  14509. begin
  14510. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_TRANSFORM, @AMatrix));
  14511. end;
  14512. procedure TBLContext.Translate(const APoint: TBLPointI);
  14513. var
  14514. Data: array [0..1] of Double;
  14515. begin
  14516. Data[0] := APoint.FHandle.x;
  14517. Data[1] := APoint.FHandle.y;
  14518. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_TRANSLATE, @Data));
  14519. end;
  14520. procedure TBLContext.Translate(const AX, AY: Double);
  14521. var
  14522. Data: array [0..1] of Double;
  14523. begin
  14524. Data[0] := AX;
  14525. Data[1] := AY;
  14526. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_TRANSLATE, @Data));
  14527. end;
  14528. procedure TBLContext.Translate(const APoint: TBLPoint);
  14529. begin
  14530. _BLCheck(blContextMatrixOp(@FHandle, BL_MATRIX2D_OP_TRANSLATE, @APoint));
  14531. end;
  14532. procedure TBLContext.UserToMeta;
  14533. begin
  14534. _BLCheck(blContextUserToMeta(@FHandle));
  14535. end;
  14536. {$ENDREGION 'Context'}
  14537. {$REGION 'Runtime'}
  14538. { TBLRuntimeBuildInfo }
  14539. function TBLRuntimeBuildInfo.GetBaselineCpuFeatures: TBLRuntimeCpuFeatures;
  14540. begin
  14541. Byte(Result) := FHandle.baselineCpuFeatures;
  14542. end;
  14543. function TBLRuntimeBuildInfo.GetBuildType: TBLRuntimeBuildType;
  14544. begin
  14545. Result := TBLRuntimeBuildType(FHandle.buildType);
  14546. end;
  14547. function TBLRuntimeBuildInfo.GetSupportedCpuFeatures: TBLRuntimeCpuFeatures;
  14548. begin
  14549. Byte(Result) := FHandle.supportedCpuFeatures;
  14550. end;
  14551. { TBLRuntimeSystemInfo }
  14552. function TBLRuntimeSystemInfo.GetCpuArch: TBLRuntimeCpuArch;
  14553. begin
  14554. Result := TBLRuntimeCpuArch(FHandle.cpuArch);
  14555. end;
  14556. function TBLRuntimeSystemInfo.GetCpuFeatures: TBLRuntimeCpuFeatures;
  14557. begin
  14558. Byte(Result) := FHandle.cpuFeatures;
  14559. end;
  14560. { TBLRuntime }
  14561. class procedure TBLRuntime.Cleanup(const AFlags: TBLRuntimeCleanupFlags);
  14562. begin
  14563. _BLCheck(blRuntimeCleanup(Byte(AFlags)));
  14564. end;
  14565. class procedure TBLRuntime.LogMessage(const AMessage: String;
  14566. const AArgs: array of const);
  14567. begin
  14568. _BLCheck(blRuntimeMessageOut(MarshaledAString(UTF8String(Format(AMessage, AArgs)))));
  14569. end;
  14570. class procedure TBLRuntime.LogMessage(const AMessage: String);
  14571. begin
  14572. _BLCheck(blRuntimeMessageOut(MarshaledAString(UTF8String(AMessage))));
  14573. end;
  14574. class procedure TBLRuntime.QueryBuildInfo(out AInfo: TBLRuntimeBuildInfo);
  14575. begin
  14576. _BLCheck(blRuntimeQueryInfo(BL_RUNTIME_INFO_TYPE_BUILD, @AInfo));
  14577. end;
  14578. class procedure TBLRuntime.QueryResourceInfo(out AInfo: TBLRuntimeResourceInfo);
  14579. begin
  14580. _BLCheck(blRuntimeQueryInfo(BL_RUNTIME_INFO_TYPE_RESOURCE, @AInfo));
  14581. end;
  14582. class procedure TBLRuntime.QuerySystemInfo(out AInfo: TBLRuntimeSystemInfo);
  14583. begin
  14584. _BLCheck(blRuntimeQueryInfo(BL_RUNTIME_INFO_TYPE_SYSTEM, @AInfo));
  14585. end;
  14586. {$ENDREGION 'Runtime'}
  14587. {$REGION 'Internal'}
  14588. procedure _BLCheck(const AResult: BLResultCode);
  14589. begin
  14590. if (AResult <> BL_SUCCESS) and Assigned(GErrorHandler) then
  14591. GErrorHandler(TBLResultCode(AResult), GErrorUserData);
  14592. end;
  14593. {$ENDREGION 'Internal'}
  14594. {$REGION 'Initialization'}
  14595. initialization
  14596. BLSetExceptionErrorHandler;
  14597. {$ENDREGION 'Initialization'}
  14598. end.